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.

  • Constructor Details

    • RemoteLockManager

      public RemoteLockManager()
  • Method Details

    • get

      public static RemoteLockManager get()
    • getRecurrencePeriod

      public long getRecurrencePeriod()
      Specified by:
      getRecurrencePeriod in class PeriodicWork
    • doRun

      protected void doRun()
      Specified by:
      doRun in class SafeTimerTask
    • 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 and skipIfLocked is true, state is RemoteLockState.SKIPPED. Otherwise state is RemoteLockState.QUEUED and the entry is registered in the LRM queue so it participates in unified priority dispatch with local pipeline lock() steps.

    • find

      @CheckForNull public RemoteLockRecord find(String lockId)
      Returns the record for the given lockId, or null if not found.
    • heartbeat

      public boolean heartbeat(String lockId)
      Updates the heartbeat timestamp for an ACQUIRED lock.
      Returns:
      false if the lockId is unknown or not in ACQUIRED state.
    • release

      public void release(String lockId)
      Releases a lock, freeing the underlying resource(s). Idempotent.