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 RasNodes |
nodes |
Constructor and Description |
---|
BaseResourceAwareStrategy() |
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<RasNode> 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(RasNode 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)
protected List<Component> getSpouts(TopologyDetails td)
Get a list of all the spouts in the topology.
td
- topology to get spouts frompublic List<RasNode> hostnameToNodes(String hostname)
hostname to Ids.
hostname
- the hostname.Copyright © 2020 The Apache Software Foundation. All rights reserved.