diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java index dc86b12731a..baea68db9b8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/indexing/IndexingStats.java @@ -152,11 +152,15 @@ public class IndexingStats implements Streamable, ToXContent { } public void add(IndexingStats indexingStats) { + add(indexingStats, true); + } + + public void add(IndexingStats indexingStats, boolean includeTypes) { if (indexingStats == null) { return; } totalStats.add(indexingStats.totalStats); - if (indexingStats.typeStats != null && !indexingStats.typeStats.isEmpty()) { + if (includeTypes && indexingStats.typeStats != null && !indexingStats.typeStats.isEmpty()) { if (typeStats == null) { typeStats = new HashMap(indexingStats.typeStats.size()); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesService.java index 8bb0e9bbd66..faa329b3894 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -38,7 +38,12 @@ public interface IndicesService extends Iterable, LifecycleCompone */ public boolean changesAllowed(); - NodeIndicesStats stats(); + /** + * Returns the node stats indices stats. The includePrevious flag controls + * if old shards stats will be aggregated as well (only for relevant stats, such as + * refresh and indexing, not for docs/store). + */ + NodeIndicesStats stats(boolean includePrevious); boolean hasIndex(String index); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java index 52da15bfdec..68271476655 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java @@ -67,6 +67,7 @@ import org.elasticsearch.index.service.IndexService; import org.elasticsearch.index.service.InternalIndexService; import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.index.shard.DocsStats; +import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.similarity.SimilarityModule; import org.elasticsearch.index.store.IndexStoreModule; @@ -115,6 +116,8 @@ public class InternalIndicesService extends AbstractLifecycleComponent indices = ImmutableMap.of(); + private final OldShardsStats oldShardsStats = new OldShardsStats(); + @Inject public InternalIndicesService(Settings settings, NodeEnvironment nodeEnv, ThreadPool threadPool, IndicesLifecycle indicesLifecycle, IndicesAnalysisService indicesAnalysisService, IndicesStore indicesStore, Injector injector) { super(settings); this.nodeEnv = nodeEnv; @@ -125,6 +128,8 @@ public class InternalIndicesService extends AbstractLifecycleComponent