Skip to content

Commit d193ca8

Browse files
authored
Use disassociate in preference to deassociate (#37704)
1 parent 2439f68 commit d193ca8

25 files changed

+50
-50
lines changed

server/src/main/java/org/elasticsearch/cluster/coordination/JoinTaskExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ protected ClusterState.Builder becomeMasterAndTrimConflictingNodes(ClusterState
188188
.blocks(currentState.blocks())
189189
.removeGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID)).build();
190190
logger.trace("becomeMasterAndTrimConflictingNodes: {}", tmpState.nodes());
191-
tmpState = PersistentTasksCustomMetaData.deassociateDeadNodes(tmpState);
192-
return ClusterState.builder(allocationService.deassociateDeadNodes(tmpState, false, "removed dead nodes on election"));
191+
tmpState = PersistentTasksCustomMetaData.disassociateDeadNodes(tmpState);
192+
return ClusterState.builder(allocationService.disassociateDeadNodes(tmpState, false, "removed dead nodes on election"));
193193
}
194194

195195
@Override

server/src/main/java/org/elasticsearch/cluster/coordination/NodeRemovalClusterStateTaskExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public ClusterTasksResult<Task> execute(final ClusterState currentState, final L
9292

9393
protected ClusterTasksResult<Task> getTaskClusterTasksResult(ClusterState currentState, List<Task> tasks,
9494
ClusterState remainingNodesClusterState) {
95-
ClusterState ptasksDeassociatedState = PersistentTasksCustomMetaData.deassociateDeadNodes(remainingNodesClusterState);
95+
ClusterState ptasksDisassociatedState = PersistentTasksCustomMetaData.disassociateDeadNodes(remainingNodesClusterState);
9696
final ClusterTasksResult.Builder<Task> resultBuilder = ClusterTasksResult.<Task>builder().successes(tasks);
97-
return resultBuilder.build(allocationService.deassociateDeadNodes(ptasksDeassociatedState, true, describeTasks(tasks)));
97+
return resultBuilder.build(allocationService.disassociateDeadNodes(ptasksDisassociatedState, true, describeTasks(tasks)));
9898
}
9999

100100
// visible for testing

server/src/main/java/org/elasticsearch/cluster/routing/DelayedAllocationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* the delay marker). These are shards that have become unassigned due to a node leaving
4646
* and which were assigned the delay marker based on the index delay setting
4747
* {@link UnassignedInfo#INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING}
48-
* (see {@link AllocationService#deassociateDeadNodes(RoutingAllocation)}).
48+
* (see {@link AllocationService#disassociateDeadNodes(RoutingAllocation)}.
4949
* This class is responsible for choosing the next (closest) delay expiration of a
5050
* delayed shard to schedule a reroute to remove the delay marker.
5151
* The actual removal of the delay marker happens in

server/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public ShardRouting activePrimary(ShardId shardId) {
327327
*
328328
*/
329329
public ShardRouting activeReplicaWithHighestVersion(ShardId shardId) {
330-
// It's possible for replicaNodeVersion to be null, when deassociating dead nodes
330+
// It's possible for replicaNodeVersion to be null, when disassociating dead nodes
331331
// that have been removed, the shards are failed, and part of the shard failing
332332
// calls this method with an out-of-date RoutingNodes, where the version might not
333333
// be accessible. Therefore, we need to protect against the version being null

server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ public ClusterState applyFailedShards(final ClusterState clusterState, final Lis
216216
* unassigned an shards that are associated with nodes that are no longer part of the cluster, potentially promoting replicas
217217
* if needed.
218218
*/
219-
public ClusterState deassociateDeadNodes(ClusterState clusterState, boolean reroute, String reason) {
219+
public ClusterState disassociateDeadNodes(ClusterState clusterState, boolean reroute, String reason) {
220220
RoutingNodes routingNodes = getMutableRoutingNodes(clusterState);
221221
// shuffle the unassigned nodes, just so we won't have things like poison failed shards
222222
routingNodes.unassigned().shuffle();
223223
RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, routingNodes, clusterState,
224224
clusterInfoService.getClusterInfo(), currentNanoTime());
225225

226226
// first, clear from the shards any node id they used to belong to that is now dead
227-
deassociateDeadNodes(allocation);
227+
disassociateDeadNodes(allocation);
228228

229229
if (allocation.routingNodesChanged()) {
230230
clusterState = buildResult(clusterState, allocation);
@@ -400,7 +400,7 @@ private boolean hasDeadNodes(RoutingAllocation allocation) {
400400
}
401401

402402
private void reroute(RoutingAllocation allocation) {
403-
assert hasDeadNodes(allocation) == false : "dead nodes should be explicitly cleaned up. See deassociateDeadNodes";
403+
assert hasDeadNodes(allocation) == false : "dead nodes should be explicitly cleaned up. See disassociateDeadNodes";
404404
assert AutoExpandReplicas.getAutoExpandReplicaChanges(allocation.metaData(), allocation.nodes()).isEmpty() :
405405
"auto-expand replicas out of sync with number of nodes in the cluster";
406406

@@ -414,7 +414,7 @@ private void reroute(RoutingAllocation allocation) {
414414
assert RoutingNodes.assertShardStats(allocation.routingNodes());
415415
}
416416

417-
private void deassociateDeadNodes(RoutingAllocation allocation) {
417+
private void disassociateDeadNodes(RoutingAllocation allocation) {
418418
for (Iterator<RoutingNode> it = allocation.routingNodes().mutableIterator(); it.hasNext(); ) {
419419
RoutingNode node = it.next();
420420
if (allocation.nodes().getDataNodes().containsKey(node.nodeId())) {

server/src/main/java/org/elasticsearch/persistent/PersistentTasksCustomMetaData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public static <Params extends PersistentTaskParams> PersistentTask<Params> getTa
225225
* @return If no changes the argument {@code clusterState} is returned else
226226
* a copy with the modified tasks
227227
*/
228-
public static ClusterState deassociateDeadNodes(ClusterState clusterState) {
228+
public static ClusterState disassociateDeadNodes(ClusterState clusterState) {
229229
PersistentTasksCustomMetaData tasks = getPersistentTasksCustomMetaData(clusterState);
230230
if (tasks == null) {
231231
return clusterState;

server/src/test/java/org/elasticsearch/cluster/coordination/NodeRemovalClusterStateTaskExecutorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void testRemovingNonExistentNodes() throws Exception {
7070

7171
public void testRerouteAfterRemovingNodes() throws Exception {
7272
final AllocationService allocationService = mock(AllocationService.class);
73-
when(allocationService.deassociateDeadNodes(any(ClusterState.class), eq(true), any(String.class)))
73+
when(allocationService.disassociateDeadNodes(any(ClusterState.class), eq(true), any(String.class)))
7474
.thenAnswer(im -> im.getArguments()[0]);
7575

7676
final AtomicReference<ClusterState> remainingNodesClusterState = new AtomicReference<>();
@@ -102,7 +102,7 @@ protected ClusterState remainingNodesClusterState(ClusterState currentState,
102102
final ClusterStateTaskExecutor.ClusterTasksResult<NodeRemovalClusterStateTaskExecutor.Task> result =
103103
executor.execute(clusterState, tasks);
104104

105-
verify(allocationService).deassociateDeadNodes(eq(remainingNodesClusterState.get()), eq(true), any(String.class));
105+
verify(allocationService).disassociateDeadNodes(eq(remainingNodesClusterState.get()), eq(true), any(String.class));
106106

107107
for (final NodeRemovalClusterStateTaskExecutor.Task task : tasks) {
108108
assertNull(result.resultingState.nodes().get(task.node().getId()));

server/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationServiceTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void testNoDelayedUnassigned() throws Exception {
104104
nodes.add(newNode("node3"));
105105
}
106106
clusterState = ClusterState.builder(clusterState).nodes(nodes).build();
107-
clusterState = allocationService.deassociateDeadNodes(clusterState, true, "reroute");
107+
clusterState = allocationService.disassociateDeadNodes(clusterState, true, "reroute");
108108
ClusterState newState = clusterState;
109109
List<ShardRouting> unassignedShards = newState.getRoutingTable().shardsWithState(ShardRoutingState.UNASSIGNED);
110110
if (nodeAvailableForAllocation) {
@@ -153,7 +153,7 @@ public void testDelayedUnassignedScheduleReroute() throws Exception {
153153

154154
// remove node that has replica and reroute
155155
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove(nodeId)).build();
156-
clusterState = allocationService.deassociateDeadNodes(clusterState, true, "reroute");
156+
clusterState = allocationService.disassociateDeadNodes(clusterState, true, "reroute");
157157
ClusterState stateWithDelayedShard = clusterState;
158158
// make sure the replica is marked as delayed (i.e. not reallocated)
159159
assertEquals(1, UnassignedInfo.getNumberOfDelayedUnassigned(stateWithDelayedShard));
@@ -264,7 +264,7 @@ public void testDelayedUnassignedScheduleRerouteAfterDelayedReroute() throws Exc
264264
.build();
265265
// make sure both replicas are marked as delayed (i.e. not reallocated)
266266
allocationService.setNanoTimeOverride(baseTimestampNanos);
267-
clusterState = allocationService.deassociateDeadNodes(clusterState, true, "reroute");
267+
clusterState = allocationService.disassociateDeadNodes(clusterState, true, "reroute");
268268
final ClusterState stateWithDelayedShards = clusterState;
269269
assertEquals(2, UnassignedInfo.getNumberOfDelayedUnassigned(stateWithDelayedShards));
270270
RoutingNodes.UnassignedShards.UnassignedIterator iter = stateWithDelayedShards.getRoutingNodes().unassigned().iterator();
@@ -401,7 +401,7 @@ public void testDelayedUnassignedScheduleRerouteRescheduledOnShorterDelay() thro
401401
// remove node that has replica and reroute
402402
clusterState = ClusterState.builder(clusterState).nodes(
403403
DiscoveryNodes.builder(clusterState.nodes()).remove(nodeIdOfFooReplica)).build();
404-
clusterState = allocationService.deassociateDeadNodes(clusterState, true, "fake node left");
404+
clusterState = allocationService.disassociateDeadNodes(clusterState, true, "fake node left");
405405
ClusterState stateWithDelayedShard = clusterState;
406406
// make sure the replica is marked as delayed (i.e. not reallocated)
407407
assertEquals(1, UnassignedInfo.getNumberOfDelayedUnassigned(stateWithDelayedShard));
@@ -444,7 +444,7 @@ public void testDelayedUnassignedScheduleRerouteRescheduledOnShorterDelay() thro
444444
// remove node that has replica and reroute
445445
clusterState = ClusterState.builder(stateWithDelayedShard).nodes(
446446
DiscoveryNodes.builder(stateWithDelayedShard.nodes()).remove(nodeIdOfBarReplica)).build();
447-
ClusterState stateWithShorterDelay = allocationService.deassociateDeadNodes(clusterState, true, "fake node left");
447+
ClusterState stateWithShorterDelay = allocationService.disassociateDeadNodes(clusterState, true, "fake node left");
448448
delayedAllocationService.setNanoTimeOverride(clusterChangeEventTimestampNanos);
449449
delayedAllocationService.clusterChanged(
450450
new ClusterChangedEvent("fake node left", stateWithShorterDelay, stateWithDelayedShard));

server/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void testNodeLeave() {
241241
assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(false));
242242
// remove node2 and reroute
243243
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
244-
clusterState = allocation.deassociateDeadNodes(clusterState, true, "reroute");
244+
clusterState = allocation.disassociateDeadNodes(clusterState, true, "reroute");
245245
// verify that NODE_LEAVE is the reason for meta
246246
assertThat(clusterState.getRoutingNodes().unassigned().size() > 0, equalTo(true));
247247
assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(1));
@@ -332,7 +332,7 @@ public void testNumberOfDelayedUnassigned() throws Exception {
332332
// remove node2 and reroute
333333
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
334334
// make sure both replicas are marked as delayed (i.e. not reallocated)
335-
clusterState = allocation.deassociateDeadNodes(clusterState, true, "reroute");
335+
clusterState = allocation.disassociateDeadNodes(clusterState, true, "reroute");
336336
assertThat(clusterState.toString(), UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), equalTo(2));
337337
}
338338

@@ -364,7 +364,7 @@ public void testFindNextDelayedAllocation() {
364364
final long baseTime = System.nanoTime();
365365
allocation.setNanoTimeOverride(baseTime);
366366
clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder(clusterState.nodes()).remove("node2")).build();
367-
clusterState = allocation.deassociateDeadNodes(clusterState, true, "reroute");
367+
clusterState = allocation.disassociateDeadNodes(clusterState, true, "reroute");
368368

369369
final long delta = randomBoolean() ? 0 : randomInt((int) expectMinDelaySettingsNanos - 1);
370370

server/src/test/java/org/elasticsearch/cluster/routing/allocation/AddIncrementallyTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private ClusterState removeNodes(ClusterState clusterState, AllocationService se
341341
}
342342

343343
clusterState = ClusterState.builder(clusterState).nodes(nodes.build()).build();
344-
clusterState = service.deassociateDeadNodes(clusterState, true, "reroute");
344+
clusterState = service.disassociateDeadNodes(clusterState, true, "reroute");
345345

346346
logger.info("start all the primary shards, replicas will start initializing");
347347
RoutingNodes routingNodes = clusterState.getRoutingNodes();

0 commit comments

Comments
 (0)