Class NormalizedResourceOffer
- java.lang.Object
-
- org.apache.storm.scheduler.resource.normalization.NormalizedResourceOffer
-
- All Implemented Interfaces:
NormalizedResourcesWithMemory
public class NormalizedResourceOffer extends Object implements NormalizedResourcesWithMemory
An offer of resources with normalized resource names.
-
-
Constructor Summary
Constructors Constructor Description NormalizedResourceOffer()Create an offer with all resources set to 0.NormalizedResourceOffer(Map<String,? extends Number> resources)Create a new normalized resource offer.NormalizedResourceOffer(NormalizedResourceOffer other)Copy Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(NormalizedResourcesWithMemory other)booleanareAnyOverZero()Return true if any of the resources are > 0.doublecalculateAveragePercentageUsedBy(NormalizedResourceOffer used)Calculate the average percentage used.doublecalculateMinPercentageUsedBy(NormalizedResourceOffer used)Calculate 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.booleancouldHoldIgnoringSharedMemory(NormalizedResourcesWithMemory other)Check if resources might be able to fit.booleancouldHoldIgnoringSharedMemoryAndCpu(NormalizedResourcesWithMemory other)NormalizedResourcesgetNormalizedResources()doublegetTotalCpu()doublegetTotalMemoryMb()booleanremove(WorkerResources other, ResourceMetrics resourceMetrics)Remove the resources in other from this.booleanremove(NormalizedResourcesWithMemory other)booleanremove(NormalizedResourcesWithMemory other, ResourceMetrics resourceMetrics)Remove the resources in other from this.Map<String,Double>toNormalizedMap()Return these resources as a normalized map.StringtoString()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 Detail
-
NormalizedResourceOffer
public NormalizedResourceOffer(Map<String,? extends Number> resources)
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
public NormalizedResourceOffer(NormalizedResourceOffer other)
Copy Constructor.- Parameters:
other- what to copy.
-
-
Method Detail
-
getTotalMemoryMb
public double getTotalMemoryMb()
- Specified by:
getTotalMemoryMbin interfaceNormalizedResourcesWithMemory
-
toNormalizedMap
public Map<String,Double> toNormalizedMap()
Return these resources as a normalized map.- Returns:
- the normalized map.
-
add
public void add(NormalizedResourcesWithMemory other)
-
remove
public boolean remove(NormalizedResourcesWithMemory other, ResourceMetrics resourceMetrics)
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
public boolean remove(NormalizedResourcesWithMemory other)
-
remove
public boolean remove(WorkerResources other, ResourceMetrics resourceMetrics)
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
public double calculateAveragePercentageUsedBy(NormalizedResourceOffer used)
Calculate the average percentage used.
-
calculateMinPercentageUsedBy
public double calculateMinPercentageUsedBy(NormalizedResourceOffer used)
Calculate the min percentage used of the resource.
-
couldHoldIgnoringSharedMemory
public boolean couldHoldIgnoringSharedMemory(NormalizedResourcesWithMemory other)
Check if resources might be able to fit.
-
couldHoldIgnoringSharedMemoryAndCpu
public boolean couldHoldIgnoringSharedMemoryAndCpu(NormalizedResourcesWithMemory other)
-
getTotalCpu
public double getTotalCpu()
-
getNormalizedResources
public NormalizedResources getNormalizedResources()
- Specified by:
getNormalizedResourcesin interfaceNormalizedResourcesWithMemory
-
updateForRareResourceAffinity
public 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.- 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
public boolean couldFit(double minWorkerCpu, NormalizedResourceRequest requestedResources)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.
-
-