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);
}
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;
}
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());
}
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);
}
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);
}
Aggregations