use of org.openkilda.messaging.command.CommandWithReplyToMessage in project open-kilda by telstra.
the class RecordHandler method doControllerMsg.
protected void doControllerMsg(CommandMessage message) {
// Define the destination topic where the reply will be sent to.
final String replyToTopic;
if (message instanceof CommandWithReplyToMessage) {
replyToTopic = ((CommandWithReplyToMessage) message).getReplyTo();
} else {
replyToTopic = OUTPUT_FLOW_TOPIC;
}
final Destination replyDestination = getDestinationForTopic(replyToTopic);
try {
CommandData data = message.getData();
handleCommand(message, data, replyToTopic, replyDestination);
} catch (FlowCommandException e) {
ErrorMessage error = new ErrorMessage(e.makeErrorResponse(), System.currentTimeMillis(), message.getCorrelationId(), replyDestination);
context.getKafkaProducer().postMessage(replyToTopic, error);
} catch (Exception e) {
logger.error("Unhandled exception: {}", e);
}
}
use of org.openkilda.messaging.command.CommandWithReplyToMessage in project open-kilda by telstra.
the class SwitchServiceImpl method syncRules.
@Override
public SyncRulesOutput syncRules(String switchId, String correlationId) {
SyncRulesRequest request = new SyncRulesRequest(switchId);
CommandWithReplyToMessage commandMessage = new CommandWithReplyToMessage(request, System.currentTimeMillis(), correlationId, Destination.TOPOLOGY_ENGINE, northboundTopic);
messageProducer.send(topoEngTopic, commandMessage);
Message message = messageConsumer.poll(correlationId);
SyncRulesResponse response = (SyncRulesResponse) validateInfoMessage(commandMessage, message, correlationId);
return switchMapper.toSuncRulesOutput(response);
}
use of org.openkilda.messaging.command.CommandWithReplyToMessage in project open-kilda by telstra.
the class SwitchServiceImpl method installRules.
@Override
public List<Long> installRules(String switchId, InstallRulesAction installAction, String correlationId) {
LOGGER.debug("Install switch rules request received");
SwitchRulesInstallRequest data = new SwitchRulesInstallRequest(switchId, installAction);
CommandMessage request = new CommandWithReplyToMessage(data, System.currentTimeMillis(), correlationId, Destination.CONTROLLER, northboundTopic);
messageProducer.send(floodlightTopic, request);
Message message = messageConsumer.poll(correlationId);
SwitchRulesResponse response = (SwitchRulesResponse) validateInfoMessage(request, message, correlationId);
return response.getRuleIds();
}
use of org.openkilda.messaging.command.CommandWithReplyToMessage in project open-kilda by telstra.
the class SwitchServiceImpl method deleteRules.
@Override
public List<Long> deleteRules(String switchId, DeleteRulesAction deleteAction, Long cookie, String correlationId) {
LOGGER.debug("Delete switch rules request received");
// TODO: remove messageConsumer.clear() as a part of NB cleanup (clear isn't required)
messageConsumer.clear();
SwitchRulesDeleteRequest data = new SwitchRulesDeleteRequest(switchId, deleteAction, cookie);
CommandMessage request = new CommandWithReplyToMessage(data, System.currentTimeMillis(), correlationId, Destination.CONTROLLER, northboundTopic);
messageProducer.send(floodlightTopic, request);
Message message = messageConsumer.poll(correlationId);
SwitchRulesResponse response = (SwitchRulesResponse) validateInfoMessage(request, message, correlationId);
return response.getRuleIds();
}
use of org.openkilda.messaging.command.CommandWithReplyToMessage 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();
}
Aggregations