JacksonYao287 commented on a change in pull request #2808:
URL: https://github.com/apache/ozone/pull/2808#discussion_r752007790
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/FindTargetGreedy.java
##########
@@ -44,37 +46,64 @@
private ContainerManager containerManager;
private PlacementPolicy placementPolicy;
+ private Map<DatanodeDetails, Long> sizeEnteringNode;
+ private NodeManager nodeManager;
+ private ContainerBalancerConfiguration config;
+ private Double upperLimit;
+ private List<DatanodeUsageInfo> potentialTargets;
public FindTargetGreedy(
ContainerManager containerManager,
- PlacementPolicy placementPolicy) {
+ PlacementPolicy placementPolicy,
+ NodeManager nodeManager) {
+ sizeEnteringNode = new HashMap<>();
this.containerManager = containerManager;
this.placementPolicy = placementPolicy;
+ this.nodeManager = nodeManager;
+ }
+
+ private void setUpperLimit(Double upperLimit){
+ this.upperLimit = upperLimit;
+ }
+
+ private void setPotentialTargets(List<DatanodeUsageInfo> potentialTargets) {
+ this.potentialTargets = potentialTargets;
+ sizeEnteringNode.clear();
+ potentialTargets.forEach(
+ p -> sizeEnteringNode.put(p.getDatanodeDetails(), 0L));
+ }
+
+ private void setConfiguration(ContainerBalancerConfiguration conf) {
+ this.config = conf;
}
/**
* Find a {@link ContainerMoveSelection} consisting of a target and
* container to move for a source datanode. Favours more under-utilized
nodes.
* @param source Datanode to find a target for
- * @param potentialTargets Collection of potential target datanodes
* @param candidateContainers Set of candidate containers satisfying
* selection criteria
* {@link ContainerBalancerSelectionCriteria}
- * @param canSizeEnterTarget A functional interface whose apply
* (DatanodeDetails, Long) method returns true if the size specified in the
* second argument can enter the specified DatanodeDetails node
* @return Found target and container
*/
@Override
public ContainerMoveSelection findTargetForContainerMove(
- DatanodeDetails source, Collection<DatanodeDetails> potentialTargets,
- Set<ContainerID> candidateContainers,
- BiFunction<DatanodeDetails, Long, Boolean> canSizeEnterTarget) {
- for (DatanodeDetails target : potentialTargets) {
+ DatanodeDetails source, Set<ContainerID> candidateContainers) {
+ potentialTargets.sort((a, b) -> {
Review comment:
i think we should use TreeSet here.
in `FindSourceGreedy`, we always try to get the top one source, and if no
target and be matched with it , we will remove it.
but here, we never remove any target , and just try to find a target with
Middle-order traversal。but we can not do traversal on priorityqueue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]