Search in sources :

Example 6 with DumpMetersForFlowHsRequest

use of org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest in project open-kilda by telstra.

the class DumpYFlowResourcesAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowValidationContext context, YFlowValidationFsm stateMachine) {
    String yFlowId = stateMachine.getYFlowId();
    YFlow yFlow = yFlowRepository.findById(yFlowId).orElseThrow(() -> new FlowProcessingException(ErrorType.NOT_FOUND, format("Y-flow %s not found", yFlowId)));
    log.debug("Start validating y-flow {} resources", yFlowId);
    List<SwitchId> switchIds = Stream.of(yFlow.getSharedEndpoint().getSwitchId(), yFlow.getYPoint(), yFlow.getProtectedPathYPoint()).filter(Objects::nonNull).collect(Collectors.toList());
    int switchCount = switchIds.size();
    stateMachine.setAwaitingRules(switchCount);
    stateMachine.setAwaitingMeters(switchCount);
    log.debug("Send commands to get rules & meters on {} switches", switchCount);
    YFlowValidationHubCarrier carrier = stateMachine.getCarrier();
    switchIds.forEach(switchId -> {
        carrier.sendSpeakerRequest(yFlowId, new DumpRulesForFlowHsRequest(switchId));
        carrier.sendSpeakerRequest(yFlowId, new DumpMetersForFlowHsRequest(switchId));
    });
}
Also used : YFlow(org.openkilda.model.YFlow) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) YFlowValidationHubCarrier(org.openkilda.wfm.topology.flowhs.service.yflow.YFlowValidationHubCarrier) SwitchId(org.openkilda.model.SwitchId)

Example 7 with DumpMetersForFlowHsRequest

use of org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest in project open-kilda by telstra.

the class FlowValidationHubServiceTest method testTimeout.

@Test
public void testTimeout() throws DuplicateKeyException, UnknownKeyException {
    FlowValidationHubCarrier carrier = new FlowValidationHubCarrier() {

        @Override
        public void sendSpeakerRequest(String flowId, CommandData commandData) {
            assertTrue(commandData instanceof DumpRulesForFlowHsRequest || commandData instanceof DumpMetersForFlowHsRequest || commandData instanceof DumpGroupsForFlowHsRequest);
            List<SwitchId> switchIds = Lists.newArrayList(TEST_SWITCH_ID_A, TEST_SWITCH_ID_B, TEST_SWITCH_ID_C, TEST_SWITCH_ID_E);
            if (commandData instanceof DumpRulesForFlowHsRequest) {
                assertTrue(switchIds.contains(((DumpRulesForFlowHsRequest) commandData).getSwitchId()));
            } else if (commandData instanceof DumpMetersForFlowHsRequest) {
                assertTrue(switchIds.contains(((DumpMetersForFlowHsRequest) commandData).getSwitchId()));
            } else {
                assertTrue(switchIds.contains(((DumpGroupsForFlowHsRequest) commandData).getSwitchId()));
            }
        }

        @Override
        public void sendNorthboundResponse(List<? extends InfoData> message) {
            fail();
        }

        @Override
        public void sendNorthboundResponse(Message message) {
            assertEquals(ErrorType.OPERATION_TIMED_OUT, ((ErrorMessage) message).getData().getErrorType());
        }

        @Override
        public void cancelTimeoutCallback(String key) {
            assertEquals(TEST_KEY, key);
        }

        @Override
        public void sendInactive() {
        }
    };
    flowValidationHubService = new FlowValidationHubService(carrier, persistenceManager, flowResourcesManager, MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT);
    buildTransitVlanFlow("");
    flowValidationHubService.handleFlowValidationRequest(TEST_KEY, new CommandContext(), new FlowValidationRequest(TEST_FLOW_ID_A));
    flowValidationHubService.handleTimeout(TEST_KEY);
}
Also used : DumpGroupsForFlowHsRequest(org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest) Message(org.openkilda.messaging.Message) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandContext(org.openkilda.wfm.CommandContext) SwitchId(org.openkilda.model.SwitchId) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) FlowValidationRequest(org.openkilda.messaging.command.flow.FlowValidationRequest) InfoData(org.openkilda.messaging.info.InfoData) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) List(java.util.List) CommandData(org.openkilda.messaging.command.CommandData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) Test(org.junit.Test)

Example 8 with DumpMetersForFlowHsRequest

use of org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest in project open-kilda by telstra.

the class FlowValidationHubServiceTest method testFlowNotFoundError.

