Class WorkspaceList
Computer
to keep track of workspaces that are actively in use.- Since:
- 1.319
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Book keeping for workspace allocation.static class
Represents a leased workspace that needs to be returned later. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAcquires the given workspace.Allocates a workspace by adding some variation to the given base to make it unique.Just record that this workspace is being used, without paying any attention to the synchronization support.static FilePath
Locates a conventional temporary directory to be associated with a workspace.
-
Field Details
-
COMBINATOR
The token that combines the project name and unique number to create unique workspace directory.- Since:
- 2.244
-
TMP_DIR_SUFFIX
Suffix for temporary folders.
-
-
Constructor Details
-
WorkspaceList
public WorkspaceList()
-
-
Method Details
-
allocate
Allocates a workspace by adding some variation to the given base to make it unique.This method doesn't block prolonged amount of time. Whenever a desired workspace is in use, the unique variation is added.
- Throws:
InterruptedException
-
allocate
public WorkspaceList.Lease allocate(@NonNull FilePath base, Object context) throws InterruptedException - Parameters:
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.- Throws:
InterruptedException
-
record
Just record that this workspace is being used, without paying any attention to the synchronization support. -
acquire
Acquires the given workspace. If necessary, this method blocks until it's made available.- Returns:
- The same
FilePath
as given to this method. - Throws:
InterruptedException
-
acquire
- Parameters:
quick
- If true, indicates that the acquired workspace will be returned quickly. This makes other calls toallocate(FilePath)
to wait for the release of this workspace.- Throws:
InterruptedException
-
acquire
public WorkspaceList.Lease acquire(@NonNull FilePath p, boolean quick, Object context) throws InterruptedException - Parameters:
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.- Throws:
InterruptedException
-
tempDir
Locates a conventional temporary directory to be associated with a workspace.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.- Parameters:
ws
- a directory such as a build workspace- Returns:
- a sibling directory, for example
…/something@tmp
for…/something
, ornull
ifFilePath.getParent()
is null - Since:
- 1.652
-