|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.scheduler.core.AbstractSchedulerService
public abstract class AbstractSchedulerService
Base class for implementing a scheduler service. Provides JobRunner registration,
and job status tracking.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.atlassian.scheduler.core.LifecycleAwareSchedulerService |
|---|
LifecycleAwareSchedulerService.State |
| Field Summary | |
|---|---|
protected static Comparator<JobDetails> |
BY_JOB_ID
Sorts by job ID (and nothing else). |
| Constructor Summary | |
|---|---|
protected |
AbstractSchedulerService(RunDetailsDao runDetailsDao)
|
| Method Summary | |
|---|---|
RunDetails |
addRunDetails(JobId jobId,
Date startedAt,
RunOutcome runOutcome,
String message)
Creates or updates the job status record for the given job ID. |
protected static SchedulerServiceException |
checked(SchedulerRuntimeException sre)
Converts the unchecked SchedulerRuntimeException to the checked
SchedulerServiceException. |
JobRunner |
getJobRunner(JobRunnerKey jobRunnerKey)
|
Set<JobRunnerKey> |
getRegisteredJobRunnerKeys()
Returns all of the job runner keys that currently have registered job runners, regardless of whether or not any jobs have actually been scheduled
for them. |
LifecycleAwareSchedulerService.State |
getState()
Returns the scheduler service's running state. |
void |
registerJobRunner(JobRunnerKey jobRunnerKey,
JobRunner jobRunner)
Registers the job runner for a given job runner key. |
JobId |
scheduleJobWithGeneratedId(JobConfig jobConfig)
Schedules a "dynamic" job by generating a new unique job ID. |
void |
shutdown()
Permanent shutdown of the scheduler. |
protected abstract void |
shutdownImpl()
Provided by the scheduler service to implement shutdown() requests. |
void |
standby()
Places the scheduler into standby mode. |
protected abstract void |
standbyImpl()
Provided by the scheduler service to implement standby() requests. |
void |
start()
Starts the scheduler if it had never been started or had been placed in LifecycleAwareSchedulerService.standby() mode. |
protected abstract void |
startImpl()
Provided by the scheduler service to implement start() requests. |
void |
unregisterJobRunner(JobRunnerKey jobRunnerKey)
Unregisters the specified job runner. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.atlassian.scheduler.SchedulerService |
|---|
getJobDetails, getJobRunnerKeysForAllScheduledJobs, getJobsByJobRunnerKey, scheduleJob, unscheduleJob |
| Field Detail |
|---|
protected static final Comparator<JobDetails> BY_JOB_ID
SchedulerService.getJobsByJobRunnerKey(JobRunnerKey).
| Constructor Detail |
|---|
protected AbstractSchedulerService(RunDetailsDao runDetailsDao)
| Method Detail |
|---|
public void registerJobRunner(@Nonnull
JobRunnerKey jobRunnerKey,
@Nonnull
JobRunner jobRunner)
SchedulerServicejobRunnerKey will replace any existing registration.
A job that is scheduled to run but has no registered job runner is reported as
unavailable.
registerJobRunner in interface SchedulerServicejobRunnerKey - Globally unique job runner key.jobRunner - the concrete object capable of running instances of this job
public void unregisterJobRunner(@Nonnull
JobRunnerKey jobRunnerKey)
SchedulerServiceJobs that fire with no registered job runner will fail to start.
unregisterJobRunner in interface SchedulerServicejobRunnerKey - Globally unique job runner key.
public JobRunner getJobRunner(@Nonnull
JobRunnerKey jobRunnerKey)
@Nonnull public Set<JobRunnerKey> getRegisteredJobRunnerKeys()
SchedulerServicescheduled
for them. The job runner keys are not guaranteed to be returned in any particular order.
getRegisteredJobRunnerKeys in interface SchedulerServiceSchedulerService.getJobRunnerKeysForAllScheduledJobs()
@Nonnull
public JobId scheduleJobWithGeneratedId(@Nonnull
JobConfig jobConfig)
throws SchedulerServiceException
SchedulerService
scheduleJobWithGeneratedId in interface SchedulerServicejobConfig - the configuration details for the job instance including schedule,
run mode, run parameters, etc.
SchedulerServiceException - if the job cannot be scheduled because there is a problem
with either the provided configuration or within the scheduler implementation itself
public RunDetails addRunDetails(@Nonnull
JobId jobId,
@Nonnull
Date startedAt,
@Nonnull
RunOutcome runOutcome,
@Nullable
String message)
jobId - the job ID for which the status is being updatedstartedAt - the clock time that the run started atrunOutcome - the result of the runmessage - an optional informational message to include in the RunDetails
public final void start()
throws SchedulerServiceException
LifecycleAwareSchedulerServiceLifecycleAwareSchedulerService.standby() mode.
If the scheduler was already active, then the request has no effect.
start in interface LifecycleAwareSchedulerServiceSchedulerServiceException - if the scheduler cannot be started
public final void standby()
throws SchedulerServiceException
LifecycleAwareSchedulerServicestarted
again. If the scheduler was already in standby, then the request has no effect.
standby in interface LifecycleAwareSchedulerServiceSchedulerServiceException - if the scheduler cannot be be placed in standby modepublic final void shutdown()
LifecycleAwareSchedulerService
shutdown in interface LifecycleAwareSchedulerService@Nonnull public final LifecycleAwareSchedulerService.State getState()
LifecycleAwareSchedulerServiceLifecycleAwareSchedulerService.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.
getState in interface LifecycleAwareSchedulerService
protected abstract void startImpl()
throws SchedulerServiceException
start() requests. This
is only ever called while in State#STANDBY, and throwing an exception will
prevent the state from being updated.
SchedulerServiceException - if the scheduler implementation fails to start
protected abstract void standbyImpl()
throws SchedulerServiceException
standby() requests. This
is only ever called while in State#STARTED, and throwing an exception will
prevent the state from being updated.
SchedulerServiceException - if the scheduler implementation fails to enter standby modeprotected abstract void shutdownImpl()
shutdown() requests. This
is only ever called if the scheduler has not already been shut down, and throwing an
exception does not prevent the scheduler service from entering this state.
protected static SchedulerServiceException checked(SchedulerRuntimeException sre)
SchedulerRuntimeException to the checked
SchedulerServiceException. It makes sense to do this in many cases
where the checked exception is declared, as the caller is already having to
handle it.
The message and cause of the SchedulerServiceException are taken from
the cause of the runtime exception. If no cause
was set, then the runtime exception itself is used.
sre - the scheduler runtime exception to convert
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||