Class NormalizedResourceOffer
java.lang.Object
org.apache.storm.scheduler.resource.normalization.NormalizedResourceOffer
- All Implemented Interfaces:
NormalizedResourcesWithMemory
An offer of resources with normalized resource names.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an offer with all resources set to 0.NormalizedResourceOffer(Map<String, ? extends Number> resources) Create a new normalized resource offer.Copy Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(NormalizedResourcesWithMemory other) booleanReturn true if any of the resources are > 0.doubleCalculate the average percentage used.doubleCalculate the min percentage used of the resource.voidclear()Set all resources to 0.booleancouldFit(double minWorkerCpu, NormalizedResourceRequest requestedResources) Is there any possibility that a resource request could ever fit on this.booleanCheck if resources might be able to fit.booleandoubledoublebooleanremove(WorkerResources other, ResourceMetrics resourceMetrics) Remove the resources in other from this.booleanbooleanremove(NormalizedResourcesWithMemory other, ResourceMetrics resourceMetrics) Remove the resources in other from this.Return these resources as a normalized map.toString()voidupdateForRareResourceAffinity(NormalizedResourceRequest requestedResources) If a node or rack has a kind of resource not in a request, make that resource negative so when sorting that node or rack will be less likely to be selected.
-
Constructor Details
-
NormalizedResourceOffer
Create a new normalized resource offer.- Parameters:
resources- the resources to be normalized.
-
NormalizedResourceOffer
public NormalizedResourceOffer()Create an offer with all resources set to 0. -
NormalizedResourceOffer
Copy Constructor.- Parameters:
other- what to copy.
-
-
Method Details
-
getTotalMemoryMb
public double getTotalMemoryMb()- Specified by:
getTotalMemoryMbin interfaceNormalizedResourcesWithMemory
-
toNormalizedMap
Return these resources as a normalized map.- Returns:
- the normalized map.
-
add
-
remove
Remove the resources in other from this.- Parameters:
other- the resources to be removed.resourceMetrics- The resource related metrics- Returns:
- true if one or more resources in other were larger than available resources in this, else false.
-
remove
-
remove
Remove the resources in other from this.- Parameters:
other- the resources to be removed.resourceMetrics- The resource related metrics- Returns:
- true if one or more resources in other were larger than available resources in this, else false.
-
calculateAveragePercentageUsedBy
Calculate the average percentage used. -
calculateMinPercentageUsedBy
Calculate the min percentage used of the resource. -
getTotalCpu
public double getTotalCpu() -
getNormalizedResources
- Specified by:
getNormalizedResourcesin interfaceNormalizedResourcesWithMemory
-
toString
-
updateForRareResourceAffinity
If a node or rack has a kind of resource not in a request, make that resource negative so when sorting that node or rack will be less likely to be selected.- Parameters:
requestedResources- the requested resources.
-
clear
public void clear()Description copied from interface:NormalizedResourcesWithMemorySet all resources to 0.- Specified by:
clearin interfaceNormalizedResourcesWithMemory
-
areAnyOverZero
public boolean areAnyOverZero()Description copied from interface:NormalizedResourcesWithMemoryReturn true if any of the resources are > 0.- Specified by:
areAnyOverZeroin interfaceNormalizedResourcesWithMemory
-
couldFit
Is there any possibility that a resource request could ever fit on this.- Parameters:
minWorkerCpu- the configured minimum worker CPUrequestedResources- the requested resources- Returns:
- true if there is the possibility it might fit, no guarantee that it will, or false if there is no way it would ever fit.
-