Search in sources :

Example 1 with FlowDumpResponse

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

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

the class SwitchValidateServiceImplTest method doNothingWhenFsmNotFound.

@Test
public void doNothingWhenFsmNotFound() {
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    verifyZeroInteractions(carrier);
    verifyZeroInteractions(validationService);
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) Test(org.junit.Test)

Example 3 with FlowDumpResponse

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

the class SwitchValidateServiceImplTest method receiveOnlyRules.

@Test
public void receiveOnlyRules() {
    handleRequestAndInitDataReceive();
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(validationService);
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) Test(org.junit.Test)

Example 4 with FlowDumpResponse

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

the class SwitchValidateServiceImplTest method receiveTaskError.

@Test
public void receiveTaskError() {
    handleRequestAndInitDataReceive();
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    ErrorMessage errorMessage = getErrorMessage();
    service.handleTaskError(KEY, errorMessage);
    verify(carrier).cancelTimeoutCallback(eq(KEY));
    verify(carrier).errorResponse(eq(KEY), eq(errorMessage.getData().getErrorType()), any(String.class), any(String.class));
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(validationService);
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) Test(org.junit.Test)

Example 5 with FlowDumpResponse

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

the class SwitchValidateServiceImplTest method handleDataReceiveAndValidate.

private void handleDataReceiveAndValidate() {
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    service.handleMeterEntriesResponse(KEY, new MeterDumpResponse(SWITCH_ID, singletonList(meterSpeakerData)));
    service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
    verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
    verify(validationService).validateMeters(eq(SWITCH_ID), any(), any());
    verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) MeterDumpResponse(org.openkilda.messaging.info.meter.MeterDumpResponse)

Aggregations

FlowDumpResponse (org.openkilda.messaging.info.flow.FlowDumpResponse)9 Test (org.junit.Test)6 GroupDumpResponse (org.openkilda.messaging.info.group.GroupDumpResponse)5 InfoMessage (org.openkilda.messaging.info.InfoMessage)4 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)3 MeterDumpResponse (org.openkilda.messaging.info.meter.MeterDumpResponse)3 CommandData (org.openkilda.messaging.command.CommandData)2 SwitchValidationResponse (org.openkilda.messaging.info.switches.SwitchValidationResponse)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1