Fixed 2 bugs in SRManager:
  - setting mpls id when not pushing label
  - handling the same topology event multiple times

Change-Id: I04bf00942cd11faf993b431151b5bf2dae7a7ab2
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
index e3d3470..a9446ef 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -288,7 +288,6 @@
      *
      */
     private void handleTopologyChangeEvents() {
-
         numOfEventProcess ++;
 
         Collection<LinkData> linkEntriesAdded = new ArrayList<LinkData>();
@@ -306,7 +305,6 @@
             // Ex: link s1-s2 down, link s1-s2 up --> Do nothing
             // Ex: ink s1-s2 up, s1-p1,p2 down --> link s1-s2 down
             TopologyEvents topologyEvents = topologyEventQueue.poll();
-
             linkEntriesAdded.addAll(topologyEvents.getAddedLinkDataEntries());
             portEntriesAdded.addAll(topologyEvents.getAddedPortDataEntries());
             portEntriesRemoved.addAll(topologyEvents.getRemovedPortDataEntries());
@@ -343,13 +341,21 @@
             if (!switchAdded.isEmpty()) {
                 processSwitchAdd(switchAdded);
             }
+            linkEntriesAdded.clear();
+            portEntriesAdded.clear();
+            portEntriesRemoved.clear();
+            linkEntriesRemoved.clear();
+            switchAdded.clear();
+            switchRemoved.clear();
+            mastershipRemoved.clear();
+
         }
 
         // TODO: 100ms is enough to check both mastership removed events
         // and the port removed events? What if the PORT_STATUS packets comes late?
         if (!mastershipRemoved.isEmpty()) {
             if (portEntriesRemoved.isEmpty()) {
-                log.debug("Just mastership is removed. Do not anthing.");
+                log.debug("Just mastership is removed. Do not do anthing.");
             }
             else {
                 HashMap<String, MastershipData> mastershipToRemove =
@@ -894,7 +900,7 @@
             //actions.add(pushMplsAction);
             //actions.add(copyTtlOutAction);
             //actions.add(decMplsTtlAction);
-            actions.add(setIdAction);
+            // actions.add(setIdAction);
             groupAction.setEdgeLabel(Integer.parseInt(mplsLabel));
 
         }
@@ -914,7 +920,7 @@
                 //actions.add(pushMplsAction);
                 //actions.add(copyTtlOutAction);
                 //actions.add(decMplsTtlAction);
-                actions.add(setIdAction);
+                // actions.add(setIdAction);
                 groupAction.setEdgeLabel(Integer.parseInt(mplsLabel));
             }
         }