public class ResourcePool extends Object
RequestAllocator. The resources pool is essentially a vector
of doubles where each dimension represents a resource. A set of resource requests exceeds the availability of the
pool if the vector sum of those requests is larger than the vector of resources in the pool along any dimension.| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_DIMENSION_TOLERANCE |
| Modifier | Constructor and Description |
|---|---|
protected |
ResourcePool(Map<String,Double> maxResources,
Map<String,Double> tolerances,
Map<String,Double> defaultRequirements) |
protected |
ResourcePool(ResourcePool other) |
| Modifier and Type | Method and Description |
|---|---|
protected ResourcePool |
contractPool(ResourceRequirement requirement) |
boolean |
exceedsHardBound(ResourceRequirement requirement,
boolean orEqual) |
boolean |
exceedsSoftBound(ResourceRequirement requirement,
boolean orEqual) |
ResourceRequirement.Builder |
getResourceRequirementBuilder()
Use to create a
ResourceRequirement compatible with this ResourcePool. |
String |
stringifyRequirement(ResourceRequirement requirement)
Stringify a
ResourceRequirement with the appropriate dimension labels. |
String |
toString() |
public static final double DEFAULT_DIMENSION_TOLERANCE
protected ResourcePool(Map<String,Double> maxResources, Map<String,Double> tolerances, Map<String,Double> defaultRequirements)
maxResources - Maximum resource availability along each dimension. Each entry in this map is a dimension. Note
this is considered a soft bound (e.g. max resources may be exceeded by a tolerance).tolerances - The hard limit on resources availability along each dimension is set to maxResource * tolerance.
The default tolerance is DEFAULT_DIMENSION_TOLERANCE. It is recommended to always have a
tolerance >1, as some RequestAllocators will do unnecessary work if the soft and hard
bounds are too close to each other.defaultRequirements - Specifies the default usage of the resources along each dimension when creating a
ResourceRequirement. Default is 0.protected ResourcePool(ResourcePool other)
public String stringifyRequirement(ResourceRequirement requirement)
ResourceRequirement with the appropriate dimension labels.public boolean exceedsSoftBound(ResourceRequirement requirement, boolean orEqual)
ResourceRequirement exceeds the soft bound long any dimension. If the parameter
orEqual is true, then matching along any dimension will also return true.public boolean exceedsHardBound(ResourceRequirement requirement, boolean orEqual)
ResourceRequirement exceeds the hard bound long any dimension. If the parameter
orEqual is true, then matching along any dimension will also return true.public ResourceRequirement.Builder getResourceRequirementBuilder()
ResourceRequirement compatible with this ResourcePool.protected ResourcePool contractPool(ResourceRequirement requirement)
ResourcePool which is a copy of this ResourcePool except its resource vector has been
reduced by the input ResourceRequirement.