Search in sources :

Example 26 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class YFlowUpdateServiceTest method shouldFailOnTimeoutDuringMeterInstallation.

@Test
public void shouldFailOnTimeoutDuringMeterInstallation() throws UnroutableFlowException, RecoverableException, DuplicateKeyException, UnknownKeyException {
    // given
    YFlowRequest request = createYFlow();
    request.setMaximumBandwidth(2000L);
    request.getSubFlows().get(0).setEndpoint(newFirstEndpoint);
    request.getSubFlows().get(1).setEndpoint(newSecondEndpoint);
    preparePathComputationForUpdate("test_flow_1", buildNewFirstSubFlowPathPair(), buildFirstSubFlowPathPair());
    preparePathComputationForUpdate("test_flow_2", buildNewSecondSubFlowPathPair(), buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP, SWITCH_TRANSIT);
    YFlowUpdateService service = makeYFlowUpdateService(0);
    // when
    service.handleRequest(request.getYFlowId(), new CommandContext(), request);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
    // and
    handleSpeakerCommandsAndTimeoutInstall(service, request.getYFlowId());
    // then
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
    YFlow flow = getYFlow(request.getYFlowId());
    assertEquals(1000L, flow.getMaximumBandwidth());
    Set<SwitchId> expectedEndpointSwitchIds = Stream.of(SWITCH_FIRST_EP, SWITCH_SECOND_EP).collect(Collectors.toSet());
    Set<SwitchId> actualEndpointSwitchIds = flow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
    assertEquals(expectedEndpointSwitchIds, actualEndpointSwitchIds);
}
Also used : YFlow(org.openkilda.model.YFlow) CommandContext(org.openkilda.wfm.CommandContext) SwitchId(org.openkilda.model.SwitchId) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 27 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class YFlowUpdateServiceTest method shouldUpdateFlowWithTransitSwitches.

@Test
public void shouldUpdateFlowWithTransitSwitches() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
    // given
    YFlowRequest request = createYFlow();
    request.setMaximumBandwidth(2000L);
    request.getSubFlows().get(0).setEndpoint(newFirstEndpoint);
    request.getSubFlows().get(1).setEndpoint(newSecondEndpoint);
    preparePathComputationForUpdate("test_flow_1", buildNewFirstSubFlowPathPair());
    preparePathComputationForUpdate("test_flow_2", buildNewSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP, SWITCH_TRANSIT);
    // when
    processUpdateRequestAndSpeakerCommands(request);
    verifyNorthboundSuccessResponse(yFlowUpdateHubCarrier, YFlowResponse.class);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
    verifyAffinity(request.getYFlowId());
    YFlow flow = getYFlow(request.getYFlowId());
    assertEquals(2000L, flow.getMaximumBandwidth());
    Set<SwitchId> expectedEndpointSwitchIds = Stream.of(SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP).collect(Collectors.toSet());
    Set<SwitchId> actualEndpointSwitchIds = flow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
    assertEquals(expectedEndpointSwitchIds, actualEndpointSwitchIds);
}
Also used : YFlow(org.openkilda.model.YFlow) SwitchId(org.openkilda.model.SwitchId) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 28 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class YFlowUpdateServiceTest method shouldPatchFlowWithTransitSwitches.

