From 00ed31d000f20f29d963cc5af7acd07cf148715c Mon Sep 17 00:00:00 2001 From: Howard Date: Tue, 7 Jul 2020 14:33:56 +0800 Subject: [PATCH] Remove IndexShardRoutingTable#primaryAsList (#59044) --- .../cluster/routing/IndexShardRoutingTable.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 97cf855b8b6..86bca1998eb 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/IndexShardRoutingTable.java @@ -59,7 +59,6 @@ public class IndexShardRoutingTable implements Iterable { final ShardId shardId; final ShardRouting primary; - final List primaryAsList; final List replicas; final List shards; final List activeShards; @@ -120,11 +119,6 @@ public class IndexShardRoutingTable implements Iterable { } 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 { * 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) {