- java.lang.Object
-
- com.alibaba.rcm.ResourceType
-
public class ResourceType extends Object
Enumeration ofConstraint
's type.class
is used instead ofenum
to 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 ResourceType
CPU_PERCENT
Throttling the CPU usage by CPU percentage.static ResourceType
HEAP_RETAINED
Throttling the max heap usage.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ResourceType(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Constraint
newConstraint(long... values)
protected void
validate(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,
150
means 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 IllegalArgumentException
Checks 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
-
-