- java.lang.Object
-
- com.alibaba.rcm.ResourceType
-
public class ResourceType extends Object
Enumeration ofConstraint's type.classis used instead ofenumto provide extensibility. Implementation of resource management can define its resource type. Below is an example of extension ResourceType:public class MyResourceType extends ResourceType { public final static ResourceType CPU_CFS = new MyResourceType(); public MyResourceType() {} }CPU_CFS is an instance of
ResourceType, so it can be used wherever ResourceType is handled.The descriptions and parameters of each public final static value need to be documented in detail.
-
-
Field Summary
Fields Modifier and Type Field Description static ResourceTypeCPU_PERCENTThrottling the CPU usage by CPU percentage.static ResourceTypeHEAP_RETAINEDThrottling the max heap usage.
-
Constructor Summary
Constructors Modifier Constructor Description protectedResourceType(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstraintnewConstraint(long... values)protected voidvalidate(long... values)Checks the validity of parameters.
-
-
-
Field Detail
-
CPU_PERCENT
public static final ResourceType CPU_PERCENT
Throttling the CPU usage by CPU percentage.param #1: CPU usage measured in a percentage granularity. The value ranges from 0 to CPU_COUNT * 100. For example,
150means that ResourceContainer can use up to 1.5 CPU cores.
-
HEAP_RETAINED
public static final ResourceType HEAP_RETAINED
Throttling the max heap usage.param #1: maximum heap size in bytes
-
-
Constructor Detail
-
ResourceType
protected ResourceType(String name)
-
-
Method Detail
-
newConstraint
public Constraint newConstraint(long... values)
- Parameters:
values- constraint values- Returns:
- newly-created Constraint
- Throws:
IllegalArgumentException- when parameter check fails
-
validate
protected void validate(long... values) throws IllegalArgumentExceptionChecks the validity of parameters. Since a long [] is used to express the configuration, a length and range check is required.Each ResourceType instance can implement its own
validate()method through Override, for example:public final static ResourceType MY_RESOURCE = new ResourceType() { protected void validate(long[] values) throws IllegalArgumentException { // the check logic } };- Parameters:
values- parameter value- Throws:
IllegalArgumentException- if validation failed
-
-