Class PeriodicWork
- java.lang.Object
-
- java.util.TimerTask
-
- hudson.triggers.SafeTimerTask
-
- hudson.model.PeriodicWork
-
- All Implemented Interfaces:
ExtensionPoint
,Runnable
- Direct Known Subclasses:
AsyncPeriodicWork
,ComputerRetentionWork
,HudsonHomeDiskUsageChecker
,LoadStatistics.LoadStatisticsUpdater
,MemoryUsageMonitor
,NodeProvisioner.NodeProvisionerInvoker
,Trigger.Cron
public abstract class PeriodicWork extends SafeTimerTask implements ExtensionPoint
Extension point to perform a periodic task in Hudson (throughTimer
.)This extension point is useful if your plugin needs to perform some work in the background periodically (for example, monitoring, batch processing, garbage collection, etc.)
Put
Extension
on your class to have it picked up and registered automatically, or manually insert this toTrigger.timer
.This class is designed to run a short task. Implementations whose periodic work takes a long time to run should extend from
AsyncPeriodicWork
instead.- Author:
- Kohsuke Kawaguchi
- See Also:
AsyncPeriodicWork
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.triggers.SafeTimerTask
SafeTimerTask.ExceptionRunnable
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description PeriodicWork()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExtensionList<PeriodicWork>
all()
Returns all the registeredPeriodicWork
s.long
getInitialDelay()
Gets the number of milliseconds til the first execution.abstract long
getRecurrencePeriod()
Gets the number of milliseconds between successive executions.static void
init()
-
Methods inherited from class hudson.triggers.SafeTimerTask
doRun, getLogsRoot, of, run
-
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
-
-
-
Field Detail
-
logger
@Deprecated protected final Logger logger
Deprecated.Use your own logger, or send messages to the logger inAsyncPeriodicWork.execute(hudson.model.TaskListener)
.
-
MIN
protected static final long MIN
- See Also:
- Constant Field Values
-
HOUR
protected static final long HOUR
- See Also:
- Constant Field Values
-
DAY
protected static final long DAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRecurrencePeriod
public abstract long getRecurrencePeriod()
Gets the number of milliseconds between successive executions.Hudson calls this method once to set up a recurring timer, instead of calling this each time after the previous execution completed. So this class cannot be used to implement a non-regular recurring timer.
IOW, the method should always return the same value.
-
getInitialDelay
public long getInitialDelay()
Gets the number of milliseconds til the first execution.By default it chooses the value randomly between 0 and
getRecurrencePeriod()
-
all
public static ExtensionList<PeriodicWork> all()
Returns all the registeredPeriodicWork
s.
-
init
@Initializer(after=JOB_CONFIG_ADAPTED) public static void init()
-
-