Skip to content

Commit

Permalink
Refactor hasComputationConverged (elastic#116331)
Browse files Browse the repository at this point in the history
  • Loading branch information
pxsalehi authored and alexey-ivanov-es committed Nov 28, 2024
1 parent 72a395c commit b74e50a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public DesiredBalance compute(
nextReportTime = currentTime + timeWarningInterval;
}

if (hasComputationConverged(hasChanges, i)) {
if (hasChanges == false && hasEnoughIterations(i)) {
logger.debug(
"Desired balance computation for [{}] converged after [{}] and [{}] iterations",
desiredBalanceInput.index(),
Expand Down Expand Up @@ -415,8 +415,8 @@ public DesiredBalance compute(
}

// visible for testing
boolean hasComputationConverged(boolean hasRoutingChanges, int currentIteration) {
return hasRoutingChanges == false;
boolean hasEnoughIterations(int currentIteration) {
return true;
}

private static Map<ShardId, ShardAssignment> collectShardAssignments(RoutingNodes routingNodes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ public DesiredBalance compute(
}

@Override
boolean hasComputationConverged(boolean hasRoutingChanges, int currentIteration) {
return super.hasComputationConverged(hasRoutingChanges, currentIteration) && currentIteration >= minIterations;
boolean hasEnoughIterations(int currentIteration) {
return currentIteration >= minIterations;
}
},
reconcileAction,
Expand Down

0 comments on commit b74e50a

Please sign in to comment.