public class ResourceType extends Object
Constraint
's type.
class
is used instead of enum
to provide extensibility.
An implementation of resource management can define its own
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 details.
Modifier and Type | Field and Description |
---|---|
static ResourceType |
CPU_PERCENT
Throttling the CPU usage by cpu percentage.
|
static ResourceType |
HEAP_RETAINED
Throttling the max heap usage.
|
Modifier | Constructor and Description |
---|---|
protected |
ResourceType(String name) |
Modifier and Type | Method and Description |
---|---|
Constraint |
newConstraint(long... values)
|
String |
toString() |
protected boolean |
validate(long[] values)
Checks the validity of parameters.
|
public static final ResourceType CPU_PERCENT
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.
public static final ResourceType HEAP_RETAINED
param #1: maximum heap size in bytes
protected ResourceType(String name)
public final Constraint newConstraint(long... values)
values
- constraint valuesIllegalArgumentException
- when parameter check failsprotected boolean validate(long[] values)
Each ResourceType instance can implement its own validate()
method through Override, for example:
public final static ResourceType MY_RESOURCE = new ResourceType() { protected boolean validate(long[] values) { // the check logic } };
values
- parameter value"Copyright 2018, Alibaba, Inc."