Package hudson.model
Class AperiodicWork
java.lang.Object
java.util.TimerTask
hudson.triggers.SafeTimerTask
hudson.model.AperiodicWork
- All Implemented Interfaces:
ExtensionPoint,Runnable
- Direct Known Subclasses:
AsyncAperiodicWork,ComputerRetentionWork,DoubleLaunchChecker.Schedule
Extension point which allows scheduling a task with variable interval. Interval in evaluated every time before next
task is scheduled by calling
getRecurrencePeriod(). Task to be scheduled is obtain by calling getNewInstance().
This class is similar to PeriodicWork. The main difference is in re-evaluating delay interval every time.
See PeriodicWork for details. Analog of AsyncPeriodicWork is AsyncAperiodicWork.
- Since:
- 1.410
- Author:
- vjuranek
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.triggers.SafeTimerTask
SafeTimerTask.ExceptionRunnableNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<AperiodicWork> all()Returns all the registeredAperiodicWorks.protected abstract voidfinal voiddoRun()longGets the number of milliseconds till the first execution.abstract AperiodicWorkGets new instance of task to be executed.abstract longGets the number of milliseconds between successive executions.static voidinit()Methods inherited from class hudson.triggers.SafeTimerTask
getLogsRoot, of, runMethods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
Field Details
-
logger
-
-
Constructor Details
-
AperiodicWork
public AperiodicWork()
-
-
Method Details
-
getRecurrencePeriod
public abstract long getRecurrencePeriod()Gets the number of milliseconds between successive executions.Jenkins calls this method every time the timer task is scheduled.
-
getNewInstance
Gets new instance of task to be executed. Method should return new instance each time, as there no check, if previously scheduled task already finished. Returning same instance could lead to throwingIllegalStateException(especially in case ofAsyncAperiodicWork) and therefore scheduling of next tasks will be broken.- Returns:
- AperiodicWork - timer task instance to be executed
-
getInitialDelay
public long getInitialDelay()Gets the number of milliseconds till the first execution.By default it chooses the value randomly between 0 and
getRecurrencePeriod() -
doRun
- Specified by:
doRunin classSafeTimerTask- Throws:
Exception
-
init
-
doAperiodicRun
protected abstract void doAperiodicRun() -
all
Returns all the registeredAperiodicWorks.
-