@Test
public void testFlowNotFoundError() throws DuplicateKeyException, UnknownKeyException {
    FlowValidationHubCarrier carrier = new FlowValidationHubCarrier() {

        @Override
        public void sendSpeakerRequest(String flowId, CommandData commandData) {
            assertTrue(commandData instanceof DumpRulesForFlowHsRequest || commandData instanceof DumpMetersForFlowHsRequest || commandData instanceof DumpGroupsForFlowHsRequest);
            List<SwitchId> switchIds = Lists.newArrayList(TEST_SWITCH_ID_A, TEST_SWITCH_ID_B, TEST_SWITCH_ID_C, TEST_SWITCH_ID_E);
            if (commandData instanceof DumpRulesForFlowHsRequest) {
                assertTrue(switchIds.contains(((DumpRulesForFlowHsRequest) commandData).getSwitchId()));
            } else if (commandData instanceof DumpMetersForFlowHsRequest) {
                assertTrue(switchIds.contains(((DumpMetersForFlowHsRequest) commandData).getSwitchId()));
            } else {
                assertTrue(switchIds.contains(((DumpGroupsForFlowHsRequest) commandData).getSwitchId()));
            }
        }

        @Override
        public void sendNorthboundResponse(List<? extends InfoData> message) {
            fail();
        }

        @Override
        public void sendNorthboundResponse(Message message) {
            assertEquals(ErrorType.NOT_FOUND, ((ErrorMessage) message).getData().getErrorType());
        }

        @Override
        public void cancelTimeoutCallback(String key) {
            assertEquals(TEST_KEY, key);
        }

        @Override
        public void sendInactive() {
        }
    };
    flowValidationHubService = new FlowValidationHubService(carrier, persistenceManager, flowResourcesManager, MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT);
    buildTransitVlanFlow("");
    flowValidationHubService.handleFlowValidationRequest(TEST_KEY, new CommandContext(), new FlowValidationRequest("test"));
    flowValidationHubService.handleFlowValidationRequest(TEST_KEY, new CommandContext(), new FlowValidationRequest(TEST_FLOW_ID_A));
    transactionManager.doInTransaction(() -> flowRepository.remove(flowRepository.findById(TEST_FLOW_ID_A).get()));
    for (SwitchFlowEntries switchFlowEntries : getSwitchFlowEntriesWithTransitVlan()) {
        flowValidationHubService.handleAsyncResponse(TEST_KEY, switchFlowEntries);
    }
    for (SwitchMeterEntries switchMeterEntries : getSwitchMeterEntries()) {
        flowValidationHubService.handleAsyncResponse(TEST_KEY, switchMeterEntries);
    }
    for (SwitchGroupEntries switchGroupEntries : getSwitchGroupEntries()) {
        flowValidationHubService.handleAsyncResponse(TEST_KEY, switchGroupEntries);
    }
}
Also used : DumpGroupsForFlowHsRequest(org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest) SwitchFlowEntries(org.openkilda.messaging.info.rule.SwitchFlowEntries) Message(org.openkilda.messaging.Message) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandContext(org.openkilda.wfm.CommandContext) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) SwitchId(org.openkilda.model.SwitchId) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) FlowValidationRequest(org.openkilda.messaging.command.flow.FlowValidationRequest) InfoData(org.openkilda.messaging.info.InfoData) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) SwitchGroupEntries(org.openkilda.messaging.info.rule.SwitchGroupEntries) List(java.util.List) CommandData(org.openkilda.messaging.command.CommandData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) Test(org.junit.Test)

Example 9 with DumpMetersForFlowHsRequest

use of org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest in project open-kilda by telstra.

the class RecordHandler method handleCommand.

