Search in sources :

Example 1 with MeterConfigStatsData

use of org.openkilda.messaging.info.stats.MeterConfigStatsData 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 MeterConfigStatsData

use of org.openkilda.messaging.info.stats.MeterConfigStatsData in project open-kilda by telstra.

the class StatsTopologyTest method meterConfigStatsTest.

@Test
public void meterConfigStatsTest() {
    final SwitchId switchId = new SwitchId(1L);
    final List<MeterConfigReply> stats = Collections.singletonList(new MeterConfigReply(2, Arrays.asList(1L, 2L, 3L)));
    sendStatsMessage(new MeterConfigStatsData(switchId, stats));
    List<Datapoint> datapoints = pollDatapoints(3);
    datapoints.forEach(datapoint -> {
        assertThat(datapoint.getTags().get("switchid"), is(switchId.toOtsdFormat()));
        assertThat(datapoint.getTime(), is(timestamp));
        assertThat(datapoint.getMetric(), is(METRIC_PREFIX + "switch.meters"));
    });
}
Also used : Datapoint(org.openkilda.messaging.info.Datapoint) MeterConfigStatsData(org.openkilda.messaging.info.stats.MeterConfigStatsData) SwitchId(org.openkilda.model.SwitchId) MeterConfigReply(org.openkilda.messaging.info.stats.MeterConfigReply) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 3 with MeterConfigStatsData

use of org.openkilda.messaging.info.stats.MeterConfigStatsData in project open-kilda by telstra.

the class SpeakerStatsRouterBolt method handleInput.

@Override
protected void handleInput(Tuple tuple) throws Exception {
    log.debug("Ingoing tuple: {}", tuple);
    if (active) {
        Message message = pullValue(tuple, FIELD_ID_PAYLOAD, Message.class);
        if (!(message instanceof InfoMessage)) {
            return;
        }
        InfoMessage infoMessage = (InfoMessage) message;
        final InfoData data = infoMessage.getData();
        if (data instanceof PortStatsData) {
            log.debug("Port stats message: {}", infoMessage);
            emitWithContext(PORT_STATS_STREAM, tuple, new Values(infoMessage));
        } else if (data instanceof MeterConfigStatsData) {
            log.debug("Meter config stats message: {}", infoMessage);
            emitWithContext(METER_CFG_STATS_STREAM, tuple, new Values(infoMessage));
        } else if (data instanceof MeterStatsData) {
            log.debug("Meter stats message: {}", infoMessage);
            emitWithContext(TO_CACHE_STREAM, tuple, new Values(data));
        } else if (data instanceof FlowStatsData) {
            log.debug("Flow stats message: {}", infoMessage);
            ImmutablePair<FlowStatsData, FlowStatsData> splitData = splitSystemRuleStatsAndFlowStats((FlowStatsData) data);
            emitWithContext(SYSTEM_RULES_STATS_STREAM, tuple, new Values(splitData.getKey()));
            emitWithContext(TO_CACHE_STREAM, tuple, new Values(splitData.getValue()));
        } else if (data instanceof SwitchTableStatsData) {
            log.debug("Table stats message: {}", infoMessage);
            emitWithContext(TABLE_STATS_STREAM, tuple, new Values(data));
        } else if (data instanceof GetPacketInOutStatsResponse) {
            log.debug("Packet in out stats message: {}", infoMessage);
            emitWithContext(PACKET_IN_OUT_STATS_STREAM, tuple, new Values(data));
        } else {
        // FIXME (ncherevko): we might receive few unexpected messages here,
        // need to fix it and uncomment below line
        // unhandledInput(tuple);
        }
    }
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) GetPacketInOutStatsResponse(org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse) MeterConfigStatsData(org.openkilda.messaging.info.stats.MeterConfigStatsData) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Values(org.apache.storm.tuple.Values) PortStatsData(org.openkilda.messaging.info.stats.PortStatsData) SwitchTableStatsData(org.openkilda.messaging.info.stats.SwitchTableStatsData)

