You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add cancellation support in TransportGetAllocationStatsAction (elastic#127371)
Replaces the use of a SingleResultDeduplicator by refactoring the cache as a
subclass of CancellableSingleObjectCache. Refactored the AllocationStatsService
and NodeAllocationStatsAndWeightsCalculator to accept the Runnable used to test
for cancellation.
Closeselastic#123248
Copy file name to clipboardExpand all lines: server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportGetAllocationStatsAction.java
Copy file name to clipboardExpand all lines: server/src/main/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationStatsAndWeightsCalculator.java
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,7 @@ public Map<String, NodeAllocationStatsAndWeight> nodesAllocationStatsAndWeights(
58
58
Metadatametadata,
59
59
RoutingNodesroutingNodes,
60
60
ClusterInfoclusterInfo,
61
+
RunnableensureNotCancelled,
61
62
@NullableDesiredBalancedesiredBalance
62
63
) {
63
64
if (metadata.hasAnyIndices()) {
@@ -78,6 +79,7 @@ public Map<String, NodeAllocationStatsAndWeight> nodesAllocationStatsAndWeights(
78
79
longforecastedDiskUsage = 0;
79
80
longcurrentDiskUsage = 0;
80
81
for (ShardRoutingshardRouting : node) {
82
+
ensureNotCancelled.run();
81
83
if (shardRouting.relocating()) {
82
84
// Skip the shard if it is moving off this node. The node running recovery will count it.
Copy file name to clipboardExpand all lines: server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -391,6 +391,13 @@ public void resetDesiredBalance() {
391
391
resetCurrentDesiredBalance = true;
392
392
}
393
393
394
+
/**
395
+
* Used as the argument for the {@code ensureNotCancelled} {@code Runnable} when calling the
396
+
* {@code nodeAllocationStatsAndWeightsCalculator} since there is no cancellation mechanism when called from
0 commit comments