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/TopologyEvents.java b/src/main/java/net/onrc/onos/core/topology/TopologyEvents.java
index 543c1cb..c930714 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyEvents.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyEvents.java
@@ -42,10 +42,11 @@
     private final Collection<HostEvent> removedHostEvents;
 
     /**
-     * Constructor.
+     * Constructor for added and removed events.
      *
      * @param addedMastershipEvents the collection of added Mastership Events.
-     * @param removedMastershipEvents the collection of removed Mastership Events.
+     * @param removedMastershipEvents the collection of removed Mastership
+     *        Events.
      * @param addedSwitchEvents the collection of added Switch Events.
      * @param removedSwitchEvents the collection of removed Switch Events.
      * @param addedPortEvents the collection of added Port Events.
@@ -90,6 +91,37 @@
     }
 
     /**
+     * Constructor for added events only.
+     *
+     * @param addedMastershipEvents the collection of added Mastership Events.
+     * @param addedSwitchEvents the collection of added Switch Events.
+     * @param addedPortEvents the collection of added Port Events.
+     * @param addedLinkEvents the collection of added Link Events.
+     * @param addedHostEvents the collection of added Host Events.
+     */
+    public TopologyEvents(Collection<MastershipEvent> addedMastershipEvents,
+                          Collection<SwitchEvent> addedSwitchEvents,
+                          Collection<PortEvent> addedPortEvents,
+                          Collection<LinkEvent> addedLinkEvents,
+                          Collection<HostEvent> addedHostEvents) {
+        this.addedMastershipEvents =
+            Collections.unmodifiableCollection(addedMastershipEvents);
+        this.removedMastershipEvents = Collections.emptyList();
+        this.addedSwitchEvents =
+            Collections.unmodifiableCollection(addedSwitchEvents);
+        this.removedSwitchEvents = Collections.emptyList();
+        this.addedPortEvents =
+            Collections.unmodifiableCollection(addedPortEvents);
+        this.removedPortEvents = Collections.emptyList();
+        this.addedLinkEvents =
+            Collections.unmodifiableCollection(addedLinkEvents);
+        this.removedLinkEvents = Collections.emptyList();
+        this.addedHostEvents =
+            Collections.unmodifiableCollection(addedHostEvents);
+        this.removedHostEvents = Collections.emptyList();
+    }
+
+    /**
      * Gets the collection of added Mastership Events.
      *
      * @return the collection of added Mastership Events.