Class ResourceMapArrayBridge

java.lang.Object
org.apache.storm.scheduler.resource.normalization.ResourceMapArrayBridge

public class ResourceMapArrayBridge extends Object
Provides translation between normalized resource maps and resource value arrays. Some operations use resource value arrays instead of the full normalized resource map as an optimization. See NormalizedResources.
  • Constructor Details

    • ResourceMapArrayBridge

      public ResourceMapArrayBridge()
  • Method Details

    • translateToResourceArray

      public double[] translateToResourceArray(Map<String,Double> normalizedResources)
      Translates a normalized resource map to an array of resource values. Each resource name will be assigned an index in the array, which is guaranteed to be consistent with subsequent invocations of this method. Note that CPU and memory resources are not translated by this method, as they are expected to be captured elsewhere.
      Parameters:
      normalizedResources - The resources to translate to an array
      Returns:
      The array of resource values
    • empty

      public double[] empty()
      Create an array that has all values 0.
      Returns:
      the empty array.
    • translateFromResourceArray

      public Map<String,Double> translateFromResourceArray(double[] resources)
      Translates an array of resource values to a normalized resource map.
      Parameters:
      resources - The resource array to translate
      Returns:
      The normalized resource map
    • getResourceNamesToArrayIndex

      public Map<String,Integer> getResourceNamesToArrayIndex()