Class RestartDrain
java.lang.Object
org.jenkins.ci.plugins.saferestart.RestartDrain
- All Implemented Interfaces:
ExtensionPoint
Drain mode: block new top-level builds, let running builds finish, then trigger a safe restart.
Core quiet-down cannot be used for this. It also blocks the Pipeline node steps of
builds that are already running, so those builds could never finish and the restart would never
happen. Drain mode only holds back new builds, see RestartDrainQueueTaskDispatcher, and
enters core quiet-down through Jenkins.safeRestart(String) once nothing is running.
The state is transient. A restart or crash while draining resets it.
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Stops holding back new builds.voidTriggers the restart if the drain is active and nothing is running.static RestartDrainget()Builds that are still running.longgetSince()booleanisActive()voidStarts holding back new builds.
-
Constructor Details
-
RestartDrain
public RestartDrain()
-
-
Method Details
-
get
-
isActive
public boolean isActive()- Returns:
- true while new builds are held back and the restart is pending
-
getMessage
- Returns:
- the message shown in the shutdown banner once the restart starts, or null
-
getStartedBy
- Returns:
- name of the user who started the drain, or null when not active
-
getSince
public long getSince()- Returns:
- epoch milliseconds when the drain started, or 0 when not active
-
start
Starts holding back new builds. Restarts right away if nothing is running. Does nothing if already active.- Parameters:
message- optional message for the shutdown banner
-
cancel
public void cancel()Stops holding back new builds. No restart happens. -
checkAndRestart
public void checkAndRestart()Triggers the restart if the drain is active and nothing is running. Safe to call from any thread; the drain is deactivated before the restart is triggered so it fires only once. -
getRunningBuilds
Builds that are still running. For lazy-loading job types only builds already in memory are inspected: a running build is always loaded, and this avoids reading build records from disk on every check.- Returns:
- running builds, never null
-