Class RemoteResolver
java.lang.Object
org.jenkins.plugins.lockableresources.remote.RemoteResolver
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public final class RemoteResolver
extends Object
Server-side resolution for remote lock requests: the admission check (existence/exposure) and
resolution through the canonical
LockableResourcesManager.getAvailableResources(java.util.List<org.jenkins.plugins.lockableresources.queue.LockableResourcesStruct>) path -
the same one local lock() uses, with the configured exposeLabel set as the candidate
filter. The server never re-implements lock() semantics; this class only decides
which resources a remote request may see and resolves them, then hands off to the manager.
A pure, stateless collaborator over the manager's public API. Every call must be made while holding
LockableResourcesManager.syncResources - the caller acquires it; this class never takes the lock
itself.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionavailableForRemote(List<LockableResourcesStruct> structs, RemoteLockRequest req) Resolves a remote request (given its canonicalstructs, fromtoRemoteStructs(org.jenkins.plugins.lockableresources.remote.RemoteLockRequest)) through the canonicalLockableResourcesManager.getAvailableResources(java.util.List<org.jenkins.plugins.lockableresources.queue.LockableResourcesStruct>)path, applying the configuredexposeLabelset as the candidate-visibility filter (a resource is visible iff it carries any exposeLabel - OR).remoteLockEnvVars(String variable, List<LockableResource> resources) BuildslockEnvVarsfor an acquired remote lock from the resolved resources, via the sharedLockStepExecution.buildLockEnvVars(java.lang.String, java.util.LinkedHashMap<java.lang.String, java.util.List<org.jenkins.plugins.lockableresources.LockableResourceProperty>>)- identical to local, including resource-property env vars.Builds the canonicalLockableResourcesStructlist for a remote request, mirroringLockStep.getResources()(main selector + eachextraentry).Admission check for a remote request: every selector (the main one and eachextraentry) must reference something this remote client could actually lock - a resource that exists and is exposed, or a label with at least one exposed candidate.
-
Constructor Details
-
RemoteResolver
-
-
Method Details
-
validateRemoteSelectors
Admission check for a remote request: every selector (the main one and eachextraentry) must reference something this remote client could actually lock - a resource that exists and is exposed, or a label with at least one exposed candidate. Exposure means "carries any configuredexposeLabel" (seeLockableResourcesManager.getExposeLabels()). This is the only remote-specific gate; the actual resolution still goes through the canonicalLockableResourcesManager.getAvailableResources(java.util.List<org.jenkins.plugins.lockableresources.queue.LockableResourcesStruct>)path. Must be called underLockableResourcesManager.syncResources.- Returns:
- an error code (
"UNKNOWN_RESOURCE"/"UNKNOWN_LABEL") ornullwhen all selectors are admissible. The caller maps the code to HTTP 404.
-
toRemoteStructs
Builds the canonicalLockableResourcesStructlist for a remote request, mirroringLockStep.getResources()(main selector + eachextraentry). Resources are resolved by name only (no ephemeral creation): admission (validateRemoteSelectors(org.jenkins.plugins.lockableresources.remote.RemoteLockRequest)) has already confirmed every named selector exists and is exposed, so a remote request never materialises new resources on the server. Must be called underLockableResourcesManager.syncResources. -
availableForRemote
@CheckForNull public List<LockableResource> availableForRemote(@NonNull List<LockableResourcesStruct> structs, @NonNull RemoteLockRequest req) Resolves a remote request (given its canonicalstructs, fromtoRemoteStructs(org.jenkins.plugins.lockableresources.remote.RemoteLockRequest)) through the canonicalLockableResourcesManager.getAvailableResources(java.util.List<org.jenkins.plugins.lockableresources.queue.LockableResourcesStruct>)path, applying the configuredexposeLabelset as the candidate-visibility filter (a resource is visible iff it carries any exposeLabel - OR). The filter is a plainPredicateso the canonical resolver never learns about exposeLabel; the "requested-label AND exposeLabel" intersection is expressed entirely here, leaving local lock()'s single-label matching untouched. Returns the resources to lock (atomically) ornullif not all currently satisfiable (-> QUEUED, like local). Shared by the immediate acquire and queue-promotion paths. Must be called underLockableResourcesManager.syncResources. -
remoteLockEnvVars
@CheckForNull public static Map<String,String> remoteLockEnvVars(@CheckForNull String variable, @NonNull List<LockableResource> resources) BuildslockEnvVarsfor an acquired remote lock from the resolved resources, via the sharedLockStepExecution.buildLockEnvVars(java.lang.String, java.util.LinkedHashMap<java.lang.String, java.util.List<org.jenkins.plugins.lockableresources.LockableResourceProperty>>)- identical to local, including resource-property env vars. Returnsnullwhen novariablewas requested.
-