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