Class RemoteLockSession

java.lang.Object
org.jenkins.plugins.lockableresources.remote.RemoteLockSession
All Implemented Interfaces:
Serializable

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class RemoteLockSession extends Object implements Serializable
Client-side state machine for a remote lock(): enqueue the acquire request, short-poll the remote server for the outcome, heartbeat while the body runs, and release on completion. A serializable collaborator of the lock() step execution.

The session owns the transport/scheduling state (poll & heartbeat timers, retry budget, the persisted serverId/lockId/state). Everything that requires the workflow step's own context - running the lock body, signalling success/failure - is delegated to a RemoteLockSession.Host (implemented by LockStepExecution). The session is serialized as a field of the step execution, so it survives a controller restart; the timers are transient and rebuilt by onResume(Host).

See Also:
  • Constructor Details

    • RemoteLockSession

      public RemoteLockSession()
  • Method Details

    • getLockId

      @CheckForNull public String getLockId()
      Returns:
      the remote lockId once enqueued (used by the step for resume detection); may be null.
    • getServerId

      @CheckForNull public String getServerId()
      Returns:
      the target serverId once the acquire has been enqueued; may be null.
    • fail

      public void fail(RemoteLockSession.Host host, Throwable cause)
      Fails the session (fail-closed; no release) - used by the host when running the body throws.
    • start

      public boolean start(RemoteLockSession.Host host) throws Exception
      Throws:
      Exception
    • onBodyFinished

      public void onBodyFinished(RemoteLockSession.Host host)
      Called by the step's body callback when the lock body finishes - cancel heartbeat and release the lease.
    • stop

      public void stop(RemoteLockSession.Host host, Throwable cause)
      Aborts an in-flight session (step stopped): cancel timers, best-effort release, fail the context.
    • onResume

      public void onResume(RemoteLockSession.Host host)
      Resumes the session after a controller restart (rebuilds the poll loop or fails closed).