com.atlassian.scheduler.core
Interface LifecycleAwareSchedulerService

All Superinterfaces:
SchedulerService
All Known Implementing Classes:
AbstractSchedulerService, Quartz1SchedulerService, Quartz2SchedulerService

public interface LifecycleAwareSchedulerService
extends SchedulerService

An interface that scheduler service implementations will generally be expected to implement so that they can be stopped from accepting jobs when the application is not at a point in its lifecycle where it should be running them. For example, if the plugin system has not finished coming up, then this node's scheduler should not be claiming jobs, because it would steal clustered jobs that another node in the cluster would be able to process when we know we are unlikely to be ready.

As a general rule, scheduler implementations should begin in standby() mode, where they will not run any jobs until explicitly started. Once started, the scheduler may be placed back into standby mode and restarted as often as needed. The shutdown() method should only be called when the SchedulerService is being disposed and will not be asked to start() again.

Since:
v1.0

Nested Class Summary
static class LifecycleAwareSchedulerService.State
          A representation of the scheduler's current state.
 
Method Summary
 LifecycleAwareSchedulerService.State getState()
          Returns the scheduler service's running state.
 void shutdown()
          Permanent shutdown of the scheduler.
 void standby()
          Places the scheduler into standby mode.
 void start()
          Starts the scheduler if it had never been started or had been placed in standby() mode.
 
Methods inherited from interface com.atlassian.scheduler.SchedulerService
getJobDetails, getJobRunnerKeysForAllScheduledJobs, getJobsByJobRunnerKey, getRegisteredJobRunnerKeys, registerJobRunner, scheduleJob, scheduleJobWithGeneratedId, unregisterJobRunner, unscheduleJob
 

Method Detail

start

void start()
           throws SchedulerServiceException
Starts the scheduler if it had never been started or had been placed in standby() mode. If the scheduler was already active, then the request has no effect.

Throws:
SchedulerServiceException - if the scheduler cannot be started

standby

void standby()
             throws SchedulerServiceException
Places the scheduler into standby mode. This stops jobs from running until it is started again. If the scheduler was already in standby, then the request has no effect.

Throws:
SchedulerServiceException - if the scheduler cannot be be placed in standby mode

shutdown

void shutdown()
Permanent shutdown of the scheduler. Once this has been called, no more jobs will be run and most requests will fail. The scheduler cannot be restarted once it has been shut down.


getState

@Nonnull
LifecycleAwareSchedulerService.State getState()
Returns the scheduler service's running state. The scheduler is initially in LifecycleAwareSchedulerService.State.STANDBY and can be moved between this state and LifecycleAwareSchedulerService.State.STANDBY freely. LifecycleAwareSchedulerService.State.SHUTDOWN is terminal — that is, once shut down, the scheduler's state can no longer be changed.

Returns:
the scheduler service's running state.


Copyright © 2014 Atlassian. All Rights Reserved.