Search in sources :

Example 61 with PathId

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()));
}
Also used : PathId(org.openkilda.model.PathId) SwitchId(org.openkilda.model.SwitchId) PathSegment(org.openkilda.model.PathSegment) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 62 with PathId

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;
}
Also used : Collectors.groupingBy(java.util.stream.Collectors.groupingBy) PathSegmentFrame(org.openkilda.persistence.ferma.frames.PathSegmentFrame) FlowEncapsulationTypeConverter(org.openkilda.persistence.ferma.frames.converters.FlowEncapsulationTypeConverter) HashMap(java.util.HashMap) IslConfig(org.openkilda.model.IslConfig) SwitchIdConverter(org.openkilda.persistence.ferma.frames.converters.SwitchIdConverter) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Collections.unmodifiableCollection(java.util.Collections.unmodifiableCollection) IslStatusConverter(org.openkilda.persistence.ferma.frames.converters.IslStatusConverter) Collectors.mapping(java.util.stream.Collectors.mapping) IslRepository(org.openkilda.persistence.repositories.IslRepository) Map(java.util.Map) SwitchFrame(org.openkilda.persistence.ferma.frames.SwitchFrame) Collectors.toSet(java.util.stream.Collectors.toSet) PathId(org.openkilda.model.PathId) P(org.apache.tinkerpop.gremlin.process.traversal.P) Edge(org.apache.tinkerpop.gremlin.structure.Edge) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) Switch(org.openkilda.model.Switch) IslFrame(org.openkilda.persistence.ferma.frames.IslFrame) SwitchStatusConverter(org.openkilda.persistence.ferma.frames.converters.SwitchStatusConverter) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) Set(java.util.Set) org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__) IslStatus(org.openkilda.model.IslStatus) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) KildaBaseEdgeFrame(org.openkilda.persistence.ferma.frames.KildaBaseEdgeFrame) FermaPersistentImplementation(org.openkilda.persistence.ferma.FermaPersistentImplementation) SwitchPropertiesFrame(org.openkilda.persistence.ferma.frames.SwitchPropertiesFrame) Instant(java.time.Instant) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) IslData(org.openkilda.model.Isl.IslData) SwitchId(org.openkilda.model.SwitchId) FramedGraph(com.syncleus.ferma.FramedGraph) Optional(java.util.Optional) Isl(org.openkilda.model.Isl) SwitchStatus(org.openkilda.model.SwitchStatus) PathIdConverter(org.openkilda.persistence.ferma.frames.converters.PathIdConverter) Isl(org.openkilda.model.Isl) PathIdConverter(org.openkilda.persistence.ferma.frames.converters.PathIdConverter) IslFrame(org.openkilda.persistence.ferma.frames.IslFrame) ArrayList(java.util.ArrayList)

Example 63 with PathId

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()));
}
Also used : PathId(org.openkilda.model.PathId) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 64 with PathId

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;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowPath(org.openkilda.model.FlowPath) MeterId(org.openkilda.model.MeterId)

Example 65 with PathId

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);
}
Also used : PathId(org.openkilda.model.PathId) Test(org.junit.Test)

Aggregations

PathId (org.openkilda.model.PathId)124 Flow (org.openkilda.model.Flow)65 FlowPath (org.openkilda.model.FlowPath)65 Test (org.junit.Test)44 Switch (org.openkilda.model.Switch)29 SwitchId (org.openkilda.model.SwitchId)28 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)27 PathSegment (org.openkilda.model.PathSegment)26 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)21 MeterId (org.openkilda.model.MeterId)19 ArrayList (java.util.ArrayList)18 List (java.util.List)13 Slf4j (lombok.extern.slf4j.Slf4j)11 GetPathsResult (org.openkilda.pce.GetPathsResult)11 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)10 Path (org.openkilda.pce.Path)10 Collection (java.util.Collection)9 RecoverableException (org.openkilda.pce.exception.RecoverableException)9 String.format (java.lang.String.format)8 HashMap (java.util.HashMap)8