use of org.openkilda.messaging.info.stats.SwitchPortStatusData in project open-kilda by telstra.
the class RecordHandler method doPortsCommandDataRequest.
private void doPortsCommandDataRequest(Set<SwitchId> scope, PortsCommandData payload, String correlationId) {
ISwitchManager switchManager = context.getModuleContext().getServiceImpl(ISwitchManager.class);
try {
logger.info("Getting ports data. Requester: {}", payload.getRequester());
Map<DatapathId, IOFSwitch> allSwitchMap = context.getSwitchManager().getAllSwitchMap(true);
for (Map.Entry<DatapathId, IOFSwitch> entry : allSwitchMap.entrySet()) {
SwitchId switchId = new SwitchId(entry.getKey().toString());
if (!scope.contains(switchId)) {
continue;
}
try {
IOFSwitch sw = entry.getValue();
Set<PortStatusData> statuses = new HashSet<>();
for (OFPortDesc portDesc : switchManager.getPhysicalPorts(sw.getId())) {
statuses.add(new PortStatusData(portDesc.getPortNo().getPortNumber(), portDesc.isEnabled() ? PortStatus.UP : PortStatus.DOWN));
}
SwitchPortStatusData response = SwitchPortStatusData.builder().switchId(switchId).ports(statuses).requester(payload.getRequester()).build();
InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), correlationId);
getKafkaProducer().sendMessageAndTrack(context.getKafkaStatsTopic(), infoMessage);
} catch (Exception e) {
logger.error("Could not get port stats data for switch '{}' with error '{}'", switchId, e.getMessage(), e);
}
}
} catch (Exception e) {
logger.error("Could not get port data for stats '{}'", e.getMessage(), e);
}
}
use of org.openkilda.messaging.info.stats.SwitchPortStatusData in project open-kilda by telstra.
the class WfmStatsParseBolt method handleInput.
@Override
public void handleInput(Tuple tuple) {
if (active) {
log.debug("Ingoing tuple: {}", tuple);
Message message = (Message) tuple.getValueByField(MessageKafkaTranslator.FIELD_ID_PAYLOAD);
try {
InfoData data = getInfoData(message);
if (data instanceof SwitchPortStatusData) {
doParseSwitchPortsData((SwitchPortStatusData) data);
}
} catch (MessageException e) {
log.error("Not an InfoMessage in queue message={}", message);
}
}
}
Aggregations