Class ResourceSpec

  • All Implemented Interfaces:
    Serializable

    @Internal
    public final class ResourceSpec
    extends Object
    implements Serializable
    Describe the different resource factors of the operator with UDF.

    Resource provides merge(ResourceSpec) method for chained operators when generating job graph.

    Resource provides lessThanOrEqual(ResourceSpec) method to compare these fields in sequence:

    1. CPU cores
    2. Task Heap Memory
    3. Task Off-Heap Memory
    4. Managed Memory
    5. Extended resources
    See Also:
    Serialized Form
    • Field Detail

      • UNKNOWN

        public static final ResourceSpec UNKNOWN
        A ResourceSpec that indicates an unknown set of resources.
      • DEFAULT

        public static final ResourceSpec DEFAULT
        The default ResourceSpec used for operators and transformation functions. Currently equal to UNKNOWN.
      • ZERO

        public static final ResourceSpec ZERO
        A ResourceSpec that indicates zero amount of resources.
    • Method Detail

      • merge

        public ResourceSpec merge​(ResourceSpec other)
        Used by system internally to merge the other resources of chained operators when generating the job graph.
        Parameters:
        other - Reference to resource to merge in.
        Returns:
        The new resource with merged values.
      • subtract

        public ResourceSpec subtract​(ResourceSpec other)
        Subtracts another resource spec from this one.
        Parameters:
        other - The other resource spec to subtract.
        Returns:
        The subtracted resource spec.
      • getTaskHeapMemory

        public org.apache.flink.configuration.MemorySize getTaskHeapMemory()
      • getTaskOffHeapMemory

        public org.apache.flink.configuration.MemorySize getTaskOffHeapMemory()
      • getManagedMemory

        public org.apache.flink.configuration.MemorySize getManagedMemory()
      • lessThanOrEqual

        public boolean lessThanOrEqual​(ResourceSpec other)
        Checks the current resource less than or equal with the other resource by comparing all the fields in the resource.
        Parameters:
        other - The resource to compare
        Returns:
        True if current resource is less than or equal with the other resource, otherwise return false.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • newBuilder

        public static ResourceSpec.Builder newBuilder​(double cpuCores,
                                                      int taskHeapMemoryMB)
      • newBuilder

        public static ResourceSpec.Builder newBuilder​(double cpuCores,
                                                      org.apache.flink.configuration.MemorySize taskHeapMemory)