Omit current* stats for OldShardStats (closes #13386)

This commit is contained in:
Alex Chow 2015-09-24 17:23:08 -07:00
parent c379505525
commit 9bea7cbda8
8 changed files with 52 additions and 18 deletions

View File

@ -50,6 +50,10 @@ public class FlushStats implements Streamable, ToXContent {
}
public void add(FlushStats flushStats) {
addTotals(flushStats);
}
public void addTotals(FlushStats flushStats) {
if (flushStats == null) {
return;
}

View File

@ -51,6 +51,14 @@ public class GetStats implements Streamable, ToXContent {
}
public void add(GetStats stats) {
if (stats == null) {
return;
}
current += stats.current;
addTotals(stats);
}
public void addTotals(GetStats stats) {
if (stats == null) {
return;
}

View File

@ -232,7 +232,7 @@ public class IndexingStats implements Streamable, ToXContent {
if (indexingStats == null) {
return;
}
totalStats.add(indexingStats.totalStats);
addTotals(indexingStats);
if (includeTypes && indexingStats.typeStats != null && !indexingStats.typeStats.isEmpty()) {
if (typeStats == null) {
typeStats = new HashMap<>(indexingStats.typeStats.size());
@ -248,6 +248,13 @@ public class IndexingStats implements Streamable, ToXContent {
}
}
public void addTotals(IndexingStats indexingStats) {
if (indexingStats == null) {
return;
}
totalStats.add(indexingStats.totalStats);
}
public Stats getTotal() {
return this.totalStats;
}

View File

@ -76,6 +76,17 @@ public class MergeStats implements Streamable, ToXContent {
}
public void add(MergeStats mergeStats) {
if (mergeStats == null) {
return;
}
this.current += mergeStats.current;
this.currentNumDocs += mergeStats.currentNumDocs;
this.currentSizeInBytes += mergeStats.currentSizeInBytes;
addTotals(mergeStats);
}
public void addTotals(MergeStats mergeStats) {
if (mergeStats == null) {
return;
}
@ -83,9 +94,6 @@ public class MergeStats implements Streamable, ToXContent {
this.totalTimeInMillis += mergeStats.totalTimeInMillis;
this.totalNumDocs += mergeStats.totalNumDocs;
this.totalSizeInBytes += mergeStats.totalSizeInBytes;
this.current += mergeStats.current;
this.currentNumDocs += mergeStats.currentNumDocs;
this.currentSizeInBytes += mergeStats.currentSizeInBytes;
this.totalStoppedTimeInMillis += mergeStats.totalStoppedTimeInMillis;
this.totalThrottledTimeInMillis += mergeStats.totalThrottledTimeInMillis;
if (this.totalBytesPerSecAutoThrottle == Long.MAX_VALUE || mergeStats.totalBytesPerSecAutoThrottle == Long.MAX_VALUE) {

View File

@ -47,15 +47,11 @@ public class RecoveryStats implements ToXContent, Streamable {
if (recoveryStats != null) {
this.currentAsSource.addAndGet(recoveryStats.currentAsSource());
this.currentAsTarget.addAndGet(recoveryStats.currentAsTarget());
this.throttleTimeInNanos.addAndGet(recoveryStats.throttleTime().nanos());
}
addTotals(recoveryStats);
}
/**
* add statistics that should be accumulated about old shards after they have been
* deleted or relocated
*/
public void addAsOld(RecoveryStats recoveryStats) {
public void addTotals(RecoveryStats recoveryStats) {
if (recoveryStats != null) {
this.throttleTimeInNanos.addAndGet(recoveryStats.throttleTime().nanos());
}

View File

@ -50,6 +50,10 @@ public class RefreshStats implements Streamable, ToXContent {
}
public void add(RefreshStats refreshStats) {
addTotals(refreshStats);
}
public void addTotals(RefreshStats refreshStats) {
if (refreshStats == null) {
return;
}

View File

@ -221,7 +221,7 @@ public class SearchStats implements Streamable, ToXContent {
if (searchStats == null) {
return;
}
totalStats.add(searchStats.totalStats);
addTotals(searchStats);
openContexts += searchStats.openContexts;
if (includeTypes && searchStats.groupStats != null && !searchStats.groupStats.isEmpty()) {
if (groupStats == null) {
@ -238,6 +238,13 @@ public class SearchStats implements Streamable, ToXContent {
}
}
public void addTotals(SearchStats searchStats) {
if (searchStats == null) {
return;
}
totalStats.add(searchStats.totalStats);
}
public Stats getTotal() {
return this.totalStats;
}

View File

@ -446,13 +446,13 @@ public class IndicesService extends AbstractLifecycleComponent<IndicesService> i
public synchronized void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard,
@IndexSettings Settings indexSettings) {
if (indexShard != null) {
getStats.add(indexShard.getStats());
indexingStats.add(indexShard.indexingStats(), false);
searchStats.add(indexShard.searchStats(), false);
mergeStats.add(indexShard.mergeStats());
refreshStats.add(indexShard.refreshStats());
flushStats.add(indexShard.flushStats());
recoveryStats.addAsOld(indexShard.recoveryStats());
getStats.addTotals(indexShard.getStats());
indexingStats.addTotals(indexShard.indexingStats());
searchStats.addTotals(indexShard.searchStats());
mergeStats.addTotals(indexShard.mergeStats());
refreshStats.addTotals(indexShard.refreshStats());
flushStats.addTotals(indexShard.flushStats());
recoveryStats.addTotals(indexShard.recoveryStats());
}
}
}