Deleted device manager's inside global cache and changed to use the topo cache.
The reason is it caused some unmatched condition with the topo cache when link and port status was changed.
The DeviceEvent timing is changed.
The old one sends it when it is appeared, or attachment point or IP is changed, but now it sends every packet-in to update last-time-seen.

Note:
Looks like there is some vulnerability for changing the mastership of switches.
During mastership changes, the intent reroute is occured, and for a short period of time links or ports haven't found,
so the intent cann't calcurate its path.

Change-Id: I311fa5ad368ca833915999ad112274f1a7979387
diff --git a/src/main/java/net/onrc/onos/core/topology/DeviceImpl.java b/src/main/java/net/onrc/onos/core/topology/DeviceImpl.java
index fc1628e..0ba23dd 100644
--- a/src/main/java/net/onrc/onos/core/topology/DeviceImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/DeviceImpl.java
@@ -47,19 +47,19 @@
     /**
      * Only {@link TopologyManager} should use this method.
      *
-     * @param p
+     * @param port the port that the device is attached to
      */
-    void addAttachmentPoint(Port p) {
-        this.attachmentPoints.remove(p);
-        this.attachmentPoints.addFirst(p);
+    void addAttachmentPoint(Port port) {
+        this.attachmentPoints.remove(port);
+        this.attachmentPoints.addFirst(port);
     }
 
     /**
      * Only {@link TopologyManager} should use this method.
      *
-     * @param p
+     * @param port the port that the device is attached to
      */
-    boolean removeAttachmentPoint(Port p) {
-        return this.attachmentPoints.remove(p);
+    boolean removeAttachmentPoint(Port port) {
+        return this.attachmentPoints.remove(port);
     }
 }
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
index 8e0a4e6..343102b 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
@@ -1085,6 +1085,8 @@
             attachmentFound = true;
         }
 
+        deviceImpl.setLastSeenTime(deviceEvent.getLastSeenTime());
+
         // Update the device in the topology
         if (attachmentFound) {
             log.debug("Storing the device info into the Topology: mac {}", deviceEvent.getMac());
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index 36399bc..eb76c1e 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -307,8 +307,7 @@
     public void onosDeviceAdded(OnosDevice device) {
         log.debug("Called onosDeviceAdded mac {}", device.getMacAddress());
 
-        SwitchPort sp = new SwitchPort(device.getSwitchDPID(),
-                (long) device.getSwitchPort());
+        SwitchPort sp = new SwitchPort(device.getSwitchDPID(), device.getSwitchPort());
         List<SwitchPort> spLists = new ArrayList<SwitchPort>();
         spLists.add(sp);
         DeviceEvent event = new DeviceEvent(device.getMacAddress());