Class RemoteLockManager
java.lang.Object
java.util.TimerTask
hudson.triggers.SafeTimerTask
hudson.model.PeriodicWork
org.jenkins.plugins.lockableresources.remote.RemoteLockManager
- All Implemented Interfaces:
ExtensionPoint,Runnable
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
@Extension
public class RemoteLockManager
extends PeriodicWork
Server-side manager for remote lock records.
Runs a 1-second tick loop (via PeriodicWork) that:
- Attempts to promote QUEUED records to ACQUIRED when their resource(s) become free.
- Marks ACQUIRED records as STALE when heartbeat times out.
- Cleans up terminal (SKIPPED/FAILED) records after a TTL.
STALE locks are held until an administrator explicitly releases them.
In-memory state is lost on Jenkins restart; all transient remote locks are
automatically freed because LockableResource.remoteLockedBy is transient.
-
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 inherited from class hudson.model.PeriodicWork
DAY, HOUR, logger, MIN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoRun()enqueue(RemoteLockRequest lockRequest, String clientId) Enqueues a new remote acquire request.Returns the record for the given lockId, ornullif not found.static RemoteLockManagerget()longbooleanUpdates the heartbeat timestamp for an ACQUIRED lock.voidReleases a lock, freeing the underlying resource(s).Methods inherited from class hudson.model.PeriodicWork
all, getInitialDelay, initMethods inherited from class hudson.triggers.SafeTimerTask
getLogsRoot, of, runMethods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
Constructor Details
-
RemoteLockManager
public RemoteLockManager()
-
-
Method Details
-
get
-
getRecurrencePeriod
public long getRecurrencePeriod()- Specified by:
getRecurrencePeriodin classPeriodicWork
-
doRun
protected void doRun()- Specified by:
doRunin classSafeTimerTask
-
enqueue
public RemoteLockRecord enqueue(@NonNull RemoteLockRequest lockRequest, @CheckForNull String clientId) Enqueues a new remote acquire request.Immediately attempts to lock the resource(s). If successful the returned record has state
RemoteLockState.ACQUIRED. If the resource is busy andskipIfLockedis true, state isRemoteLockState.SKIPPED. Otherwise state isRemoteLockState.QUEUEDand the entry is registered in the LRM queue so it participates in unified priority dispatch with local pipeline lock() steps. -
find
Returns the record for the given lockId, ornullif not found. -
heartbeat
Updates the heartbeat timestamp for an ACQUIRED lock.- Returns:
falseif the lockId is unknown or not in ACQUIRED state.
-
release
Releases a lock, freeing the underlying resource(s). Idempotent.
-