Search in sources :

Example 36 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class NetworkCache method getDirectlyConnectedSwitches.

/**
 * Gets all {@link SwitchInfoData} instances directly connected to specified.
 *
 * @param switchId switch id
 * @return {@link Set} of {@link SwitchInfoData} instances
 * @throws CacheException if {@link SwitchInfoData} instance with specified id does not exist
 */
public Set<SwitchInfoData> getDirectlyConnectedSwitches(String switchId) throws CacheException {
    logger.debug("Get all switches directly connected to {} switch ", switchId);
    SwitchInfoData node = getSwitch(switchId);
    return network.adjacentNodes(node);
}
Also used : SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData)

Example 37 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class NetworkCache method getIslsBySource.

/**
 * Gets all {@link IslInfoData} instances which start node is specified {@link SwitchInfoData} instance.
 *
 * @param switchId {@link SwitchInfoData} instance id
 * @return {@link Set} of {@link IslInfoData} instances
 * @throws CacheException if {@link SwitchInfoData} instance with specified id does not exists
 */
public Set<IslInfoData> getIslsBySource(String switchId) {
    logger.debug("Get all isls by source switch {}", switchId);
    SwitchInfoData startNode = getSwitch(switchId);
    return network.outEdges(startNode);
}
Also used : SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData)

Example 38 with SwitchInfoData

use of org.openkilda.messaging.info.event.SwitchInfoData in project open-kilda by telstra.

the class TopologyEventsBasicTest method the_links_disappear_from_the_topology_engine.

@Then("^the links disappear from the topology engine\\.$")
public void the_links_disappear_from_the_topology_engine() throws Exception {
    // todo check whether we need to wait until links will disappear or we might delete them instantly when switch goes down
    TimeUnit.SECONDS.sleep(15);
    final SwitchInfoData middleSwitch = getMiddleSwitch(SwitchesUtils.dumpSwitches());
    final List<IslInfoData> links = LinksUtils.dumpLinks();
    List<IslInfoData> switchLinks = links.stream().filter(isl -> isLinkBelongToSwitch(middleSwitch.getSwitchId(), isl)).filter(isl -> isl.getState() == IslChangeType.DISCOVERED).collect(Collectors.toList());
    assertTrue("Switch shouldn't have any active links", switchLinks.isEmpty());
}
Also used : IntStream(java.util.stream.IntStream) StringUtils(org.apache.commons.lang.StringUtils) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) SwitchState(org.openkilda.messaging.info.event.SwitchState) LinksUtils(org.openkilda.LinksUtils) Assert.assertTrue(org.junit.Assert.assertTrue) IslChangeType(org.openkilda.messaging.info.event.IslChangeType) PathNode(org.openkilda.messaging.info.event.PathNode) Collectors(java.util.stream.Collectors) TestTopologyBuilder(org.openkilda.topo.builders.TestTopologyBuilder) NumberUtils(org.apache.commons.lang.math.NumberUtils) Assert.assertThat(org.junit.Assert.assertThat) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.is(org.hamcrest.Matchers.is) SwitchesUtils(org.openkilda.SwitchesUtils) PendingException(cucumber.api.PendingException) Comparator(java.util.Comparator) Then(cucumber.api.java.en.Then) When(cucumber.api.java.en.When) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Then(cucumber.api.java.en.Then)

Aggregations

SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)38 Test (org.junit.Test)11 InfoMessage (org.openkilda.messaging.info.InfoMessage)9 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)9 CacheException (org.openkilda.messaging.error.CacheException)8 CommandMessage (org.openkilda.messaging.command.CommandMessage)7 PathNode (org.openkilda.messaging.info.event.PathNode)6 PortInfoData (org.openkilda.messaging.info.event.PortInfoData)5 Transactional (org.springframework.transaction.annotation.Transactional)5 IOException (java.io.IOException)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 InfoData (org.openkilda.messaging.info.InfoData)4 NetworkInfoData (org.openkilda.messaging.info.discovery.NetworkInfoData)4 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)4 Then (cucumber.api.java.en.Then)3 When (cucumber.api.java.en.When)3 Comparator (java.util.Comparator)3 Switch (org.openkilda.topology.domain.Switch)3 PendingException (cucumber.api.PendingException)2