Search in sources :

Example 1 with StatsComponentType

use of org.openkilda.wfm.topology.stats.StatsComponentType in project open-kilda by telstra.

the class MeterConfigMetricGenBolt method execute.

@Override
public void execute(Tuple input) {
    StatsComponentType componentId = StatsComponentType.valueOf(input.getSourceComponent());
    InfoMessage message = (InfoMessage) input.getValueByField(MESSAGE_FIELD);
    if (!Destination.WFM_STATS.equals(message.getDestination())) {
        collector.ack(input);
        return;
    }
    LOGGER.debug("Meter config stats message: {}={}, component={}, stream={}", CORRELATION_ID, message.getCorrelationId(), componentId, StatsStreamType.valueOf(input.getSourceStreamId()));
    MeterConfigStatsData data = (MeterConfigStatsData) message.getData();
    long timestamp = message.getTimestamp();
    try {
        String switchId = data.getSwitchId().replaceAll(":", "");
        for (MeterConfigReply reply : data.getStats()) {
            for (Long meterId : reply.getMeterIds()) {
                emit(timestamp, meterId, switchId);
            }
        }
    } finally {
        collector.ack(input);
    }
}
Also used : StatsComponentType(org.openkilda.wfm.topology.stats.StatsComponentType) MeterConfigStatsData(org.openkilda.messaging.info.stats.MeterConfigStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) MeterConfigReply(org.openkilda.messaging.info.stats.MeterConfigReply)

Example 2 with StatsComponentType

use of org.openkilda.wfm.topology.stats.StatsComponentType in project open-kilda by telstra.

the class PortMetricGenBolt method execute.

@Override
public void execute(Tuple input) {
    StatsComponentType componentId = StatsComponentType.valueOf(input.getSourceComponent());
    InfoMessage message = (InfoMessage) input.getValueByField(MESSAGE_FIELD);
    if (!Destination.WFM_STATS.equals(message.getDestination())) {
        collector.ack(input);
        return;
    }
    LOGGER.debug("Port stats message: {}={}, component={}, stream={}", CORRELATION_ID, message.getCorrelationId(), componentId, StatsStreamType.valueOf(input.getSourceStreamId()));
    PortStatsData data = (PortStatsData) message.getData();
    long timestamp = message.getTimestamp();
    try {
        String switchId = switchNameCache.get(data.getSwitchId());
        if (switchId == null) {
            switchId = "SW" + data.getSwitchId().replaceAll(":", "").toUpperCase();
            switchNameCache.put(data.getSwitchId(), switchId);
        }
        for (PortStatsReply reply : data.getStats()) {
            for (PortStatsEntry entry : reply.getEntries()) {
                emit(entry, timestamp, switchId);
            }
        }
    } finally {
        collector.ack(input);
    }
}
Also used : StatsComponentType(org.openkilda.wfm.topology.stats.StatsComponentType) InfoMessage(org.openkilda.messaging.info.InfoMessage) PortStatsData(org.openkilda.messaging.info.stats.PortStatsData) PortStatsEntry(org.openkilda.messaging.info.stats.PortStatsEntry) PortStatsReply(org.openkilda.messaging.info.stats.PortStatsReply)

Example 3 with StatsComponentType

use of org.openkilda.wfm.topology.stats.StatsComponentType in project open-kilda by telstra.

the class FlowMetricGenBolt method execute.

@Override
public void execute(Tuple input) {
    StatsComponentType componentId = StatsComponentType.valueOf(input.getSourceComponent());
    InfoMessage message = (InfoMessage) input.getValueByField(MESSAGE_FIELD);
    if (!Destination.WFM_STATS.equals(message.getDestination())) {
        collector.ack(input);
        return;
    }
    LOGGER.debug("Flow stats message: {}={}, component={}, stream={}", CORRELATION_ID, message.getCorrelationId(), componentId, StatsStreamType.valueOf(input.getSourceStreamId()));
    FlowStatsData data = (FlowStatsData) message.getData();
    long timestamp = message.getTimestamp();
    String switchId = data.getSwitchId().replaceAll(":", "");
    try {
        for (FlowStatsReply reply : data.getStats()) {
            for (FlowStatsEntry entry : reply.getEntries()) {
                emit(entry, timestamp, switchId);
            }
        }
        collector.ack(input);
    } catch (ServiceUnavailableException e) {
        LOGGER.error("Error process: {}", input.toString(), e);
        // If we can't connect to Neo then don't know if valid input
        collector.fail(input);
    } catch (Exception e) {
        // We tried, no need to try again
        collector.ack(input);
    }
}
Also used : FlowStatsReply(org.openkilda.messaging.info.stats.FlowStatsReply) FlowStatsEntry(org.openkilda.messaging.info.stats.FlowStatsEntry) StatsComponentType(org.openkilda.wfm.topology.stats.StatsComponentType) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException) MalformedURLException(java.net.MalformedURLException) FlowCookieException(org.openkilda.wfm.topology.FlowCookieException) ClientException(org.neo4j.driver.v1.exceptions.ClientException) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)3 StatsComponentType (org.openkilda.wfm.topology.stats.StatsComponentType)3 MalformedURLException (java.net.MalformedURLException)1 ClientException (org.neo4j.driver.v1.exceptions.ClientException)1 ServiceUnavailableException (org.neo4j.driver.v1.exceptions.ServiceUnavailableException)1 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)1 FlowStatsEntry (org.openkilda.messaging.info.stats.FlowStatsEntry)1 FlowStatsReply (org.openkilda.messaging.info.stats.FlowStatsReply)1 MeterConfigReply (org.openkilda.messaging.info.stats.MeterConfigReply)1 MeterConfigStatsData (org.openkilda.messaging.info.stats.MeterConfigStatsData)1 PortStatsData (org.openkilda.messaging.info.stats.PortStatsData)1 PortStatsEntry (org.openkilda.messaging.info.stats.PortStatsEntry)1 PortStatsReply (org.openkilda.messaging.info.stats.PortStatsReply)1 FlowCookieException (org.openkilda.wfm.topology.FlowCookieException)1