Search in sources :

Example 1 with SwitchTableStatsData

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

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

the class StatsTopologyTest method tableStatsTest.

@Test
public void tableStatsTest() {
    TableStatsEntry entry = TableStatsEntry.builder().tableId(1).activeEntries(100).lookupCount(2000).matchedCount(1900).build();
    SwitchTableStatsData tableStatsData = SwitchTableStatsData.builder().switchId(SWITCH_ID_1).tableStatsEntries(ImmutableList.of(entry)).build();
    sendStatsMessage(tableStatsData);
    List<Datapoint> datapoints = pollDatapoints(4);
    Map<String, Datapoint> datapointMap = createDatapointMap(datapoints);
    assertEquals(entry.getActiveEntries(), datapointMap.get(METRIC_PREFIX + "switch.table.active").getValue().intValue());
    assertEquals(entry.getLookupCount(), datapointMap.get(METRIC_PREFIX + "switch.table.lookup").getValue().longValue());
    assertEquals(entry.getMatchedCount(), datapointMap.get(METRIC_PREFIX + "switch.table.matched").getValue().longValue());
    assertEquals(entry.getLookupCount() - entry.getMatchedCount(), datapointMap.get(METRIC_PREFIX + "switch.table.missed").getValue().longValue());
    datapoints.forEach(datapoint -> {
        assertEquals(SWITCH_ID_1.toOtsdFormat(), datapoint.getTags().get("switchid"));
        assertEquals(entry.getTableId(), Integer.parseInt(datapoint.getTags().get("tableid")));
        assertEquals(timestamp, datapoint.getTime().longValue());
    });
}
Also used : TableStatsEntry(org.openkilda.messaging.info.stats.TableStatsEntry) Datapoint(org.openkilda.messaging.info.Datapoint) SwitchTableStatsData(org.openkilda.messaging.info.stats.SwitchTableStatsData) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

SwitchTableStatsData (org.openkilda.messaging.info.stats.SwitchTableStatsData)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Values (org.apache.storm.tuple.Values)1 Test (org.junit.Test)1 Message (org.openkilda.messaging.Message)1 Datapoint (org.openkilda.messaging.info.Datapoint)1 InfoData (org.openkilda.messaging.info.InfoData)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 GetPacketInOutStatsResponse (org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse)1 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)1 MeterConfigStatsData (org.openkilda.messaging.info.stats.MeterConfigStatsData)1 MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)1 PortStatsData (org.openkilda.messaging.info.stats.PortStatsData)1 TableStatsEntry (org.openkilda.messaging.info.stats.TableStatsEntry)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1