Package hudson.model
Class AsyncPeriodicWork
- java.lang.Object
-
- java.util.TimerTask
-
- hudson.triggers.SafeTimerTask
-
- hudson.model.PeriodicWork
-
- hudson.model.AsyncPeriodicWork
-
- All Implemented Interfaces:
ExtensionPoint
,Runnable
- Direct Known Subclasses:
BackgroundGlobalBuildDiscarder
,ConnectionActivityMonitor
,DailyCheck
,FingerprintCleanupThread
,Telemetry.TelemetryReporter
,WorkspaceCleanupThread
public abstract class AsyncPeriodicWork extends PeriodicWork
PeriodicWork
that takes a long time to run.Subclasses will implement the
execute(TaskListener)
method and can carry out a long-running task. This runs in a separate thread so as not to block the timer thread, and this class handles all those details.- Author:
- Kohsuke Kawaguchi
-
-
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 Modifier Constructor Description protected
AsyncPeriodicWork(String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StreamTaskListener
createListener()
void
doRun()
Schedules this periodic work now in a new thread, if one isn't already running.protected abstract void
execute(TaskListener listener)
Executes the task.protected Level
getErrorLoggingLevel()
Returns the logging level at which error messages are displayed.protected File
getLogFile()
Determines the log file that records the result of this task.protected Level
getNormalLoggingLevel()
Returns the logging level at which normal messages are displayed.protected Level
getSlowLoggingLevel()
Returns the logging level at which previous task still executing messages is displayed.-
Methods inherited from class hudson.model.PeriodicWork
all, getInitialDelay, getRecurrencePeriod, init
-
Methods inherited from class hudson.triggers.SafeTimerTask
getLogsRoot, of, run
-
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
-
-
-
Field Detail
-
name
public final String name
Human readable name of the work.
-
-
Constructor Detail
-
AsyncPeriodicWork
protected AsyncPeriodicWork(String name)
-
-
Method Detail
-
doRun
public final void doRun()
Schedules this periodic work now in a new thread, if one isn't already running.- Specified by:
doRun
in classSafeTimerTask
-
createListener
protected StreamTaskListener createListener()
-
getLogFile
protected File getLogFile()
Determines the log file that records the result of this task.
-
getNormalLoggingLevel
protected Level getNormalLoggingLevel()
Returns the logging level at which normal messages are displayed.- Returns:
- The logging level as @Level.
- Since:
- 1.551
-
getSlowLoggingLevel
protected Level getSlowLoggingLevel()
Returns the logging level at which previous task still executing messages is displayed.- Returns:
- The logging level as @Level.
- Since:
- 1.565
-
getErrorLoggingLevel
protected Level getErrorLoggingLevel()
Returns the logging level at which error messages are displayed.- Returns:
- The logging level as @Level.
- Since:
- 1.551
-
execute
protected abstract void execute(TaskListener listener) throws IOException, InterruptedException
Executes the task.- Parameters:
listener
- Output sent will be reported to the users. (this work is TBD.)- Throws:
InterruptedException
- The caller will record the exception and moves on.IOException
- The caller will record the exception and moves on.
-
-