Search in sources :

Example 1 with GroupDumpResponse

use of org.openkilda.messaging.info.group.GroupDumpResponse 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 GroupDumpResponse

use of org.openkilda.messaging.info.group.GroupDumpResponse 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)

Example 3 with GroupDumpResponse

use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.

the class SwitchValidateServiceImplTest method validationSuccessWithUnsupportedMeters.

@Test
public void validationSuccessWithUnsupportedMeters() {
    handleRequestAndInitDataReceive();
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    service.handleMetersUnsupportedResponse(KEY);
    service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
    verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
    verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
    verify(carrier).cancelTimeoutCallback(eq(KEY));
    ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
    verify(carrier).response(eq(KEY), responseCaptor.capture());
    SwitchValidationResponse response = (SwitchValidationResponse) responseCaptor.getValue().getData();
    assertEquals(singletonList(flowSpeakerData.getCookie().getValue()), response.getRules().getMissing());
    assertNull(response.getMeters());
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(validationService);
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchValidationResponse(org.openkilda.messaging.info.switches.SwitchValidationResponse) Test(org.junit.Test)

Example 4 with GroupDumpResponse

use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.

the class SwitchValidateServiceImplTest method validationWithoutMetersSuccess.

@Test
public void validationWithoutMetersSuccess() {
    request = SwitchValidateRequest.builder().switchId(SWITCH_ID).build();
    service.handleSwitchValidateRequest(KEY, request);
    verify(carrier, times(2)).sendCommandToSpeaker(eq(KEY), any(CommandData.class));
    service.handleFlowEntriesResponse(KEY, new FlowDumpResponse(SWITCH_ID, singletonList(flowSpeakerData)));
    service.handleGroupEntriesResponse(KEY, new GroupDumpResponse(SWITCH_ID, emptyList()));
    verify(validationService).validateRules(eq(SWITCH_ID), any(), any());
    verify(validationService).validateGroups(eq(SWITCH_ID), any(), any());
    verify(carrier).cancelTimeoutCallback(eq(KEY));
    ArgumentCaptor<InfoMessage> responseCaptor = ArgumentCaptor.forClass(InfoMessage.class);
    verify(carrier).response(eq(KEY), responseCaptor.capture());
    SwitchValidationResponse response = (SwitchValidationResponse) responseCaptor.getValue().getData();
    assertEquals(singletonList(flowSpeakerData.getCookie().getValue()), response.getRules().getMissing());
    assertNull(response.getMeters());
    verifyNoMoreInteractions(carrier);
    verifyNoMoreInteractions(validationService);
}
Also used : FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandData(org.openkilda.messaging.command.CommandData) SwitchValidationResponse(org.openkilda.messaging.info.switches.SwitchValidationResponse) Test(org.junit.Test)

Example 5 with GroupDumpResponse

use of org.openkilda.messaging.info.group.GroupDumpResponse in project open-kilda by telstra.

the class RecordHandler method dumpRuleMangerGroupsRequest.

private void dumpRuleMangerGroupsRequest(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
    try {
        logger.debug("Loading installed groups for switch {}", switchId);
        List<OFGroupDescStatsEntry> ofGroupDescStatsEntries = context.getSwitchManager().dumpGroups(DatapathId.of(switchId.toLong()));
        List<GroupSpeakerData> groups = ofGroupDescStatsEntries.stream().map(OfGroupConverter.INSTANCE::convertToGroupSpeakerData).collect(Collectors.toList());
        GroupDumpResponse response = GroupDumpResponse.builder().switchId(switchId).groupSpeakerData(groups).build();
        sender.accept(response);
    } catch (SwitchOperationException e) {
        logger.error("Dumping of groups on switch '{}' was unsuccessful: {}", switchId, e.getMessage());
        ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("The switch was not found when requesting a groups dump.").buildData();
        sender.accept(errorData);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) OfGroupConverter(org.openkilda.floodlight.converter.rulemanager.OfGroupConverter) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) ErrorData(org.openkilda.messaging.error.ErrorData)

Aggregations

GroupDumpResponse (org.openkilda.messaging.info.group.GroupDumpResponse)5 FlowDumpResponse (org.openkilda.messaging.info.flow.FlowDumpResponse)4 InfoMessage (org.openkilda.messaging.info.InfoMessage)3 Test (org.junit.Test)2 MeterDumpResponse (org.openkilda.messaging.info.meter.MeterDumpResponse)2 SwitchValidationResponse (org.openkilda.messaging.info.switches.SwitchValidationResponse)2 OfGroupConverter (org.openkilda.floodlight.converter.rulemanager.OfGroupConverter)1 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 Message (org.openkilda.messaging.Message)1 CommandData (org.openkilda.messaging.command.CommandData)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 ErrorData (org.openkilda.messaging.error.ErrorData)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 FlowCommandErrorData (org.openkilda.messaging.error.rule.FlowCommandErrorData)1 InfoData (org.openkilda.messaging.info.InfoData)1 FlowInstallResponse (org.openkilda.messaging.info.flow.FlowInstallResponse)1 FlowReinstallResponse (org.openkilda.messaging.info.flow.FlowReinstallResponse)1 FlowRemoveResponse (org.openkilda.messaging.info.flow.FlowRemoveResponse)1 CreateLogicalPortResponse (org.openkilda.messaging.info.grpc.CreateLogicalPortResponse)1