use of org.openkilda.model.PathId in project open-kilda by telstra.
the class BaseResourceAllocationActionTest method updateAvailableBandwidthNoOverProvisionTest.
@Test()
public void updateAvailableBandwidthNoOverProvisionTest() throws ResourceAllocationException {
islRepositorySpy = spy(persistenceManager.getRepositoryFactory().createIslRepository());
when(repositoryFactory.createIslRepository()).thenReturn(islRepositorySpy);
doReturn(1L).when(islRepositorySpy).updateAvailableBandwidth(any(), anyInt(), any(), anyInt());
BaseResourceAllocationAction action = mock(BaseResourceAllocationAction.class, Mockito.withSettings().useConstructor(persistenceManager, 3, 3, 3, pathComputer, resourcesManager, dashboardLogger).defaultAnswer(Mockito.CALLS_REAL_METHODS));
PathSegment segment = PathSegment.builder().pathId(new PathId("")).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).srcPort(1).destSwitch(Switch.builder().switchId(new SwitchId(2)).build()).destPort(2).build();
action.createPathSegments(singletonList(segment), Suppliers.ofInstance(emptyMap()));
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FermaIslRepository method findByPathIds.
@Override
public Collection<Isl> findByPathIds(List<PathId> pathIds) {
List<String> pathIdAsStr = pathIds.stream().map(PathIdConverter.INSTANCE::toGraphProperty).collect(Collectors.toList());
List<? extends PathSegmentFrame> segmentFrames = framedGraph().traverse(g -> g.V().hasLabel(PathSegmentFrame.FRAME_LABEL).has(PathSegmentFrame.PATH_ID_PROPERTY, P.within(pathIdAsStr))).toListExplicit(PathSegmentFrame.class);
if (segmentFrames.isEmpty()) {
return emptyList();
}
List<Isl> result = new ArrayList<>();
segmentFrames.forEach(segmentFrame -> {
framedGraph().traverse(g -> g.E().hasLabel(IslFrame.FRAME_LABEL).has(IslFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(segmentFrame.getSrcSwitchId())).has(IslFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(segmentFrame.getDestSwitchId())).has(IslFrame.SRC_PORT_PROPERTY, segmentFrame.getSrcPort()).has(IslFrame.DST_PORT_PROPERTY, segmentFrame.getDestPort())).frameExplicit(IslFrame.class).forEachRemaining(frame -> result.add(addIslConfigToIsl(new Isl(frame))));
});
return result;
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method shouldFindFlowPathIdsByFlowIds.
@Test
public void shouldFindFlowPathIdsByFlowIds() {
Flow flowA = buildTestProtectedFlow(TEST_FLOW_ID_1, switchA, PORT_1, VLAN_1, switchB, PORT_2, VLAN_2);
flowRepository.add(flowA);
Flow flowB = buildTestFlow(TEST_FLOW_ID_2, switchA, PORT_1, VLAN_2, switchB, PORT_2, 0);
flowRepository.add(flowB);
Flow flowC = buildTestProtectedFlow(TEST_FLOW_ID_3, switchB, PORT_1, VLAN_1, switchB, PORT_3, VLAN_1);
flowRepository.add(flowC);
Collection<PathId> pathIds = flowPathRepository.findActualPathIdsByFlowIds(Sets.newHashSet(TEST_FLOW_ID_1, TEST_FLOW_ID_2));
assertEquals(6, pathIds.size());
assertTrue(pathIds.contains(flowA.getForwardPathId()));
assertTrue(pathIds.contains(flowA.getReversePathId()));
assertTrue(pathIds.contains(flowA.getProtectedForwardPathId()));
assertTrue(pathIds.contains(flowA.getProtectedReversePathId()));
assertTrue(pathIds.contains(flowB.getForwardPathId()));
assertTrue(pathIds.contains(flowB.getReversePathId()));
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method createFlowPath.
private FlowPath createFlowPath(Flow flow, String suffixName, long cookie, long meterId, Switch srcSwitch, Switch dstSwitch) {
FlowPath flowPath = FlowPath.builder().pathId(new PathId(flow.getFlowId() + suffixName)).cookie(new FlowSegmentCookie(cookie)).meterId(new MeterId(meterId)).srcSwitch(srcSwitch).destSwitch(dstSwitch).status(FlowPathStatus.ACTIVE).build();
flowPathRepository.add(flowPath);
return flowPath;
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class PathIdConverterTest method shouldConvertIdToString.
@Test
public void shouldConvertIdToString() {
// given
PathId pathId = new PathId("test_path_id");
// when
String graphObject = PathIdConverter.INSTANCE.toGraphProperty(pathId);
// then
assertEquals(pathId.getId(), graphObject);
}
Aggregations