use of org.openkilda.messaging.info.switches.SwitchPortsDescription in project open-kilda by telstra.
the class SwitchServiceImpl method getSwitchPortsDescription.
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture<SwitchPortsDescription> getSwitchPortsDescription(SwitchId switchId) {
String correlationId = RequestCorrelationId.getId();
DumpSwitchPortsDescriptionRequest request = new DumpSwitchPortsDescriptionRequest(switchId);
CommandMessage commandMessage = new CommandMessage(request, System.currentTimeMillis(), correlationId, Destination.CONTROLLER);
return messagingChannel.sendAndGet(floodlightTopic, commandMessage).thenApply(SwitchPortsDescription.class::cast);
}
use of org.openkilda.messaging.info.switches.SwitchPortsDescription in project open-kilda by telstra.
the class RecordHandler method doDumpSwitchPortsDescriptionRequest.
private void doDumpSwitchPortsDescriptionRequest(CommandMessage message) {
DumpSwitchPortsDescriptionRequest request = (DumpSwitchPortsDescriptionRequest) message.getData();
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaNorthboundTopic();
try {
SwitchId switchId = request.getSwitchId();
logger.info("Dump ALL ports description for switch {}", switchId);
SwitchPortsDescription response = getSwitchPortsDescription(switchId);
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, infoMessage);
} catch (SwitchOperationException e) {
logger.error("Unable to dump switch port descriptions request", e);
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump switch port descriptions request").withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
use of org.openkilda.messaging.info.switches.SwitchPortsDescription in project open-kilda by telstra.
the class RecordHandler method doDumpPortDescriptionRequest.
private void doDumpPortDescriptionRequest(CommandMessage message) {
DumpPortDescriptionRequest request = (DumpPortDescriptionRequest) message.getData();
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaNorthboundTopic();
try {
SwitchId switchId = request.getSwitchId();
logger.info("Get port {}_{} description", switchId, request.getPortNumber());
SwitchPortsDescription switchPortsDescription = getSwitchPortsDescription(switchId);
int port = request.getPortNumber();
PortDescription response = switchPortsDescription.getPortsDescription().stream().filter(x -> x.getPortNumber() == port).findFirst().orElseThrow(() -> new SwitchOperationException(DatapathId.of(switchId.toLong()), format("Port %s_%d does not exists.", switchId, port)));
InfoMessage infoMessage = new InfoMessage(response, message.getTimestamp(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, infoMessage);
} catch (SwitchOperationException e) {
logger.error("Unable to dump port description request", e);
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump port description request").withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
}
}
Aggregations