Search in sources :

Example 11 with SwitchMeterEntries

use of org.openkilda.messaging.info.meter.SwitchMeterEntries in project open-kilda by telstra.

the class FlowMeterModifyFsm method responseReceived.

protected void responseReceived(FlowMeterModifyState from, FlowMeterModifyState to, FlowMeterModifyEvent event, Object context) {
    SwitchMeterEntries switchMeterEntries = (SwitchMeterEntries) context;
    switchMeterEntriesList.add(switchMeterEntries);
    log.info("Key: {}; Switch meters received for switch {}", key, switchMeterEntries.getSwitchId());
    if (--awaitingRequests == 0) {
        fire(NEXT);
    }
}
Also used : SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries)

Example 12 with SwitchMeterEntries

use of org.openkilda.messaging.info.meter.SwitchMeterEntries in project open-kilda by telstra.

the class FlowMeterModifyHubService method handleAsyncResponse.

/**
 * Handle response from speaker worker.
 */
public void handleAsyncResponse(String key, Message message) {
    FlowMeterModifyFsm fsm = fsms.get(key);
    if (message instanceof InfoMessage) {
        InfoData data = ((InfoMessage) message).getData();
        if (data instanceof SwitchMeterEntries) {
            fsm.fire(FlowMeterModifyEvent.RESPONSE_RECEIVED, data);
        } else {
            log.warn("Key: {}; Unhandled message {}", key, message);
        }
    } else if (message instanceof ErrorMessage) {
        fsm.fire(FlowMeterModifyEvent.ERROR, message);
    }
    process(fsm);
}
Also used : FlowMeterModifyFsm(org.openkilda.wfm.topology.nbworker.fsm.FlowMeterModifyFsm) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) ErrorMessage(org.openkilda.messaging.error.ErrorMessage)

Example 13 with SwitchMeterEntries

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

Aggregations

SwitchMeterEntries (org.openkilda.messaging.info.meter.SwitchMeterEntries)13 SwitchFlowEntries (org.openkilda.messaging.info.rule.SwitchFlowEntries)6 SwitchId (org.openkilda.model.SwitchId)5 List (java.util.List)4 SwitchMeterUnsupported (org.openkilda.messaging.info.meter.SwitchMeterUnsupported)4 SwitchGroupEntries (org.openkilda.messaging.info.rule.SwitchGroupEntries)4 ArrayList (java.util.ArrayList)3 ErrorData (org.openkilda.messaging.error.ErrorData)3 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)3 InfoData (org.openkilda.messaging.info.InfoData)3 FlowNotFoundException (org.openkilda.wfm.error.FlowNotFoundException)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)2 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)2 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)2 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)2 Message (org.openkilda.messaging.Message)2 CommandData (org.openkilda.messaging.command.CommandData)2 FlowValidationRequest (org.openkilda.messaging.command.flow.FlowValidationRequest)2