Class ResourceMapArrayBridge
java.lang.Object
org.apache.storm.scheduler.resource.normalization.ResourceMapArrayBridge
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble[]
empty()
Create an array that has all values 0.translateFromResourceArray
(double[] resources) Translates an array of resource values to a normalized resource map.double[]
translateToResourceArray
(Map<String, Double> normalizedResources) Translates a normalized resource map to an array of resource values.
-
Constructor Details
-
ResourceMapArrayBridge
public ResourceMapArrayBridge()
-
-
Method Details
-
translateToResourceArray
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
Translates an array of resource values to a normalized resource map.- Parameters:
resources
- The resource array to translate- Returns:
- The normalized resource map
-
getResourceNamesToArrayIndex
-