public class LocalityMulticastAMRMProxyPolicy extends AbstractAMRMProxyPolicy
FederationAMRMProxyPolicy
interface that
carefully multicasts the requests with the following behavior:
Host localized ResourceRequest
s are always forwarded to the RM that
owns the corresponding node, based on the feedback of a
SubClusterResolver
. If the SubClusterResolver
cannot resolve
this node we default to forwarding the ResourceRequest
to the home
sub-cluster.
Rack localized ResourceRequest
s are forwarded to the RMs that owns
the corresponding rack. Note that in some deployments each rack could be
striped across multiple RMs. This policy respects that. If the
SubClusterResolver
cannot resolve this rack we default to forwarding
the ResourceRequest
to the home sub-cluster.
ANY requests corresponding to node/rack local requests are forwarded only to the set of RMs that owns the corresponding localized requests. The number of containers listed in each ANY is proportional to the number of localized container requests (associated to this ANY via the same allocateRequestId).
ANY that are not associated to node/rack local requests are split among RMs
based on the "weights" in the WeightedPolicyInfo
configuration *and*
headroom information. The headroomAlpha
parameter of the policy
configuration indicates how much headroom contributes to the splitting
choice. Value of 1.0f indicates the weights are interpreted only as 0/1
boolean but all splitting is based on the advertised headroom (fallback to
1/N for RMs that we don't have headroom info from). An headroomAlpha
value of 0.0f means headroom is ignored and all splitting decisions are
proportional to the "weights" in the configuration of the policy.
ANY of zero size are forwarded to all known subclusters (i.e., subclusters where we scheduled containers before), as they may represent a user attempt to cancel a previous request (and we are mostly stateless now, so should forward to all known RMs).
Invariants:
The policy always excludes non-active RMs.
The policy always excludes RMs that do not appear in the policy configuration weights, or have a weight of 0 (even if localized resources explicit refer to it).
(Bar rounding to closest ceiling of fractional containers) The sum of requests made to multiple RMs at the ANY level "adds-up" to the user request. The maximum possible excess in a given request is a number of containers less or equal to number of sub-clusters in the federation.
Modifier and Type | Class and Description |
---|---|
protected class |
LocalityMulticastAMRMProxyPolicy.AllocationBookkeeper
This helper class is used to book-keep the requests made to each
subcluster, and maintain useful statistics to split ANY requests.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PRINT_RR_MAX |
static org.slf4j.Logger |
LOG |
static String |
PRINT_RR_MAX |
Constructor and Description |
---|
LocalityMulticastAMRMProxyPolicy() |
Modifier and Type | Method and Description |
---|---|
protected ArrayList<Integer> |
computeIntegerAssignment(int totalNum,
ArrayList<Float> weightsList)
Split the integer into bins according to the weights.
|
protected SubClusterId |
getSubClusterForUnResolvedRequest(LocalityMulticastAMRMProxyPolicy.AllocationBookkeeper bookKeeper,
long allocationId)
For unit test to override.
|
void |
notifyOfResponse(SubClusterId subClusterId,
org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse response)
This method should be invoked to notify the policy about responses being
received.
|
static String |
prettyPrintRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> response,
int max)
Print a list of Resource Requests into a one line string.
|
void |
reinitialize(FederationPolicyInitializationContext policyContext)
This method is invoked to initialize of update the configuration of
policies.
|
protected SubClusterId |
routeNodeRequestIfNeeded(SubClusterId targetId,
int maxThreshold,
Set<SubClusterId> activeAndEnabledSCs)
When certain subcluster is too loaded, reroute Node requests going there.
|
Map<SubClusterId,List<org.apache.hadoop.yarn.api.records.ResourceRequest>> |
splitResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> resourceRequests,
Set<SubClusterId> timedOutSubClusters)
Splits the
ResourceRequest s from the client across one or more
sub-clusters based on the policy semantics (e.g., broadcast, load-based). |
validate
getActiveSubclusters, getIsDirty, getPolicyContext, getPolicyInfo, setPolicyContext, setPolicyInfo
public static final org.slf4j.Logger LOG
public static final String PRINT_RR_MAX
public static final int DEFAULT_PRINT_RR_MAX
public static String prettyPrintRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> response, int max)
response
- list of ResourceRequestmax
- number of ResourceRequest to printpublic void reinitialize(FederationPolicyInitializationContext policyContext) throws FederationPolicyInitializationException
ConfigurableFederationPolicy
reinitialize
in interface ConfigurableFederationPolicy
reinitialize
in class AbstractConfigurableFederationPolicy
policyContext
- the new context to provide to implementor.FederationPolicyInitializationException
- in case the initialization
fails.public void notifyOfResponse(SubClusterId subClusterId, org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse response) throws org.apache.hadoop.yarn.exceptions.YarnException
FederationAMRMProxyPolicy
notifyOfResponse
in interface FederationAMRMProxyPolicy
notifyOfResponse
in class AbstractAMRMProxyPolicy
subClusterId
- the id of the subcluster sending the notificationresponse
- the response received from one of the RMsorg.apache.hadoop.yarn.exceptions.YarnException
- in case the response is not validpublic Map<SubClusterId,List<org.apache.hadoop.yarn.api.records.ResourceRequest>> splitResourceRequests(List<org.apache.hadoop.yarn.api.records.ResourceRequest> resourceRequests, Set<SubClusterId> timedOutSubClusters) throws org.apache.hadoop.yarn.exceptions.YarnException
FederationAMRMProxyPolicy
ResourceRequest
s from the client across one or more
sub-clusters based on the policy semantics (e.g., broadcast, load-based).resourceRequests
- the list of ResourceRequest
s from the AM to
be splittimedOutSubClusters
- the set of sub-clusters that haven't had a
successful heart-beat response for a while.SubClusterId
to the
list of ResourceRequest
s that should be forwarded to itorg.apache.hadoop.yarn.exceptions.YarnException
- in case the request is malformed or no viable
sub-clusters can be found.protected SubClusterId getSubClusterForUnResolvedRequest(LocalityMulticastAMRMProxyPolicy.AllocationBookkeeper bookKeeper, long allocationId)
bookKeeper
- bookKeeperallocationId
- allocationId.@VisibleForTesting protected ArrayList<Integer> computeIntegerAssignment(int totalNum, ArrayList<Float> weightsList) throws org.apache.hadoop.yarn.exceptions.YarnException
totalNum
- total number of containers to splitweightsList
- the weights for each subclusterorg.apache.hadoop.yarn.exceptions.YarnException
- if failsprotected SubClusterId routeNodeRequestIfNeeded(SubClusterId targetId, int maxThreshold, Set<SubClusterId> activeAndEnabledSCs)
targetId
- current subClusterId where request is sentmaxThreshold
- threshold for Pending countactiveAndEnabledSCs
- list of active scCopyright © 2008–2024 Apache Software Foundation. All rights reserved.