Search in sources :

Example 1 with PortDescription

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);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) SwitchPortsDescription(org.openkilda.messaging.info.switches.SwitchPortsDescription) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) DumpPortDescriptionRequest(org.openkilda.messaging.command.switches.DumpPortDescriptionRequest) PortDescription(org.openkilda.messaging.info.switches.PortDescription) SwitchId(org.openkilda.model.SwitchId) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 2 with PortDescription

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);
}
Also used : DumpPortDescriptionRequest(org.openkilda.messaging.command.switches.DumpPortDescriptionRequest) PortDescription(org.openkilda.messaging.info.switches.PortDescription) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

DumpPortDescriptionRequest (org.openkilda.messaging.command.switches.DumpPortDescriptionRequest)2 PortDescription (org.openkilda.messaging.info.switches.PortDescription)2 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 SwitchPortsDescription (org.openkilda.messaging.info.switches.SwitchPortsDescription)1 FlowEndpoint (org.openkilda.model.FlowEndpoint)1 SwitchId (org.openkilda.model.SwitchId)1