sangho
Committed by Gerrit Code Review

[ONOS-4983] Fix the bug of gateway information modification

Change-Id: Ie5b672b5034e2cdac08d674da510e21f02588e6d
...@@ -21,7 +21,6 @@ import com.google.common.collect.Lists; ...@@ -21,7 +21,6 @@ import com.google.common.collect.Lists;
21 import org.apache.felix.scr.annotations.Activate; 21 import org.apache.felix.scr.annotations.Activate;
22 import org.apache.felix.scr.annotations.Component; 22 import org.apache.felix.scr.annotations.Component;
23 import org.apache.felix.scr.annotations.Deactivate; 23 import org.apache.felix.scr.annotations.Deactivate;
24 -
25 import org.apache.felix.scr.annotations.Reference; 24 import org.apache.felix.scr.annotations.Reference;
26 import org.apache.felix.scr.annotations.ReferenceCardinality; 25 import org.apache.felix.scr.annotations.ReferenceCardinality;
27 import org.apache.felix.scr.annotations.Service; 26 import org.apache.felix.scr.annotations.Service;
...@@ -29,7 +28,6 @@ import org.onlab.util.KryoNamespace; ...@@ -29,7 +28,6 @@ import org.onlab.util.KryoNamespace;
29 import org.onlab.util.Tools; 28 import org.onlab.util.Tools;
30 import org.onosproject.core.ApplicationId; 29 import org.onosproject.core.ApplicationId;
31 import org.onosproject.core.CoreService; 30 import org.onosproject.core.CoreService;
32 -
33 import org.onosproject.core.GroupId; 31 import org.onosproject.core.GroupId;
34 import org.onosproject.net.DeviceId; 32 import org.onosproject.net.DeviceId;
35 import org.onosproject.net.Port; 33 import org.onosproject.net.Port;
...@@ -50,11 +48,6 @@ import org.onosproject.net.group.GroupService; ...@@ -50,11 +48,6 @@ import org.onosproject.net.group.GroupService;
50 import org.onosproject.scalablegateway.api.GatewayNode; 48 import org.onosproject.scalablegateway.api.GatewayNode;
51 import org.onosproject.scalablegateway.api.GatewayNodeConfig; 49 import org.onosproject.scalablegateway.api.GatewayNodeConfig;
52 import org.onosproject.scalablegateway.api.ScalableGatewayService; 50 import org.onosproject.scalablegateway.api.ScalableGatewayService;
53 -
54 -import java.util.List;
55 -import java.util.Objects;
56 -import java.util.Optional;
57 -
58 import org.onosproject.store.serializers.KryoNamespaces; 51 import org.onosproject.store.serializers.KryoNamespaces;
59 import org.onosproject.store.service.ConsistentMap; 52 import org.onosproject.store.service.ConsistentMap;
60 import org.onosproject.store.service.Serializer; 53 import org.onosproject.store.service.Serializer;
...@@ -63,6 +56,10 @@ import org.onosproject.store.service.Versioned; ...@@ -63,6 +56,10 @@ import org.onosproject.store.service.Versioned;
63 import org.slf4j.Logger; 56 import org.slf4j.Logger;
64 import org.slf4j.LoggerFactory; 57 import org.slf4j.LoggerFactory;
65 58
59 +import java.util.List;
60 +import java.util.Objects;
61 +import java.util.Optional;
62 +
66 import static org.onosproject.net.AnnotationKeys.PORT_NAME; 63 import static org.onosproject.net.AnnotationKeys.PORT_NAME;
67 64
68 /** 65 /**
...@@ -210,11 +207,16 @@ public class ScalableGatewayManager implements ScalableGatewayService { ...@@ -210,11 +207,16 @@ public class ScalableGatewayManager implements ScalableGatewayService {
210 207
211 @Override 208 @Override
212 public synchronized boolean addGatewayNode(GatewayNode gatewayNode) { 209 public synchronized boolean addGatewayNode(GatewayNode gatewayNode) {
213 - Versioned<GatewayNode> existingNode = gatewayNodeMap.putIfAbsent( 210 + Versioned<GatewayNode> existingNode = gatewayNodeMap.put(gatewayNode.getGatewayDeviceId(),
214 - gatewayNode.getGatewayDeviceId(), gatewayNode); 211 + gatewayNode);
215 if (existingNode == null) { 212 if (existingNode == null) {
216 updateGatewayGroup(gatewayNode, true); 213 updateGatewayGroup(gatewayNode, true);
217 - log.info("Added {} to gateway pool", gatewayNode); 214 + log.info("Gateway {} is added to Gateway pool", gatewayNode);
215 + return true;
216 + } else if (!existingNode.value().equals(gatewayNode)) {
217 + updateGatewayGroup(existingNode.value(), false);
218 + updateGatewayGroup(gatewayNode, true);
219 + log.info("Gateway {} is updated", gatewayNode);
218 return true; 220 return true;
219 } else { 221 } else {
220 return false; 222 return false;
......