use of org.openkilda.messaging.info.switches.PortDescription 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);
}
}
use of org.openkilda.messaging.info.switches.PortDescription in project open-kilda by telstra.
the class SwitchServiceImpl method getPortDescription.
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture<PortDescription> getPortDescription(SwitchId switchId, int port) {
String correlationId = RequestCorrelationId.getId();
DumpPortDescriptionRequest request = new DumpPortDescriptionRequest(switchId, port);
CommandMessage commandMessage = new CommandMessage(request, System.currentTimeMillis(), correlationId, Destination.CONTROLLER);
return messagingChannel.sendAndGet(floodlightTopic, commandMessage).thenApply(PortDescription.class::cast);
}
Aggregations