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
ConstructorDescriptionCreate 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 TypeMethodDescriptionvoid
add
(NormalizedResourcesWithMemory other) boolean
Return true if any of the resources are > 0.double
Calculate the average percentage used.double
Calculate the min percentage used of the resource.void
clear()
Set all resources to 0.boolean
couldFit
(double minWorkerCpu, NormalizedResourceRequest requestedResources) Is there any possibility that a resource request could ever fit on this.boolean
Check if resources might be able to fit.boolean
double
double
boolean
remove
(WorkerResources other, ResourceMetrics resourceMetrics) Remove the resources in other from this.boolean
boolean
remove
(NormalizedResourcesWithMemory other, ResourceMetrics resourceMetrics) Remove the resources in other from this.Return these resources as a normalized map.toString()
void
updateForRareResourceAffinity
(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:
getTotalMemoryMb
in 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:
getNormalizedResources
in 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:NormalizedResourcesWithMemory
Set all resources to 0.- Specified by:
clear
in interfaceNormalizedResourcesWithMemory
-
areAnyOverZero
public boolean areAnyOverZero()Description copied from interface:NormalizedResourcesWithMemory
Return true if any of the resources are > 0.- Specified by:
areAnyOverZero
in 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.
-