use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldNotInjectRetryWhenReceivedFailedRuleInstallResponseOnTerminatingSwitch.
@Test
public void shouldNotInjectRetryWhenReceivedFailedRuleInstallResponseOnTerminatingSwitch() {
FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_B.getSwitchId()))).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
assertNull(rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
}
use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldComputeIgnoreBandwidthFlag.
@Test
public void shouldComputeIgnoreBandwidthFlag() {
FlowThrottlingData data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(true).strictBandwidth(false).build();
assertTrue(rerouteQueueService.computeIgnoreBandwidth(data, true));
assertTrue(rerouteQueueService.computeIgnoreBandwidth(data, false));
data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(false).strictBandwidth(false).build();
assertTrue(rerouteQueueService.computeIgnoreBandwidth(data, true));
assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, false));
data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(true).strictBandwidth(true).build();
assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, true));
assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, false));
data = FlowThrottlingData.builder().affectedIsl(Collections.emptySet()).ignoreBandwidth(false).strictBandwidth(true).build();
assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, true));
assertFalse(rerouteQueueService.computeIgnoreBandwidth(data, false));
}
use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch.
@Test
public void shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch() {
FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
FlowThrottlingData pending = FlowThrottlingData.builder().correlationId("pending").priority(7).timeCreate(flow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(false).effectivelyDown(true).reason("another reason").build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_C.getSwitchId()))).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
String retryCorrelationId = CORRELATION_ID + " : retry #1 ignore_bw false";
FlowThrottlingData expected = getFlowThrottlingData(flow, retryCorrelationId).build();
expected.setPriority(pending.getPriority());
expected.setReason(pending.getReason());
assertEquals(expected, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
FlowRerouteRequest expectedRequest = getFlowRerouteRequest(FLOW_ID, expected);
verify(carrier).sendRerouteRequest(eq(retryCorrelationId), eq(expectedRequest));
}
use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.
the class RerouteServiceTest method processManualRerouteRequestForYFlow.
@Test
public void processManualRerouteRequestForYFlow() {
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
YFlowRepository yFlowRepository = mock(YFlowRepository.class);
when(repositoryFactory.createYFlowRepository()).thenReturn(yFlowRepository);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
when(yFlowRepository.findById(YFLOW_ID)).thenReturn(Optional.of(regularYFlow));
RerouteService rerouteService = new RerouteService(persistenceManager);
YFlowRerouteRequest request = new YFlowRerouteRequest(regularYFlow.getYFlowId(), Collections.emptySet(), true, "reason", false);
rerouteService.processRerouteRequest(carrier, CORRELATION_ID, request);
FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularYFlow.getPriority()).timeCreate(regularYFlow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(true).reason("reason").yFlow(true).build();
verify(carrier).emitManualRerouteCommand(eq(regularYFlow.getYFlowId()), eq(expected));
}
use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.
the class FlowRerouteQueueBolt method handleRerouteBoltMessage.
private void handleRerouteBoltMessage(Tuple tuple) throws PipelineException {
String flowId = pullValue(tuple, RerouteBolt.FLOW_ID_FIELD, String.class);
FlowThrottlingData throttlingData;
switch(tuple.getSourceStreamId()) {
case STREAM_REROUTE_REQUEST_ID:
throttlingData = (FlowThrottlingData) tuple.getValueByField(RerouteBolt.THROTTLING_DATA_FIELD);
rerouteQueueService.processAutomaticRequest(flowId, throttlingData);
break;
case STREAM_MANUAL_REROUTE_REQUEST_ID:
throttlingData = (FlowThrottlingData) tuple.getValueByField(RerouteBolt.THROTTLING_DATA_FIELD);
rerouteQueueService.processManualRequest(flowId, throttlingData);
break;
default:
unhandledInput(tuple);
}
}
Aggregations