Fix: Store router identifier combines with scheme as a DeviceId

Use hashcode of mapping key as an unique mapping identifier.

Change-Id: I7ed602467e889b70279cb9fabdc6340fa4f42f99
diff --git a/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/impl/LispMappingProvider.java b/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/impl/LispMappingProvider.java
index eb985c3..b4fd841 100644
--- a/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/impl/LispMappingProvider.java
+++ b/providers/lisp/mapping/src/main/java/org/onosproject/provider/lisp/mapping/impl/LispMappingProvider.java
@@ -42,6 +42,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.List;
 
 import static org.onosproject.mapping.MappingStore.Type.MAP_CACHE;
@@ -137,7 +139,7 @@
                 return;
             }
 
-            DeviceId deviceId = DeviceId.deviceId(routerId.toString());
+            DeviceId deviceId = getDeviceId(routerId.toString());
             switch (msg.getType()) {
 
                 case LISP_MAP_REQUEST:
@@ -162,7 +164,7 @@
                 return;
             }
 
-            DeviceId deviceId = DeviceId.deviceId(routerId.toString());
+            DeviceId deviceId = getDeviceId(routerId.toString());
             switch (msg.getType()) {
 
                 case LISP_MAP_REPLY:
@@ -197,4 +199,19 @@
             });
         }
     }
+
+    /**
+     * Obtains the DeviceId contains IP address of LISP router.
+     *
+     * @param ip IP address
+     * @return DeviceId device identifier
+     */
+    private DeviceId getDeviceId(String ip) {
+        try {
+            return DeviceId.deviceId(new URI(SCHEME_NAME, ip, null));
+        } catch (URISyntaxException e) {
+            throw new IllegalArgumentException("Unable to build deviceID for device "
+                    + ip, e);
+        }
+    }
 }