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);
}
}
}
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());
});
}
Aggregations