Class SimpleSchedulerManager

java.lang.Object
net.solarnetwork.central.scheduler.SimpleSchedulerManager
All Implemented Interfaces:
SchedulerManager, net.solarnetwork.service.PingTest, net.solarnetwork.service.ServiceLifecycleObserver

public class SimpleSchedulerManager extends Object implements SchedulerManager, net.solarnetwork.service.PingTest, net.solarnetwork.service.ServiceLifecycleObserver
Implementation of SchedulerManager using a TaskScheduler.
  • Field Details

    • DEFUALT_PING_TEST_MAX_EXECUTION

      public static final long DEFUALT_PING_TEST_MAX_EXECUTION
      The default pingTestMaximumExecutionMilliseconds property value.
      See Also:
    • DEFAULT_BLOCKED_JOB_MAX_SECONDS

      public static final long DEFAULT_BLOCKED_JOB_MAX_SECONDS
      The default blockedJobMaxSeconds property value.
      See Also:
  • Constructor Details

    • SimpleSchedulerManager

      public SimpleSchedulerManager(org.springframework.scheduling.TaskScheduler taskScheduler)
      Constructor.
      Parameters:
      taskScheduler - the scheduler
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • serviceDidStartup

      public void serviceDidStartup()
      Specified by:
      serviceDidStartup in interface net.solarnetwork.service.ServiceLifecycleObserver
    • serviceDidShutdown

      public void serviceDidShutdown()
      Specified by:
      serviceDidShutdown in interface net.solarnetwork.service.ServiceLifecycleObserver
    • currentStatus

      public SchedulerStatus currentStatus()
      Description copied from interface: SchedulerManager
      Get the current status of the scheduler.
      Specified by:
      currentStatus in interface SchedulerManager
      Returns:
      the current status
    • updateStatus

      public void updateStatus(SchedulerStatus desiredStatus)
      Description copied from interface: SchedulerManager
      Change the status of the scheduler.
      Specified by:
      updateStatus in interface SchedulerManager
      Parameters:
      desiredStatus - the desired status to set
    • allJobInfos

      public Collection<JobInfo> allJobInfos()
      Description copied from interface: SchedulerManager
      Get a collection of all available scheduled jobs.
      Specified by:
      allJobInfos in interface SchedulerManager
      Returns:
      the collection of jobs; never null
    • pauseJob

      public void pauseJob(String groupId, String id)
      Description copied from interface: SchedulerManager
      Pause a specific job.
      Specified by:
      pauseJob in interface SchedulerManager
      Parameters:
      groupId - the job group ID
      id - the job ID
    • resumeJob

      public void resumeJob(String groupId, String id)
      Description copied from interface: SchedulerManager
      Resume a paused job.
      Specified by:
      resumeJob in interface SchedulerManager
      Parameters:
      groupId - the job group ID
      id - the job ID
    • scheduleJob

      public ScheduledFuture<?> scheduleJob(String groupId, String id, Runnable task, org.springframework.scheduling.Trigger trigger)
      Description copied from interface: SchedulerManager
      Schedule a job.

      If a job with the same group ID and ID has previously been scheduled, it will be re-scheduled using the given trigger.

      Specified by:
      scheduleJob in interface SchedulerManager
      Parameters:
      groupId - the job group ID
      id - the job ID
      trigger - the desired trigger
      Returns:
      the scheduled future
    • unscheduleJob

      public boolean unscheduleJob(String groupId, String id)
      Description copied from interface: SchedulerManager
      Unschedule a job.
      Specified by:
      unscheduleJob in interface SchedulerManager
      Parameters:
      groupId - the job group ID
      id - the job ID
      Returns:
      true if a job with matching group ID and ID was successfully unscheduled
    • getPingTestId

      public String getPingTestId()
      Specified by:
      getPingTestId in interface net.solarnetwork.service.PingTest
    • getPingTestName

      public String getPingTestName()
      Specified by:
      getPingTestName in interface net.solarnetwork.service.PingTest
    • getPingTestMaximumExecutionMilliseconds

      public long getPingTestMaximumExecutionMilliseconds()
      Specified by:
      getPingTestMaximumExecutionMilliseconds in interface net.solarnetwork.service.PingTest
    • performPingTest

      public net.solarnetwork.service.PingTest.Result performPingTest() throws Exception
      Specified by:
      performPingTest in interface net.solarnetwork.service.PingTest
      Throws:
      Exception
    • getBlockedJobMaxSeconds

      public long getBlockedJobMaxSeconds()
    • setBlockedJobMaxSeconds

      public void setBlockedJobMaxSeconds(long blockedJobMaxSeconds)
      A minimum amount of seconds before a blocked job results in an error.
      Parameters:
      blockedJobMaxSeconds - The number of seconds.
    • setPingTestMaximumExecutionMilliseconds

      public void setPingTestMaximumExecutionMilliseconds(long pingTestMaximumExecutionMilliseconds)
      Set the maximum ping test execution time.
      Parameters:
      pingTestMaximumExecutionMilliseconds - the maximum execution time, in milliseconds; defaults to DEFUALT_PING_TEST_MAX_EXECUTION
      Since:
      1.7