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);
}
}
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);
}
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);
}
}
Aggregations