java.lang.Object
net.i2p.router.JobTiming
All Implemented Interfaces:
Clock.ClockUpdateListener

public class JobTimingextends Object implements Clock.ClockUpdateListener
Define the timing requirements and statistics for a particular job

For use by the router only. Not to be used by applications or plugins.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
    When the job really finished, in ms.
    private long
    When the job really started, in ms.
    private final RouterContext
    Supplies the clock the times are taken on.
    private long
    When the job was scheduled to run, in ms.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a JobTiming for the given context.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    end(long now)
    Record the actual end.
    long
    The actual end time when the job finished execution.
    long
    The actual start time when the job began execution.
    long
    # of milliseconds after the epoch to start the job.
    void
    offsetChanged(long delta)
    Adjust all timing values by the specified delta.
    void
    setActualEnd(long actualEndTime)
    The actual end time when the job finished execution.
    void
    setActualStart(long actualStartTime)
    The actual start time when the job began execution.
    void
    setStartAfter(long startTime)
    WARNING - this does not force a resort of the job queue any more...
    void
    start(long now)
    Record the actual start.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _start

      private volatile long _start
      When the job was scheduled to run, in ms.
    • _actualStart

      private volatile long _actualStart
      When the job really started, in ms.
    • _actualEnd

      private volatile long _actualEnd
      When the job really finished, in ms.
    • _context

      private final RouterContext _context
      Supplies the clock the times are taken on.
  • Constructor Details

    • JobTiming

      public JobTiming(RouterContext context)
      Create a JobTiming for the given context.
      Parameters:
      context - the router context
  • Method Details

    • getStartAfter

      public long getStartAfter()
      # of milliseconds after the epoch to start the job.
      Returns:
      the scheduled start time
    • setStartAfter

      public void setStartAfter(long startTime)
      WARNING - this does not force a resort of the job queue any more... ALWAYS call JobImpl.requeue(long) instead if job is already queued.
      Parameters:
      startTime - the new start time
    • getActualStart

      public long getActualStart()
      The actual start time when the job began execution.
      Returns:
      the actual start time
    • setActualStart

      public void setActualStart(long actualStartTime)
      The actual start time when the job began execution.
      Parameters:
      actualStartTime - the actual start time
    • start

      public void start(long now)
      Record the actual start.

      The caller supplies the timestamp because JobQueueRunner already reads the clock once per job and reuses that value for the run start, the queue-wait origin and the lag origin; a second read here only added clock skew between the timing record and the reported lag.

      Parameters:
      now - the actual start time in milliseconds
    • getActualEnd

      public long getActualEnd()
      The actual end time when the job finished execution.
      Returns:
      the actual end time
    • setActualEnd

      public void setActualEnd(long actualEndTime)
      The actual end time when the job finished execution.
      Parameters:
      actualEndTime - the actual end time
    • end

      public void end(long now)
      Record the actual end.

      As with start(long), the caller passes in a clock reading it already needs, keeping the duration consistent with the timestamp JobQueueRunner takes around updateStats().

      Parameters:
      now - the actual end time in milliseconds
    • offsetChanged

      public void offsetChanged(long delta)
      Adjust all timing values by the specified delta.
      Specified by:
      offsetChanged in interface Clock.ClockUpdateListener
      Parameters:
      delta - = (new offset - old offset), where each offset = (now() - System.currentTimeMillis())