Search in sources :

Example 11 with RerouteQueue

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());
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) SpeakerRequestError(org.openkilda.messaging.info.reroute.error.SpeakerRequestError) Test(org.junit.Test)

Example 12 with RerouteQueue

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));
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) SpeakerRequestError(org.openkilda.messaging.info.reroute.error.SpeakerRequestError) Test(org.junit.Test)

Example 13 with RerouteQueue

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));
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) SpeakerRequestError(org.openkilda.messaging.info.reroute.error.SpeakerRequestError) Test(org.junit.Test)

Example 14 with RerouteQueue

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);
    }
}
Also used : YFlow(org.openkilda.model.YFlow) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) ErrorData(org.openkilda.messaging.error.ErrorData) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow)

Example 15 with RerouteQueue

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)));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) Test(org.junit.Test)

Aggregations

RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)19 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)17 Test (org.junit.Test)15 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)7 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)6 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)5 SpeakerRequestError (org.openkilda.messaging.info.reroute.error.SpeakerRequestError)4 IslEndpoint (org.openkilda.model.IslEndpoint)4 Flow (org.openkilda.model.Flow)3 YFlow (org.openkilda.model.YFlow)3 YSubFlow (org.openkilda.model.YSubFlow)3 ErrorData (org.openkilda.messaging.error.ErrorData)2 NoPathFoundError (org.openkilda.messaging.info.reroute.error.NoPathFoundError)2 RerouteError (org.openkilda.messaging.info.reroute.error.RerouteError)2 RerouteInProgressError (org.openkilda.messaging.info.reroute.error.RerouteInProgressError)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 String.format (java.lang.String.format)1 Instant (java.time.Instant)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1