Search in sources :

Example 96 with FlowPath

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

the class SpeakerFlowSegmentRequestBuilderTest method verifyReverseTransitRequest.

private void verifyReverseTransitRequest(Flow flow, SwitchId datapath, FlowSegmentRequest rawRequest) {
    FlowPath path = Objects.requireNonNull(flow.getReversePath());
    verifyCommonTransitRequest(flow, path, datapath, rawRequest);
}
Also used : FlowPath(org.openkilda.model.FlowPath)

Example 97 with FlowPath

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

the class FlowPathBuilder method isSamePath.

/**
 * Check whether the path and flow path represent the same.
 *
 * @param path the path to evaluate.
 * @param flowPath the flow path to evaluate.
 */
public boolean isSamePath(Path path, FlowPath flowPath) {
    if (!path.getSrcSwitchId().equals(flowPath.getSrcSwitchId()) || !path.getDestSwitchId().equals(flowPath.getDestSwitchId()) || path.getSegments().size() != flowPath.getSegments().size()) {
        return false;
    }
    Iterator<Segment> pathIt = path.getSegments().iterator();
    Iterator<PathSegment> flowPathIt = flowPath.getSegments().iterator();
    while (pathIt.hasNext() && flowPathIt.hasNext()) {
        Path.Segment pathSegment = pathIt.next();
        PathSegment flowSegment = flowPathIt.next();
        if (!pathSegment.getSrcSwitchId().equals(flowSegment.getSrcSwitchId()) || !pathSegment.getDestSwitchId().equals(flowSegment.getDestSwitchId()) || pathSegment.getSrcPort() != flowSegment.getSrcPort() || pathSegment.getDestPort() != flowSegment.getDestPort()) {
            return false;
        }
    }
    return true;
}
Also used : FlowPath(org.openkilda.model.FlowPath) Path(org.openkilda.pce.Path) Segment(org.openkilda.pce.Path.Segment) PathSegment(org.openkilda.model.PathSegment) PathSegment(org.openkilda.model.PathSegment) Segment(org.openkilda.pce.Path.Segment)

Example 98 with FlowPath

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

the class IntersectionComputerTest method shouldCalculateSharedPathWithNoSegments.

@Test
public void shouldCalculateSharedPathWithNoSegments() {
    FlowPath firstPath = FlowPath.builder().pathId(PATH_ID).srcSwitch(makeSwitch(SWITCH_ID_A)).destSwitch(makeSwitch(SWITCH_ID_C)).segments(Lists.newArrayList(buildPathSegment(NEW_PATH_ID, SWITCH_ID_A, SWITCH_ID_D, 1, 1), buildPathSegment(NEW_PATH_ID, SWITCH_ID_D, SWITCH_ID_C, 2, 2))).build();
    FlowPath secondPath = FlowPath.builder().pathId(NEW_PATH_ID).srcSwitch(makeSwitch(SWITCH_ID_A)).destSwitch(makeSwitch(SWITCH_ID_D)).segments(Lists.newArrayList(buildPathSegment(NEW_PATH_ID, SWITCH_ID_A, SWITCH_ID_B, 1, 1), buildPathSegment(NEW_PATH_ID, SWITCH_ID_B, SWITCH_ID_D, 3, 3))).build();
    List<PathSegment> sharedPath = IntersectionComputer.calculatePathIntersectionFromSource(asList(firstPath, secondPath));
    assertEquals(0, sharedPath.size());
}
Also used : PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 99 with FlowPath

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

the class IntersectionComputerTest method fullIntersection.

@Test
public void fullIntersection() {
    List<FlowPath> paths = getFlowPaths();
    paths.addAll(getFlowPaths(NEW_PATH_ID, NEW_PATH_ID_REVERSE, flow2));
    IntersectionComputer computer = new IntersectionComputer(FLOW_ID, PATH_ID, PATH_ID_REVERSE, paths);
    OverlappingSegmentsStats stats = computer.getOverlappingStats(NEW_PATH_ID, NEW_PATH_ID_REVERSE);
    assertEquals(new OverlappingSegmentsStats(2, 3, 100, 100), stats);
}
Also used : OverlappingSegmentsStats(org.openkilda.messaging.payload.flow.OverlappingSegmentsStats) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

Example 100 with FlowPath

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

the class IntersectionComputerTest method noGroupIntersections.

@Test
public void noGroupIntersections() {
    List<FlowPath> paths = getFlowPaths();
    IntersectionComputer computer = new IntersectionComputer(FLOW_ID, PATH_ID, PATH_ID_REVERSE, paths);
    OverlappingSegmentsStats stats = computer.getOverlappingStats();
    assertEquals(ZERO_STATS, stats);
}
Also used : OverlappingSegmentsStats(org.openkilda.messaging.payload.flow.OverlappingSegmentsStats) FlowPath(org.openkilda.model.FlowPath) Test(org.junit.Test)

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