public class NormalizedResourceOffer extends Object implements NormalizedResourcesWithMemory
An offer of resources with normalized resource names.
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
add(NormalizedResourcesWithMemory other) |
boolean |
areAnyOverZero()
Return true if any of the resources are > 0.
|
double |
calculateAveragePercentageUsedBy(NormalizedResourceOffer used)
Calculate the average percentage used.
|
double |
calculateMinPercentageUsedBy(NormalizedResourceOffer used)
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 |
couldHoldIgnoringSharedMemory(NormalizedResourcesWithMemory other)
Check if resources might be able to fit.
|
boolean |
couldHoldIgnoringSharedMemoryAndCpu(NormalizedResourcesWithMemory other) |
NormalizedResources |
getNormalizedResources() |
double |
getTotalCpu() |
double |
getTotalMemoryMb() |
boolean |
remove(NormalizedResourcesWithMemory other) |
boolean |
remove(NormalizedResourcesWithMemory other,
ResourceMetrics resourceMetrics)
Remove the resources in other from this.
|
boolean |
remove(WorkerResources other,
ResourceMetrics resourceMetrics)
Remove the resources in other from this.
|
Map<String,Double> |
toNormalizedMap()
Return these resources as a normalized map.
|
String |
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.
|
public NormalizedResourceOffer(Map<String,? extends Number> resources)
Create a new normalized resource offer.
resources
- the resources to be normalized.public NormalizedResourceOffer()
Create an offer with all resources set to 0.
public NormalizedResourceOffer(NormalizedResourceOffer other)
Copy Constructor.
other
- what to copy.public double getTotalMemoryMb()
getTotalMemoryMb
in interface NormalizedResourcesWithMemory
public Map<String,Double> toNormalizedMap()
Return these resources as a normalized map.
public void add(NormalizedResourcesWithMemory other)
public boolean remove(NormalizedResourcesWithMemory other, ResourceMetrics resourceMetrics)
Remove the resources in other from this.
other
- the resources to be removed.resourceMetrics
- The resource related metricspublic boolean remove(NormalizedResourcesWithMemory other)
public boolean remove(WorkerResources other, ResourceMetrics resourceMetrics)
Remove the resources in other from this.
other
- the resources to be removed.resourceMetrics
- The resource related metricspublic double calculateAveragePercentageUsedBy(NormalizedResourceOffer used)
Calculate the average percentage used.
public double calculateMinPercentageUsedBy(NormalizedResourceOffer used)
Calculate the min percentage used of the resource.
public boolean couldHoldIgnoringSharedMemory(NormalizedResourcesWithMemory other)
Check if resources might be able to fit.
public boolean couldHoldIgnoringSharedMemoryAndCpu(NormalizedResourcesWithMemory other)
public double getTotalCpu()
public NormalizedResources getNormalizedResources()
getNormalizedResources
in interface NormalizedResourcesWithMemory
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.
requestedResources
- the requested resources.public void clear()
NormalizedResourcesWithMemory
Set all resources to 0.
clear
in interface NormalizedResourcesWithMemory
public boolean areAnyOverZero()
NormalizedResourcesWithMemory
Return true if any of the resources are > 0.
areAnyOverZero
in interface NormalizedResourcesWithMemory
public boolean couldFit(double minWorkerCpu, NormalizedResourceRequest requestedResources)
Is there any possibility that a resource request could ever fit on this.
minWorkerCpu
- the configured minimum worker CPUrequestedResources
- the requested resourcesCopyright © 2022 The Apache Software Foundation. All rights reserved.