Class ResourceAllocation

  • All Implemented Interfaces:
    Serializable

    public final class ResourceAllocation
    extends Object
    implements Serializable
    Describes the resource allocation for a job server process. This indicates:
    • the number of virtual cores allotted
    • the amount of memory (in MB) allotted
    See Also:
    Serialized Form
    • Constructor Detail

      • ResourceAllocation

        public ResourceAllocation​(int cpus,
                                  int memory)
    • Method Detail

      • getCPU

        public int getCPU()
        Gets the number of virtual cores allotted.
        Returns:
        the allocated CPU
      • getMemory

        public int getMemory()
        Gets the memory, in MB, allotted.
        Returns:
        the allocated memory
      • forWorker

        public ResourceAllocation forWorker​(int partitions)
        Computes the resource allotment for a worker process. The original allocation is taken to represent a per-partition allotment, with the result being the total allotment for the worker handling those partitions.
        Parameters:
        partitions - the number of partitions handled by the worker
        Returns:
        the worker's resource allocation
      • calculatePartitions

        public int calculatePartitions​(ResourceAllocation usage)
        Computes the number of partitions of the specified usage within the allocation.
        Parameters:
        usage - the per-partition resource allotment
        Returns:
        the number of partitions fitting in this allocation
      • calculateDominantUsage

        public double calculateDominantUsage​(ResourceAllocation usage)
        Computes the dominant share of resources for the specified usage relative to this allocation. This is the maximum percentage of total capacity used per resource type.
        Parameters:
        usage - resource usage for which to compute share
        Returns:
        the fraction of total capacity for the most used resource.