Search in sources :

Example 6 with Isl

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

the class FermaIslRepository method findByPartialEndpoints.

@Override
public Collection<Isl> findByPartialEndpoints(SwitchId srcSwitchId, Integer srcPort, SwitchId dstSwitchId, Integer dstPort) {
    List<Isl> result = new ArrayList<>();
    framedGraph().traverse(g -> {
        GraphTraversal<Edge, Edge> traversal = g.E().hasLabel(IslFrame.FRAME_LABEL);
        if (srcSwitchId != null) {
            traversal = traversal.has(IslFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(srcSwitchId));
        }
        if (dstSwitchId != null) {
            traversal = traversal.has(IslFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(dstSwitchId));
        }
        if (srcPort != null) {
            traversal = traversal.has(IslFrame.SRC_PORT_PROPERTY, srcPort);
        }
        if (dstPort != null) {
            traversal = traversal.has(IslFrame.DST_PORT_PROPERTY, dstPort);
        }
        return traversal;
    }).frameExplicit(IslFrame.class).forEachRemaining(frame -> result.add(addIslConfigToIsl(new Isl(frame))));
    return unmodifiableCollection(result);
}
Also used : Isl(org.openkilda.model.Isl) IslFrame(org.openkilda.persistence.ferma.frames.IslFrame) ArrayList(java.util.ArrayList) Edge(org.apache.tinkerpop.gremlin.structure.Edge)

Example 7 with Isl

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

the class FermaIslRepositoryTest method shouldFindIslByEndpoint.

@Test
public void shouldFindIslByEndpoint() {
    Isl isl = createIsl(switchA, 111, switchB, 112);
    assertTrue(islRepository.existsByEndpoint(TEST_SWITCH_A_ID, 111));
    List<Isl> foundIsls = Lists.newArrayList(islRepository.findByEndpoint(TEST_SWITCH_A_ID, 111));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl));
    foundIsls = Lists.newArrayList(islRepository.findByEndpoint(TEST_SWITCH_B_ID, 112));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl));
}
Also used : Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 8 with Isl

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

the class FermaIslRepositoryTest method shouldFindIslBySrcEndpoint.

@Test
public void shouldFindIslBySrcEndpoint() {
    Isl isl = createIsl(switchA, 111, switchB, 112);
    List<Isl> foundIsls = Lists.newArrayList(islRepository.findBySrcEndpoint(TEST_SWITCH_A_ID, 111));
    assertThat(foundIsls, Matchers.hasSize(1));
    assertThat(foundIsls, Matchers.contains(isl));
}
Also used : Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 9 with Isl

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

the class FermaIslRepositoryTest method shouldFindIslByEndpoints.

@Test
public void shouldFindIslByEndpoints() {
    Isl isl = createIsl(switchA, 111, switchB, 112);
    Isl foundIsl = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 111, TEST_SWITCH_B_ID, 112).get();
    assertEquals(isl, foundIsl);
}
Also used : Isl(org.openkilda.model.Isl) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 10 with Isl

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

the class FermaIslRepositoryTest method createIsl.

private Isl createIsl(Switch srcSwitch, Integer srcPort, Switch destSwitch, Integer destPort, IslStatus status, Long availableBandwidth) {
    Isl.IslBuilder islBuilder = Isl.builder().srcSwitch(srcSwitch).destSwitch(destSwitch).status(status);
    if (srcPort != null) {
        islBuilder.srcPort(srcPort);
    }
    if (destPort != null) {
        islBuilder.destPort(destPort);
    }
    if (availableBandwidth != null) {
        islBuilder.availableBandwidth(availableBandwidth);
    }
    Isl isl = islBuilder.build();
    islRepository.add(isl);
    return isl;
}
Also used : Isl(org.openkilda.model.Isl)

Aggregations

Isl (org.openkilda.model.Isl)83 Test (org.junit.Test)49 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)25 Endpoint (org.openkilda.wfm.share.model.Endpoint)18 Switch (org.openkilda.model.Switch)17 IslReference (org.openkilda.wfm.share.model.IslReference)11 SwitchId (org.openkilda.model.SwitchId)10 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)9 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)8 ArrayList (java.util.ArrayList)6 PathId (org.openkilda.model.PathId)6 Flow (org.openkilda.model.Flow)5 IslRepository (org.openkilda.persistence.repositories.IslRepository)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 FlowPath (org.openkilda.model.FlowPath)4 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)4 IslFrame (org.openkilda.persistence.ferma.frames.IslFrame)4