public class NormalizedResourceOffer extends Object implements NormalizedResourcesWithMemory
| 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)
resources - the resources to be normalized.public NormalizedResourceOffer()
public NormalizedResourceOffer(NormalizedResourceOffer other)
other - what to copy.public double getTotalMemoryMb()
getTotalMemoryMb in interface NormalizedResourcesWithMemorypublic Map<String,Double> toNormalizedMap()
public void add(NormalizedResourcesWithMemory other)
public boolean remove(NormalizedResourcesWithMemory other, ResourceMetrics resourceMetrics)
other - the resources to be removed.resourceMetrics - The resource related metricspublic boolean remove(NormalizedResourcesWithMemory other)
public boolean remove(WorkerResources other, ResourceMetrics resourceMetrics)
other - the resources to be removed.resourceMetrics - The resource related metricspublic double calculateAveragePercentageUsedBy(NormalizedResourceOffer used)
public double calculateMinPercentageUsedBy(NormalizedResourceOffer used)
public boolean couldHoldIgnoringSharedMemory(NormalizedResourcesWithMemory other)
public boolean couldHoldIgnoringSharedMemoryAndCpu(NormalizedResourcesWithMemory other)
public double getTotalCpu()
public NormalizedResources getNormalizedResources()
getNormalizedResources in interface NormalizedResourcesWithMemorypublic void updateForRareResourceAffinity(NormalizedResourceRequest requestedResources)
requestedResources - the requested resources.public void clear()
NormalizedResourcesWithMemoryclear in interface NormalizedResourcesWithMemorypublic boolean areAnyOverZero()
NormalizedResourcesWithMemoryareAnyOverZero in interface NormalizedResourcesWithMemorypublic boolean couldFit(double minWorkerCpu,
                        NormalizedResourceRequest requestedResources)
minWorkerCpu - the configured minimum worker CPUrequestedResources - the requested resourcesCopyright © 2023 The Apache Software Foundation. All rights reserved.