Search in sources :

Example 1 with OperatorInfo

use of com.datatorrent.stram.webapp.OperatorInfo in project apex-core by apache.

the class StreamingContainerManager method fillPhysicalOperatorInfo.

private OperatorInfo fillPhysicalOperatorInfo(PTOperator operator) {
    OperatorInfo oi = new OperatorInfo();
    oi.container = operator.getContainer().getExternalId();
    oi.host = operator.getContainer().host;
    oi.id = Integer.toString(operator.getId());
    oi.name = operator.getName();
    oi.className = operator.getOperatorMeta().getOperator().getClass().getName();
    oi.status = operator.getState().toString();
    if (operator.isUnifier()) {
        oi.unifierClass = operator.getUnifierClass().getName();
    }
    oi.logicalName = operator.getOperatorMeta().getName();
    OperatorStatus os = operator.stats;
    oi.recordingId = os.recordingId;
    oi.totalTuplesProcessed = os.totalTuplesProcessed.get();
    oi.totalTuplesEmitted = os.totalTuplesEmitted.get();
    oi.tuplesProcessedPSMA = os.tuplesProcessedPSMA.get();
    oi.tuplesEmittedPSMA = os.tuplesEmittedPSMA.get();
    oi.cpuPercentageMA = os.cpuNanosPMSMA.getAvg() / 10000;
    oi.latencyMA = os.latencyMA.getAvg();
    oi.failureCount = operator.failureCount;
    oi.recoveryWindowId = toWsWindowId(operator.getRecoveryCheckpoint().windowId);
    oi.currentWindowId = toWsWindowId(os.currentWindowId.get());
    if (os.lastHeartbeat != null) {
        oi.lastHeartbeat = os.lastHeartbeat.getGeneratedTms();
    }
    if (os.checkpointStats != null) {
        oi.checkpointTime = os.checkpointStats.checkpointTime;
        oi.checkpointStartTime = os.checkpointStats.checkpointStartTime;
    }
    oi.checkpointTimeMA = os.checkpointTimeMA.getAvg();
    for (PortStatus ps : os.inputPortStatusList.values()) {
        PortInfo pinfo = new PortInfo();
        pinfo.name = ps.portName;
        pinfo.type = "input";
        pinfo.totalTuples = ps.totalTuples;
        pinfo.tuplesPSMA = Math.round(ps.tuplesPMSMA.getAvg() * 1000);
        pinfo.bufferServerBytesPSMA = Math.round(ps.bufferServerBytesPMSMA.getAvg() * 1000);
        pinfo.queueSizeMA = ps.queueSizeMA.getAvg();
        pinfo.recordingId = ps.recordingId;
        oi.addPort(pinfo);
    }
    for (PortStatus ps : os.outputPortStatusList.values()) {
        PortInfo pinfo = new PortInfo();
        pinfo.name = ps.portName;
        pinfo.type = "output";
        pinfo.totalTuples = ps.totalTuples;
        pinfo.tuplesPSMA = Math.round(ps.tuplesPMSMA.getAvg() * 1000);
        pinfo.bufferServerBytesPSMA = Math.round(ps.bufferServerBytesPMSMA.getAvg() * 1000);
        pinfo.recordingId = ps.recordingId;
        oi.addPort(pinfo);
    }
    oi.counters = os.getLastWindowedStats().size() > 0 ? os.getLastWindowedStats().get(os.getLastWindowedStats().size() - 1).counters : null;
    oi.metrics = os.getLastWindowedStats().size() > 0 ? os.getLastWindowedStats().get(os.getLastWindowedStats().size() - 1).metrics : null;
    return oi;
}
Also used : PortInfo(com.datatorrent.stram.webapp.PortInfo) OperatorStatus(com.datatorrent.stram.plan.physical.OperatorStatus) LogicalOperatorStatus(com.datatorrent.stram.plan.logical.LogicalOperatorStatus) PortStatus(com.datatorrent.stram.plan.physical.OperatorStatus.PortStatus) LogicalOperatorInfo(com.datatorrent.stram.webapp.LogicalOperatorInfo) OperatorInfo(com.datatorrent.stram.webapp.OperatorInfo)

Example 2 with OperatorInfo

use of com.datatorrent.stram.webapp.OperatorInfo in project apex-core by apache.

the class FSStatsRecorder method recordOperators.

@Override
public void recordOperators(List<OperatorInfo> operatorList, long timestamp) throws IOException {
    for (OperatorInfo operatorInfo : operatorList) {
        FSPartFileCollection operatorStorage;
        if (!logicalOperatorStorageMap.containsKey(operatorInfo.name)) {
            operatorStorage = new FSPartFileCollection();
            operatorStorage.setBasePath(basePath + "/operators/" + operatorInfo.name);
            operatorStorage.setup();
            operatorStorage.writeMetaData((VERSION + "\n").getBytes());
            logicalOperatorStorageMap.put(operatorInfo.name, operatorStorage);
        } else {
            operatorStorage = logicalOperatorStorageMap.get(operatorInfo.name);
        }
        if (!knownOperators.contains(operatorInfo.id)) {
            knownOperators.add(operatorInfo.id);
            Map<String, Object> fieldMap = extractRecordFields(operatorInfo, "meta");
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            Slice f = streamCodec.toByteArray(fieldMap);
            bos.write(f.buffer, f.offset, f.length);
            bos.write("\n".getBytes());
            queue.add(new WriteOperation(operatorStorage, bos.toByteArray(), true));
        }
        Map<String, Object> fieldMap = extractRecordFields(operatorInfo, "stats");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Slice f = streamCodec.toByteArray(fieldMap);
        bos.write((operatorInfo.id + ":").getBytes());
        bos.write((String.valueOf(timestamp) + ":").getBytes());
        bos.write(f.buffer, f.offset, f.length);
        bos.write("\n".getBytes());
        queue.add(new WriteOperation(operatorStorage, bos.toByteArray(), false));
    }
}
Also used : FSPartFileCollection(com.datatorrent.stram.util.FSPartFileCollection) Slice(com.datatorrent.netlet.util.Slice) OperatorInfo(com.datatorrent.stram.webapp.OperatorInfo) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

OperatorInfo (com.datatorrent.stram.webapp.OperatorInfo)2 Slice (com.datatorrent.netlet.util.Slice)1 LogicalOperatorStatus (com.datatorrent.stram.plan.logical.LogicalOperatorStatus)1 OperatorStatus (com.datatorrent.stram.plan.physical.OperatorStatus)1 PortStatus (com.datatorrent.stram.plan.physical.OperatorStatus.PortStatus)1 FSPartFileCollection (com.datatorrent.stram.util.FSPartFileCollection)1 LogicalOperatorInfo (com.datatorrent.stram.webapp.LogicalOperatorInfo)1 PortInfo (com.datatorrent.stram.webapp.PortInfo)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1