Search in sources :

Example 56 with FlowPath

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

the class FermaFlowPathRepositoryTest method shouldNotFindPathByWrongSegmentDestSwitch.

@Test
public void shouldNotFindPathByWrongSegmentDestSwitch() {
    FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100);
    flow.setForwardPath(flowPath);
    Collection<FlowPath> foundPaths = flowPathRepository.findBySegmentDestSwitch(switchA.getSwitchId());
    assertThat(foundPaths, Matchers.empty());
}
Also used : FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 57 with FlowPath

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

the class FermaIslRepositoryTest method createFlowWithPath.

private Flow createFlowWithPath(int forwardBandwidth, int reverseBandwidth) {
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(switchA).destSwitch(switchB).status(FlowStatus.UP).build();
    FlowPath forwardPath = FlowPath.builder().srcSwitch(switchA).destSwitch(switchB).pathId(new PathId(TEST_FLOW_ID + "_forward_path")).cookie(new FlowSegmentCookie(1)).meterId(new MeterId(1)).status(FlowPathStatus.ACTIVE).bandwidth(forwardBandwidth).ignoreBandwidth(false).build();
    flow.setForwardPath(forwardPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).build();
    forwardPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reversePath = FlowPath.builder().srcSwitch(switchB).destSwitch(switchA).pathId(new PathId(TEST_FLOW_ID + "_reverse_path")).cookie(new FlowSegmentCookie(2)).meterId(new MeterId(2)).status(FlowPathStatus.ACTIVE).bandwidth(reverseBandwidth).ignoreBandwidth(false).build();
    flow.setReversePath(reversePath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reversePath.getPathId()).srcSwitch(switchB).srcPort(2).destSwitch(switchA).destPort(1).build();
    reversePath.setSegments(Collections.singletonList(reverseSegment));
    flowRepository.add(flow);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 58 with FlowPath

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

the class FermaIslRepositoryTest method createPathWithSegment.

private FlowPath createPathWithSegment(String pathId, Switch srcSwitch, Integer srcPort, Switch destSwitch, Integer destPort, long bandwidth, String sharedBandwidthGroupId) {
    PathId pathIdAsObj = new PathId(pathId);
    FlowPath path = FlowPath.builder().srcSwitch(srcSwitch).destSwitch(destSwitch).pathId(pathIdAsObj).bandwidth(bandwidth).sharedBandwidthGroupId(sharedBandwidthGroupId).segments(Collections.singletonList(PathSegment.builder().pathId(pathIdAsObj).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build())).build();
    flowPathRepository.add(path);
    return path;
}
Also used : PathId(org.openkilda.model.PathId) FlowPath(org.openkilda.model.FlowPath)

Example 59 with FlowPath

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

the class LinkOperationsBolt method updateLinkUnderMaintenanceFlag.

private List<IslInfoData> updateLinkUnderMaintenanceFlag(UpdateLinkUnderMaintenanceRequest request) {
    SwitchId srcSwitch = request.getSource().getDatapath();
    Integer srcPort = request.getSource().getPortNumber();
    SwitchId dstSwitch = request.getDestination().getDatapath();
    Integer dstPort = request.getDestination().getPortNumber();
    boolean underMaintenance = request.isUnderMaintenance();
    boolean evacuate = request.isEvacuate();
    List<Isl> isl;
    try {
        isl = linkOperationsService.updateLinkUnderMaintenanceFlag(srcSwitch, srcPort, dstSwitch, dstPort, underMaintenance);
        if (underMaintenance && evacuate) {
            Set<IslEndpoint> affectedIslEndpoints = new HashSet<>();
            affectedIslEndpoints.add(new IslEndpoint(srcSwitch, srcPort));
            affectedIslEndpoints.add(new IslEndpoint(dstSwitch, dstPort));
            String reason = format("evacuated due to link maintenance %s_%d - %s_%d", srcSwitch, srcPort, dstSwitch, dstPort);
            Collection<FlowPath> targetPaths = flowOperationsService.getFlowPathsForLink(srcSwitch, srcPort, dstSwitch, dstPort);
            for (FlowRerouteRequest reroute : flowOperationsService.makeRerouteRequests(targetPaths, affectedIslEndpoints, reason)) {
                CommandContext forkedContext = getCommandContext().fork(reroute.getFlowId());
                getOutput().emit(StreamType.REROUTE.toString(), getCurrentTuple(), new Values(reroute, forkedContext.getCorrelationId()));
            }
        }
    } catch (IslNotFoundException e) {
        throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
    }
    return isl.stream().map(IslMapper.INSTANCE::map).collect(Collectors.toList());
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) Isl(org.openkilda.model.Isl) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values) SwitchId(org.openkilda.model.SwitchId) MessageException(org.openkilda.messaging.error.MessageException) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) FlowPath(org.openkilda.model.FlowPath) HashSet(java.util.HashSet) IslMapper(org.openkilda.wfm.share.mappers.IslMapper)

Example 60 with FlowPath

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

the class FlowOperationsServiceTest method createOrphanFlowPaths.

private void createOrphanFlowPaths(Flow flow, Switch srcSwitch, int srcPort, Switch dstSwitch, int dstPort, PathId forwardPartId, PathId reversePathId, Switch transitSwitch) {
    FlowPath forwardPath = FlowPath.builder().pathId(forwardPartId).srcSwitch(srcSwitch).destSwitch(dstSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, UNMASKED_COOKIE)).build();
    FlowPath reversePath = FlowPath.builder().pathId(reversePathId).srcSwitch(dstSwitch).destSwitch(srcSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, UNMASKED_COOKIE)).build();
    if (!srcSwitch.getSwitchId().equals(dstSwitch.getSwitchId())) {
        if (transitSwitch == null) {
            // direct paths between src and dst switches
            forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, dstSwitch, dstPort)));
            reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, srcSwitch, srcPort)));
        } else {
            // src switch ==> transit switch ==> dst switch
            forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, transitSwitch, srcPort), createPathSegment(forwardPath.getPathId(), transitSwitch, dstPort, dstSwitch, dstPort)));
            reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, transitSwitch, dstPort), createPathSegment(reversePath.getPathId(), transitSwitch, srcPort, srcSwitch, srcPort)));
        }
    }
    flowPathRepository.add(forwardPath);
    flowPathRepository.add(reversePath);
    flow.addPaths(forwardPath, reversePath);
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowPath(org.openkilda.model.FlowPath)

Aggregations

FlowPath (org.openkilda.model.FlowPath)229 Flow (org.openkilda.model.Flow)128 Test (org.junit.Test)108 PathId (org.openkilda.model.PathId)65 PathSegment (org.openkilda.model.PathSegment)42 SwitchId (org.openkilda.model.SwitchId)40 ArrayList (java.util.ArrayList)39 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)33 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)29 Switch (org.openkilda.model.Switch)28 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)27 SpeakerData (org.openkilda.rulemanager.SpeakerData)27 Action (org.openkilda.rulemanager.action.Action)26 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)26 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)26 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)26 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)26 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)26 MeterId (org.openkilda.model.MeterId)20 YFlow (org.openkilda.model.YFlow)19