Example 4 with MeterConfigStatsData

use of org.openkilda.messaging.info.stats.MeterConfigStatsData in project open-kilda by telstra.

the class SpeakerBolt method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(Tuple tuple) {
    logger.debug("Ingoing tuple: {}", tuple);
    String request = tuple.getString(0);
    // String request = tuple.getStringByField("value");
    try {
        Message stats = Utils.MAPPER.readValue(request, Message.class);
        if (!Destination.WFM_STATS.equals(stats.getDestination()) || !(stats instanceof InfoMessage)) {
            return;
        }
        InfoMessage message = (InfoMessage) stats;
        final InfoData data = message.getData();
        if (data instanceof PortStatsData) {
            logger.debug("Port stats message: {}", new Values(request));
            outputCollector.emit(PORT_STATS_STREAM, tuple, new Values(message));
        } else if (data instanceof MeterConfigStatsData) {
            logger.debug("Meter config stats message: {}", new Values(request));
            outputCollector.emit(METER_CFG_STATS_STREAM, tuple, new Values(message));
        } else if (data instanceof FlowStatsData) {
            logger.debug("Flow stats message: {}", new Values(request));
            outputCollector.emit(FLOW_STATS_STREAM, tuple, new Values(message));
        }
    } catch (IOException exception) {
        logger.error("Could not deserialize message={}", request, exception);
    } finally {
        outputCollector.ack(tuple);
        logger.debug("Message ack: {}", request);
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) AbstractTopology.fieldMessage(org.openkilda.wfm.topology.AbstractTopology.fieldMessage) MeterConfigStatsData(org.openkilda.messaging.info.stats.MeterConfigStatsData) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Values(org.apache.storm.tuple.Values) PortStatsData(org.openkilda.messaging.info.stats.PortStatsData) IOException(java.io.IOException)

Example 5 with MeterConfigStatsData

use of org.openkilda.messaging.info.stats.MeterConfigStatsData in project open-kilda by telstra.

the class MeterConfigMetricGenBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws Exception {
    InfoMessage message = (InfoMessage) input.getValueByField(KafkaRecordTranslator.FIELD_ID_PAYLOAD);
    MeterConfigStatsData data = (MeterConfigStatsData) message.getData();
    long timestamp = message.getTimestamp();
    SwitchId switchId = data.getSwitchId();
    for (MeterConfigReply reply : data.getStats()) {
        for (Long meterId : reply.getMeterIds()) {
            emit(timestamp, meterId, switchId);
        }
    }
}
Also used : MeterConfigStatsData(org.openkilda.messaging.info.stats.MeterConfigStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchId(org.openkilda.model.SwitchId) MeterConfigReply(org.openkilda.messaging.info.stats.MeterConfigReply)

Aggregations

MeterConfigStatsData (org.openkilda.messaging.info.stats.MeterConfigStatsData)5 InfoMessage (org.openkilda.messaging.info.InfoMessage)4 MeterConfigReply (org.openkilda.messaging.info.stats.MeterConfigReply)3 Values (org.apache.storm.tuple.Values)2 Message (org.openkilda.messaging.Message)2 InfoData (org.openkilda.messaging.info.InfoData)2 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)2 PortStatsData (org.openkilda.messaging.info.stats.PortStatsData)2 SwitchId (org.openkilda.model.SwitchId)2 IOException (java.io.IOException)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Test (org.junit.Test)1 Datapoint (org.openkilda.messaging.info.Datapoint)1 GetPacketInOutStatsResponse (org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse)1 MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)1 SwitchTableStatsData (org.openkilda.messaging.info.stats.SwitchTableStatsData)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1 AbstractTopology.fieldMessage (org.openkilda.wfm.topology.AbstractTopology.fieldMessage)1 StatsComponentType (org.openkilda.wfm.topology.stats.StatsComponentType)1