Class Scheduler

java.lang.Object
org.torproject.metrics.collector.cron.Scheduler
All Implemented Interfaces:
java.util.concurrent.ThreadFactory

public final class Scheduler
extends java.lang.Object
implements java.util.concurrent.ThreadFactory
Scheduler that starts the modules configured in collector.properties.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String ACTIVATED  
    static java.lang.String OFFSETMIN  
    static java.lang.String PERIODMIN  
  • Method Summary

    Modifier and Type Method Description
    protected static long computeInitialDelayMillis​(long currentMillis, long offsetMillis, long periodMillis)  
    static Scheduler getInstance()  
    java.lang.Thread newThread​(java.lang.Runnable runner)
    Provide a nice name for debugging and log thread creation.
    boolean scheduleModuleRuns​(java.util.Map<Key,​java.lang.Class<? extends CollecTorMain>> collecTorMains, Configuration conf)
    Schedule all classes given according to the parameters in the configuration and return whether the caller should wait for completion.
    void shutdownScheduler()
    Try to shutdown smoothly, i.e., wait for running tasks to terminate.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • getInstance

      public static Scheduler getInstance()
    • scheduleModuleRuns

      public boolean scheduleModuleRuns​(java.util.Map<Key,​java.lang.Class<? extends CollecTorMain>> collecTorMains, Configuration conf)
      Schedule all classes given according to the parameters in the configuration and return whether the caller should wait for completion.
    • computeInitialDelayMillis

      protected static long computeInitialDelayMillis​(long currentMillis, long offsetMillis, long periodMillis)
    • shutdownScheduler

      public void shutdownScheduler()
      Try to shutdown smoothly, i.e., wait for running tasks to terminate.
    • newThread

      public java.lang.Thread newThread​(java.lang.Runnable runner)
      Provide a nice name for debugging and log thread creation.
      Specified by:
      newThread in interface java.util.concurrent.ThreadFactory