@InterfaceAudience.Private @InterfaceStability.Unstable public abstract class ResourceCalculator extends Object
Resource
comparison and manipulation interfaces.Constructor and Description |
---|
ResourceCalculator() |
Modifier and Type | Method and Description |
---|---|
int |
compare(org.apache.hadoop.yarn.api.records.Resource clusterResource,
org.apache.hadoop.yarn.api.records.Resource lhs,
org.apache.hadoop.yarn.api.records.Resource rhs)
On a cluster with capacity
clusterResource , compare lhs
and rhs considering all resources. |
abstract int |
compare(org.apache.hadoop.yarn.api.records.Resource clusterResource,
org.apache.hadoop.yarn.api.records.Resource lhs,
org.apache.hadoop.yarn.api.records.Resource rhs,
boolean singleType)
On a cluster with capacity
clusterResource , compare lhs
and rhs . |
abstract long |
computeAvailableContainers(org.apache.hadoop.yarn.api.records.Resource available,
org.apache.hadoop.yarn.api.records.Resource required)
Compute the number of containers which can be allocated given
available and required resources. |
abstract float |
divide(org.apache.hadoop.yarn.api.records.Resource clusterResource,
org.apache.hadoop.yarn.api.records.Resource numerator,
org.apache.hadoop.yarn.api.records.Resource denominator)
Divide resource
numerator by resource denominator
using specified policy (domination, average, fairness etc.); hence overall
clusterResource is provided for context. |
static int |
divideAndCeil(int a,
float b) |
static int |
divideAndCeil(int a,
int b) |
static long |
divideAndCeil(long a,
float b) |
static long |
divideAndCeil(long a,
long b) |
abstract org.apache.hadoop.yarn.api.records.Resource |
divideAndCeil(org.apache.hadoop.yarn.api.records.Resource numerator,
float denominator)
Divide-and-ceil
numerator by denominator . |
abstract org.apache.hadoop.yarn.api.records.Resource |
divideAndCeil(org.apache.hadoop.yarn.api.records.Resource numerator,
int denominator)
Divide-and-ceil
numerator by denominator . |
static float |
divideSafelyAsFloat(long lhs,
long rhs)
Divides lhs by rhs.
|
abstract boolean |
fitsIn(org.apache.hadoop.yarn.api.records.Resource smaller,
org.apache.hadoop.yarn.api.records.Resource bigger)
Check if a smaller resource can be contained by bigger resource.
|
abstract Set<String> |
getInsufficientResourceNames(org.apache.hadoop.yarn.api.records.Resource required,
org.apache.hadoop.yarn.api.records.Resource available)
Get insufficient resource names via comparing required resource and
capacity resource.
|
abstract boolean |
isAllInvalidDivisor(org.apache.hadoop.yarn.api.records.Resource r)
Determine if all resources are zero.
|
abstract boolean |
isAnyMajorResourceAboveZero(org.apache.hadoop.yarn.api.records.Resource resource)
Check if resource has any major resource types (which are all NodeManagers
included) has a > 0 value.
|
abstract boolean |
isAnyMajorResourceZeroOrNegative(org.apache.hadoop.yarn.api.records.Resource resource)
Check if resource has any major resource types (which are all NodeManagers
included) a zero value or negative value.
|
abstract boolean |
isInvalidDivisor(org.apache.hadoop.yarn.api.records.Resource r)
Determine if a resource is not suitable for use as a divisor
(will result in divide by 0, etc)
|
abstract org.apache.hadoop.yarn.api.records.Resource |
multiplyAndNormalizeDown(org.apache.hadoop.yarn.api.records.Resource r,
double by,
org.apache.hadoop.yarn.api.records.Resource stepFactor)
Multiply resource
r by factor by
and normalize down using step-factor stepFactor . |
abstract org.apache.hadoop.yarn.api.records.Resource |
multiplyAndNormalizeUp(org.apache.hadoop.yarn.api.records.Resource r,
double[] by,
org.apache.hadoop.yarn.api.records.Resource stepFactor)
Multiply resource
r by factor by
and normalize up using step-factor stepFactor . |
abstract org.apache.hadoop.yarn.api.records.Resource |
multiplyAndNormalizeUp(org.apache.hadoop.yarn.api.records.Resource r,
double by,
org.apache.hadoop.yarn.api.records.Resource stepFactor)
Multiply resource
r by factor by
and normalize up using step-factor stepFactor . |
abstract org.apache.hadoop.yarn.api.records.Resource |
normalize(org.apache.hadoop.yarn.api.records.Resource r,
org.apache.hadoop.yarn.api.records.Resource minimumResource,
org.apache.hadoop.yarn.api.records.Resource maximumResource,
org.apache.hadoop.yarn.api.records.Resource stepFactor)
Normalize resource
r given the base
minimumResource and verify against max allowed
maximumResource using a step factor for the normalization. |
abstract org.apache.hadoop.yarn.api.records.Resource |
normalizeDown(org.apache.hadoop.yarn.api.records.Resource r,
org.apache.hadoop.yarn.api.records.Resource stepFactor)
Get resource
r and normalize down using step-factor
stepFactor . |
abstract float |
ratio(org.apache.hadoop.yarn.api.records.Resource a,
org.apache.hadoop.yarn.api.records.Resource b)
Ratio of resource
a to resource b . |
static int |
roundDown(int a,
int b) |
static long |
roundDown(long a,
long b) |
abstract org.apache.hadoop.yarn.api.records.Resource |
roundDown(org.apache.hadoop.yarn.api.records.Resource r,
org.apache.hadoop.yarn.api.records.Resource stepFactor)
Round-down resource
r given factor stepFactor . |
static int |
roundUp(int a,
int b) |
static long |
roundUp(long a,
long b) |
abstract org.apache.hadoop.yarn.api.records.Resource |
roundUp(org.apache.hadoop.yarn.api.records.Resource r,
org.apache.hadoop.yarn.api.records.Resource stepFactor)
Round-up resource
r given factor stepFactor . |
public abstract int compare(org.apache.hadoop.yarn.api.records.Resource clusterResource, org.apache.hadoop.yarn.api.records.Resource lhs, org.apache.hadoop.yarn.api.records.Resource rhs, boolean singleType)
clusterResource
, compare lhs
and rhs
. Consider all resources unless singleType
is set
to true. When singleType
is set to true, consider only one
resource as per the ResourceCalculator
implementation; the
DefaultResourceCalculator
considers memory and
DominantResourceCalculator
considers the dominant resource.clusterResource
- cluster capacitylhs
- First Resource
to comparerhs
- Second Resource
to comparesingleType
- Whether to consider a single resource type or all
resource typeslhs
is smaller, 0 if equal and 1 if it is largerpublic int compare(org.apache.hadoop.yarn.api.records.Resource clusterResource, org.apache.hadoop.yarn.api.records.Resource lhs, org.apache.hadoop.yarn.api.records.Resource rhs)
clusterResource
, compare lhs
and rhs
considering all resources.clusterResource
- cluster capacitylhs
- First Resource
to comparerhs
- Second Resource
to comparelhs
is smaller, 0 if equal and 1 if it is largerpublic static int divideAndCeil(int a, int b)
public static int divideAndCeil(int a, float b)
public static long divideAndCeil(long a, long b)
public static long divideAndCeil(long a, float b)
public static float divideSafelyAsFloat(long lhs, long rhs)
lhs
- left number.rhs
- right number.public static int roundUp(int a, int b)
public static long roundUp(long a, long b)
public static long roundDown(long a, long b)
public static int roundDown(int a, int b)
public abstract long computeAvailableContainers(org.apache.hadoop.yarn.api.records.Resource available, org.apache.hadoop.yarn.api.records.Resource required)
available
and required
resources.available
- available resourcesrequired
- required resourcespublic abstract org.apache.hadoop.yarn.api.records.Resource multiplyAndNormalizeUp(org.apache.hadoop.yarn.api.records.Resource r, double by, org.apache.hadoop.yarn.api.records.Resource stepFactor)
r
by factor by
and normalize up using step-factor stepFactor
.r
- resource to be multipliedby
- multiplierstepFactor
- factor by which to normalize uppublic abstract org.apache.hadoop.yarn.api.records.Resource multiplyAndNormalizeUp(org.apache.hadoop.yarn.api.records.Resource r, double[] by, org.apache.hadoop.yarn.api.records.Resource stepFactor)
r
by factor by
and normalize up using step-factor stepFactor
.r
- resource to be multipliedby
- multiplier array for all resource typesstepFactor
- factor by which to normalize uppublic abstract org.apache.hadoop.yarn.api.records.Resource multiplyAndNormalizeDown(org.apache.hadoop.yarn.api.records.Resource r, double by, org.apache.hadoop.yarn.api.records.Resource stepFactor)
r
by factor by
and normalize down using step-factor stepFactor
.r
- resource to be multipliedby
- multiplierstepFactor
- factor by which to normalize downpublic abstract org.apache.hadoop.yarn.api.records.Resource normalize(org.apache.hadoop.yarn.api.records.Resource r, org.apache.hadoop.yarn.api.records.Resource minimumResource, org.apache.hadoop.yarn.api.records.Resource maximumResource, org.apache.hadoop.yarn.api.records.Resource stepFactor)
r
given the base
minimumResource
and verify against max allowed
maximumResource
using a step factor for the normalization.r
- resourceminimumResource
- minimum valuemaximumResource
- the upper bound of the resource to be allocatedstepFactor
- the increment for resources to be allocatedpublic abstract org.apache.hadoop.yarn.api.records.Resource roundUp(org.apache.hadoop.yarn.api.records.Resource r, org.apache.hadoop.yarn.api.records.Resource stepFactor)
r
given factor stepFactor
.r
- resourcestepFactor
- step-factorpublic abstract org.apache.hadoop.yarn.api.records.Resource roundDown(org.apache.hadoop.yarn.api.records.Resource r, org.apache.hadoop.yarn.api.records.Resource stepFactor)
r
given factor stepFactor
.r
- resourcestepFactor
- step-factorpublic abstract float divide(org.apache.hadoop.yarn.api.records.Resource clusterResource, org.apache.hadoop.yarn.api.records.Resource numerator, org.apache.hadoop.yarn.api.records.Resource denominator)
numerator
by resource denominator
using specified policy (domination, average, fairness etc.); hence overall
clusterResource
is provided for context.clusterResource
- cluster resourcesnumerator
- numeratordenominator
- denominatornumerator
/denominator
using specific policypublic abstract boolean isInvalidDivisor(org.apache.hadoop.yarn.api.records.Resource r)
r
- resourcepublic abstract boolean isAllInvalidDivisor(org.apache.hadoop.yarn.api.records.Resource r)
r
- resourcepublic abstract float ratio(org.apache.hadoop.yarn.api.records.Resource a, org.apache.hadoop.yarn.api.records.Resource b)
a
to resource b
.a
- resourceb
- resourcea
to resource b
public abstract org.apache.hadoop.yarn.api.records.Resource divideAndCeil(org.apache.hadoop.yarn.api.records.Resource numerator, int denominator)
numerator
by denominator
.numerator
- numerator resourcedenominator
- denominatorpublic abstract org.apache.hadoop.yarn.api.records.Resource divideAndCeil(org.apache.hadoop.yarn.api.records.Resource numerator, float denominator)
numerator
by denominator
.numerator
- numerator resourcedenominator
- denominatorpublic abstract boolean fitsIn(org.apache.hadoop.yarn.api.records.Resource smaller, org.apache.hadoop.yarn.api.records.Resource bigger)
smaller
- smaller resource.bigger
- bigger resource.public abstract boolean isAnyMajorResourceZeroOrNegative(org.apache.hadoop.yarn.api.records.Resource resource)
resource
- resourcepublic abstract org.apache.hadoop.yarn.api.records.Resource normalizeDown(org.apache.hadoop.yarn.api.records.Resource r, org.apache.hadoop.yarn.api.records.Resource stepFactor)
r
and normalize down using step-factor
stepFactor
.r
- resource to be multipliedstepFactor
- factor by which to normalize downpublic abstract boolean isAnyMajorResourceAboveZero(org.apache.hadoop.yarn.api.records.Resource resource)
resource
- resourcepublic abstract Set<String> getInsufficientResourceNames(org.apache.hadoop.yarn.api.records.Resource required, org.apache.hadoop.yarn.api.records.Resource available)
required
- - required resourceavailable
- - available resourceCopyright © 2008–2024 Apache Software Foundation. All rights reserved.