public abstract class BaseResourceAwareStrategy extends Object implements IStrategy
Modifier and Type | Class and Description |
---|---|
static class |
BaseResourceAwareStrategy.NodeSortType
Different node sorting types available.
|
Modifier and Type | Field and Description |
---|---|
protected Cluster |
cluster |
protected Map<String,Set<ExecutorDetails>> |
compToExecs |
protected Map<String,Object> |
config |
protected IExecSorter |
execSorter |
protected Map<ExecutorDetails,String> |
execToComp |
protected RasNodes |
nodes |
protected INodeSorter |
nodeSorter |
protected BaseResourceAwareStrategy.NodeSortType |
nodeSortType |
protected boolean |
orderExecutorsByProximity |
protected SchedulingSearcherState |
searcherState |
protected boolean |
sortNodesForEachExecutor |
protected TopologyDetails |
topologyDetails |
protected String |
topoName |
Constructor and Description |
---|
BaseResourceAwareStrategy() |
BaseResourceAwareStrategy(boolean sortNodesForEachExecutor,
BaseResourceAwareStrategy.NodeSortType nodeSortType)
Initialize for the default implementation of schedule().
|
Modifier and Type | Method and Description |
---|---|
protected SchedulingResult |
checkSchedulingFeasibility()
Check scheduling feasibility for a quick failure as the second step in
schedule(Cluster, TopologyDetails) . |
static int |
getMaxStateSearchFromTopoConf(Map<String,Object> topoConf) |
List<RasNode> |
hostnameToNodes(String hostname)
hostname to Ids.
|
RasNode |
idToNode(String id)
Find RASNode for specified node id.
|
protected boolean |
isExecAssignmentToWorkerValid(ExecutorDetails exec,
WorkerSlot worker)
Check if the assignment of the executor to the worker is valid.
|
static boolean |
isOrderByProximity(Map<String,Object> topoConf) |
void |
prepare(Map<String,Object> config)
Prepare the Strategy for scheduling.
|
protected void |
prepareForScheduling(Cluster cluster,
TopologyDetails topologyDetails)
Initialize instance variables as the first step in
schedule(Cluster, TopologyDetails) . |
SchedulingResult |
schedule(Cluster cluster,
TopologyDetails td)
Note that this method is not thread-safe.
|
protected SchedulingResult |
scheduleExecutorsOnNodes(List<ExecutorDetails> orderedExecutors,
Iterable<String> sortedNodesIter)
Try to schedule till successful or till limits (backtrack count or time) have been exceeded.
|
protected void |
setExecSorter(IExecSorter execSorter)
Set the pluggable sorter for ExecutorDetails.
|
protected void |
setNodeSorter(INodeSorter nodeSorter)
Set the pluggable sorter for Nodes.
|
protected final boolean sortNodesForEachExecutor
protected final BaseResourceAwareStrategy.NodeSortType nodeSortType
protected Cluster cluster
protected TopologyDetails topologyDetails
protected RasNodes nodes
protected String topoName
protected Map<String,Set<ExecutorDetails>> compToExecs
protected Map<ExecutorDetails,String> execToComp
protected boolean orderExecutorsByProximity
protected SchedulingSearcherState searcherState
protected IExecSorter execSorter
protected INodeSorter nodeSorter
public BaseResourceAwareStrategy()
public BaseResourceAwareStrategy(boolean sortNodesForEachExecutor, BaseResourceAwareStrategy.NodeSortType nodeSortType)
Initialize for the default implementation of schedule().
sortNodesForEachExecutor
- Sort nodes before scheduling each executor.nodeSortType
- type of sorting to be applied to object resource collection BaseResourceAwareStrategy.NodeSortType
.public void prepare(Map<String,Object> config)
IStrategy
Prepare the Strategy for scheduling.
public SchedulingResult schedule(Cluster cluster, TopologyDetails td)
Note that this method is not thread-safe. Several instance variables are generated from supplied parameters. In addition, the following instance variables are set to complete scheduling:
searcherState
execSorter
to sort executorsnodeSorter
to sort nodesScheduling consists of three main steps:
prepareForScheduling(Cluster, TopologyDetails)
checkSchedulingFeasibility()
, andscheduleExecutorsOnNodes(List, Iterable)
The executors and nodes are sorted in the order most conducive to scheduling for the strategy. Those interfaces may be overridden by subclasses using mutators:
setExecSorter(IExecSorter)
andsetNodeSorter(INodeSorter)
protected void prepareForScheduling(Cluster cluster, TopologyDetails topologyDetails)
Initialize instance variables as the first step in schedule(Cluster, TopologyDetails)
. This method may be extended by subclasses to initialize additional variables as in ConstraintSolverStrategy.prepareForScheduling(Cluster, TopologyDetails)
.
cluster
- on which executors will be scheduled.topologyDetails
- to be scheduled.protected void setExecSorter(IExecSorter execSorter)
Set the pluggable sorter for ExecutorDetails.
execSorter
- to use for sorting executorDetails when scheduling.protected void setNodeSorter(INodeSorter nodeSorter)
Set the pluggable sorter for Nodes.
nodeSorter
- to use for sorting nodes when scheduling.public static int getMaxStateSearchFromTopoConf(Map<String,Object> topoConf)
protected SchedulingResult checkSchedulingFeasibility()
Check scheduling feasibility for a quick failure as the second step in schedule(Cluster, TopologyDetails)
. If scheduling is not possible, then return a SchedulingStatus object with a failure status. If fully scheduled then return a successful SchedulingStatus. This method can be extended by subclasses ConstraintSolverStrategy.checkSchedulingFeasibility()
to check for additional failure conditions.
SchedulingResult
to terminate scheduling, otherwise return null to continue scheduling.protected boolean isExecAssignmentToWorkerValid(ExecutorDetails exec, WorkerSlot worker)
Check if the assignment of the executor to the worker is valid. In simple cases, this is simply a check of RasNode.wouldFit(WorkerSlot, ExecutorDetails, TopologyDetails)
. This method may be extended by subclasses to add additional checks, see ConstraintSolverStrategy.isExecAssignmentToWorkerValid(ExecutorDetails, WorkerSlot)
.
exec
- being scheduled.worker
- on which to schedule.public List<RasNode> hostnameToNodes(String hostname)
hostname to Ids.
hostname
- the hostname.public RasNode idToNode(String id)
Find RASNode for specified node id.
id
- the node/supervisor id to lookupprotected SchedulingResult scheduleExecutorsOnNodes(List<ExecutorDetails> orderedExecutors, Iterable<String> sortedNodesIter)
Try to schedule till successful or till limits (backtrack count or time) have been exceeded.
orderedExecutors
- Executors sorted in the preferred order cannot be null.sortedNodesIter
- Node iterable which may be null.Copyright © 2022 The Apache Software Foundation. All rights reserved.