Search in sources :

Example 36 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowServiceImpl method rerouteFlowV2.

@Override
public CompletableFuture<FlowRerouteResponseV2> rerouteFlowV2(String flowId) {
    logger.info("Processing flow reroute: {}", flowId);
    FlowRerouteRequest payload = createManualFlowRerouteRequest(flowId, false, false, "initiated via Northbound");
    CommandMessage command = new CommandMessage(payload, System.currentTimeMillis(), RequestCorrelationId.getId(), Destination.WFM);
    return messagingChannel.sendAndGet(rerouteTopic, command).thenApply(FlowRerouteResponse.class::cast).thenApply(response -> flowMapper.toRerouteResponseV2(flowId, response.getPayload(), response.isRerouted()));
}
Also used : FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) FlowRerouteRequest.createManualFlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest.createManualFlowRerouteRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 37 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldFailRerouteYSubFlow.

@Test
public void shouldFailRerouteYSubFlow() throws UnroutableFlowException, RecoverableException {
    Flow origin = makeFlow();
    createTestYFlowForSubFlow(origin);
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowRerouteService service = makeService();
    IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    verifyNoSpeakerInteraction(carrier);
    verifyNorthboundErrorResponse(carrier, ErrorType.REQUEST_INVALID);
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 38 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldMoveFlowToDegradedIfPathWithRequiredLatencyNotFound.

@Test
public void shouldMoveFlowToDegradedIfPathWithRequiredLatencyNotFound() throws Exception {
    Flow origin = makeFlow();
    origin.setTargetPathComputationStrategy(MAX_LATENCY);
    setupFlowRepositorySpy().findById(origin.getFlowId()).ifPresent(foundPath -> foundPath.setTargetPathComputationStrategy(MAX_LATENCY));
    when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), any(Collection.class))).thenReturn(make3SwitchesPathPair(true));
    FlowRerouteService service = makeService();
    IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        produceAsyncResponse(service, speakerRequest);
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.DEGRADED);
    verifyPathReplace(origin, result);
    assertEquals(MAX_LATENCY, result.getPathComputationStrategy());
    assertNull(result.getTargetPathComputationStrategy());
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) Collection(java.util.Collection) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 39 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldFailRerouteFlowIfNoResourcesAvailable.

@Test
public void shouldFailRerouteFlowIfNoResourcesAvailable() throws RecoverableException, UnroutableFlowException, ResourceAllocationException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    doThrow(new ResourceAllocationException(injectedErrorMessage)).when(flowResourcesManager).allocateFlowResources(makeFlowArgumentMatch(origin.getFlowId()), any(), any());
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
    testExpectedFailure(dummyRequestKey, request, commandContext, origin, FlowStatus.UP, ErrorType.INTERNAL_ERROR);
    verify(flowResourcesManager, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).allocateFlowResources(makeFlowArgumentMatch(origin.getFlowId()), any(), any());
}
Also used : FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) ResourceAllocationException(org.openkilda.wfm.share.flow.resources.ResourceAllocationException) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 40 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldSkipRerouteIfNoNewPathFound.

@Test
public void shouldSkipRerouteIfNoNewPathFound() throws RecoverableException, UnroutableFlowException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make2SwitchesPathPair());
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
    makeService().handleRequest(dummyRequestKey, request, commandContext);
    verifyNoSpeakerInteraction(carrier);
    verifyNorthboundSuccessResponse(carrier);
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyNoPathReplace(origin, result);
}
Also used : FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)49 Test (org.junit.Test)27 Flow (org.openkilda.model.Flow)23 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)14 Values (org.apache.storm.tuple.Values)10 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)9 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 IslEndpoint (org.openkilda.model.IslEndpoint)8 CommandContext (org.openkilda.wfm.CommandContext)7 FlowPath (org.openkilda.model.FlowPath)6 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)5 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)4 GetPathsResult (org.openkilda.pce.GetPathsResult)4 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)4 HashSet (java.util.HashSet)3 RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Ignore (org.junit.Ignore)2 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)2