Browse Source

Use activeShards to get all active shards (#63861)

No need to iterate over shard routings.
Shintaro Murakami 4 years ago
parent
commit
267e8933b7

+ 1 - 5
server/src/main/java/org/elasticsearch/cluster/routing/IndexRoutingTable.java

@@ -79,11 +79,7 @@ public class IndexRoutingTable extends AbstractDiffable<IndexRoutingTable> imple
         this.shards = shards;
         List<ShardRouting> allActiveShards = new ArrayList<>();
         for (IntObjectCursor<IndexShardRoutingTable> cursor : shards) {
-            for (ShardRouting shardRouting : cursor.value) {
-                if (shardRouting.active()) {
-                    allActiveShards.add(shardRouting);
-                }
-            }
+            allActiveShards.addAll(cursor.value.activeShards());
         }
         this.allActiveShards = Collections.unmodifiableList(allActiveShards);
     }