Package org.jenkinsci.plugins.ewm
Class DiskAllocationStrategy
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<DiskAllocationStrategy>
-
- org.jenkinsci.plugins.ewm.DiskAllocationStrategy
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<DiskAllocationStrategy>
- Direct Known Subclasses:
AbstractDiskSpeedStrategy
,MostUsableSpaceStrategy
public abstract class DiskAllocationStrategy extends AbstractDescribableImpl<DiskAllocationStrategy> implements ExtensionPoint
Abstract class for defining a disk allocation strategy. Each disk allocation strategy should extend this class and provide its own implementation of disk allocation.- Author:
- Alexandru Somai
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description DiskAllocationStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExtensionList<DiskAllocationStrategy>
all()
static ExtensionList<DiskAllocationStrategyDescriptor>
allDescriptors()
abstract Disk
allocateDisk(List<Disk> disks)
Allocates a disk from the given list.long
getEstimatedWorkspaceSize()
Returns the estimated workspace size in MB.long
retrieveUsableSpaceInBytes(Disk disk)
Retrieves the usable space in bytes for the givenDisk
entry.protected long
retrieveUsableSpaceInMegaBytes(Disk disk)
Retrieves the usable space in MB for the givenDisk
entry.void
setEstimatedWorkspaceSize(long estimatedWorkspaceSize)
Sets the estimated workspace size.-
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
-
-
-
Method Detail
-
all
@Nonnull public static ExtensionList<DiskAllocationStrategy> all()
- Returns:
- all registered
DiskAllocationStrategy
s.
-
allDescriptors
@Nonnull public static ExtensionList<DiskAllocationStrategyDescriptor> allDescriptors()
- Returns:
- the registered
DiskAllocationStrategyDescriptor
s for theDiskAllocationStrategy
.
-
allocateDisk
@Nonnull public abstract Disk allocateDisk(@Nonnull List<Disk> disks) throws IOException
Allocates a disk from the given list. The list contains at least oneDisk
entry.- Parameters:
disks
- the entries from which to allocate a disk. The list has at least one element- Returns:
- the selected disk
- Throws:
IOException
- if any mandatory field is missing from theDisk
entry, or if the disk allocation fails for any reason
-
retrieveUsableSpaceInBytes
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public long retrieveUsableSpaceInBytes(Disk disk) throws IOException
Retrieves the usable space in bytes for the givenDisk
entry. It uses the mounting point property that is defined in the Jenkins global config for each Disk.- Parameters:
disk
- the disk entry- Returns:
- the disk's usable space in bytes
- Throws:
IOException
- if mounting point from Jenkins master to Disk isnull
, or if the usable space can't be retrieved for security reasons- See Also:
File.getUsableSpace()
-
retrieveUsableSpaceInMegaBytes
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected final long retrieveUsableSpaceInMegaBytes(Disk disk) throws IOException
Retrieves the usable space in MB for the givenDisk
entry. It converts the value returned byretrieveUsableSpaceInBytes(Disk)
to MB.- Parameters:
disk
- the disk entry- Returns:
- the disk's usable space in MB
- Throws:
IOException
- same asretrieveUsableSpaceInBytes(Disk)
- See Also:
retrieveUsableSpaceInBytes(Disk)
,bytesToMega(long)
-
getEstimatedWorkspaceSize
public long getEstimatedWorkspaceSize()
Returns the estimated workspace size in MB.- Returns:
- the estimated workspace size in MB
-
setEstimatedWorkspaceSize
public void setEstimatedWorkspaceSize(long estimatedWorkspaceSize)
Sets the estimated workspace size. It must be set in MB.- Parameters:
estimatedWorkspaceSize
- the estimated workspace size in MB
-
-