@VisibleForTesting
void handleCommand(CommandMessage message) {
    logger.debug("Handling message: '{}'.", message);
    CommandData data = message.getData();
    if (data instanceof DiscoverIslCommandData) {
        doDiscoverIslCommand((DiscoverIslCommandData) data, message.getCorrelationId());
    } else if (data instanceof DiscoverPathCommandData) {
        doDiscoverPathCommand(data);
    } else if (data instanceof RemoveFlowForSwitchManagerRequest) {
        doDeleteFlowForSwitchManager(message);
    } else if (data instanceof ModifyFlowMeterForSwitchManagerRequest) {
        doModifyFlowMeterForSwitchManager(message);
    } else if (data instanceof ModifyDefaultMeterForSwitchManagerRequest) {
        doModifyDefaultMeterForSwitchManager(message);
    } else if (data instanceof ReinstallDefaultFlowForSwitchManagerRequest) {
        doReinstallDefaultFlowForSwitchManager(message);
    } else if (data instanceof NetworkCommandData) {
        doNetworkDump((NetworkCommandData) data);
    } else if (data instanceof SwitchRulesDeleteRequest) {
        doDeleteSwitchRules(message);
    } else if (data instanceof SwitchRulesInstallRequest) {
        doInstallSwitchRules(message);
    } else if (data instanceof DumpRulesForFlowHsRequest) {
        doDumpRulesForFlowHsRequest(message);
    } else if (data instanceof DumpRulesRequest) {
        doDumpRulesRequest(message);
    } else if (data instanceof DumpRulesForSwitchManagerRequest) {
        doDumpRulesForSwitchManagerRequest(message);
    } else if (data instanceof InstallFlowForSwitchManagerRequest) {
        doInstallFlowForSwitchManager(message);
    } else if (data instanceof DeleterMeterForSwitchManagerRequest) {
        doDeleteMeter(message, context.getKafkaSwitchManagerTopic());
    } else if (data instanceof DeleteMeterRequest) {
        doDeleteMeter(message, context.getKafkaNorthboundTopic());
    } else if (data instanceof PortConfigurationRequest) {
        doConfigurePort(message);
    } else if (data instanceof DumpSwitchPortsDescriptionRequest) {
        doDumpSwitchPortsDescriptionRequest(message);
    } else if (data instanceof DumpPortDescriptionRequest) {
        doDumpPortDescriptionRequest(message);
    } else if (data instanceof DumpMetersRequest) {
        doDumpMetersRequest(message);
    } else if (data instanceof DumpMetersForSwitchManagerRequest) {
        doDumpMetersForSwitchManagerRequest(message);
    } else if (data instanceof DumpMetersForFlowHsRequest) {
        doDumpMetersForFlowHsRequest(message);
    } else if (data instanceof MeterModifyCommandRequest) {
        doModifyMeterRequest(message);
    } else if (data instanceof AliveRequest) {
        doAliveRequest(message);
    } else if (data instanceof InstallIslDefaultRulesCommand) {
        doInstallIslDefaultRule(message);
    } else if (data instanceof RemoveIslDefaultRulesCommand) {
        doRemoveIslDefaultRule(message);
    } else if (data instanceof DumpGroupsForSwitchManagerRequest) {
        doDumpGroupsForSwitchManagerRequest(message);
    } else if (data instanceof DumpGroupsForFlowHsRequest) {
        doDumpGroupsForFlowHsRequest(message);
    } else if (data instanceof InstallGroupRequest) {
        doInstallGroupRequest(message);
    } else if (data instanceof ModifyGroupRequest) {
        doModifyGroupRequest(message);
    } else if (data instanceof DeleteGroupRequest) {
        doDeleteGroupRequest(message);
    } else if (data instanceof BroadcastWrapper) {
        handleBroadcastCommand(message, (BroadcastWrapper) data);
    } else {
        handlerNotFound(data);
    }
}
Also used : DumpGroupsForFlowHsRequest(org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest) RemoveFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest) InstallGroupRequest(org.openkilda.messaging.command.switches.InstallGroupRequest) DumpGroupsForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpGroupsForSwitchManagerRequest) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) InstallIslDefaultRulesCommand(org.openkilda.messaging.payload.switches.InstallIslDefaultRulesCommand) DumpMetersRequest(org.openkilda.messaging.command.switches.DumpMetersRequest) BroadcastWrapper(org.openkilda.messaging.command.BroadcastWrapper) DumpMetersForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) DumpRulesRequest(org.openkilda.messaging.command.switches.DumpRulesRequest) ModifyDefaultMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest) DumpRulesForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest) ModifyGroupRequest(org.openkilda.messaging.command.switches.ModifyGroupRequest) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) SwitchRulesInstallRequest(org.openkilda.messaging.command.switches.SwitchRulesInstallRequest) DumpPortDescriptionRequest(org.openkilda.messaging.command.switches.DumpPortDescriptionRequest) RemoveIslDefaultRulesCommand(org.openkilda.messaging.payload.switches.RemoveIslDefaultRulesCommand) ModifyFlowMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyFlowMeterForSwitchManagerRequest) DeleteGroupRequest(org.openkilda.messaging.command.switches.DeleteGroupRequest) PortConfigurationRequest(org.openkilda.messaging.command.switches.PortConfigurationRequest) DeleterMeterForSwitchManagerRequest(org.openkilda.messaging.command.switches.DeleterMeterForSwitchManagerRequest) DumpSwitchPortsDescriptionRequest(org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) MeterModifyCommandRequest(org.openkilda.messaging.command.flow.MeterModifyCommandRequest) SwitchRulesDeleteRequest(org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) PortsCommandData(org.openkilda.messaging.command.discovery.PortsCommandData) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData) CommandData(org.openkilda.messaging.command.CommandData) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) DeleteMeterRequest(org.openkilda.messaging.command.flow.DeleteMeterRequest) AliveRequest(org.openkilda.messaging.AliveRequest) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DumpMetersForFlowHsRequest (org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest)9 DumpRulesForFlowHsRequest (org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest)8 DumpGroupsForFlowHsRequest (org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest)6 SwitchId (org.openkilda.model.SwitchId)6 CommandData (org.openkilda.messaging.command.CommandData)5 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)4 InfoData (org.openkilda.messaging.info.InfoData)4 List (java.util.List)3 Test (org.junit.Test)3 Message (org.openkilda.messaging.Message)3 FlowValidationRequest (org.openkilda.messaging.command.flow.FlowValidationRequest)3 CommandContext (org.openkilda.wfm.CommandContext)3 DeleteMeterRequest (org.openkilda.messaging.command.flow.DeleteMeterRequest)2 InstallFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)2 ReinstallDefaultFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest)2 RemoveFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest)2 DumpMetersForSwitchManagerRequest (org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest)2 DumpMetersRequest (org.openkilda.messaging.command.switches.DumpMetersRequest)2 DumpPortDescriptionRequest (org.openkilda.messaging.command.switches.DumpPortDescriptionRequest)2 DumpRulesForSwitchManagerRequest (org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest)2