Search in sources :

Example 1 with FlowInstallResponse

use of org.openkilda.messaging.info.flow.FlowInstallResponse in project open-kilda by telstra.

the class SwitchManagerHub method onWorkerResponse.

@Override
protected void onWorkerResponse(Tuple input) throws PipelineException {
    String key = KeyProvider.getParentKey(input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY));
    Message message = pullValue(input, MessageKafkaTranslator.FIELD_ID_PAYLOAD, Message.class);
    if (message instanceof InfoMessage) {
        InfoData data = ((InfoMessage) message).getData();
        if (data instanceof FlowDumpResponse) {
            validateService.handleFlowEntriesResponse(key, (FlowDumpResponse) data);
        } else if (data instanceof GroupDumpResponse) {
            validateService.handleGroupEntriesResponse(key, (GroupDumpResponse) data);
        } else if (data instanceof DumpLogicalPortsResponse) {
            validateService.handleLogicalPortResponse(key, (DumpLogicalPortsResponse) data);
        } else if (data instanceof MeterDumpResponse) {
            validateService.handleMeterEntriesResponse(key, (MeterDumpResponse) data);
        } else if (data instanceof SwitchMeterData) {
            handleMetersResponse(key, (SwitchMeterData) data);
        } else if (data instanceof FlowInstallResponse) {
            syncService.handleInstallRulesResponse(key);
        } else if (data instanceof FlowRemoveResponse) {
            syncService.handleRemoveRulesResponse(key);
        } else if (data instanceof FlowReinstallResponse) {
            syncService.handleReinstallDefaultRulesResponse(key, (FlowReinstallResponse) data);
        } else if (data instanceof DeleteMeterResponse) {
            syncService.handleRemoveMetersResponse(key);
        } else if (data instanceof ModifyMeterResponse) {
            syncService.handleModifyMetersResponse(key);
        } else if (data instanceof InstallGroupResponse) {
            syncService.handleInstallGroupResponse(key);
        } else if (data instanceof ModifyGroupResponse) {
            syncService.handleModifyGroupResponse(key);
        } else if (data instanceof DeleteGroupResponse) {
            syncService.handleDeleteGroupResponse(key);
        } else if (data instanceof SwitchRulesResponse) {
            switchRuleService.rulesResponse(key, (SwitchRulesResponse) data);
        } else if (data instanceof CreateLogicalPortResponse) {
            createLagPortService.handleGrpcResponse(key, (CreateLogicalPortResponse) data);
            syncService.handleCreateLogicalPortResponse(key);
        } else if (data instanceof DeleteLogicalPortResponse) {
            deleteLagPortService.handleGrpcResponse(key, (DeleteLogicalPortResponse) data);
            syncService.handleDeleteLogicalPortResponse(key);
        } else {
            log.warn("Receive unexpected InfoData for key {}: {}", key, data);
        }
    } else if (message instanceof ErrorMessage) {
        log.warn("Receive ErrorMessage for key {}", key);
        validateService.handleTaskError(key, (ErrorMessage) message);
        syncService.handleTaskError(key, (ErrorMessage) message);
        createLagPortService.handleTaskError(key, (ErrorMessage) message);
        deleteLagPortService.handleTaskError(key, (ErrorMessage) message);
    }
}
Also used : DumpLogicalPortsResponse(org.openkilda.messaging.info.grpc.DumpLogicalPortsResponse) SwitchMeterData(org.openkilda.messaging.info.meter.SwitchMeterData) FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) FlowReinstallResponse(org.openkilda.messaging.info.flow.FlowReinstallResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) Message(org.openkilda.messaging.Message) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ModifyMeterResponse(org.openkilda.messaging.info.switches.ModifyMeterResponse) DeleteMeterResponse(org.openkilda.messaging.info.switches.DeleteMeterResponse) FlowInstallResponse(org.openkilda.messaging.info.flow.FlowInstallResponse) DeleteLogicalPortResponse(org.openkilda.messaging.info.grpc.DeleteLogicalPortResponse) FlowRemoveResponse(org.openkilda.messaging.info.flow.FlowRemoveResponse) CreateLogicalPortResponse(org.openkilda.messaging.info.grpc.CreateLogicalPortResponse) DeleteGroupResponse(org.openkilda.messaging.info.switches.DeleteGroupResponse) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) InstallGroupResponse(org.openkilda.messaging.info.switches.InstallGroupResponse) SwitchRulesResponse(org.openkilda.messaging.info.switches.SwitchRulesResponse) MeterDumpResponse(org.openkilda.messaging.info.meter.MeterDumpResponse) ModifyGroupResponse(org.openkilda.messaging.info.switches.ModifyGroupResponse) ErrorMessage(org.openkilda.messaging.error.ErrorMessage)

Example 2 with FlowInstallResponse

use of org.openkilda.messaging.info.flow.FlowInstallResponse 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);
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) FlowSegmentWrapperCommand(org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) FlowInstallResponse(org.openkilda.messaging.info.flow.FlowInstallResponse) FlowSegmentResponseFactory(org.openkilda.floodlight.command.flow.FlowSegmentResponseFactory) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowCommandException(org.openkilda.floodlight.error.FlowCommandException) MessageContext(org.openkilda.messaging.MessageContext) FlowSegmentSyncResponseFactory(org.openkilda.floodlight.command.flow.FlowSegmentSyncResponseFactory) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) ErrorData(org.openkilda.messaging.error.ErrorData)

Aggregations

ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 FlowInstallResponse (org.openkilda.messaging.info.flow.FlowInstallResponse)2 FlowSegmentResponseFactory (org.openkilda.floodlight.command.flow.FlowSegmentResponseFactory)1 FlowSegmentSyncResponseFactory (org.openkilda.floodlight.command.flow.FlowSegmentSyncResponseFactory)1 FlowSegmentWrapperCommand (org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand)1 FlowCommandException (org.openkilda.floodlight.error.FlowCommandException)1 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 Message (org.openkilda.messaging.Message)1 MessageContext (org.openkilda.messaging.MessageContext)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 InstallFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)1 ErrorData (org.openkilda.messaging.error.ErrorData)1 FlowCommandErrorData (org.openkilda.messaging.error.rule.FlowCommandErrorData)1 InfoData (org.openkilda.messaging.info.InfoData)1 FlowDumpResponse (org.openkilda.messaging.info.flow.FlowDumpResponse)1 FlowReinstallResponse (org.openkilda.messaging.info.flow.FlowReinstallResponse)1 FlowRemoveResponse (org.openkilda.messaging.info.flow.FlowRemoveResponse)1 GroupDumpResponse (org.openkilda.messaging.info.group.GroupDumpResponse)1