ONOS-1871: Send Topology MastershipEvent info to Topology listeners.
The MastershipEvent info is needed by applications such as the GUI
(via the Websocket client).
NOTE: Previously, the Mastership Events were sent only when there
was any change, but no Mastership Events were sent when a listener
has just subscribed.
The solution is to add a mechanism for creating and sending Topology
Snapshot event to new listeners, and that event also includes
the Mastership Events.
The modifications are:
* Renamed and updated the ITopologyService API for adding/removing
Topology listeners:
OLD: registerTopologyListener() and deregisterTopologyListener()
NEW: addListener() and removeListener()
Also, addListener() has a second argument:
"boolean startFromSnapshot"
If that argument is true, and if the topology is not empty, the first
(expected) event to that listener should be a snapshot of the current
topology.
* Added TopologyEvents() constructor for ADDED events only. Such event
can be used to represent a snapshot of the topology.
* Added new APIs to TopologyInternal:
getAllSwitchEvents(), getAllPortEvents(), get AllLinkEvents(),
getAllHostEvents()
Those APIs are needed for creating a snapshot of the topology.
* Added a mechanism for creating empty (NO-OP) TopologyEvent instance,
and use that mechanism to "wake-up" the EventHandler processing thread
when it needs to send Topology Snapshot to a new listener.
This solution is (kind-of) a hack.
Change-Id: Ie1eb52242f58682aac61f54af29c3b5d291ac0bd
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyInternal.java b/src/main/java/net/onrc/onos/core/topology/TopologyInternal.java
index 10b008e..9656013 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyInternal.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyInternal.java
@@ -11,7 +11,6 @@
* Interface to reference internal self-contained elements.
*/
public interface TopologyInternal extends Topology {
-
/**
* Gets a SwitchEvent.
*
@@ -21,6 +20,13 @@
public SwitchEvent getSwitchEvent(Dpid dpid);
/**
+ * Gets all SwitchEvent entries.
+ *
+ * @return all SwitchEvent entries.
+ */
+ public Collection<SwitchEvent> getAllSwitchEvents();
+
+ /**
* Gets a PortEvent.
*
* @param port Port identifier
@@ -29,6 +35,13 @@
public PortEvent getPortEvent(SwitchPort port);
/**
+ * Gets all PortEvent entries.
+ *
+ * @return all PortEvent entries.
+ */
+ public Collection<PortEvent> getAllPortEvents();
+
+ /**
* Gets a LinkEvent.
*
* @param linkId Link identifier
@@ -46,14 +59,21 @@
public LinkEvent getLinkEvent(final LinkTuple linkId, final String type);
/**
- * Gets a LinkEvent.
+ * Gets a collection of LinkEvent entries.
*
* @param linkId Link identifier
- * @return Collection of LinkEvent
+ * @return Collection of LinkEvent entries.
*/
public Collection<LinkEvent> getLinkEvents(LinkTuple linkId);
/**
+ * Gets all LinkEvent entries.
+ *
+ * @return all LinkEvent entries.
+ */
+ public Collection<LinkEvent> getAllLinkEvents();
+
+ /**
* Gets a HostEvent.
*
* @param mac MACAddress of the host
@@ -61,4 +81,10 @@
*/
public HostEvent getHostEvent(MACAddress mac);
+ /**
+ * Gets all HostEvent entries.
+ *
+ * @return all HostEvent entries.
+ */
+ public Collection<HostEvent> getAllHostEvents();
}