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