Search in sources :

Example 1 with ConnectModeRequest

use of org.openkilda.messaging.command.switches.ConnectModeRequest in project open-kilda by telstra.

the class RecordHandler method doConnectMode.

private void doConnectMode(ConnectModeRequest request, String correlationId) {
    if (request.getMode() != null) {
        logger.debug("Setting CONNECT MODE to '{}'", request.getMode());
    } else {
        logger.debug("Getting CONNECT MODE");
    }
    ISwitchManager switchManager = context.getSwitchManager();
    ConnectModeRequest.Mode result = switchManager.connectMode(request.getMode());
    logger.info("CONNECT MODE is now '{}'", result);
    ConnectModeResponse response = new ConnectModeResponse(result);
    InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), correlationId);
    getKafkaProducer().sendMessageAndTrack(context.getKafkaNorthboundTopic(), infoMessage);
}
Also used : ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) InfoMessage(org.openkilda.messaging.info.InfoMessage) ConnectModeResponse(org.openkilda.messaging.info.switches.ConnectModeResponse)

Example 2 with ConnectModeRequest

use of org.openkilda.messaging.command.switches.ConnectModeRequest in project open-kilda by telstra.

the class RecordHandler method doConnectMode.

private void doConnectMode(final CommandMessage message, String replyToTopic, Destination replyDestination) {
    ConnectModeRequest request = (ConnectModeRequest) message.getData();
    if (request.getMode() != null)
        logger.debug("Setting CONNECT MODE to '{}'", request.getMode());
    else
        logger.debug("Getting CONNECT MODE");
    ISwitchManager switchManager = context.getSwitchManager();
    ConnectModeRequest.Mode result = switchManager.connectMode(request.getMode());
    logger.debug("CONNECT MODE is now '{}'", result);
    ConnectModeResponse response = new ConnectModeResponse(result);
    InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), message.getCorrelationId(), replyDestination);
    context.getKafkaProducer().postMessage(replyToTopic, infoMessage);
}
Also used : ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) InfoMessage(org.openkilda.messaging.info.InfoMessage) ConnectModeResponse(org.openkilda.messaging.info.switches.ConnectModeResponse)

Example 3 with ConnectModeRequest

use of org.openkilda.messaging.command.switches.ConnectModeRequest in project open-kilda by telstra.

the class SwitchServiceImpl method connectMode.

@Override
public ConnectModeRequest.Mode connectMode(ConnectModeRequest.Mode mode, String correlationId) {
    LOGGER.debug("Set/Get switch connect mode request received: mode = {}", mode);
    ConnectModeRequest data = new ConnectModeRequest(mode);
    CommandMessage request = new CommandWithReplyToMessage(data, System.currentTimeMillis(), correlationId, Destination.CONTROLLER, northboundTopic);
    messageProducer.send(floodlightTopic, request);
    Message message = messageConsumer.poll(correlationId);
    ConnectModeResponse response = (ConnectModeResponse) validateInfoMessage(request, message, correlationId);
    return response.getMode();
}
Also used : ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) ConnectModeResponse(org.openkilda.messaging.info.switches.ConnectModeResponse)

Example 4 with ConnectModeRequest

use of org.openkilda.messaging.command.switches.ConnectModeRequest in project open-kilda by telstra.

the class SwitchServiceImpl method connectMode.

/**
 * {@inheritDoc}
 */
@Override
public CompletableFuture<ConnectModeRequest.Mode> connectMode(ConnectModeRequest.Mode mode) {
    final String correlationId = RequestCorrelationId.getId();
    logger.debug("Set/Get switch connect mode request received: mode = {}", mode);
    ConnectModeRequest data = new ConnectModeRequest(mode);
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGet(floodlightTopic, request).thenApply(ConnectModeResponse.class::cast).thenApply(ConnectModeResponse::getMode);
}
Also used : ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage) ConnectModeResponse(org.openkilda.messaging.info.switches.ConnectModeResponse)

Aggregations

ConnectModeRequest (org.openkilda.messaging.command.switches.ConnectModeRequest)4 ConnectModeResponse (org.openkilda.messaging.info.switches.ConnectModeResponse)4 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 Message (org.openkilda.messaging.Message)1 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)1