java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ResourceVector
All Implemented Interfaces:
Iterable<Map.Entry<String,Double>>

public class ResourceVector extends Object implements Iterable<Map.Entry<String,Double>>
Represents a simple resource floating point value grouped by resource names.
  • Constructor Details

    • ResourceVector

      public ResourceVector()
  • Method Details

    • newInstance

      public static ResourceVector newInstance()
      Creates a new ResourceVector with all pre-defined resources set to zero.
      Returns:
      zero resource vector
    • of

      public static ResourceVector of(double value)
      Creates a new ResourceVector with all pre-defined resources set to the same value.
      Parameters:
      value - the value to set all resources to
      Returns:
      uniform resource vector
    • of

      public static ResourceVector of(org.apache.hadoop.yarn.api.records.Resource resource)
      Creates a new ResourceVector with the values set in a Resource object.
      Parameters:
      resource - resource object the resource vector will be based on
      Returns:
      uniform resource vector
    • decrement

      public void decrement(ResourceVector otherResourceVector)
      Decrements values for each resource defined in the given resource vector.
      Parameters:
      otherResourceVector - rhs resource vector of the subtraction
    • decrement

      public void decrement(String resourceName, double value)
      Decrements the given resource by the specified value.
      Parameters:
      resourceName - name of the resource
      value - value to be subtracted from the resource's current value
    • increment

      public void increment(String resourceName, double value)
      Increments the given resource by the specified value.
      Parameters:
      resourceName - name of the resource
      value - value to be added to the resource's current value
    • getValue

      public double getValue(String resourceName)
    • setValue

      public void setValue(String resourceName, double value)
    • isEmpty

      public boolean isEmpty()
    • getResourceNames

      public Set<String> getResourceNames()
    • iterator

      public Iterator<Map.Entry<String,Double>> iterator()
      Specified by:
      iterator in interface Iterable<Map.Entry<String,Double>>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object