Skip to content

Commit 8db9181

Browse files
authored
Refactor hasComputationConverged (#116331)
See #115511 (comment).
1 parent f816034 commit 8db9181

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public DesiredBalance compute(
335335
nextReportTime = currentTime + timeWarningInterval;
336336
}
337337

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

417417
// visible for testing
418-
boolean hasComputationConverged(boolean hasRoutingChanges, int currentIteration) {
419-
return hasRoutingChanges == false;
418+
boolean hasEnoughIterations(int currentIteration) {
419+
return true;
420420
}
421421

422422
private static Map<ShardId, ShardAssignment> collectShardAssignments(RoutingNodes routingNodes) {

server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocatorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ public DesiredBalance compute(
408408
}
409409

410410
@Override
411-
boolean hasComputationConverged(boolean hasRoutingChanges, int currentIteration) {
412-
return super.hasComputationConverged(hasRoutingChanges, currentIteration) && currentIteration >= minIterations;
411+
boolean hasEnoughIterations(int currentIteration) {
412+
return currentIteration >= minIterations;
413413
}
414414
},
415415
reconcileAction,

0 commit comments

Comments
 (0)