Search in sources :

Example 1 with FlowSegmentCookieBuilder

use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.

the class BaseResourceAllocationAction method createFlowPathPair.

protected FlowPathPair createFlowPathPair(String flowId, FlowResources flowResources, GetPathsResult pathPair, boolean forceToIgnoreBandwidth, String sharedBandwidthGroupId) {
    FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(flowResources.getUnmaskedCookie());
    return transactionManager.doInTransaction(() -> {
        Flow flow = getFlow(flowId);
        updateSwitchRelatedFlowProperties(flow);
        Path forward = pathPair.getForward();
        List<PathSegment> forwardSegments = pathSegmentRepository.findByPathId(flowResources.getForward().getPathId());
        FlowPath newForwardPath = flowPathBuilder.buildFlowPath(flow, flowResources.getForward(), forward.getLatency(), forward.getSrcSwitchId(), forward.getDestSwitchId(), forwardSegments, cookieBuilder.direction(FlowPathDirection.FORWARD).build(), forceToIgnoreBandwidth, sharedBandwidthGroupId);
        newForwardPath.setStatus(FlowPathStatus.IN_PROGRESS);
        Path reverse = pathPair.getReverse();
        List<PathSegment> reverseSegments = pathSegmentRepository.findByPathId(flowResources.getReverse().getPathId());
        FlowPath newReversePath = flowPathBuilder.buildFlowPath(flow, flowResources.getReverse(), reverse.getLatency(), reverse.getSrcSwitchId(), reverse.getDestSwitchId(), reverseSegments, cookieBuilder.direction(FlowPathDirection.REVERSE).build(), forceToIgnoreBandwidth, sharedBandwidthGroupId);
        newReversePath.setStatus(FlowPathStatus.IN_PROGRESS);
        log.debug("Persisting the paths {}/{}", newForwardPath, newReversePath);
        flowPathRepository.add(newForwardPath);
        flowPathRepository.add(newReversePath);
        flow.addPaths(newForwardPath, newReversePath);
        return FlowPathPair.builder().forward(newForwardPath).reverse(newReversePath).build();
    });
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) FlowSegmentCookieBuilder(org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 2 with FlowSegmentCookieBuilder

use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.

the class ResourcesAllocationAction method allocateProtectedPath.

private void allocateProtectedPath(FlowCreateFsm stateMachine) throws UnroutableFlowException, RecoverableException, ResourceAllocationException, FlowNotFoundException {
    String flowId = stateMachine.getFlowId();
    Flow tmpFlow = getFlow(flowId);
    if (!tmpFlow.isAllocateProtectedPath()) {
        return;
    }
    tmpFlow.setDiverseGroupId(getFlowDiverseGroupFromContext(flowId).orElseThrow(() -> new FlowNotFoundException(flowId)));
    GetPathsResult protectedPath = pathComputer.getPath(tmpFlow);
    stateMachine.setBackUpProtectedPathComputationWayUsed(protectedPath.isBackUpPathComputationWayUsed());
    boolean overlappingProtectedPathFound = flowPathBuilder.arePathsOverlapped(protectedPath.getForward(), tmpFlow.getForwardPath()) || flowPathBuilder.arePathsOverlapped(protectedPath.getReverse(), tmpFlow.getReversePath());
    if (overlappingProtectedPathFound) {
        log.info("Couldn't find non overlapping protected path. Result flow state: {}", tmpFlow);
        throw new UnroutableFlowException("Couldn't find non overlapping protected path", tmpFlow.getFlowId());
    }
    log.debug("Creating the protected path {} for flow {}", protectedPath, tmpFlow);
    transactionManager.doInTransaction(() -> {
        Flow flow = getFlow(flowId);
        FlowResources flowResources = resourcesManager.allocateFlowResources(flow);
        final FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(flowResources.getUnmaskedCookie());
        FlowPath forward = flowPathBuilder.buildFlowPath(flow, flowResources.getForward(), protectedPath.getForward(), cookieBuilder.direction(FlowPathDirection.FORWARD).build(), false, stateMachine.getSharedBandwidthGroupId());
        forward.setStatus(FlowPathStatus.IN_PROGRESS);
        flowPathRepository.add(forward);
        flow.setProtectedForwardPath(forward);
        FlowPath reverse = flowPathBuilder.buildFlowPath(flow, flowResources.getReverse(), protectedPath.getReverse(), cookieBuilder.direction(FlowPathDirection.REVERSE).build(), false, stateMachine.getSharedBandwidthGroupId());
        reverse.setStatus(FlowPathStatus.IN_PROGRESS);
        flowPathRepository.add(reverse);
        flow.setProtectedReversePath(reverse);
        updateIslsForFlowPath(forward.getPathId());
        updateIslsForFlowPath(reverse.getPathId());
        stateMachine.setProtectedForwardPathId(forward.getPathId());
        stateMachine.setProtectedReversePathId(reverse.getPathId());
        log.debug("Allocated resources for the flow {}: {}", flow.getFlowId(), flowResources);
        stateMachine.getFlowResources().add(flowResources);
    });
}
Also used : FlowNotFoundException(org.openkilda.wfm.error.FlowNotFoundException) FlowResources(org.openkilda.wfm.share.flow.resources.FlowResources) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) FlowSegmentCookieBuilder(org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) YSubFlow(org.openkilda.model.YSubFlow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) YFlow(org.openkilda.model.YFlow) GetPathsResult(org.openkilda.pce.GetPathsResult)

