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 SummaryConstructorsConstructorDescriptionCreate an offer with all resources set to 0.NormalizedResourceOffer(Map<String, ? extends Number> resources) Create a new normalized resource offer.Copy Constructor.
- 
Method SummaryModifier 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- 
NormalizedResourceOfferCreate a new normalized resource offer.- Parameters:
- resources- the resources to be normalized.
 
- 
NormalizedResourceOfferpublic NormalizedResourceOffer()Create an offer with all resources set to 0.
- 
NormalizedResourceOfferCopy Constructor.- Parameters:
- other- what to copy.
 
 
- 
- 
Method Details- 
getTotalMemoryMbpublic double getTotalMemoryMb()- Specified by:
- getTotalMemoryMbin interface- NormalizedResourcesWithMemory
 
- 
toNormalizedMapReturn these resources as a normalized map.- Returns:
- the normalized map.
 
- 
add
- 
removeRemove 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
- 
removeRemove 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.
 
- 
calculateAveragePercentageUsedByCalculate the average percentage used.
- 
calculateMinPercentageUsedByCalculate the min percentage used of the resource.
- 
getTotalCpupublic double getTotalCpu()
- 
getNormalizedResources- Specified by:
- getNormalizedResourcesin interface- NormalizedResourcesWithMemory
 
- 
toString
- 
updateForRareResourceAffinityIf 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.
 
- 
clearpublic void clear()Description copied from interface:NormalizedResourcesWithMemorySet all resources to 0.- Specified by:
- clearin interface- NormalizedResourcesWithMemory
 
- 
areAnyOverZeropublic boolean areAnyOverZero()Description copied from interface:NormalizedResourcesWithMemoryReturn true if any of the resources are > 0.- Specified by:
- areAnyOverZeroin interface- NormalizedResourcesWithMemory
 
- 
couldFitIs there any possibility that a resource request could ever fit on this.- Parameters:
- minWorkerCpu- the configured minimum worker CPU
- requestedResources- 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.
 
 
-