@Test
public void shouldPatchFlowWithTransitSwitches() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
    // given
    createYFlow();
    List<SubFlowPartialUpdateDto> subFlowPartialUpdateDtos = new ArrayList<>();
    subFlowPartialUpdateDtos.add(SubFlowPartialUpdateDto.builder().flowId("test_flow_1").endpoint(FlowPartialUpdateEndpoint.builder().switchId(SWITCH_NEW_FIRST_EP).portNumber(2).vlanId(103).build()).build());
    subFlowPartialUpdateDtos.add(SubFlowPartialUpdateDto.builder().flowId("test_flow_2").endpoint(FlowPartialUpdateEndpoint.builder().switchId(SWITCH_NEW_SECOND_EP).portNumber(3).vlanId(104).build()).build());
    YFlowPartialUpdateRequest request = YFlowPartialUpdateRequest.builder().yFlowId("test_successful_yflow").maximumBandwidth(2000L).subFlows(subFlowPartialUpdateDtos).build();
    preparePathComputationForUpdate("test_flow_1", buildNewFirstSubFlowPathPair());
    preparePathComputationForUpdate("test_flow_2", buildNewSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP, SWITCH_TRANSIT);
    // when
    processUpdateRequestAndSpeakerCommands(request);
    verifyNorthboundSuccessResponse(yFlowUpdateHubCarrier, YFlowResponse.class);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
    YFlow flow = getYFlow(request.getYFlowId());
    assertEquals(2000L, flow.getMaximumBandwidth());
    Set<SwitchId> expectedEndpointSwitchIds = Stream.of(SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP).collect(Collectors.toSet());
    Set<SwitchId> actualEndpointSwitchIds = flow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
    assertEquals(expectedEndpointSwitchIds, actualEndpointSwitchIds);
}
Also used : YFlow(org.openkilda.model.YFlow) ArrayList(java.util.ArrayList) SwitchId(org.openkilda.model.SwitchId) SubFlowPartialUpdateDto(org.openkilda.messaging.command.yflow.SubFlowPartialUpdateDto) YFlowPartialUpdateRequest(org.openkilda.messaging.command.yflow.YFlowPartialUpdateRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 29 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class RerouteQueueService method processAutomaticRequest.

/**
 * Put reroute request to throttling.
 *
 * @param flowId flow id
 * @param throttlingData reroute request params
 */
public void processAutomaticRequest(String flowId, FlowThrottlingData throttlingData) {
    if (throttlingData.isYFlow()) {
        Optional<YFlow> flow = yFlowRepository.findById(flowId);
        if (!flow.isPresent()) {
            log.warn(format("Y-flow %s not found. Skip the reroute operation of this flow.", flowId));
            return;
        } else if (flow.get().isPinned()) {
            log.info(format("Y-flow %s is pinned. Skip the reroute operation of this flow.", flowId));
            return;
        }
    } else {
        Optional<Flow> flow = flowRepository.findById(flowId);
        if (!flow.isPresent()) {
            log.warn(format("Flow %s not found. Skip the reroute operation of this flow.", flowId));
            return;
        } else if (flow.get().isPinned()) {
            log.info(format("Flow %s is pinned. Skip the reroute operation of this flow.", flowId));
            return;
        }
    }
    log.info("Puts reroute request for flow {} with correlationId {}.", flowId, throttlingData.getCorrelationId());
    RerouteQueue rerouteQueue = getRerouteQueue(flowId);
    rerouteQueue.putToThrottling(throttlingData);
    carrier.sendExtendTimeWindowEvent();
}
Also used : YFlow(org.openkilda.model.YFlow) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow)

Example 30 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class FlowFetcher method handleOnDemandYFlowRequest.

private void handleOnDemandYFlowRequest(Tuple input) throws PipelineException {
    log.debug("Handle on demand ping request");
    YFlowPingRequest request = pullOnDemandYFlowRequest(input);
    Optional<YFlow> optionalYFlow = yFlowRepository.findById(request.getYFlowId());
    if (!optionalYFlow.isPresent()) {
        emitOnDemandYFlowResponse(input, request, format("YFlow %s does not exist", request.getYFlowId()));
        return;
    }
    YFlow yFlow = optionalYFlow.get();
    Set<YSubFlow> subFlows = yFlow.getSubFlows();
    if (subFlows.isEmpty()) {
        emitOnDemandYFlowResponse(input, request, format("YFlow %s has no sub flows", request.getYFlowId()));
        return;
    }
    GroupId groupId = new GroupId(subFlows.size() * DIRECTION_COUNT_PER_FLOW);
    List<PingContext> subFlowPingRequests = new ArrayList<>();
    for (YSubFlow subFlow : subFlows) {
        Flow flow = subFlow.getFlow();
        // Load paths to use in PingProducer
        flow.getPaths();
        flowRepository.detach(flow);
        Optional<FlowTransitEncapsulation> transitEncapsulation = getTransitEncapsulation(flow);
        if (transitEncapsulation.isPresent()) {
            subFlowPingRequests.add(PingContext.builder().group(groupId).kind(Kinds.ON_DEMAND_Y_FLOW).flow(flow).yFlowId(yFlow.getYFlowId()).transitEncapsulation(transitEncapsulation.get()).timeout(request.getTimeout()).build());
        } else {
            emitOnDemandYFlowResponse(input, request, format("Encapsulation resource not found for sub flow %s of YFlow %s", subFlow.getSubFlowId(), yFlow.getYFlowId()));
            return;
        }
    }
    CommandContext commandContext = pullContext(input);
    for (PingContext pingContext : subFlowPingRequests) {
        emit(input, pingContext, commandContext);
    }
}
Also used : YFlow(org.openkilda.model.YFlow) CommandContext(org.openkilda.wfm.CommandContext) ArrayList(java.util.ArrayList) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) YSubFlow(org.openkilda.model.YSubFlow) GroupId(org.openkilda.wfm.topology.ping.model.GroupId) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) YFlowPingRequest(org.openkilda.messaging.command.flow.YFlowPingRequest)

Aggregations

YFlow (org.openkilda.model.YFlow)74 Flow (org.openkilda.model.Flow)30 SwitchId (org.openkilda.model.SwitchId)29 YSubFlow (org.openkilda.model.YSubFlow)26 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)19 Test (org.junit.Test)12 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)12 ArrayList (java.util.ArrayList)11 FlowStatus (org.openkilda.model.FlowStatus)10 CommandContext (org.openkilda.wfm.CommandContext)10 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)10 FlowPath (org.openkilda.model.FlowPath)9 FlowEndpoint (org.openkilda.model.FlowEndpoint)8 InstallSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest)6 Switch (org.openkilda.model.Switch)6 HashSet (java.util.HashSet)5 DeleteSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest)5 SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4