Module java.base

Class Constraint


  • public class Constraint
    extends Object
    A Constraint is a pair of ResourceType and values. The constrained resource and specification of parameter values are documented in enum constants in ResourceType

    A Constraint must be associated with one ResourceType, so we provide factory method ResourceType.newConstraint(long...) to implement this restriction. For example:

       Constraint cpuConstraint = ResourceType.CPU_PERCENT.newConstraint(30);
     

    ResourceContainer and Constraint follow the one-to-many relationship. ResourceContainer.getConstraints() can fetch the Constraint associated with ResourceContainer.

    • Method Detail

      • getResourceType

        public ResourceType getResourceType()
        Returns the currently restricted resource type.
        Returns:
        resource type
      • getValues

        public long[] getValues()
        Returns the constraint value of ResourceType described by a long[], which is documented on the ResourceType enums.

        The returned value is a copy of the internal storage array to prevent modification.

        Returns:
        constraint values