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