Example 3 with FlowSegmentCookieBuilder

use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.

the class HistoryMapper method map.

/**
 * Note: you have to additionally set {@link org.openkilda.wfm.share.history.model.FlowDumpData.DumpType}
 * to the dump data.
 */
public FlowDumpData map(Flow flow, FlowResources resources, DumpType dumpType) {
    FlowDumpData result = generatedMap(flow, resources, dumpType);
    FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(resources.getUnmaskedCookie());
    result.setForwardCookie(cookieBuilder.direction(FlowPathDirection.FORWARD).build());
    result.setReverseCookie(cookieBuilder.direction(FlowPathDirection.REVERSE).build());
    return result;
}
Also used : FlowDumpData(org.openkilda.wfm.share.history.model.FlowDumpData) FlowSegmentCookieBuilder(org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder)

Example 4 with FlowSegmentCookieBuilder

use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.

the class ResourcesAllocationAction method allocateMainPath.

private void allocateMainPath(FlowCreateFsm stateMachine) throws UnroutableFlowException, RecoverableException, ResourceAllocationException {
    GetPathsResult paths = pathComputer.getPath(getFlow(stateMachine.getFlowId()));
    stateMachine.setBackUpPrimaryPathComputationWayUsed(paths.isBackUpPathComputationWayUsed());
    log.debug("Creating the primary path {} for flow {}", paths, stateMachine.getFlowId());
    transactionManager.doInTransaction(() -> {
        Flow flow = getFlow(stateMachine.getFlowId());
        FlowResources flowResources = resourcesManager.allocateFlowResources(flow);
        final FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(flowResources.getUnmaskedCookie());
        updateSwitchRelatedFlowProperties(flow);
        FlowPath forward = flowPathBuilder.buildFlowPath(flow, flowResources.getForward(), paths.getForward(), cookieBuilder.direction(FlowPathDirection.FORWARD).build(), false, stateMachine.getSharedBandwidthGroupId());
        forward.setStatus(FlowPathStatus.IN_PROGRESS);
        flowPathRepository.add(forward);
        flow.setForwardPath(forward);
        FlowPath reverse = flowPathBuilder.buildFlowPath(flow, flowResources.getReverse(), paths.getReverse(), cookieBuilder.direction(FlowPathDirection.REVERSE).build(), false, stateMachine.getSharedBandwidthGroupId());
        reverse.setStatus(FlowPathStatus.IN_PROGRESS);
        flowPathRepository.add(reverse);
        flow.setReversePath(reverse);
        updateIslsForFlowPath(forward.getPathId());
        updateIslsForFlowPath(reverse.getPathId());
        stateMachine.setForwardPathId(forward.getPathId());
        stateMachine.setReversePathId(reverse.getPathId());
        log.debug("Allocated resources for the flow {}: {}", flow.getFlowId(), flowResources);
        stateMachine.getFlowResources().add(flowResources);
    });
}
Also used : FlowResources(org.openkilda.wfm.share.flow.resources.FlowResources) FlowSegmentCookieBuilder(org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder) FlowPath(org.openkilda.model.FlowPath) GetPathsResult(org.openkilda.pce.GetPathsResult) Flow(org.openkilda.model.Flow) YSubFlow(org.openkilda.model.YSubFlow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) YFlow(org.openkilda.model.YFlow)

Aggregations

FlowSegmentCookieBuilder (org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder)4 Flow (org.openkilda.model.Flow)3 FlowPath (org.openkilda.model.FlowPath)3 YFlow (org.openkilda.model.YFlow)2 YSubFlow (org.openkilda.model.YSubFlow)2 GetPathsResult (org.openkilda.pce.GetPathsResult)2 FlowResources (org.openkilda.wfm.share.flow.resources.FlowResources)2 RequestedFlow (org.openkilda.wfm.topology.flowhs.model.RequestedFlow)2 PathSegment (org.openkilda.model.PathSegment)1 Path (org.openkilda.pce.Path)1 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)1 FlowNotFoundException (org.openkilda.wfm.error.FlowNotFoundException)1 FlowDumpData (org.openkilda.wfm.share.history.model.FlowDumpData)1