ONOS-4492 Fix bug of vrouter and floatingip can't syncronized between nodes

Change-Id: I8bad7a6419039cf67bc843f9b8c54f07fc4a02b7
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java
index d7868da..dd8911e 100644
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java
+++ b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java
@@ -20,6 +20,7 @@
 
 import java.util.Collection;
 import java.util.Objects;
+import java.util.Set;
 
 /**
  * Representation of a Router gateway.
@@ -28,11 +29,11 @@
 
     private final TenantNetworkId networkId;
     private final boolean enableSnat;
-    private final Collection<FixedIp> externalFixedIps;
+    private final Set<FixedIp> externalFixedIps;
 
     // Public construction is prohibited
     private RouterGateway(TenantNetworkId networkId, boolean enableSnat,
-                         Collection<FixedIp> externalFixedIps) {
+                         Set<FixedIp> externalFixedIps) {
         this.networkId = checkNotNull(networkId, "networkId cannot be null");
         this.enableSnat = checkNotNull(enableSnat, "enableSnat cannot be null");
         this.externalFixedIps = checkNotNull(externalFixedIps, "externalFixedIps cannot be null");
@@ -47,7 +48,7 @@
      * @return RouterGateway
      */
     public static RouterGateway routerGateway(TenantNetworkId networkId, boolean enableSnat,
-                                              Collection<FixedIp> externalFixedIps) {
+                                              Set<FixedIp> externalFixedIps) {
         return new RouterGateway(networkId, enableSnat, externalFixedIps);
     }
 
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/FloatingIpManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/FloatingIpManager.java
index 9fd73f5..a8b4edf 100644
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/FloatingIpManager.java
+++ b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/FloatingIpManager.java
@@ -21,6 +21,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Set;
+import java.util.UUID;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -102,7 +103,8 @@
                 .register(FloatingIp.class, FloatingIpId.class,
                           TenantNetworkId.class, TenantId.class,
                           FloatingIp.Status.class, RouterId.class,
-                          VirtualPortId.class, DefaultFloatingIp.class);
+                          VirtualPortId.class, DefaultFloatingIp.class,
+                          UUID.class);
         floatingIpStore = storageService
                 .<FloatingIpId, FloatingIp>eventuallyConsistentMapBuilder()
                 .withName(FLOATINGIPSTORE).withSerializer(serializer)
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
index 84fd73c..a4b3fa3 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
@@ -435,10 +435,10 @@
         } else if (gateway.get("external_fixed_ips").isNull()) {
             throw new IllegalArgumentException("external_fixed_ips should not be empty");
         }
-        Collection<FixedIp> fixedIpList = jsonNodeToFixedIp(gateway
+        Iterable<FixedIp> fixedIpList = jsonNodeToFixedIp(gateway
                 .get("external_fixed_ips"));
         RouterGateway gatewayObj = RouterGateway
-                .routerGateway(networkId, enableSnat, fixedIpList);
+                .routerGateway(networkId, enableSnat, Sets.newHashSet(fixedIpList));
         return gatewayObj;
     }
 
@@ -448,7 +448,7 @@
      * @param fixedIp the allocationPools JsonNode
      * @return a collection of fixedIp
      */
-    private Collection<FixedIp> jsonNodeToFixedIp(JsonNode fixedIp) {
+    private Iterable<FixedIp> jsonNodeToFixedIp(JsonNode fixedIp) {
         checkNotNull(fixedIp, JSON_NOT_NULL);
         ConcurrentMap<Integer, FixedIp> fixedIpMaps = Maps.newConcurrentMap();
         Integer i = 0;