use of org.openkilda.wfm.topology.reroute.model.RerouteQueue 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.RerouteQueue 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.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitchYFlow.
@Test
public void shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitchYFlow() {
FlowThrottlingData inProgress = getFlowThrottlingData(yFlow, CORRELATION_ID).build();
FlowThrottlingData pending = FlowThrottlingData.builder().correlationId("pending").priority(7).timeCreate(yFlow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(false).effectivelyDown(true).reason("another reason").yFlow(true).build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).build();
rerouteQueueService.getReroutes().put(YFLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(YFLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_C.getSwitchId()))).yFlow(true).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
String retryCorrelationId = CORRELATION_ID + " : retry #1 ignore_bw false";
FlowThrottlingData expected = getFlowThrottlingData(yFlow, retryCorrelationId).build();
expected.setPriority(pending.getPriority());
expected.setReason(pending.getReason());
assertEquals(expected, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
YFlowRerouteRequest expectedRequest = getYFlowRerouteRequest(YFLOW_ID, expected);
verify(carrier).sendRerouteRequest(eq(retryCorrelationId), eq(expectedRequest));
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueService method processManualRequest.
/**
* Process manual reroute request.
*
* @param flowId flow id
* @param throttlingData reroute request params
*/
public void processManualRequest(String flowId, FlowThrottlingData throttlingData) {
if (throttlingData.isYFlow()) {
Optional<YFlow> yFlow = yFlowRepository.findById(flowId);
if (!yFlow.isPresent()) {
String description = format("Y-flow %s not found", flowId);
ErrorData errorData = new ErrorData(ErrorType.NOT_FOUND, "Could not reroute y-flow", description);
carrier.emitFlowRerouteError(errorData);
return;
} else if (yFlow.get().isPinned()) {
String description = "Can't reroute pinned y-flow";
ErrorData errorData = new ErrorData(ErrorType.UNPROCESSABLE_REQUEST, "Could not reroute y-flow", description);
carrier.emitFlowRerouteError(errorData);
return;
}
} else {
Optional<Flow> flow = flowRepository.findById(flowId);
if (!flow.isPresent()) {
String description = format("Flow %s not found", flowId);
ErrorData errorData = new ErrorData(ErrorType.NOT_FOUND, "Could not reroute flow", description);
carrier.emitFlowRerouteError(errorData);
return;
} else if (flow.get().isPinned()) {
String description = "Can't reroute pinned flow";
ErrorData errorData = new ErrorData(ErrorType.UNPROCESSABLE_REQUEST, "Could not reroute flow", description);
carrier.emitFlowRerouteError(errorData);
return;
}
}
RerouteQueue rerouteQueue = getRerouteQueue(flowId);
if (rerouteQueue.hasInProgress()) {
String description = format("Flow %s is in reroute process", flowId);
ErrorData errorData = new ErrorData(ErrorType.UNPROCESSABLE_REQUEST, "Could not reroute flow", description);
carrier.emitFlowRerouteError(errorData);
} else {
rerouteQueue.putToInProgress(throttlingData);
sendRerouteRequest(flowId, throttlingData);
}
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldPrioritizeLowBandwidthFlowWithCostAndAvailableBandwidthPathComputationStrategy.
@Test
public void shouldPrioritizeLowBandwidthFlowWithCostAndAvailableBandwidthPathComputationStrategy() {
FlowThrottlingData first = getFlowThrottlingData(flow, CORRELATION_ID).priority(100).build();
FlowThrottlingData second = getFlowThrottlingData(flow, CORRELATION_ID).pathComputationStrategy(PathComputationStrategy.COST_AND_AVAILABLE_BANDWIDTH).bandwidth(100).build();
FlowThrottlingData third = getFlowThrottlingData(flow, CORRELATION_ID).pathComputationStrategy(PathComputationStrategy.COST_AND_AVAILABLE_BANDWIDTH).bandwidth(1000).build();
RerouteQueue firstQueue = RerouteQueue.builder().throttling(first).build();
RerouteQueue secondQueue = RerouteQueue.builder().throttling(second).build();
RerouteQueue thirdQueue = RerouteQueue.builder().throttling(third).build();
rerouteQueueService.getReroutes().put("third flow", thirdQueue);
rerouteQueueService.getReroutes().put("second flow", secondQueue);
rerouteQueueService.getReroutes().put("first flow", firstQueue);
rerouteQueueService.flushThrottling();
verify(carrier).sendRerouteRequest(any(String.class), eq(getFlowRerouteRequest("first flow", first)));
verify(carrier).sendRerouteRequest(any(String.class), eq(getFlowRerouteRequest("second flow", second)));
verify(carrier).sendRerouteRequest(any(String.class), eq(getFlowRerouteRequest("third flow", third)));
}
Aggregations