Class JobQueue

java.lang.Object
net.i2p.router.JobQueue

public class JobQueue
extends Object
Manage the pending jobs according to whatever algorithm is appropriate, giving preference to earlier scheduled jobs. For use by the router only. Not to be used by applications or plugins.
  • Constructor Details

    • JobQueue

      public JobQueue​(RouterContext context)
      Does not start the pumper. Caller MUST call startup.
  • Method Details

    • addJob

      public void addJob​(Job job)
      Enqueue the specified job
    • removeJob

      public void removeJob​(Job job)
    • isJobActive

      @Deprecated public boolean isJobActive​(Job job)
      Deprecated.
      unused
      Returns true if a given job is waiting or running; false if the job is finished or doesn't exist in the queue.
    • timingUpdated

      @Deprecated public void timingUpdated()
      Deprecated.
      contention - see JobTiming.setStartAfter() comments
    • getReadyCount

      public int getReadyCount()
    • getMaxLag

      public long getMaxLag()
    • allowParallelOperation

      public void allowParallelOperation()
    • startup

      public void startup()
      Start the pumper.
      Since:
      0.9.19
    • restart

      @Deprecated public void restart()
      Deprecated.
      do you really want to do this?
    • shutdown

      void shutdown()
    • isAlive

      boolean isAlive()
    • getLastJobBegin

      public long getLastJobBegin()
      When did the most recently begin job start?
      Since:
      Broken before 0.9.51, always returned -1
    • getLastJobEnd

      public long getLastJobEnd()
      When did the most recently begin job start?
      Since:
      Broken before 0.9.51, always returned -1
    • getLastJob

      public Job getLastJob()
      retrieve the most recently begin and still currently active job, or null if no jobs are running
    • getNext

      Job getNext()
      Blocking call to retrieve the next ready job
    • runQueue

      public void runQueue​(int numThreads)
      Start up the queue with the specified number of concurrent processors. If this method has already been called, it will increase the number of runners if necessary. This does not ever stop or reduce threads.
    • removeRunner

      void removeRunner​(int id)
    • updateStats

      void updateStats​(Job job, long doStart, long origStartAfter, long duration)
      calculate and update the job timings if it was lagged too much or took too long to run, spit out a warning (and if its really excessive, kill the router)
    • getJobs

      public int getJobs​(Collection<Job> readyJobs, Collection<Job> timedJobs, Collection<Job> activeJobs, Collection<Job> justFinishedJobs)
      Dump the current state. For the router console jobs status page.
      Parameters:
      readyJobs - out parameter
      timedJobs - out parameter
      activeJobs - out parameter
      justFinishedJobs - out parameter
      Returns:
      number of job runners
      Since:
      0.8.9
    • getJobStats

      public Collection<JobStats> getJobStats()
      Current job stats. For the router console jobs status page.
      Since:
      0.8.9
    • renderStatusHTML

      @Deprecated public void renderStatusHTML​(Writer out) throws IOException
      Deprecated.
      moved to router console
      Throws:
      IOException