Remove IndexShardRoutingTable#primaryAsList (#59044)

This commit is contained in:
Howard 2020-07-07 14:33:56 +08:00 committed by David Turner
parent be13dea113
commit 00ed31d000
1 changed files with 4 additions and 7 deletions

View File

@ -59,7 +59,6 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
final ShardId shardId;
final ShardRouting primary;
final List<ShardRouting> primaryAsList;
final List<ShardRouting> replicas;
final List<ShardRouting> shards;
final List<ShardRouting> activeShards;
@ -120,11 +119,6 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
}
this.allShardsStarted = allShardsStarted;
this.primary = primary;
if (primary != null) {
this.primaryAsList = Collections.singletonList(primary);
} else {
this.primaryAsList = Collections.emptyList();
}
this.replicas = Collections.unmodifiableList(replicas);
this.activeShards = Collections.unmodifiableList(activeShards);
this.assignedShards = Collections.unmodifiableList(assignedShards);
@ -418,7 +412,10 @@ public class IndexShardRoutingTable implements Iterable<ShardRouting> {
* Returns an iterator only on the primary shard.
*/
public ShardIterator primaryShardIt() {
return new PlainShardIterator(shardId, primaryAsList);
if (primary != null) {
return new PlainShardIterator(shardId, Collections.singletonList(primary));
}
return new PlainShardIterator(shardId, Collections.emptyList());
}
public ShardIterator onlyNodeActiveInitializingShardsIt(String nodeId) {