public abstract class BaseResourceAwareStrategy extends Object implements IStrategy
Modifier and Type | Class and Description |
---|---|
protected static class |
BaseResourceAwareStrategy.AllResources
a class to contain individual object resources as well as cumulative stats.
|
protected static interface |
BaseResourceAwareStrategy.ExistingScheduleFunc
interface for calculating the number of existing executors scheduled on a object (rack or node).
|
protected static class |
BaseResourceAwareStrategy.ObjectResources
class to keep track of resources on a rack or node.
|
Modifier and Type | Field and Description |
---|---|
protected Cluster |
cluster |
protected RAS_Nodes |
nodes |
Constructor and Description |
---|
BaseResourceAwareStrategy() |
Modifier and Type | Method and Description |
---|---|
protected WorkerSlot |
findWorkerForExec(ExecutorDetails exec,
TopologyDetails td,
Iterable<String> sortedNodes)
Find a worker to schedule executor exec on.
|
protected List<Component> |
getSpouts(TopologyDetails td)
Get a list of all the spouts in the topology.
|
List<RAS_Node> |
hostnameToNodes(String hostname)
hostname to Ids.
|
RAS_Node |
idToNode(String id)
Find RAS_Node for specified node id.
|
protected List<String> |
makeHostToNodeIds(List<String> hosts) |
protected SchedulingResult |
mkNotEnoughResources(TopologyDetails td) |
protected String |
nodeToRack(RAS_Node node)
Get the rack on which a node is a part of.
|
protected List<ExecutorDetails> |
orderExecutors(TopologyDetails td,
Collection<ExecutorDetails> unassignedExecutors)
Order executors based on how many in and out connections it will potentially need to make, in descending order.
|
void |
prepare(Map<String,Object> config)
Prepare the Strategy for scheduling.
|
protected boolean |
scheduleExecutor(ExecutorDetails exec,
TopologyDetails td,
Collection<ExecutorDetails> scheduledTasks,
Iterable<String> sortedNodes)
Schedule executor exec from topology td.
|
protected Iterable<String> |
sortAllNodes(TopologyDetails td,
ExecutorDetails exec,
List<String> favoredNodeIds,
List<String> unFavoredNodeIds) |
protected TreeSet<BaseResourceAwareStrategy.ObjectResources> |
sortNodes(List<RAS_Node> availNodes,
ExecutorDetails exec,
TopologyDetails topologyDetails,
String rackId,
Map<String,AtomicInteger> scheduledCount)
Nodes are sorted by two criteria.
|
protected abstract TreeSet<BaseResourceAwareStrategy.ObjectResources> |
sortObjectResources(BaseResourceAwareStrategy.AllResources allResources,
ExecutorDetails exec,
TopologyDetails topologyDetails,
BaseResourceAwareStrategy.ExistingScheduleFunc existingScheduleFunc) |
public void prepare(Map<String,Object> config)
IStrategy
Prepare the Strategy for scheduling.
protected SchedulingResult mkNotEnoughResources(TopologyDetails td)
protected boolean scheduleExecutor(ExecutorDetails exec, TopologyDetails td, Collection<ExecutorDetails> scheduledTasks, Iterable<String> sortedNodes)
Schedule executor exec from topology td.
exec
- the executor to scheduletd
- the topology executor exec is a part ofscheduledTasks
- executors that have been scheduledprotected abstract TreeSet<BaseResourceAwareStrategy.ObjectResources> sortObjectResources(BaseResourceAwareStrategy.AllResources allResources, ExecutorDetails exec, TopologyDetails topologyDetails, BaseResourceAwareStrategy.ExistingScheduleFunc existingScheduleFunc)
protected WorkerSlot findWorkerForExec(ExecutorDetails exec, TopologyDetails td, Iterable<String> sortedNodes)
Find a worker to schedule executor exec on.
exec
- the executor to scheduletd
- the topology that the executor is a part ofprotected TreeSet<BaseResourceAwareStrategy.ObjectResources> sortNodes(List<RAS_Node> availNodes, ExecutorDetails exec, TopologyDetails topologyDetails, String rackId, Map<String,AtomicInteger> scheduledCount)
Nodes are sorted by two criteria.
1) the number executors of the topology that needs to be scheduled is already on the node in descending order. The reasoning to sort based on criterion 1 is so we schedule the rest of a topology on the same node as the existing executors of the topology.
2) the subordinate/subservient resource availability percentage of a node in descending order We calculate the resource availability percentage by dividing the resource availability that have exhausted or little of one of the resources mentioned above will be ranked after on the node by the resource availability of the entire rack By doing this calculation, nodes nodes that have more balanced resource availability. So we will be less likely to pick a node that have a lot of one resource but a low amount of another.
availNodes
- a list of all the nodes we want to sortrackId
- the rack id availNodes are a part ofprotected Iterable<String> sortAllNodes(TopologyDetails td, ExecutorDetails exec, List<String> favoredNodeIds, List<String> unFavoredNodeIds)
protected String nodeToRack(RAS_Node node)
Get the rack on which a node is a part of.
node
- the node to find out which rack its onprotected List<ExecutorDetails> orderExecutors(TopologyDetails td, Collection<ExecutorDetails> unassignedExecutors)
Order executors based on how many in and out connections it will potentially need to make, in descending order. First order components by the number of in and out connections it will have. Then iterate through the sorted list of components. For each component sort the neighbors of that component by how many connections it will have to make with that component. Add an executor from this component and then from each neighboring component in sorted order. Do this until there is nothing left to schedule.
td
- The topology the executors belong tounassignedExecutors
- a collection of unassigned executors that need to be unassigned. Should only try to assign executors from this listprotected List<Component> getSpouts(TopologyDetails td)
Get a list of all the spouts in the topology.
td
- topology to get spouts frompublic List<RAS_Node> hostnameToNodes(String hostname)
hostname to Ids.
hostname
- the hostname.Copyright © 2019 The Apache Software Foundation. All rights reserved.