Skip to content

Commit 75e020e

Browse files
authored
Replace RoutingTable#shardsWithState(...) with RoutingNodes#unassigned(...) (#78931) (#78956)
Replaces only the production use cases of `RoutingTable#shardsWithState(...)` with `RoutingNodes#unassigned()`. Relates to #77466
1 parent 9c0c9a6 commit 75e020e

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ public long getRemainingDelay(
456456
*/
457457
public static int getNumberOfDelayedUnassigned(ClusterState state) {
458458
int count = 0;
459-
for (ShardRouting shard : state.routingTable().shardsWithState(ShardRoutingState.UNASSIGNED)) {
459+
for (ShardRouting shard : state.getRoutingNodes().unassigned()) {
460460
if (shard.unassignedInfo().isDelayed()) {
461461
count++;
462462
}
@@ -471,9 +471,8 @@ public static int getNumberOfDelayedUnassigned(ClusterState state) {
471471
*/
472472
public static long findNextDelayedAllocation(long currentNanoTime, ClusterState state) {
473473
Metadata metadata = state.metadata();
474-
RoutingTable routingTable = state.routingTable();
475474
long nextDelayNanos = Long.MAX_VALUE;
476-
for (ShardRouting shard : routingTable.shardsWithState(ShardRoutingState.UNASSIGNED)) {
475+
for (ShardRouting shard : state.getRoutingNodes().unassigned()) {
477476
UnassignedInfo unassignedInfo = shard.unassignedInfo();
478477
if (unassignedInfo.isDelayed()) {
479478
Settings indexSettings = metadata.index(shard.index()).getSettings();

server/src/main/java/org/elasticsearch/snapshots/InternalSnapshotsInfoService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.elasticsearch.cluster.routing.RecoverySource;
2222
import org.elasticsearch.cluster.routing.RerouteService;
2323
import org.elasticsearch.cluster.routing.ShardRouting;
24-
import org.elasticsearch.cluster.routing.ShardRoutingState;
2524
import org.elasticsearch.cluster.service.ClusterService;
2625
import org.elasticsearch.common.Priority;
2726
import org.elasticsearch.common.collect.ImmutableOpenMap;
@@ -320,7 +319,7 @@ int numberOfKnownSnapshotShardSizes() {
320319

321320
private static Set<SnapshotShard> listOfSnapshotShards(final ClusterState state) {
322321
final Set<SnapshotShard> snapshotShards = new HashSet<>();
323-
for (ShardRouting shardRouting : state.routingTable().shardsWithState(ShardRoutingState.UNASSIGNED)) {
322+
for (ShardRouting shardRouting : state.getRoutingNodes().unassigned()) {
324323
if (shardRouting.primary() && shardRouting.recoverySource().getType() == RecoverySource.Type.SNAPSHOT) {
325324
final RecoverySource.SnapshotRecoverySource snapshotRecoverySource = (RecoverySource.SnapshotRecoverySource) shardRouting
326325
.recoverySource();

0 commit comments

Comments
 (0)