public class DefaultResourceAwareStrategy extends BaseResourceAwareStrategy implements IStrategy
BaseResourceAwareStrategy.AllResources, BaseResourceAwareStrategy.ExistingScheduleFunc, BaseResourceAwareStrategy.ObjectResources
cluster, nodes
Constructor and Description |
---|
DefaultResourceAwareStrategy() |
Modifier and Type | Method and Description |
---|---|
SchedulingResult |
schedule(Cluster cluster,
TopologyDetails td)
This method is invoked to calculate a scheduling for topology td.
|
protected TreeSet<BaseResourceAwareStrategy.ObjectResources> |
sortObjectResources(BaseResourceAwareStrategy.AllResources allResources,
ExecutorDetails exec,
TopologyDetails topologyDetails,
BaseResourceAwareStrategy.ExistingScheduleFunc existingScheduleFunc)
Sort objects by the following two criteria.
|
findWorkerForExec, getSpouts, hostnameToNodes, idToNode, makeHostToNodeIds, mkNotEnoughResources, nodeToRack, orderExecutors, prepare, scheduleExecutor, sortAllNodes, sortNodes
public SchedulingResult schedule(Cluster cluster, TopologyDetails td)
IStrategy
This method is invoked to calculate a scheduling for topology td. Cluster will reject any changes that are not for the given topology. Any changes made to the cluster will be committed if the scheduling is successful.
NOTE: scheduling occurs as a runnable in an interruptible thread. Scheduling should consider being interrupted if long running.protected TreeSet<BaseResourceAwareStrategy.ObjectResources> sortObjectResources(BaseResourceAwareStrategy.AllResources allResources, ExecutorDetails exec, TopologyDetails topologyDetails, BaseResourceAwareStrategy.ExistingScheduleFunc existingScheduleFunc)
Sort objects by the following two criteria. 1) the number executors of the topology that needs to be scheduled is already on the object (node or rack) in descending order. The reasoning to sort based on criterion 1 is so we schedule the rest of a topology on the same object (node or rack) as the existing executors of the topology. 2) the subordinate/subservient resource availability percentage of a rack in descending order We calculate the resource availability percentage by dividing the resource availability of the object (node or rack) by the resource availability of the entire rack or cluster depending on if object references a node or a rack. By doing this calculation, objects (node or rack) that have exhausted or little of one of the resources mentioned above will be ranked after racks that have more balanced resource availability. So we will be less likely to pick a rack that have a lot of one resource but a low amount of another.
sortObjectResources
in class BaseResourceAwareStrategy
allResources
- contains all individual ObjectResources as well as cumulative statsexistingScheduleFunc
- a function to get existing executors already scheduled on this objectCopyright © 2022 The Apache Software Foundation. All rights reserved.