- java.lang.Object
-
- com.pervasive.datarush.cal.ResourceAllocation
-
- All Implemented Interfaces:
Serializable
public final class ResourceAllocation extends Object implements Serializable
Describes the resource allocation for a job server process. This indicates:- the number of virtual cores allotted
- the amount of memory (in MB) allotted
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ResourceAllocation
MASTER_DEFAULT
static ResourceAllocation
NONE
static ResourceAllocation
PARTITION_DEFAULT
-
Constructor Summary
Constructors Constructor Description ResourceAllocation(int cpus, int memory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceAllocation
add(ResourceAllocation other)
String
asPortion(ResourceAllocation usage)
double
calculateDominantUsage(ResourceAllocation usage)
Computes the dominant share of resources for the specified usage relative to this allocation.int
calculatePartitions(ResourceAllocation usage)
Computes the number of partitions of the specified usage within the allocation.boolean
contains(ResourceAllocation other)
ResourceAllocation
forWorker(int partitions)
Computes the resource allotment for a worker process.int
getCPU()
Gets the number of virtual cores allotted.int
getMemory()
Gets the memory, in MB, allotted.ResourceAllocation
subtract(ResourceAllocation usage)
String
toString()
-
-
-
Field Detail
-
NONE
public static final ResourceAllocation NONE
-
MASTER_DEFAULT
public static final ResourceAllocation MASTER_DEFAULT
-
PARTITION_DEFAULT
public static final ResourceAllocation PARTITION_DEFAULT
-
-
Method Detail
-
getCPU
public int getCPU()
Gets the number of virtual cores allotted.- Returns:
- the allocated CPU
-
getMemory
public int getMemory()
Gets the memory, in MB, allotted.- Returns:
- the allocated memory
-
forWorker
public ResourceAllocation forWorker(int partitions)
Computes the resource allotment for a worker process. The original allocation is taken to represent a per-partition allotment, with the result being the total allotment for the worker handling those partitions.- Parameters:
partitions
- the number of partitions handled by the worker- Returns:
- the worker's resource allocation
-
add
public ResourceAllocation add(ResourceAllocation other)
-
subtract
public ResourceAllocation subtract(ResourceAllocation usage)
-
calculatePartitions
public int calculatePartitions(ResourceAllocation usage)
Computes the number of partitions of the specified usage within the allocation.- Parameters:
usage
- the per-partition resource allotment- Returns:
- the number of partitions fitting in this allocation
-
calculateDominantUsage
public double calculateDominantUsage(ResourceAllocation usage)
Computes the dominant share of resources for the specified usage relative to this allocation. This is the maximum percentage of total capacity used per resource type.- Parameters:
usage
- resource usage for which to compute share- Returns:
- the fraction of total capacity for the most used resource.
-
contains
public boolean contains(ResourceAllocation other)
-
asPortion
public String asPortion(ResourceAllocation usage)
-
-