use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method createDiamondWithAffinity.
// A - B - D and A-B-D is used in flow affinity group
// + C +
void createDiamondWithAffinity() {
Switch nodeA = createSwitch("00:0A");
Switch nodeB = createSwitch("00:0B");
Switch nodeC = createSwitch("00:0C");
Switch nodeD = createSwitch("00:0D");
IslStatus status = IslStatus.ACTIVE;
int cost = 100;
createIsl(nodeA, nodeB, status, status, cost * 2, 1000, 1, cost * 2);
createIsl(nodeA, nodeC, status, status, cost, 1000, 2, cost);
createIsl(nodeB, nodeD, status, status, cost * 2, 1000, 3, cost * 2);
createIsl(nodeC, nodeD, status, status, cost, 1000, 4, cost);
createIsl(nodeB, nodeA, status, status, cost * 2, 1000, 1, cost * 2);
createIsl(nodeC, nodeA, status, status, cost, 1000, 2, cost);
createIsl(nodeD, nodeB, status, status, cost * 2, 1000, 3, cost * 2);
createIsl(nodeD, nodeC, status, status, cost, 1000, 4, cost);
int bandwith = 10;
Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(nodeA).srcPort(15).destSwitch(nodeD).destPort(16).affinityGroupId(TEST_FLOW_ID).bandwidth(bandwith).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeA).destSwitch(nodeD).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.FORWARD).build()).build();
addPathSegment(forwardPath, nodeA, nodeB, 1, 1);
addPathSegment(forwardPath, nodeB, nodeD, 3, 3);
flow.setForwardPath(forwardPath);
FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeD).destSwitch(nodeA).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.REVERSE).build()).build();
addPathSegment(reversePath, nodeD, nodeB, 3, 3);
addPathSegment(reversePath, nodeB, nodeA, 1, 1);
flow.setReversePath(reversePath);
flowRepository.add(flow);
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method shouldGetYPoint3FlowPaths.
@Test
public void shouldGetYPoint3FlowPaths() {
FlowPath flowPathA = buildFlowPath("flow_path_a", 1, 2, 3, 7);
FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 3, 4, 5);
FlowPath flowPathC = buildFlowPath("flow_path_c", 1, 2, 3, 4, 6);
PathComputer pathComputer = pathComputerFactory.getPathComputer();
SwitchId result = pathComputer.getIntersectionPoint(SWITCH_1, flowPathA, flowPathB, flowPathC);
assertEquals(new SwitchId(3), result);
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method shouldThrowPathHasNoSegmentsWhenSegmentsIsNull.
@Test
public void shouldThrowPathHasNoSegmentsWhenSegmentsIsNull() {
FlowPath flowPathA = FlowPath.builder().pathId(new PathId("flow_path_a")).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(3)).build()).build();
FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 4, 5);
InMemoryPathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(config.getMaxAllowedDepth()), config);
Exception exception = assertThrows(IllegalArgumentException.class, () -> pathComputer.convertFlowPathsToSwitchLists(SWITCH_1, flowPathA, flowPathB));
assertEquals("The path 'flow_path_a' has no path segments", exception.getMessage());
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method shouldGetYPoint2FlowPathsWithSameEndpoints.
@Test
public void shouldGetYPoint2FlowPathsWithSameEndpoints() {
FlowPath flowPathA = buildFlowPath("flow_path_a", 1, 2, 3);
FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 3);
PathComputer pathComputer = pathComputerFactory.getPathComputer();
SwitchId result = pathComputer.getIntersectionPoint(SWITCH_1, flowPathA, flowPathB);
assertEquals(new SwitchId(3), result);
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaPathSegmentRepository method updateFailedStatus.
@Override
@TransactionRequired
public void updateFailedStatus(FlowPath path, PathSegment segment, boolean failed) {
PathSegment segmentToUpdate;
if (segment.getData() instanceof PathSegmentFrame) {
segmentToUpdate = segment;
} else {
segmentToUpdate = path.getSegments().stream().filter(pathSegment -> pathSegment.getSrcSwitchId().equals(segment.getSrcSwitchId()) && pathSegment.getSrcPort() == segment.getSrcPort() && pathSegment.getDestSwitchId().equals(segment.getDestSwitchId()) && pathSegment.getDestPort() == segment.getDestPort()).findAny().orElse(null);
}
if (segmentToUpdate == null) {
throw new PersistenceException(format("PathSegment not found to be updated: %s_%d - %s_%d. Path id: %s.", segment.getSrcSwitchId(), segment.getSrcPort(), segment.getDestSwitchId(), segment.getDestPort(), path.getPathId()));
}
segmentToUpdate.setFailed(failed);
}
Aggregations