Search in sources :

Example 1 with Stats

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);
}
Also used : ContainerStats(com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.ContainerStats) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) Checkpoint(com.datatorrent.stram.api.Checkpoint) MuxSink(com.datatorrent.stram.debug.MuxSink) Sink(com.datatorrent.api.Sink) FutureTask(java.util.concurrent.FutureTask) Stats(com.datatorrent.api.Stats) ContainerStats(com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.ContainerStats)

Aggregations

Sink (com.datatorrent.api.Sink)1 Stats (com.datatorrent.api.Stats)1 Checkpoint (com.datatorrent.stram.api.Checkpoint)1 ContainerStats (com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.ContainerStats)1 MuxSink (com.datatorrent.stram.debug.MuxSink)1 IntrospectionException (java.beans.IntrospectionException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 FutureTask (java.util.concurrent.FutureTask)1