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/util/EventEntry.java b/src/main/java/net/onrc/onos/core/util/EventEntry.java
index e1abcaf..d19a1ac 100644
--- a/src/main/java/net/onrc/onos/core/util/EventEntry.java
+++ b/src/main/java/net/onrc/onos/core/util/EventEntry.java
@@ -8,12 +8,13 @@
      * The event types.
      */
     public enum Type {
-        ENTRY_ADD,            // Add or update an entry
-        ENTRY_REMOVE            // Remove an entry
+        ENTRY_ADD,              // Add or update an entry
+        ENTRY_REMOVE,           // Remove an entry
+        ENTRY_NOOP              // NO-OP event (No Operation)
     }
 
-    private Type eventType;    // The event type
-    private T eventData;    // The relevant event data entry
+    private Type eventType;     // The event type
+    private T eventData;        // The relevant event data entry
 
     /**
      * Constructor for a given event type and event-related data entry.
@@ -27,7 +28,22 @@
     }
 
     /**
-     * Test whether the event type is ENTRY_ADD.
+     * Creates a NO-OP event.
+     * <p/>
+     * This is a factory method that can be called without an object:
+     * <p/>
+     * <code>
+     *   EventEntry<TopologyEvent> eventEntry = EventEntry.makeNoop();
+     * </code>
+     *
+     * @return a NO-OP event.
+     */
+    public static <T> EventEntry<T> makeNoop() {
+        return new EventEntry<T>(Type.ENTRY_NOOP, null);
+    }
+
+    /**
+     * Tests whether the event type is ENTRY_ADD.
      *
      * @return true if the event type is ENTRY_ADD, otherwise false.
      */
@@ -36,7 +52,7 @@
     }
 
     /**
-     * Test whether the event type is ENTRY_REMOVE.
+     * Tests whether the event type is ENTRY_REMOVE.
      *
      * @return true if the event type is ENTRY_REMOVE, otherwise false.
      */
@@ -45,7 +61,16 @@
     }
 
     /**
-     * Get the event type.
+     * Tests whether the event type is ENTRY_NOOP.
+     *
+     * @return true if the event type is ENTRY_NOOP, otherwise false.
+     */
+    public boolean isNoop() {
+        return (this.eventType == Type.ENTRY_NOOP);
+    }
+
+    /**
+     * Gets the event type.
      *
      * @return the event type.
      */
@@ -54,7 +79,7 @@
     }
 
     /**
-     * Get the event-related data entry.
+     * Gets the event-related data entry.
      *
      * @return the event-related data entry.
      */