Class WorkspaceList
- java.lang.Object
-
- hudson.slaves.WorkspaceList
-
public final class WorkspaceList extends Object
Used byComputer
to keep track of workspaces that are actively in use.- Since:
- 1.319
- Author:
- Kohsuke Kawaguchi
- See Also:
Computer.getWorkspaceList()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WorkspaceList.Entry
Book keeping for workspace allocation.static class
WorkspaceList.Lease
Represents a leased workspace that needs to be returned later.
-
Field Summary
Fields Modifier and Type Field Description static String
COMBINATOR
The token that combines the project name and unique number to create unique workspace directory.static String
TMP_DIR_SUFFIX
Suffix for temporary folders.
-
Constructor Summary
Constructors Constructor Description WorkspaceList()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
allocate
public WorkspaceList.Lease allocate(@NonNull FilePath base) throws InterruptedException
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
public WorkspaceList.Lease record(@NonNull FilePath p)
Just record that this workspace is being used, without paying any attention to the synchronization support.
-
acquire
public WorkspaceList.Lease acquire(@NonNull FilePath p) throws InterruptedException
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
public WorkspaceList.Lease acquire(@NonNull FilePath p, boolean quick) throws InterruptedException
- 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
@CheckForNull public static FilePath tempDir(FilePath ws)
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
-
-