Skip to content

Commit 7d9a845

Browse files
authored
Remove unused parameter from IndexRoutingTable#readyForSearch (#121152)
1 parent b69eb8a commit 7d9a845

File tree

11 files changed

+17
-29
lines changed

11 files changed

+17
-29
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
package org.elasticsearch.cluster.routing;
1111

12-
import org.elasticsearch.cluster.ClusterState;
1312
import org.elasticsearch.cluster.Diff;
1413
import org.elasticsearch.cluster.SimpleDiffable;
1514
import org.elasticsearch.cluster.metadata.IndexMetadata;
@@ -236,7 +235,7 @@ public boolean allPrimaryShardsActive() {
236235
/**
237236
* @return <code>true</code> if an index is available to service search queries.
238237
*/
239-
public boolean readyForSearch(ClusterState clusterState) {
238+
public boolean readyForSearch() {
240239
for (IndexShardRoutingTable shardRoutingTable : this.shards) {
241240
boolean found = false;
242241
for (int idx = 0; idx < shardRoutingTable.size(); idx++) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import org.elasticsearch.TransportVersion;
1313
import org.elasticsearch.TransportVersions;
14-
import org.elasticsearch.cluster.ClusterState;
1514
import org.elasticsearch.cluster.node.DiscoveryNode;
1615
import org.elasticsearch.cluster.routing.RecoverySource.ExistingStoreRecoverySource;
1716
import org.elasticsearch.cluster.routing.RecoverySource.PeerRecoverySource;
@@ -935,7 +934,7 @@ public boolean isPromotableToPrimary() {
935934
}
936935

937936
/**
938-
* Determine if role searchable. Consumers should prefer {@link IndexRoutingTable#readyForSearch(ClusterState)} to determine if an index
937+
* Determine if role searchable. Consumers should prefer {@link IndexRoutingTable#readyForSearch()} to determine if an index
939938
* is ready to be searched.
940939
*/
941940
public boolean isSearchable() {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public void testReadyForSearch() {
4444
List.of(getShard(p2, true, ShardRoutingState.STARTED, ShardRouting.Role.DEFAULT))
4545
);
4646
IndexRoutingTable indexRoutingTable = new IndexRoutingTable(index, new IndexShardRoutingTable[] { shardTable1, shardTable2 });
47-
assertTrue(indexRoutingTable.readyForSearch(clusterState));
47+
assertTrue(indexRoutingTable.readyForSearch());
4848

4949
// 2 primaries that are index only
5050
shardTable1 = new IndexShardRoutingTable(p1, List.of(getShard(p1, true, ShardRoutingState.STARTED, ShardRouting.Role.INDEX_ONLY)));
5151
shardTable2 = new IndexShardRoutingTable(p2, List.of(getShard(p2, true, ShardRoutingState.STARTED, ShardRouting.Role.INDEX_ONLY)));
5252
indexRoutingTable = new IndexRoutingTable(index, new IndexShardRoutingTable[] { shardTable1, shardTable2 });
53-
assertFalse(indexRoutingTable.readyForSearch(clusterState));
53+
assertFalse(indexRoutingTable.readyForSearch());
5454

5555
// 2 unassigned primaries that are index only
5656
shardTable1 = new IndexShardRoutingTable(
@@ -62,7 +62,7 @@ public void testReadyForSearch() {
6262
List.of(getShard(p2, true, ShardRoutingState.UNASSIGNED, ShardRouting.Role.INDEX_ONLY))
6363
);
6464
indexRoutingTable = new IndexRoutingTable(index, new IndexShardRoutingTable[] { shardTable1, shardTable2 });
65-
assertFalse(indexRoutingTable.readyForSearch(clusterState));
65+
assertFalse(indexRoutingTable.readyForSearch());
6666

6767
// 2 primaries that are index only with replicas that are not all available
6868
shardTable1 = new IndexShardRoutingTable(
@@ -82,7 +82,7 @@ public void testReadyForSearch() {
8282
)
8383
);
8484
indexRoutingTable = new IndexRoutingTable(index, new IndexShardRoutingTable[] { shardTable1, shardTable2 });
85-
assertFalse(indexRoutingTable.readyForSearch(clusterState));
85+
assertFalse(indexRoutingTable.readyForSearch());
8686

8787
// 2 primaries that are index only with some replicas that are all available
8888
shardTable1 = new IndexShardRoutingTable(
@@ -102,7 +102,7 @@ public void testReadyForSearch() {
102102
)
103103
);
104104
indexRoutingTable = new IndexRoutingTable(index, new IndexShardRoutingTable[] { shardTable1, shardTable2 });
105-
assertTrue(indexRoutingTable.readyForSearch(clusterState));
105+
assertTrue(indexRoutingTable.readyForSearch());
106106

107107
// 2 unassigned primaries that are index only with some replicas that are all available
108108
shardTable1 = new IndexShardRoutingTable(
@@ -122,7 +122,7 @@ public void testReadyForSearch() {
122122
)
123123
);
124124
indexRoutingTable = new IndexRoutingTable(index, new IndexShardRoutingTable[] { shardTable1, shardTable2 });
125-
assertTrue(indexRoutingTable.readyForSearch(clusterState));
125+
assertTrue(indexRoutingTable.readyForSearch());
126126

127127
// 2 primaries that are index only with at least 1 replica per primary that is available
128128
shardTable1 = new IndexShardRoutingTable(
@@ -142,7 +142,7 @@ public void testReadyForSearch() {
142142
)
143143
);
144144
indexRoutingTable = new IndexRoutingTable(index, new IndexShardRoutingTable[] { shardTable1, shardTable2 });
145-
assertTrue(indexRoutingTable.readyForSearch(clusterState));
145+
assertTrue(indexRoutingTable.readyForSearch());
146146
}
147147

148148
private ShardRouting getShard(ShardId shardId, boolean isPrimary, ShardRoutingState state, ShardRouting.Role role) {

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlConfigMigrationEligibilityCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ static boolean mlConfigIndexIsAllocated(ClusterState clusterState) {
6565
}
6666

6767
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(configIndexOrAlias.getWriteIndex());
68-
return routingTable != null && routingTable.allPrimaryShardsActive() && routingTable.readyForSearch(clusterState);
68+
return routingTable != null && routingTable.allPrimaryShardsActive() && routingTable.readyForSearch();
6969
}
7070
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigAutoUpdater.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public boolean isAbleToRun(ClusterState latestState) {
6262
continue;
6363
}
6464
IndexRoutingTable routingTable = latestState.getRoutingTable().index(index);
65-
if (routingTable == null
66-
|| routingTable.allPrimaryShardsActive() == false
67-
|| routingTable.readyForSearch(latestState) == false) {
65+
if (routingTable == null || routingTable.allPrimaryShardsActive() == false || routingTable.readyForSearch() == false) {
6866
return false;
6967
}
7068
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedNodeSelector.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ private AssignmentFailure verifyIndicesActive() {
206206

207207
for (String concreteIndex : concreteIndices) {
208208
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(concreteIndex);
209-
if (routingTable == null
210-
|| routingTable.allPrimaryShardsActive() == false
211-
|| routingTable.readyForSearch(clusterState) == false) {
209+
if (routingTable == null || routingTable.allPrimaryShardsActive() == false || routingTable.readyForSearch() == false) {
212210
return new AssignmentFailure(
213211
"cannot start datafeed ["
214212
+ datafeedId

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/TrainedModelStatsService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ static boolean verifyIndicesExistAndPrimaryShardsAreActive(ClusterState clusterS
240240
return false;
241241
}
242242
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(index);
243-
if (routingTable == null
244-
|| routingTable.allPrimaryShardsActive() == false
245-
|| routingTable.readyForSearch(clusterState) == false) {
243+
if (routingTable == null || routingTable.allPrimaryShardsActive() == false || routingTable.readyForSearch() == false) {
246244
return false;
247245
}
248246
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/task/AbstractJobPersistentTasksExecutor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public static List<String> verifyIndicesPrimaryShardsAreActive(
6767
continue;
6868
}
6969
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(index);
70-
if (routingTable == null
71-
|| routingTable.allPrimaryShardsActive() == false
72-
|| routingTable.readyForSearch(clusterState) == false) {
70+
if (routingTable == null || routingTable.allPrimaryShardsActive() == false || routingTable.readyForSearch() == false) {
7371
unavailableIndices.add(index);
7472
}
7573
}

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ private Tuple<Boolean, Boolean> checkIndexAvailable(ClusterState state) {
513513
if (routingTable != null && routingTable.allPrimaryShardsActive()) {
514514
allPrimaryShards = true;
515515
}
516-
if (routingTable != null && routingTable.readyForSearch(state)) {
516+
if (routingTable != null && routingTable.readyForSearch()) {
517517
searchShards = true;
518518
}
519519
if (allPrimaryShards == false || searchShards == false) {

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformInternalIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ protected static boolean hasLatestVersionedIndex(ClusterState state) {
385385
protected static boolean allPrimaryShardsActiveForLatestVersionedIndex(ClusterState state) {
386386
IndexRoutingTable indexRouting = state.routingTable().index(TransformInternalIndexConstants.LATEST_INDEX_VERSIONED_NAME);
387387

388-
return indexRouting != null && indexRouting.allPrimaryShardsActive() && indexRouting.readyForSearch(state);
388+
return indexRouting != null && indexRouting.allPrimaryShardsActive() && indexRouting.readyForSearch();
389389
}
390390

391391
private static void waitForLatestVersionedIndexShardsActive(Client client, ActionListener<Void> listener) {

0 commit comments

Comments
 (0)