lokeshj1703 commented on a change in pull request #3129:
URL: https://github.com/apache/ozone/pull/3129#discussion_r835146859
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -408,57 +410,77 @@ private IterationResult doIteration() {
new HashSet<>(potentialTargets.size());
moveSelectionToFutureMap = new HashMap<>(unBalancedNodes.size());
boolean isMoveGenerated = false;
- try {
- // match each overUtilized node with a target
- while (true) {
- if (!isBalancerRunning()) {
- return IterationResult.ITERATION_INTERRUPTED;
- }
+ iterationResult = IterationResult.ITERATION_COMPLETED;
- IterationResult result = checkConditionsForBalancing();
- if (result != null) {
- return result;
- }
+ // match each source node with a target
+ while (true) {
+ if (!isBalancerRunning()) {
+ iterationResult = IterationResult.ITERATION_INTERRUPTED;
+ break;
+ }
- DatanodeDetails source =
- findSourceStrategy.getNextCandidateSourceDataNode();
- if (source == null) {
- break;
- }
+ if (checkIterationLimits()) {
+ /* scheduled enough moves to hit either maxSizeToMovePerIteration or
+ maxDatanodesPercentageToInvolvePerIteration limit
+ */
+ break;
+ }
- ContainerMoveSelection moveSelection = matchSourceWithTarget(source);
- if (moveSelection != null) {
- isMoveGenerated = true;
- LOG.info("ContainerBalancer is trying to move container {} from " +
- "source datanode {} to target datanode {}",
- moveSelection.getContainerID().toString(),
- source.getUuidString(),
- moveSelection.getTargetNode().getUuidString());
-
- if (moveContainer(source, moveSelection)) {
- // consider move successful for now, and update selection criteria
- updateTargetsAndSelectionCriteria(
- selectedTargets, moveSelection, source);
- }
- } else {
- // can not find any target for this source
- findSourceStrategy.removeCandidateSourceDataNode(source);
- }
+ DatanodeDetails source =
+ findSourceStrategy.getNextCandidateSourceDataNode();
+ if (source == null) {
+ // no more source DNs are present
+ break;
}
- if (!isMoveGenerated) {
- //no move option is generated, so the cluster can not be
- //balanced any more, just stop iteration and exit
- return IterationResult.CAN_NOT_BALANCE_ANY_MORE;
+ ContainerMoveSelection moveSelection = matchSourceWithTarget(source);
+ if (moveSelection != null) {
+ isMoveGenerated = true;
+ LOG.info("ContainerBalancer is trying to move container {} from " +
+ "source datanode {} to target datanode {}",
+ moveSelection.getContainerID().toString(),
+ source.getUuidString(),
+ moveSelection.getTargetNode().getUuidString());
+
+ if (moveContainer(source, moveSelection)) {
+ // consider move successful for now, and update selection criteria
+ updateTargetsAndSelectionCriteria(
+ selectedTargets, moveSelection, source);
+ }
+ } else {
+ // can not find any target for this source
+ findSourceStrategy.removeCandidateSourceDataNode(source);
}
Review comment:
Can we move the moveSelection processing logic to a separate function?
--
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]