use of com.datatorrent.api.Stats in project apex-core by apache.
the class Node method reportStats.
protected void reportStats(ContainerStats.OperatorStats stats, long windowId) {
stats.outputPorts = new ArrayList<>();
for (Entry<String, Sink<Object>> e : outputs.entrySet()) {
ContainerStats.OperatorStats.PortStats portStats = new ContainerStats.OperatorStats.PortStats(e.getKey());
portStats.tupleCount = e.getValue().getCount(true) - controlTupleCount;
portStats.endWindowTimestamp = endWindowEmitTime;
stats.outputPorts.add(portStats);
}
controlTupleCount = 0;
long currentCpuTime = tmb.getCurrentThreadCpuTime();
stats.cpuTimeUsed = currentCpuTime - lastSampleCpuTime;
lastSampleCpuTime = currentCpuTime;
if (checkpoint != null) {
stats.checkpoint = checkpoint;
stats.checkpointStats = checkpointStats;
checkpointStats = null;
checkpoint = null;
} else {
Pair<FutureTask<Stats.CheckpointStats>, CheckpointWindowInfo> pair = taskQueue.peek();
if (pair != null && pair.getFirst().isDone()) {
taskQueue.poll();
try {
CheckpointWindowInfo checkpointWindowInfo = pair.getSecond();
stats.checkpointStats = pair.getFirst().get();
stats.checkpoint = new Checkpoint(checkpointWindowInfo.windowId, checkpointWindowInfo.applicationWindowCount, checkpointWindowInfo.checkpointWindowCount);
if (operator instanceof Operator.CheckpointListener) {
((Operator.CheckpointListener) operator).checkpointed(checkpointWindowInfo.windowId);
}
} catch (Exception ex) {
throw Throwables.propagate(ex);
}
}
}
context.report(stats, windowId);
}
Aggregations