Class NodeSorter
- All Implemented Interfaces:
INodeSorter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
interface for calculating the number of existing executors scheduled on a object (rack or node). -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Cluster
protected final BaseResourceAwareStrategy.NodeSortType
protected TopologyDetails
-
Constructor Summary
ConstructorsConstructorDescriptionNodeSorter
(Cluster cluster, TopologyDetails topologyDetails, BaseResourceAwareStrategy.NodeSortType nodeSortType) Initialize for the default implementation node sorting. -
Method Summary
Modifier and TypeMethodDescriptionRacks are sorted by two criteria.hostnameToNodes
(String hostname) hostname to Ids.makeHostToNodeIds
(List<String> hosts) void
prepare
(ExecutorDetails exec) Prepare for node sorting.protected List<ObjectResourcesItem>
sortObjectResources
(ObjectResourcesSummary resourcesSummary, ExecutorDetails exec, NodeSorter.ExistingScheduleFunc existingScheduleFunc) Scheduling usessortAllNodes()
which eventually calls this method whose behavior can be altered by settingnodeSortType
.
-
Field Details
-
nodeSortType
-
cluster
-
topologyDetails
-
greyListedSupervisorIds
-
favoredNodeIds
-
unFavoredNodeIds
-
-
Constructor Details
-
NodeSorter
public NodeSorter(Cluster cluster, TopologyDetails topologyDetails, BaseResourceAwareStrategy.NodeSortType nodeSortType) Initialize for the default implementation node sorting.- Parameters:
cluster
- for which nodes will be sorted.topologyDetails
- the topology to sort for.nodeSortType
- type of sorting to be applied to object resource collectionBaseResourceAwareStrategy.NodeSortType
.
-
-
Method Details
-
prepare
Description copied from interface:INodeSorter
Prepare for node sorting. This method must be called beforeINodeSorter.getSortedRacks()
andINodeSorter.sortAllNodes()
.- Specified by:
prepare
in interfaceINodeSorter
- Parameters:
exec
- optional, may be null.
-
sortObjectResources
protected List<ObjectResourcesItem> sortObjectResources(ObjectResourcesSummary resourcesSummary, ExecutorDetails exec, NodeSorter.ExistingScheduleFunc existingScheduleFunc) Scheduling usessortAllNodes()
which eventually calls this method whose behavior can be altered by settingnodeSortType
.- Parameters:
resourcesSummary
- contains all individualObjectResourcesItem
as well as cumulative statsexec
- executor for which the sorting is doneexistingScheduleFunc
- a function to get existing executors already scheduled on this object- Returns:
- a sorted list of
ObjectResourcesItem
-
makeHostToNodeIds
-
sortAllNodes
- Specified by:
sortAllNodes
in interfaceINodeSorter
-
getSortedRacks
Racks are sorted by two criteria.1) the number executors of the topology that needs to be scheduled is already on the rack in descending order. The reasoning to sort based on criterion 1 is so we schedule the rest of a topology on the same 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 on the rack by the resource availability of the entire cluster By doing this calculation, racks 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.
- Specified by:
getSortedRacks
in interfaceINodeSorter
- Returns:
- a sorted list of racks
-
hostnameToNodes
hostname to Ids.- Parameters:
hostname
- the hostname.- Returns:
- the ids n that node.
-