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.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.solarnetwork.service.PingTest
net.solarnetwork.service.PingTest.Result -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe defaultblockedJobMaxSecondsproperty value.static final longThe defaultpingTestMaximumExecutionMillisecondsproperty value. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleSchedulerManager(org.springframework.scheduling.TaskScheduler taskScheduler) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet a collection of all available scheduled jobs.Get the current status of the scheduler.longlongvoidPause a specific job.net.solarnetwork.service.PingTest.ResultvoidResume a paused job.scheduleJob(String groupId, String id, Runnable task, org.springframework.scheduling.Trigger trigger) Schedule a job.voidvoidvoidsetBlockedJobMaxSeconds(long blockedJobMaxSeconds) A minimum amount of seconds before a blocked job results in an error.voidsetPingTestMaximumExecutionMilliseconds(long pingTestMaximumExecutionMilliseconds) Set the maximum ping test execution time.booleanunscheduleJob(String groupId, String id) Unschedule a job.voidupdateStatus(SchedulerStatus desiredStatus) Change the status of the scheduler.
-
Field Details
-
DEFUALT_PING_TEST_MAX_EXECUTION
public static final long DEFUALT_PING_TEST_MAX_EXECUTIONThe defaultpingTestMaximumExecutionMillisecondsproperty value.- See Also:
-
DEFAULT_BLOCKED_JOB_MAX_SECONDS
public static final long DEFAULT_BLOCKED_JOB_MAX_SECONDSThe defaultblockedJobMaxSecondsproperty 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:
serviceDidStartupin interfacenet.solarnetwork.service.ServiceLifecycleObserver
-
serviceDidShutdown
public void serviceDidShutdown()- Specified by:
serviceDidShutdownin interfacenet.solarnetwork.service.ServiceLifecycleObserver
-
currentStatus
Description copied from interface:SchedulerManagerGet the current status of the scheduler.- Specified by:
currentStatusin interfaceSchedulerManager- Returns:
- the current status
-
updateStatus
Description copied from interface:SchedulerManagerChange the status of the scheduler.- Specified by:
updateStatusin interfaceSchedulerManager- Parameters:
desiredStatus- the desired status to set
-
allJobInfos
Description copied from interface:SchedulerManagerGet a collection of all available scheduled jobs.- Specified by:
allJobInfosin interfaceSchedulerManager- Returns:
- the collection of jobs; never null
-
pauseJob
Description copied from interface:SchedulerManagerPause a specific job.- Specified by:
pauseJobin interfaceSchedulerManager- Parameters:
groupId- the job group IDid- the job ID
-
resumeJob
Description copied from interface:SchedulerManagerResume a paused job.- Specified by:
resumeJobin interfaceSchedulerManager- Parameters:
groupId- the job group IDid- the job ID
-
scheduleJob
public ScheduledFuture<?> scheduleJob(String groupId, String id, Runnable task, org.springframework.scheduling.Trigger trigger) Description copied from interface:SchedulerManagerSchedule 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:
scheduleJobin interfaceSchedulerManager- Parameters:
groupId- the job group IDid- the job IDtrigger- the desired trigger- Returns:
- the scheduled future
-
unscheduleJob
Description copied from interface:SchedulerManagerUnschedule a job.- Specified by:
unscheduleJobin interfaceSchedulerManager- Parameters:
groupId- the job group IDid- the job ID- Returns:
- true if a job with matching group ID and ID was successfully unscheduled
-
getPingTestId
- Specified by:
getPingTestIdin interfacenet.solarnetwork.service.PingTest
-
getPingTestName
- Specified by:
getPingTestNamein interfacenet.solarnetwork.service.PingTest
-
getPingTestMaximumExecutionMilliseconds
public long getPingTestMaximumExecutionMilliseconds()- Specified by:
getPingTestMaximumExecutionMillisecondsin interfacenet.solarnetwork.service.PingTest
-
performPingTest
- Specified by:
performPingTestin interfacenet.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 toDEFUALT_PING_TEST_MAX_EXECUTION- Since:
- 1.7
-