BugFix: LinkEvent should not be used as identifier.

Change-Id: I0e201bab52414d6b3c8cc048502440f24c5c1595
diff --git a/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java b/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java
index 27de191..15a320f 100644
--- a/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java
+++ b/src/main/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModule.java
@@ -45,6 +45,7 @@
 import net.onrc.onos.core.topology.SwitchEvent;
 import net.onrc.onos.core.topology.TopologyEvents;
 import net.onrc.onos.core.util.Dpid;
+import net.onrc.onos.core.util.LinkTuple;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -203,7 +204,7 @@
     private static final String INTENT_STATE_EVENT_CHANNEL_NAME = "onos.pathintent_state";
     private static final Logger log = LoggerFactory.getLogger(PathCalcRuntimeModule.class);
 
-    private HashSet<LinkEvent> unmatchedLinkEvents = new HashSet<>();
+    private HashSet<LinkTuple> unmatchedLinkEvents = new HashSet<>();
     private ConcurrentMap<String, Set<Long>> intentInstalledMap = new ConcurrentHashMap<String, Set<Long>>();
     private ConcurrentMap<String, Intent> staleIntents = new ConcurrentHashMap<String, Intent>();
     private DeleteIntentsTracker deleteIntentsTracker = new DeleteIntentsTracker();
@@ -652,21 +653,19 @@
 
         boolean rerouteAll = false;
         for (LinkEvent le : topologyEvents.getAddedLinkEvents()) {
-            LinkEvent rev = new LinkEvent(le.getDst().getDpid(),
-                    le.getDst().getPortNumber(), le.getSrc().getDpid(),
-                    le.getSrc().getPortNumber());
+            final LinkTuple rev = new LinkTuple(le.getDst(), le.getSrc());
             if (unmatchedLinkEvents.contains(rev)) {
                 rerouteAll = true;
                 unmatchedLinkEvents.remove(rev);
                 log.debug("Found matched LinkEvent: {} {}", rev, le);
             } else {
-                unmatchedLinkEvents.add(le);
+                unmatchedLinkEvents.add(le.getLinkTuple());
                 log.debug("Adding unmatched LinkEvent: {}", le);
             }
         }
         for (LinkEvent le : topologyEvents.getRemovedLinkEvents()) {
-            if (unmatchedLinkEvents.contains(le)) {
-                unmatchedLinkEvents.remove(le);
+            if (unmatchedLinkEvents.contains(le.getLinkTuple())) {
+                unmatchedLinkEvents.remove(le.getLinkTuple());
                 log.debug("Removing LinkEvent: {}", le);
             }
         }
diff --git a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
index 1ae1bb9..76ef3b0 100644
--- a/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
+++ b/src/test/java/net/onrc/onos/core/intent/runtime/PathCalcRuntimeModuleTest.java
@@ -23,6 +23,7 @@
 import net.onrc.onos.core.topology.MockTopology;
 import net.onrc.onos.core.topology.PortEvent;
 import net.onrc.onos.core.topology.SwitchEvent;
+import net.onrc.onos.core.topology.TopologyElement;
 import net.onrc.onos.core.topology.TopologyEvents;
 import net.onrc.onos.core.util.SwitchPort;
 
@@ -465,6 +466,8 @@
         topology.removeLink(2L, 21L, 1L, 12L);
         LinkEvent linkEvent1 = new LinkEvent(new SwitchPort(1L, 12L), new SwitchPort(2L, 21L));
         LinkEvent linkEvent2 = new LinkEvent(new SwitchPort(2L, 21L), new SwitchPort(1L, 12L));
+        linkEvent1.createStringAttribute(TopologyElement.TYPE, TopologyElement.TYPE_PACKET_LAYER);
+        linkEvent2.createStringAttribute(TopologyElement.TYPE, TopologyElement.TYPE_PACKET_LAYER);
         removedLinkEvents.add(linkEvent1);
         removedLinkEvents.add(linkEvent2);
 
@@ -699,6 +702,8 @@
         topology.removeLink(2L, 21L, 1L, 12L);
         final LinkEvent linkEvent1 = new LinkEvent(new SwitchPort(1L, 12L), new SwitchPort(2L, 21L));
         final LinkEvent linkEvent2 = new LinkEvent(new SwitchPort(2L, 21L), new SwitchPort(1L, 12L));
+        linkEvent1.createStringAttribute(TopologyElement.TYPE, TopologyElement.TYPE_PACKET_LAYER);
+        linkEvent2.createStringAttribute(TopologyElement.TYPE, TopologyElement.TYPE_PACKET_LAYER);
         removedLinkEvents.add(linkEvent1);
         removedLinkEvents.add(linkEvent2);