Remove always-true param from IndicesService#stats (#45231)

Parameter `includePrevious` is always true, so this commit inlines it.
This commit is contained in:
David Turner 2019-08-06 17:21:27 +01:00
parent 355713b9ca
commit f5d1381e01
2 changed files with 28 additions and 40 deletions

View File

@ -328,48 +328,36 @@ public class IndicesService extends AbstractLifecycleComponent
return closeLatch.await(timeout, timeUnit); return closeLatch.await(timeout, timeUnit);
} }
/** public NodeIndicesStats stats(CommonStatsFlags flags) {
* Returns the node stats indices stats. The {@code includePrevious} flag controls CommonStats commonStats = new CommonStats(flags);
* if old shards stats will be aggregated as well (only for relevant stats, such as // the cumulative statistics also account for shards that are no longer on this node, which is tracked by oldShardsStats
* refresh and indexing, not for docs/store). for (Flag flag : flags.getFlags()) {
*/ switch (flag) {
public NodeIndicesStats stats(boolean includePrevious) { case Get:
return stats(includePrevious, new CommonStatsFlags().all()); commonStats.get.add(oldShardsStats.getStats);
} break;
case Indexing:
public NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags) { commonStats.indexing.add(oldShardsStats.indexingStats);
CommonStats oldStats = new CommonStats(flags); break;
case Search:
if (includePrevious) { commonStats.search.add(oldShardsStats.searchStats);
Flag[] setFlags = flags.getFlags(); break;
for (Flag flag : setFlags) { case Merge:
switch (flag) { commonStats.merge.add(oldShardsStats.mergeStats);
case Get: break;
oldStats.get.add(oldShardsStats.getStats); case Refresh:
break; commonStats.refresh.add(oldShardsStats.refreshStats);
case Indexing: break;
oldStats.indexing.add(oldShardsStats.indexingStats); case Recovery:
break; commonStats.recoveryStats.add(oldShardsStats.recoveryStats);
case Search: break;
oldStats.search.add(oldShardsStats.searchStats); case Flush:
break; commonStats.flush.add(oldShardsStats.flushStats);
case Merge: break;
oldStats.merge.add(oldShardsStats.mergeStats);
break;
case Refresh:
oldStats.refresh.add(oldShardsStats.refreshStats);
break;
case Recovery:
oldStats.recoveryStats.add(oldShardsStats.recoveryStats);
break;
case Flush:
oldStats.flush.add(oldShardsStats.flushStats);
break;
}
} }
} }
return new NodeIndicesStats(oldStats, statsByShard(this, flags)); return new NodeIndicesStats(commonStats, statsByShard(this, flags));
} }
Map<Index, List<IndexShardStats>> statsByShard(final IndicesService indicesService, final CommonStatsFlags flags) { Map<Index, List<IndexShardStats>> statsByShard(final IndicesService indicesService, final CommonStatsFlags flags) {

View File

@ -107,7 +107,7 @@ public class NodeService implements Closeable {
// for indices stats we want to include previous allocated shards stats as well (it will // for indices stats we want to include previous allocated shards stats as well (it will
// only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats)
return new NodeStats(transportService.getLocalNode(), System.currentTimeMillis(), return new NodeStats(transportService.getLocalNode(), System.currentTimeMillis(),
indices.anySet() ? indicesService.stats(true, indices) : null, indices.anySet() ? indicesService.stats(indices) : null,
os ? monitorService.osService().stats() : null, os ? monitorService.osService().stats() : null,
process ? monitorService.processService().stats() : null, process ? monitorService.processService().stats() : null,
jvm ? monitorService.jvmService().stats() : null, jvm ? monitorService.jvmService().stats() : null,