Search in sources :

Example 1 with FlowReinstallResponse

use of org.openkilda.messaging.info.flow.FlowReinstallResponse 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 FlowReinstallResponse

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

the class SwitchSyncFsm method misconfiguredRuleReinstalled.

protected void misconfiguredRuleReinstalled(SwitchSyncState from, SwitchSyncState to, SwitchSyncEvent event, Object context) {
    log.info("Default switch rule reinstalled (switch={}, key={})", switchId, key);
    FlowReinstallResponse response = (FlowReinstallResponse) context;
    Long removedRule = response.getRemovedRule();
    if (removedRule != null && !removedDefaultRulesCookies.contains(removedRule)) {
        removedDefaultRulesCookies.add(removedRule);
    }
    Long installedRule = response.getInstalledRule();
    if (installedRule != null && !installedRulesCookies.contains(installedRule)) {
        installedRulesCookies.add(installedRule);
    }
    reinstallDefaultRulesPendingResponsesCount--;
    continueIfRulesSynchronized();
}
Also used : FlowReinstallResponse(org.openkilda.messaging.info.flow.FlowReinstallResponse)

Example 3 with FlowReinstallResponse

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

the class RecordHandler method doReinstallDefaultFlowForSwitchManager.

/**
 * Reinstall default flow.
 *
 * @param message command message for flow deletion
 */
private void doReinstallDefaultFlowForSwitchManager(CommandMessage message) {
    ReinstallDefaultFlowForSwitchManagerRequest request = (ReinstallDefaultFlowForSwitchManagerRequest) message.getData();
    IKafkaProducerService producerService = getKafkaProducer();
    String replyToTopic = context.getKafkaSwitchManagerTopic();
    long cookie = request.getCookie();
    if (!Cookie.isDefaultRule(cookie)) {
        logger.warn("Failed to reinstall default switch rule for switch: '{}'. Rule {} is not default.", request.getSwitchId(), Long.toHexString(cookie));
        anError(ErrorType.DATA_INVALID).withMessage(format("Failed to reinstall default switch rule for switch %s. Rule %s is not default", request.getSwitchId(), Long.toHexString(cookie))).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
    }
    SwitchId switchId = request.getSwitchId();
    DatapathId dpid = DatapathId.of(switchId.toLong());
    try {
        RemoveFlow command = RemoveFlow.builder().flowId("REMOVE_DEFAULT_FLOW").cookie(cookie).switchId(switchId).build();
        Set<Long> removedFlows = new HashSet<>(processDeleteFlow(command, dpid));
        for (Long removedFlow : removedFlows) {
            Long installedFlow;
            if (request instanceof ReinstallServer42FlowForSwitchManagerRequest) {
                installedFlow = processInstallServer42Rule((ReinstallServer42FlowForSwitchManagerRequest) request);
            } else {
                installedFlow = processInstallDefaultFlowByCookie(switchId, removedFlow);
            }
            InfoMessage response = new InfoMessage(new FlowReinstallResponse(removedFlow, installedFlow), System.currentTimeMillis(), message.getCorrelationId());
            producerService.sendMessageAndTrack(replyToTopic, message.getCorrelationId(), response);
        }
    } catch (SwitchOperationException e) {
        logger.error("Failed to reinstall switch rule for switch: '{}'", request.getSwitchId(), e);
        anError(ErrorType.INTERNAL_ERROR).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).sendVia(producerService);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) FlowReinstallResponse(org.openkilda.messaging.info.flow.FlowReinstallResponse) SwitchId(org.openkilda.model.SwitchId) DatapathId(org.projectfloodlight.openflow.types.DatapathId) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) InfoMessage(org.openkilda.messaging.info.InfoMessage) ReinstallServer42FlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallServer42FlowForSwitchManagerRequest) HashSet(java.util.HashSet)

Aggregations

FlowReinstallResponse (org.openkilda.messaging.info.flow.FlowReinstallResponse)3 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 HashSet (java.util.HashSet)1 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)1 Message (org.openkilda.messaging.Message)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 ReinstallDefaultFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest)1 ReinstallServer42FlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallServer42FlowForSwitchManagerRequest)1 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 InfoData (org.openkilda.messaging.info.InfoData)1 FlowDumpResponse (org.openkilda.messaging.info.flow.FlowDumpResponse)1 FlowInstallResponse (org.openkilda.messaging.info.flow.FlowInstallResponse)1 FlowRemoveResponse (org.openkilda.messaging.info.flow.FlowRemoveResponse)1 GroupDumpResponse (org.openkilda.messaging.info.group.GroupDumpResponse)1 CreateLogicalPortResponse (org.openkilda.messaging.info.grpc.CreateLogicalPortResponse)1 DeleteLogicalPortResponse (org.openkilda.messaging.info.grpc.DeleteLogicalPortResponse)1 DumpLogicalPortsResponse (org.openkilda.messaging.info.grpc.DumpLogicalPortsResponse)1