Search in sources :

Example 1 with Node

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

the class TopologyServiceImplTest method network.

@Test
public void network() throws Exception {
    List<Node> nodes = Arrays.asList(new Node(srcSwitchId, Collections.singletonList(firstTransitSwitchId)), new Node(firstTransitSwitchId, Arrays.asList(srcSwitchId, secondTransitSwitchId)), new Node(secondTransitSwitchId, Arrays.asList(firstTransitSwitchId, dstSwitchId)), new Node(dstSwitchId, Collections.singletonList(secondTransitSwitchId)));
    Topology topology = topologyService.network(DEFAULT_CORRELATION_ID);
    assertEquals(new Topology(nodes), topology);
    System.out.println(topology.toString());
}
Also used : Node(org.openkilda.topology.model.Node) Topology(org.openkilda.topology.model.Topology) Test(org.junit.Test)

Example 2 with Node

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

the class TopologyServiceImpl method network.

/**
 * {@inheritDoc}
 */
@Override
public Topology network(String correlationId) {
    logger.debug("Dumping topology: {}={}", CORRELATION_ID, correlationId);
    List<Isl> isls = islRepository.getAllIsl();
    logger.debug("Found isls: {}={}, {}", CORRELATION_ID, correlationId, isls);
    Iterable<Switch> switches = switchRepository.findAll();
    List<Node> nodes = new ArrayList<>();
    for (Switch sw : switches) {
        List<String> relationships = new ArrayList<>();
        for (Isl isl : isls) {
            if (isl.getSourceSwitch().equals(sw.getName())) {
                relationships.add(isl.getDestinationSwitch());
            }
        }
        nodes.add(new Node(sw.getName(), relationships));
    }
    return new Topology(nodes);
}
Also used : Isl(org.openkilda.topology.domain.Isl) Switch(org.openkilda.topology.domain.Switch) Node(org.openkilda.topology.model.Node) ArrayList(java.util.ArrayList) Topology(org.openkilda.topology.model.Topology)

Aggregations

Node (org.openkilda.topology.model.Node)2 Topology (org.openkilda.topology.model.Topology)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Isl (org.openkilda.topology.domain.Isl)1 Switch (org.openkilda.topology.domain.Switch)1