if (threads[i] != null) {
stats.add(threads[i].getStatsSnapshot(true));
}
}
}
Timeline timeline = slaveState.getTimeline();
long now = System.currentTimeMillis();
long cacheSize = sizeThread.getAndResetSize();
timeline.addValue(CACHE_SIZE, new Timeline.Value(now, cacheSize));
if (stats.isEmpty()) {
// add zero for all operations we've already reported
for (String valueCategory : timeline.getValueCategories()) {
if (valueCategory.endsWith(" Throughput")) {
timeline.addValue(valueCategory, new Timeline.Value(now, 0));
}
}
} else {
Statistics aggregated = stats.get(0).copy();
for (int i = 1; i < stats.size(); ++i) {
aggregated.merge(stats.get(i));
}
for (Map.Entry<String, OperationStats> entry : aggregated.getOperationsStats().entrySet()) {
Throughput throughput = entry.getValue().getRepresentation(Throughput.class, stats.size(), TimeUnit.MILLISECONDS.toNanos(aggregated.getEnd() - aggregated.getBegin()));
if (throughput != null && (throughput.actual != 0 || timeline.getValues(entry.getKey() + " Throughput") != null)) {
timeline.addValue(entry.getKey() + " Throughput", new Timeline.Value(now, throughput.actual));
}
}
}
log.trace("Adding iteration " + BackgroundOpsManager.this.stats.size() + ": " + stats);