Fix the event handler order (it is a quick fix - better solution is comming soon)

Change-Id: Ifce262a0949a38cbd164d867af0499a10774a0ed
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 e8ea854..a0253a8 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -290,17 +290,7 @@
         }
 
         // TODO: We handle multiple events with one path re-computation
-        if (!linkEntriesAdded.isEmpty()) {
-            processLinkAdd(linkEntriesAdded);
-        }
 
-        if (!portEntriesAdded.isEmpty()) {
-            processPortAdd(portEntriesAdded);
-        }
-
-        if (!switchAdded.isEmpty()) {
-            processSwitchAdd(switchAdded);
-        }
 
         if (!portEntriesRemoved.isEmpty()) {
             processPortRemoval(portEntriesRemoved);
@@ -318,6 +308,19 @@
             processMastershipRemoved(mastershipRemoved);
         }
 
+        if (!linkEntriesAdded.isEmpty()) {
+            processLinkAdd(linkEntriesAdded);
+        }
+
+        if (!portEntriesAdded.isEmpty()) {
+            processPortAdd(portEntriesAdded);
+        }
+
+        if (!switchAdded.isEmpty()) {
+            processSwitchAdd(switchAdded);
+        }
+
+
         log.debug("num events {}, num of process {}, "
                 + "num of Population {}", numOfEvents, numOfEventProcess,
                 numOfPopulation);