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