Class AgentPeriodicTaskService

java.lang.Object
org.lsst.ccs.services.AgentPeriodicTaskService
All Implemented Interfaces:
HasLifecycle, ServiceLifecycle, AgentService

public final class AgentPeriodicTaskService extends Object implements ServiceLifecycle, HasLifecycle, AgentService
A service to schedule periodic tasks. This service is responsible to manage the Agent's periodic tasks: - allow components to schedule periodic tasks - starts all the scheduled tasks once the Agent has started - stops the tasks upon shutdown It also provides utility methods to set/get the period of a task.
Author:
The LSST CCS Team
  • Constructor Details

    • AgentPeriodicTaskService

      public AgentPeriodicTaskService()
  • Method Details

    • getAgentServiceName

      public String getAgentServiceName()
      Description copied from interface: AgentService
      Get the name of this service. This name will be used to add the given service to the lookup tree.
      Specified by:
      getAgentServiceName in interface AgentService
      Returns:
      the AgentService name.
    • preBuild

      public void preBuild()
      Specified by:
      preBuild in interface ServiceLifecycle
    • build

      public void build()
      Description copied from interface: HasLifecycle
      First lifecycle hook. Modification of the component tree is allowed at this stage. After this stage the tree of component cannot be modified anymore. This is where agent periodic tasks should be scheduled.
      Specified by:
      build in interface HasLifecycle
    • preInit

      public void preInit()
      Specified by:
      preInit in interface ServiceLifecycle
    • init

      public void init()
      Description copied from interface: HasLifecycle
      Called from the enclosing Subsystem at initialization phase.

      This method is called before the children components of this object have their init method called.

      At the time it is called, connection to the messaging layer is not yet done, so there should be no attempt to send messages in the body of this method. Configuration for message listening can nevertheless be done here, such as adding MessageListener objects.

      It is unnecessary to call super.init()

      Specified by:
      init in interface HasLifecycle
    • createScheduler

      public Scheduler createScheduler(String name, int nThreads)
      Create a scheduler by name and the default number of threads. This scheduler can be then used to schedule periodic tasks. The number of threads allocated for this scheduler can be changed via a configuration parameter.
      Parameters:
      name -
      nThreads -
    • scheduleAgentPeriodicTask

      public void scheduleAgentPeriodicTask(AgentPeriodicTask task)
      Schedule a PeriodicTask. Any CCS component can schedule an AgentPeriodicTask for execution. This method is available only during the build period of . Any invocation of this method at a later stage will result in a RuntimeException.
      Parameters:
      task - The PeriodicTask to schedule
    • scheduleAgentPeriodicTask

      public void scheduleAgentPeriodicTask(AgentPeriodicTask task, String schedulerName)
    • getPeriodicTaskPeriod

      public Duration getPeriodicTaskPeriod(String taskName)
      Get the period of a PeriodicTaks.
      Parameters:
      taskName - The name of the task
      Returns:
      The periodic task period in milliseconds.
    • setPeriodicTaskPeriod

      public void setPeriodicTaskPeriod(String taskName, Duration period)
      Change the period of a PeriodicTask. This method results in a configuration change.
      Parameters:
      taskName - The name of the task
      period - The period Duration
    • getAgentPeriodicTaskNames

      @Command(name="getAgentPeriodicTaskNames", description="Get the list of the names of the scheduled tasks", type=QUERY, category=SYSTEM) public List<String> getAgentPeriodicTaskNames()
      Get the list of names of the scheduled tasks.
      Returns:
      the Enumeration of task names.