ONOS-4492 Fix bug of vrouter and floatingip can't syncronized between nodes
Change-Id: I8bad7a6419039cf67bc843f9b8c54f07fc4a02b7
Showing
3 changed files
with
10 additions
and
7 deletions
... | @@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
20 | 20 | ||
21 | import java.util.Collection; | 21 | import java.util.Collection; |
22 | import java.util.Objects; | 22 | import java.util.Objects; |
23 | +import java.util.Set; | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * Representation of a Router gateway. | 26 | * Representation of a Router gateway. |
... | @@ -28,11 +29,11 @@ public final class RouterGateway { | ... | @@ -28,11 +29,11 @@ public final class RouterGateway { |
28 | 29 | ||
29 | private final TenantNetworkId networkId; | 30 | private final TenantNetworkId networkId; |
30 | private final boolean enableSnat; | 31 | private final boolean enableSnat; |
31 | - private final Collection<FixedIp> externalFixedIps; | 32 | + private final Set<FixedIp> externalFixedIps; |
32 | 33 | ||
33 | // Public construction is prohibited | 34 | // Public construction is prohibited |
34 | private RouterGateway(TenantNetworkId networkId, boolean enableSnat, | 35 | private RouterGateway(TenantNetworkId networkId, boolean enableSnat, |
35 | - Collection<FixedIp> externalFixedIps) { | 36 | + Set<FixedIp> externalFixedIps) { |
36 | this.networkId = checkNotNull(networkId, "networkId cannot be null"); | 37 | this.networkId = checkNotNull(networkId, "networkId cannot be null"); |
37 | this.enableSnat = checkNotNull(enableSnat, "enableSnat cannot be null"); | 38 | this.enableSnat = checkNotNull(enableSnat, "enableSnat cannot be null"); |
38 | this.externalFixedIps = checkNotNull(externalFixedIps, "externalFixedIps cannot be null"); | 39 | this.externalFixedIps = checkNotNull(externalFixedIps, "externalFixedIps cannot be null"); |
... | @@ -47,7 +48,7 @@ public final class RouterGateway { | ... | @@ -47,7 +48,7 @@ public final class RouterGateway { |
47 | * @return RouterGateway | 48 | * @return RouterGateway |
48 | */ | 49 | */ |
49 | public static RouterGateway routerGateway(TenantNetworkId networkId, boolean enableSnat, | 50 | public static RouterGateway routerGateway(TenantNetworkId networkId, boolean enableSnat, |
50 | - Collection<FixedIp> externalFixedIps) { | 51 | + Set<FixedIp> externalFixedIps) { |
51 | return new RouterGateway(networkId, enableSnat, externalFixedIps); | 52 | return new RouterGateway(networkId, enableSnat, externalFixedIps); |
52 | } | 53 | } |
53 | 54 | ... | ... |
... | @@ -21,6 +21,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -21,6 +21,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
21 | import java.util.Collection; | 21 | import java.util.Collection; |
22 | import java.util.Collections; | 22 | import java.util.Collections; |
23 | import java.util.Set; | 23 | import java.util.Set; |
24 | +import java.util.UUID; | ||
24 | 25 | ||
25 | import org.apache.felix.scr.annotations.Activate; | 26 | import org.apache.felix.scr.annotations.Activate; |
26 | import org.apache.felix.scr.annotations.Component; | 27 | import org.apache.felix.scr.annotations.Component; |
... | @@ -102,7 +103,8 @@ public class FloatingIpManager implements FloatingIpService { | ... | @@ -102,7 +103,8 @@ public class FloatingIpManager implements FloatingIpService { |
102 | .register(FloatingIp.class, FloatingIpId.class, | 103 | .register(FloatingIp.class, FloatingIpId.class, |
103 | TenantNetworkId.class, TenantId.class, | 104 | TenantNetworkId.class, TenantId.class, |
104 | FloatingIp.Status.class, RouterId.class, | 105 | FloatingIp.Status.class, RouterId.class, |
105 | - VirtualPortId.class, DefaultFloatingIp.class); | 106 | + VirtualPortId.class, DefaultFloatingIp.class, |
107 | + UUID.class); | ||
106 | floatingIpStore = storageService | 108 | floatingIpStore = storageService |
107 | .<FloatingIpId, FloatingIp>eventuallyConsistentMapBuilder() | 109 | .<FloatingIpId, FloatingIp>eventuallyConsistentMapBuilder() |
108 | .withName(FLOATINGIPSTORE).withSerializer(serializer) | 110 | .withName(FLOATINGIPSTORE).withSerializer(serializer) | ... | ... |
... | @@ -435,10 +435,10 @@ public class RouterWebResource extends AbstractWebResource { | ... | @@ -435,10 +435,10 @@ public class RouterWebResource extends AbstractWebResource { |
435 | } else if (gateway.get("external_fixed_ips").isNull()) { | 435 | } else if (gateway.get("external_fixed_ips").isNull()) { |
436 | throw new IllegalArgumentException("external_fixed_ips should not be empty"); | 436 | throw new IllegalArgumentException("external_fixed_ips should not be empty"); |
437 | } | 437 | } |
438 | - Collection<FixedIp> fixedIpList = jsonNodeToFixedIp(gateway | 438 | + Iterable<FixedIp> fixedIpList = jsonNodeToFixedIp(gateway |
439 | .get("external_fixed_ips")); | 439 | .get("external_fixed_ips")); |
440 | RouterGateway gatewayObj = RouterGateway | 440 | RouterGateway gatewayObj = RouterGateway |
441 | - .routerGateway(networkId, enableSnat, fixedIpList); | 441 | + .routerGateway(networkId, enableSnat, Sets.newHashSet(fixedIpList)); |
442 | return gatewayObj; | 442 | return gatewayObj; |
443 | } | 443 | } |
444 | 444 | ||
... | @@ -448,7 +448,7 @@ public class RouterWebResource extends AbstractWebResource { | ... | @@ -448,7 +448,7 @@ public class RouterWebResource extends AbstractWebResource { |
448 | * @param fixedIp the allocationPools JsonNode | 448 | * @param fixedIp the allocationPools JsonNode |
449 | * @return a collection of fixedIp | 449 | * @return a collection of fixedIp |
450 | */ | 450 | */ |
451 | - private Collection<FixedIp> jsonNodeToFixedIp(JsonNode fixedIp) { | 451 | + private Iterable<FixedIp> jsonNodeToFixedIp(JsonNode fixedIp) { |
452 | checkNotNull(fixedIp, JSON_NOT_NULL); | 452 | checkNotNull(fixedIp, JSON_NOT_NULL); |
453 | ConcurrentMap<Integer, FixedIp> fixedIpMaps = Maps.newConcurrentMap(); | 453 | ConcurrentMap<Integer, FixedIp> fixedIpMaps = Maps.newConcurrentMap(); |
454 | Integer i = 0; | 454 | Integer i = 0; | ... | ... |
-
Please register or login to post a comment