From 520c70a22d2221f6ab2fca816dcd281d1bb488f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20Casta=C3=B1o?= Date: Wed, 29 Jan 2025 12:32:34 +0100 Subject: [PATCH] Rename IndexShardRoutingTable unpromotable related methods --- .../unpromotable/TransportBroadcastUnpromotableAction.java | 2 +- .../action/support/replication/PostWriteRefresh.java | 2 +- .../cluster/routing/IndexShardRoutingTable.java | 4 ++-- .../TransportBroadcastUnpromotableActionTests.java | 2 +- .../action/support/replication/PostWriteRefreshTests.java | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableAction.java b/server/src/main/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableAction.java index 1255dbdf7419d..c44a0118111f3 100644 --- a/server/src/main/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableAction.java @@ -76,7 +76,7 @@ protected TransportBroadcastUnpromotableAction( @Override protected void doExecute(Task task, Request request, ActionListener listener) { - final var unpromotableShards = request.indexShardRoutingTable.unpromotableShards(); + final var unpromotableShards = request.indexShardRoutingTable.assignedUnpromotableShards(); final var responses = new ArrayList(unpromotableShards.size()); try (var listeners = new RefCountingListener(listener.map(v -> combineUnpromotableShardResponses(responses)))) { diff --git a/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java b/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java index 997d859ec35a2..cefb27376f9ea 100644 --- a/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java +++ b/server/src/main/java/org/elasticsearch/action/support/replication/PostWriteRefresh.java @@ -65,7 +65,7 @@ public void onFailure(Exception e) { } }); case IMMEDIATE -> immediate(indexShard, listener.delegateFailureAndWrap((l, r) -> { - if (indexShard.getReplicationGroup().getRoutingTable().allUnpromotableShards().size() > 0) { + if (indexShard.getReplicationGroup().getRoutingTable().unpromotableShards().size() > 0) { sendUnpromotableRequests(indexShard, r.generation(), true, l, postWriteRefreshTimeout); } else { l.onResponse(true); diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java b/server/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java index 74c2c1d14b77c..14a512a206775 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java @@ -193,7 +193,7 @@ public List assignedShards() { * * @return a {@link List} of shards */ - public List unpromotableShards() { + public List assignedUnpromotableShards() { return this.assignedUnpromotableShards; } @@ -202,7 +202,7 @@ public List unpromotableShards() { * * @return a {@link List} of shards */ - public List allUnpromotableShards() { + public List unpromotableShards() { return this.unpromotableShards; } diff --git a/server/src/test/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableActionTests.java b/server/src/test/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableActionTests.java index ed12a3fda6eec..f5152dfbe7a5e 100644 --- a/server/src/test/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/broadcast/unpromotable/TransportBroadcastUnpromotableActionTests.java @@ -333,7 +333,7 @@ public void testInvalidNodes() throws Exception { // We were able to mark shards as stale, so the request finishes successfully assertThat(safeAwait(broadcastUnpromotableRequest(wrongRoutingTable, true)), equalTo(ActionResponse.Empty.INSTANCE)); - for (var shardRouting : wrongRoutingTable.unpromotableShards()) { + for (var shardRouting : wrongRoutingTable.assignedUnpromotableShards()) { Mockito.verify(shardStateAction) .remoteShardFailed( eq(shardRouting.shardId()), diff --git a/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java b/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java index 9897fe9a42547..4337d4c3d9e99 100644 --- a/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/replication/PostWriteRefreshTests.java @@ -162,7 +162,7 @@ public void testPrimaryWithUnpromotables() throws IOException { new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "message"), ShardRouting.Role.SEARCH_ONLY ); - when(routingTable.allUnpromotableShards()).thenReturn(List.of(shardRouting)); + when(routingTable.unpromotableShards()).thenReturn(List.of(shardRouting)); when(routingTable.shardId()).thenReturn(shardId); WriteRequest.RefreshPolicy policy = randomFrom(WriteRequest.RefreshPolicy.IMMEDIATE, WriteRequest.RefreshPolicy.WAIT_UNTIL); postWriteRefresh.refreshShard(policy, primary, result.getTranslogLocation(), f, postWriteRefreshTimeout); @@ -238,9 +238,9 @@ public void testWaitForWithNullLocationCompletedImmediately() throws IOException ); // Randomly test scenarios with and without unpromotables if (randomBoolean()) { - when(routingTable.allUnpromotableShards()).thenReturn(Collections.emptyList()); + when(routingTable.unpromotableShards()).thenReturn(Collections.emptyList()); } else { - when(routingTable.allUnpromotableShards()).thenReturn(List.of(shardRouting)); + when(routingTable.unpromotableShards()).thenReturn(List.of(shardRouting)); } WriteRequest.RefreshPolicy policy = WriteRequest.RefreshPolicy.WAIT_UNTIL; postWriteRefresh.refreshShard(policy, primary, null, f, postWriteRefreshTimeout);