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