public final class WorkspaceList extends Object
Computer
to keep track of workspaces that are actively in use.Computer.getWorkspaceList()
Modifier and Type | Class and Description |
---|---|
static class |
WorkspaceList.Entry
Book keeping for workspace allocation.
|
static class |
WorkspaceList.Lease
Represents a leased workspace that needs to be returned later.
|
Modifier and Type | Field and Description |
---|---|
static String |
COMBINATOR
The token that combines the project name and unique number to create unique workspace directory.
|
Constructor and Description |
---|
WorkspaceList() |
Modifier and Type | Method and Description |
---|---|
WorkspaceList.Lease |
acquire(FilePath p)
Acquires the given workspace.
|
WorkspaceList.Lease |
acquire(FilePath p,
boolean quick)
|
WorkspaceList.Lease |
acquire(FilePath p,
boolean quick,
Object context)
|
WorkspaceList.Lease |
allocate(FilePath base)
Allocates a workspace by adding some variation to the given base to make it unique.
|
WorkspaceList.Lease |
allocate(FilePath base,
Object context)
|
WorkspaceList.Lease |
record(FilePath p)
Just record that this workspace is being used, without paying any attention to the synchronization support.
|
static FilePath |
tempDir(FilePath ws)
Locates a conventional temporary directory to be associated with a workspace.
|
public static final String COMBINATOR
public WorkspaceList.Lease allocate(@NonNull FilePath base) throws InterruptedException
This method doesn't block prolonged amount of time. Whenever a desired workspace is in use, the unique variation is added.
InterruptedException
public WorkspaceList.Lease allocate(@NonNull FilePath base, Object context) throws InterruptedException
context
- Threads that share the same context can re-acquire the same lock (which will just increment the lock count.)
This allows related executors to share the same workspace.InterruptedException
public WorkspaceList.Lease record(@NonNull FilePath p)
public WorkspaceList.Lease acquire(@NonNull FilePath p) throws InterruptedException
FilePath
as given to this method.InterruptedException
public WorkspaceList.Lease acquire(@NonNull FilePath p, boolean quick) throws InterruptedException
quick
- If true, indicates that the acquired workspace will be returned quickly.
This makes other calls to allocate(FilePath)
to wait for the release of this workspace.InterruptedException
public WorkspaceList.Lease acquire(@NonNull FilePath p, boolean quick, Object context) throws InterruptedException
context
- Threads that share the same context can re-acquire the same lock (which will just increment the lock count.)
This allows related executors to share the same workspace.InterruptedException
@CheckForNull public static FilePath tempDir(FilePath ws)
This directory is suitable for temporary files to be deleted later in the course of a build,
or caches and local repositories which should persist across builds done in the same workspace.
(If multiple workspaces are present for a single job built concurrently, via allocate(FilePath)
, each will get its own temporary directory.)
It may also be used for security-sensitive files which DirectoryBrowserSupport
ought not serve,
acknowledging that these will be readable by builds of other jobs done on the same node.
Each plugin using this directory is responsible for specifying sufficiently unique subdirectory/file names.
FilePath.createTempFile(java.lang.String, java.lang.String)
may be used for this purpose if desired.
The resulting directory may not exist; you may call FilePath.mkdirs()
on it if you need it to.
It may be deleted alongside the workspace itself during cleanup actions.
ws
- a directory such as a build workspace…/something@tmp
for …/something
, or null
if FilePath.getParent()
is nullCopyright © 2004–2022. All rights reserved.