From bc54201cfc8527b3c48ce06a935b712c2763bdb5 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 19 Nov 2013 11:54:09 -0800 Subject: [PATCH] Running the node stats api while a shard is moving onto the node logs an exception fixes #4203 --- .../stats/TransportIndicesStatsAction.java | 3 +- .../indices/InternalIndicesService.java | 31 ++++--------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java index f4bebf684f1..012b0f48179 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java @@ -191,8 +191,7 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi flags.completionDataFields(request.request.completionFields()); } - ShardStats stats = new ShardStats(indexShard, flags); - return stats; + return new ShardStats(indexShard, flags); } public static class IndexShardStatsRequest extends BroadcastShardOperationRequest { diff --git a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/src/main/java/org/elasticsearch/indices/InternalIndicesService.java index d1942c8ab5d..ebc29ea7186 100644 --- a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ b/src/main/java/org/elasticsearch/indices/InternalIndicesService.java @@ -21,14 +21,12 @@ package org.elasticsearch.indices; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; import com.google.common.collect.UnmodifiableIterator; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; -import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.*; @@ -61,6 +59,7 @@ import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.service.IndexService; import org.elasticsearch.index.service.InternalIndexService; import org.elasticsearch.index.settings.IndexSettingsModule; +import org.elasticsearch.index.shard.IllegalIndexShardStateException; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.similarity.SimilarityModule; @@ -73,7 +72,6 @@ import org.elasticsearch.plugins.IndexPluginsModule; import org.elasticsearch.plugins.PluginsService; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -207,33 +205,16 @@ public class InternalIndicesService extends AbstractLifecycleComponent shardStats = Lists.newArrayList(); - for (String index : indices()) { - IndexService indexService = indexService(index); - if (indexService == null) { - continue; // something changed, move along - } - for (int shardId : indexService.shardIds()) { - IndexShard indexShard = indexService.shard(shardId); - if (indexShard == null) { - continue; - } - shardStats.add(new ShardStats(indexShard, flags)); - } - } - return shardStats.toArray(new ShardStats[shardStats.size()]); - } - /** * Returns true if changes (adding / removing) indices, shards and so on are allowed. */