Skip to content

Commit

Permalink
Rename IndexShardRoutingTable unpromotable related methods (#121155)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcofdez authored Jan 31, 2025
1 parent 0cf0009 commit 0c787bd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected TransportBroadcastUnpromotableAction(

@Override
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
final var unpromotableShards = request.indexShardRoutingTable.unpromotableShards();
final var unpromotableShards = request.indexShardRoutingTable.assignedUnpromotableShards();
final var responses = new ArrayList<Response>(unpromotableShards.size());

try (var listeners = new RefCountingListener(listener.map(v -> combineUnpromotableShardResponses(responses)))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public List<ShardRouting> assignedShards() {
*
* @return a {@link List} of shards
*/
public List<ShardRouting> unpromotableShards() {
public List<ShardRouting> assignedUnpromotableShards() {
return this.assignedUnpromotableShards;
}

Expand All @@ -202,7 +202,7 @@ public List<ShardRouting> unpromotableShards() {
*
* @return a {@link List} of shards
*/
public List<ShardRouting> allUnpromotableShards() {
public List<ShardRouting> unpromotableShards() {
return this.unpromotableShards;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0c787bd

Please sign in to comment.