add refresh stats to node indices stats section

This commit is contained in:
Shay Banon 2011-08-21 01:10:51 +03:00
parent 0549e9d1c2
commit 6fd6965bdf
2 changed files with 20 additions and 2 deletions

View File

@ -62,6 +62,7 @@ import org.elasticsearch.index.percolator.PercolatorModule;
import org.elasticsearch.index.percolator.PercolatorService; import org.elasticsearch.index.percolator.PercolatorService;
import org.elasticsearch.index.query.IndexQueryParserModule; import org.elasticsearch.index.query.IndexQueryParserModule;
import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.IndexQueryParserService;
import org.elasticsearch.index.refresh.RefreshStats;
import org.elasticsearch.index.service.IndexService; import org.elasticsearch.index.service.IndexService;
import org.elasticsearch.index.service.InternalIndexService; import org.elasticsearch.index.service.InternalIndexService;
import org.elasticsearch.index.settings.IndexSettingsModule; import org.elasticsearch.index.settings.IndexSettingsModule;
@ -174,6 +175,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
long numberOfDocs = 0; long numberOfDocs = 0;
CacheStats cacheStats = new CacheStats(); CacheStats cacheStats = new CacheStats();
MergeStats mergeStats = new MergeStats(); MergeStats mergeStats = new MergeStats();
RefreshStats refreshStats = new RefreshStats();
for (IndexService indexService : indices.values()) { for (IndexService indexService : indices.values()) {
for (IndexShard indexShard : indexService) { for (IndexShard indexShard : indexService) {
try { try {
@ -191,10 +193,11 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
} }
} }
mergeStats.add(((InternalIndexShard) indexShard).mergeScheduler().stats()); mergeStats.add(((InternalIndexShard) indexShard).mergeScheduler().stats());
refreshStats.add(indexShard.refreshStats());
} }
cacheStats.add(indexService.cache().stats()); cacheStats.add(indexService.cache().stats());
} }
return new NodeIndicesStats(new ByteSizeValue(storeTotalSize), numberOfDocs, cacheStats, mergeStats); return new NodeIndicesStats(new ByteSizeValue(storeTotalSize), numberOfDocs, cacheStats, mergeStats, refreshStats);
} }
/** /**

View File

@ -28,6 +28,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.index.cache.CacheStats; import org.elasticsearch.index.cache.CacheStats;
import org.elasticsearch.index.merge.MergeStats; import org.elasticsearch.index.merge.MergeStats;
import org.elasticsearch.index.refresh.RefreshStats;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
@ -47,14 +48,17 @@ public class NodeIndicesStats implements Streamable, Serializable, ToXContent {
private MergeStats mergeStats; private MergeStats mergeStats;
private RefreshStats refreshStats;
NodeIndicesStats() { NodeIndicesStats() {
} }
public NodeIndicesStats(ByteSizeValue storeSize, long numDocs, CacheStats cacheStats, MergeStats mergeStats) { public NodeIndicesStats(ByteSizeValue storeSize, long numDocs, CacheStats cacheStats, MergeStats mergeStats, RefreshStats refreshStats) {
this.storeSize = storeSize; this.storeSize = storeSize;
this.numDocs = numDocs; this.numDocs = numDocs;
this.cacheStats = cacheStats; this.cacheStats = cacheStats;
this.mergeStats = mergeStats; this.mergeStats = mergeStats;
this.refreshStats = refreshStats;
} }
/** /**
@ -101,6 +105,14 @@ public class NodeIndicesStats implements Streamable, Serializable, ToXContent {
return this.mergeStats; return this.mergeStats;
} }
public RefreshStats refresh() {
return this.refresh();
}
public RefreshStats getRefresh() {
return this.refresh();
}
public static NodeIndicesStats readIndicesStats(StreamInput in) throws IOException { public static NodeIndicesStats readIndicesStats(StreamInput in) throws IOException {
NodeIndicesStats stats = new NodeIndicesStats(); NodeIndicesStats stats = new NodeIndicesStats();
stats.readFrom(in); stats.readFrom(in);
@ -112,6 +124,7 @@ public class NodeIndicesStats implements Streamable, Serializable, ToXContent {
numDocs = in.readVLong(); numDocs = in.readVLong();
cacheStats = CacheStats.readCacheStats(in); cacheStats = CacheStats.readCacheStats(in);
mergeStats = MergeStats.readMergeStats(in); mergeStats = MergeStats.readMergeStats(in);
refreshStats = RefreshStats.readRefreshStats(in);
} }
@Override public void writeTo(StreamOutput out) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException {
@ -119,6 +132,7 @@ public class NodeIndicesStats implements Streamable, Serializable, ToXContent {
out.writeVLong(numDocs); out.writeVLong(numDocs);
cacheStats.writeTo(out); cacheStats.writeTo(out);
mergeStats.writeTo(out); mergeStats.writeTo(out);
refreshStats.writeTo(out);
} }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
@ -133,6 +147,7 @@ public class NodeIndicesStats implements Streamable, Serializable, ToXContent {
cacheStats.toXContent(builder, params); cacheStats.toXContent(builder, params);
mergeStats.toXContent(builder, params); mergeStats.toXContent(builder, params);
refreshStats.toXContent(builder, params);
builder.endObject(); builder.endObject();
return builder; return builder;