public class GenericResourceAwareStrategy extends BaseResourceAwareStrategy implements IStrategy
BaseResourceAwareStrategy.AllResources, BaseResourceAwareStrategy.ExistingScheduleFunc, BaseResourceAwareStrategy.ObjectResources
cluster, nodes
Constructor and Description |
---|
GenericResourceAwareStrategy() |
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.
|
static TreeSet<BaseResourceAwareStrategy.ObjectResources> |
sortObjectResourcesImpl(BaseResourceAwareStrategy.AllResources allResources,
ExecutorDetails exec,
TopologyDetails topologyDetails,
BaseResourceAwareStrategy.ExistingScheduleFunc existingScheduleFunc)
Implementation of the sortObjectResources method so other strategies can reuse it.
|
findWorkerForExec, getSpouts, hostnameToNodes, idToNode, makeHostToNodeIds, mkNotEnoughResources, nodeToRack, orderExecutors, prepare, scheduleExecutor, sortAllNodes, sortNodes
public static TreeSet<BaseResourceAwareStrategy.ObjectResources> sortObjectResourcesImpl(BaseResourceAwareStrategy.AllResources allResources, ExecutorDetails exec, TopologyDetails topologyDetails, BaseResourceAwareStrategy.ExistingScheduleFunc existingScheduleFunc)
Implementation of the sortObjectResources method so other strategies can reuse it.
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. How this differs from the DefaultResourceAwareStrategy is that the percentage boosts the node or rack if it is requested by the executor that the sorting is being done for and pulls it down if it is not. 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 and nodes or racks that have resources that are not requested will be ranked below . So we will be less likely to pick a rack that have a lot of one resource but a low amount of another and have a lot of resources that are not requested by the executor.
sortObjectResources
in class BaseResourceAwareStrategy
allResources
- contains all individual ObjectResources as well as cumulative statsexec
- executor for which the sorting is donetopologyDetails
- topologyDetails for the above executorexistingScheduleFunc
- a function to get existing executors already scheduled on this objectCopyright © 2020 The Apache Software Foundation. All rights reserved.