yuanyou

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

Change-Id: I8bad7a6419039cf67bc843f9b8c54f07fc4a02b7
......@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Objects;
import java.util.Set;
/**
* Representation of a Router gateway.
......@@ -28,11 +29,11 @@ public final class RouterGateway {
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 @@ public final class RouterGateway {
* @return RouterGateway
*/
public static RouterGateway routerGateway(TenantNetworkId networkId, boolean enableSnat,
Collection<FixedIp> externalFixedIps) {
Set<FixedIp> externalFixedIps) {
return new RouterGateway(networkId, enableSnat, externalFixedIps);
}
......
......@@ -21,6 +21,7 @@ import static org.slf4j.LoggerFactory.getLogger;
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 @@ public class FloatingIpManager implements FloatingIpService {
.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)
......
......@@ -435,10 +435,10 @@ public class RouterWebResource extends AbstractWebResource {
} 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 @@ public class RouterWebResource extends AbstractWebResource {
* @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;
......