Package hudson.model

Class 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
  • Field Details

    • name

      public final String name
      Human readable name of the work.
  • Constructor Details

    • AsyncPeriodicWork

      protected AsyncPeriodicWork(String name)
  • Method Details

    • doRun

      public final void doRun()
      Schedules this periodic work now in a new thread, if one isn't already running.
      Specified by:
      doRun in class SafeTimerTask
    • 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.