public class MesosResourceAllocation extends Object
A typical offer contains a mix of reserved and unreserved resources. The below example depicts 2 cpus reserved for 'myrole' plus 3 unreserved cpus for a total of 5 cpus:
cpus(myrole):2.0; mem(myrole):4096.0; ports(myrole):[1025-2180];
disk(*):28829.0; cpus(*):3.0; mem(*):10766.0; ports(*):[2182-3887,8082-8180,8182-32000]
This class assumes that the resources were offered without the RESERVATION_REFINEMENT
capability,
as detailed in the "Resource Format" section of the Mesos protocol definition.
This class is not thread-safe.
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
MesosResourceAllocation(Collection<org.apache.mesos.Protos.Resource> resources)
Creates an allocation of resources for tasks to take.
|
Modifier and Type | Method and Description |
---|---|
List<org.apache.mesos.Protos.Resource> |
getRemaining()
Gets the remaining resources.
|
List<org.apache.mesos.Protos.Resource> |
takeRanges(String resourceName,
int amount,
Set<String> roles)
Takes some amount of range resources (e.g.
|
List<org.apache.mesos.Protos.Resource> |
takeScalar(String resourceName,
double amount,
Set<String> roles)
Takes some amount of scalar resources (e.g.
|
String |
toString() |
public MesosResourceAllocation(Collection<org.apache.mesos.Protos.Resource> resources)
resources
- the resources to add to the allocation.public List<org.apache.mesos.Protos.Resource> getRemaining()
public List<org.apache.mesos.Protos.Resource> takeScalar(String resourceName, double amount, Set<String> roles)
amount
- the (approximate) amount to take from the available quantity.roles
- the roles to acceptpublic List<org.apache.mesos.Protos.Resource> takeRanges(String resourceName, int amount, Set<String> roles)
amount
- the number of values to take from the available range(s).roles
- the roles to acceptCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.