use of org.openkilda.floodlight.error.FlowCommandException in project open-kilda by telstra.
the class RecordHandler method installSharedFlow.
private void installSharedFlow(InstallSharedFlow command) throws SwitchOperationException, FlowCommandException {
FlowSharedSegmentCookie cookie = new FlowSharedSegmentCookie(command.getCookie());
SharedSegmentType segmentType = cookie.getSegmentType();
if (segmentType == SharedSegmentType.QINQ_OUTER_VLAN) {
context.getSwitchManager().installOuterVlanMatchSharedFlow(command.getSwitchId(), command.getId(), cookie);
} else {
throw new FlowCommandException(command.getId(), command.getCookie(), command.getTransactionId(), ErrorType.REQUEST_INVALID, format("Unsupported shared segment type %s (cookie: %s)", segmentType, cookie));
}
}
use of org.openkilda.floodlight.error.FlowCommandException in project open-kilda by telstra.
the class RecordHandler method doInstallFlowForSwitchManager.
/**
* Install of flow on the switch from SwitchManager topology.
*
* @param message with list of flows.
*/
private void doInstallFlowForSwitchManager(final CommandMessage message) {
InstallFlowForSwitchManagerRequest request = (InstallFlowForSwitchManagerRequest) message.getData();
String replyToTopic = context.getKafkaSwitchManagerTopic();
FlowSegmentResponseFactory responseFactory = new FlowSegmentSyncResponseFactory(message.getCorrelationId(), replyToTopic);
MessageContext messageContext = new MessageContext(message);
Optional<FlowSegmentWrapperCommand> syncCommand = makeSyncCommand(request.getFlowCommand(), messageContext, responseFactory);
if (syncCommand.isPresent()) {
handleSpeakerCommand(syncCommand.get());
return;
}
try {
installFlow(request.getFlowCommand());
} catch (SwitchOperationException e) {
logger.error("Error during flow installation", e);
ErrorData errorData = new ErrorData(ErrorType.INTERNAL_ERROR, "Error during flow installation", "Switch operation error");
ErrorMessage error = new ErrorMessage(errorData, System.currentTimeMillis(), message.getCorrelationId());
getKafkaProducer().sendMessageAndTrack(replyToTopic, message.getCorrelationId(), error);
} catch (FlowCommandException e) {
String errorMessage = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
logger.error("Failed to handle message {}: {}", message, errorMessage);
ErrorData errorData = new FlowCommandErrorData(e.getFlowId(), e.getCookie(), e.getTransactionId(), e.getErrorType(), errorMessage, e.getMessage());
ErrorMessage error = new ErrorMessage(errorData, System.currentTimeMillis(), message.getCorrelationId());
getKafkaProducer().sendMessageAndTrack(replyToTopic, message.getCorrelationId(), error);
}
InfoMessage response = new InfoMessage(new FlowInstallResponse(), System.currentTimeMillis(), message.getCorrelationId());
getKafkaProducer().sendMessageAndTrack(replyToTopic, message.getCorrelationId(), response);
}
Aggregations