Search in sources :

Example 1 with SwitchPortsDescription

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

Example 2 with SwitchPortsDescription

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);
    }
}
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) DumpSwitchPortsDescriptionRequest(org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchId(org.openkilda.model.SwitchId)

Example 3 with SwitchPortsDescription

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

Aggregations

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