Search in sources :

Example 1 with Handler

use of net.engio.mbassy.listener.Handler in project apex-core by apache.

the class TupleRecorderCollection method collected.

@Handler
public void collected(ContainerStatsEvent cse) {
    ContainerStats stats = cse.getContainerStats();
    for (OperatorHeartbeat node : stats.operators) {
        for (OperatorStats os : node.windowStats) {
            if (os.inputPorts != null) {
                for (PortStats ps : os.inputPorts) {
                    ps.recordingId = null;
                }
            }
            if (os.outputPorts != null) {
                for (PortStats ps : os.outputPorts) {
                    ps.recordingId = null;
                }
            }
        }
    }
    for (OperatorHeartbeat node : stats.operators) {
        String recordingId;
        TupleRecorder tupleRecorder = get(new OperatorIdPortNamePair(node.nodeId, null));
        if (tupleRecorder == null) {
            recordingId = null;
            for (Map.Entry<OperatorIdPortNamePair, TupleRecorder> entry : this.entrySet()) {
                if (entry.getKey().operatorId == node.nodeId) {
                    for (OperatorStats os : node.windowStats) {
                        if (os.inputPorts != null) {
                            for (PortStats ps : os.inputPorts) {
                                if (ps.id.equals(entry.getKey().portName)) {
                                    ps.recordingId = entry.getValue().getId();
                                    break;
                                }
                            }
                        }
                        if (os.outputPorts != null) {
                            for (PortStats ps : os.outputPorts) {
                                if (ps.id.equals(entry.getKey().portName)) {
                                    ps.recordingId = entry.getValue().getId();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        } else {
            recordingId = tupleRecorder.getId();
        }
        for (OperatorStats os : node.windowStats) {
            os.recordingId = recordingId;
        }
    }
}
Also used : ContainerStats(com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.ContainerStats) OperatorHeartbeat(com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.OperatorHeartbeat) OperatorStats(com.datatorrent.api.Stats.OperatorStats) PortStats(com.datatorrent.api.Stats.OperatorStats.PortStats) HashMap(java.util.HashMap) Map(java.util.Map) Handler(net.engio.mbassy.listener.Handler)

Aggregations

OperatorStats (com.datatorrent.api.Stats.OperatorStats)1 PortStats (com.datatorrent.api.Stats.OperatorStats.PortStats)1 ContainerStats (com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.ContainerStats)1 OperatorHeartbeat (com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.OperatorHeartbeat)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Handler (net.engio.mbassy.listener.Handler)1