}
@Override public NodeIndicesStats stats() {
long storeTotalSize = 0;
long numberOfDocs = 0;
CacheStats cacheStats = new CacheStats();
MergeStats mergeStats = new MergeStats();
for (IndexService indexService : indices.values()) {
for (IndexShard indexShard : indexService) {
try {
storeTotalSize += ((InternalIndexShard) indexShard).store().estimateSize().bytes();
} catch (IOException e) {
// ignore
}
if (indexShard.state() == IndexShardState.STARTED) {
Engine.Searcher searcher = indexShard.searcher();
try {
numberOfDocs += searcher.reader().numDocs();
} finally {
searcher.release();
}
}
mergeStats.add(((InternalIndexShard) indexShard).mergeScheduler().stats());
}
cacheStats.add(indexService.cache().stats());
}
return new NodeIndicesStats(new ByteSizeValue(storeTotalSize), numberOfDocs, cacheStats, mergeStats);
}