Search in sources :

Example 11 with DiscoveryNode

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

the class OFELinkBolt method initState.

@Override
@SuppressWarnings("unchecked")
public void initState(KeyValueState<String, Object> state) {
    watchDog = new WatchDog(watchDogInterval);
    // NB: First time the worker is created this will be null
    // TODO: what happens to state as workers go up or down
    Object payload = state.get(STATE_ID_DISCOVERY);
    if (payload == null) {
        payload = discoveryQueue = new LinkedList<>();
        state.put(islDiscoveryTopic, payload);
    } else {
        discoveryQueue = (LinkedList<DiscoveryNode>) payload;
    }
    discovery = new DiscoveryManager(islFilter, discoveryQueue, islHealthCheckInterval, islHealthCheckTimeout, islHealthFailureLimit);
}
Also used : DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) DiscoveryManager(org.openkilda.wfm.isl.DiscoveryManager) WatchDog(org.openkilda.wfm.WatchDog) LinkedList(java.util.LinkedList)

Example 12 with DiscoveryNode

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

the class DiscoveryManagerTest method handlePortUp.

@Test
public void handlePortUp() {
    // verify the switch/port is added
    // verify that adding an existing one doesn't crash it.
    List<DiscoveryNode> nodes;
    // Put in 1 node and verify it is there.
    DiscoveryNode node = new DiscoveryNode("sw1", "pt1", islHealthCheckInterval, islHealthFailureLimit);
    dm.handlePortUp(node.getSwitchId(), node.getPortId());
    nodes = dm.filterQueue(new DiscoveryManager.Node(node.getSwitchId(), node.getPortId()));
    assertEquals(1, nodes.size());
    assertEquals(node, nodes.get(0));
    // try to add it back in .. should still only be 1
    dm.handlePortUp(node.getSwitchId(), node.getPortId());
    nodes = dm.filterQueue(new DiscoveryManager.Node(node.getSwitchId(), node.getPortId()));
    assertEquals(1, nodes.size());
    assertEquals(node, nodes.get(0));
}
Also used : DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) Test(org.junit.Test)

Example 13 with DiscoveryNode

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

the class DiscoveryManagerTest method handlePortDown.

@Test
public void handlePortDown() {
    // verify the switch/port is deleted.
    // verify remove one that doesn't exist doesn't crash it
    List<DiscoveryNode> nodes;
    // Put in 1 node and then remove it. The handlePortUp test ensures the Port Up works.
    DiscoveryNode node = new DiscoveryNode("sw1", "pt1", islHealthCheckInterval, islHealthFailureLimit);
    dm.handlePortUp(node.getSwitchId(), node.getPortId());
    dm.handlePortDown(node.getSwitchId(), node.getPortId());
    nodes = dm.filterQueue(new DiscoveryManager.Node(node.getSwitchId(), node.getPortId()));
    assertEquals(0, nodes.size());
    // call PortDown again .. verify nothing bad happens.
    dm.handlePortDown(node.getSwitchId(), node.getPortId());
    nodes = dm.filterQueue(new DiscoveryManager.Node(node.getSwitchId(), node.getPortId()));
    assertEquals(0, nodes.size());
}
Also used : DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) Test(org.junit.Test)

Example 14 with DiscoveryNode

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

the class DiscoveryManagerTest method setupThreeNodes.

/**
 * several tests start with creating/adding 3 ports
 */
public void setupThreeNodes() {
    node1 = new DiscoveryNode("sw1", "pt1", islHealthCheckInterval, forlornLimit);
    node2 = new DiscoveryNode("sw1", "pt2", islHealthCheckInterval, forlornLimit);
    node3 = new DiscoveryNode("sw2", "pt1", islHealthCheckInterval, forlornLimit);
    dm.handlePortUp(node1.getSwitchId(), node1.getPortId());
    dm.handlePortUp(node2.getSwitchId(), node2.getPortId());
    dm.handlePortUp(node3.getSwitchId(), node3.getPortId());
}
Also used : DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode)

Example 15 with DiscoveryNode

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

the class OFELinkBoltTest method cacheLoadCheck.

/**
 * Part of warm mechanism checks. That test verifies appropriately unpack and fill inner
 * cache after getting network dump information from FL.
 */
@Test
public void cacheLoadCheck() throws IOException {
    // Send cache data and verify is inner state is ok
    SwitchInfoData sw1 = new SwitchInfoData("sw1", SwitchState.ADDED, "127.0.0.1", "localhost", "test switch", "kilda");
    SwitchInfoData sw2 = new SwitchInfoData("sw2", SwitchState.ADDED, "127.0.0.1", "localhost", "test switch", "kilda");
    PortInfoData sw1Port1 = new PortInfoData(sw1.getSwitchId(), 1, null, UP);
    PortInfoData sw2Port1 = new PortInfoData(sw2.getSwitchId(), 1, null, UP);
    NetworkInfoData dump = new NetworkInfoData("test", new HashSet<>(Arrays.asList(sw1, sw2)), new HashSet<>(Arrays.asList(sw1Port1, sw2Port1)), Collections.emptySet(), Collections.emptySet());
    InfoMessage info = new InfoMessage(dump, 0, DEFAULT_CORRELATION_ID, Destination.WFM);
    String request = objectMapper.writeValueAsString(info);
    Tuple dumpTuple = new TupleImpl(context, new Values(request), TASK_ID_BOLT, STREAM_ID_INPUT);
    bolt.doWork(dumpTuple);
    List<DiscoveryNode> discoveryQueue = bolt.getDiscoveryQueue();
    // I don't check discoveryQueue contents because that should be done in a test for
    // handleSwitchEvent and handlePortEvent.
    assertEquals(2, discoveryQueue.size());
}
Also used : NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) DiscoveryNode(org.openkilda.messaging.model.DiscoveryNode) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) TupleImpl(org.apache.storm.tuple.TupleImpl) Tuple(org.apache.storm.tuple.Tuple) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

DiscoveryNode (org.openkilda.messaging.model.DiscoveryNode)15 Test (org.junit.Test)4 LinkedList (java.util.LinkedList)2 Tuple (org.apache.storm.tuple.Tuple)1 TupleImpl (org.apache.storm.tuple.TupleImpl)1 Values (org.apache.storm.tuple.Values)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 NetworkInfoData (org.openkilda.messaging.info.discovery.NetworkInfoData)1 PortInfoData (org.openkilda.messaging.info.event.PortInfoData)1 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1 WatchDog (org.openkilda.wfm.WatchDog)1 DiscoveryManager (org.openkilda.wfm.isl.DiscoveryManager)1