Satish K
Committed by Gerrit Code Review

Functionality issue. 1) REMOVE event is generated though the tunnel is not remov…

…ed 2) Logic w.r.t producer name conflict with Tunnel Manager and Store

Change-Id: I9f4fea885edda97029863b90e2397446c39fdbe3
...@@ -78,7 +78,7 @@ public class DistributedTunnelStore ...@@ -78,7 +78,7 @@ public class DistributedTunnelStore
78 /** 78 /**
79 * The topic used for obtaining globally unique ids. 79 * The topic used for obtaining globally unique ids.
80 */ 80 */
81 - private String runnelOpTopoic = "tunnel-ops-ids"; 81 + private String tunnelOpTopic = "tunnel-ops-ids";
82 82
83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 83 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
84 protected ClusterCommunicationService clusterCommunicator; 84 protected ClusterCommunicationService clusterCommunicator;
...@@ -131,7 +131,7 @@ public class DistributedTunnelStore ...@@ -131,7 +131,7 @@ public class DistributedTunnelStore
131 .<ApplicationId, Set<TunnelSubscription>>eventuallyConsistentMapBuilder() 131 .<ApplicationId, Set<TunnelSubscription>>eventuallyConsistentMapBuilder()
132 .withName("type_tunnel").withSerializer(serializer) 132 .withName("type_tunnel").withSerializer(serializer)
133 .withTimestampProvider((k, v) -> new WallClockTimestamp()).build(); 133 .withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
134 - idGenerator = coreService.getIdGenerator(runnelOpTopoic); 134 + idGenerator = coreService.getIdGenerator(tunnelOpTopic);
135 log.info("Started"); 135 log.info("Started");
136 } 136 }
137 137
...@@ -236,19 +236,24 @@ public class DistributedTunnelStore ...@@ -236,19 +236,24 @@ public class DistributedTunnelStore
236 List<TunnelEvent> ls = new ArrayList<TunnelEvent>(); 236 List<TunnelEvent> ls = new ArrayList<TunnelEvent>();
237 for (TunnelId id : idSet) { 237 for (TunnelId id : idSet) {
238 deletedTunnel = tunnelIdAsKeyStore.get(id); 238 deletedTunnel = tunnelIdAsKeyStore.get(id);
239 - event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED, 239 +
240 - deletedTunnel); 240 + if (producerName == null || (producerName != null
241 - ls.add(event); 241 + && producerName.equals(deletedTunnel.providerId()))) {
242 - if (producerName.equals(deletedTunnel.providerId())) {
243 tunnelIdAsKeyStore.remove(deletedTunnel.tunnelId()); 242 tunnelIdAsKeyStore.remove(deletedTunnel.tunnelId());
244 tunnelNameAsKeyStore.get(deletedTunnel.tunnelName()) 243 tunnelNameAsKeyStore.get(deletedTunnel.tunnelName())
245 .remove(deletedTunnel.tunnelId()); 244 .remove(deletedTunnel.tunnelId());
246 srcAndDstKeyStore.get(key).remove(deletedTunnel.tunnelId()); 245 srcAndDstKeyStore.get(key).remove(deletedTunnel.tunnelId());
247 typeKeyStore.get(deletedTunnel.type()) 246 typeKeyStore.get(deletedTunnel.type())
248 .remove(deletedTunnel.tunnelId()); 247 .remove(deletedTunnel.tunnelId());
248 + event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED,
249 + deletedTunnel);
250 + ls.add(event);
249 } 251 }
250 } 252 }
251 - notifyDelegate(ls); 253 +
254 + if (!ls.isEmpty()) {
255 + notifyDelegate(ls);
256 + }
252 } 257 }
253 258
254 @Override 259 @Override
...@@ -264,20 +269,24 @@ public class DistributedTunnelStore ...@@ -264,20 +269,24 @@ public class DistributedTunnelStore
264 List<TunnelEvent> ls = new ArrayList<TunnelEvent>(); 269 List<TunnelEvent> ls = new ArrayList<TunnelEvent>();
265 for (TunnelId id : idSet) { 270 for (TunnelId id : idSet) {
266 deletedTunnel = tunnelIdAsKeyStore.get(id); 271 deletedTunnel = tunnelIdAsKeyStore.get(id);
267 - event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED, 272 +
268 - deletedTunnel); 273 + if (type.equals(deletedTunnel.type()) && (producerName == null || (producerName != null
269 - ls.add(event); 274 + && producerName.equals(deletedTunnel.providerId())))) {
270 - if (producerName.equals(deletedTunnel.providerId())
271 - && type.equals(deletedTunnel.type())) {
272 tunnelIdAsKeyStore.remove(deletedTunnel.tunnelId()); 275 tunnelIdAsKeyStore.remove(deletedTunnel.tunnelId());
273 tunnelNameAsKeyStore.get(deletedTunnel.tunnelName()) 276 tunnelNameAsKeyStore.get(deletedTunnel.tunnelName())
274 .remove(deletedTunnel.tunnelId()); 277 .remove(deletedTunnel.tunnelId());
275 srcAndDstKeyStore.get(key).remove(deletedTunnel.tunnelId()); 278 srcAndDstKeyStore.get(key).remove(deletedTunnel.tunnelId());
276 typeKeyStore.get(deletedTunnel.type()) 279 typeKeyStore.get(deletedTunnel.type())
277 .remove(deletedTunnel.tunnelId()); 280 .remove(deletedTunnel.tunnelId());
281 + event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED,
282 + deletedTunnel);
283 + ls.add(event);
278 } 284 }
279 } 285 }
280 - notifyDelegate(ls); 286 +
287 + if (!ls.isEmpty()) {
288 + notifyDelegate(ls);
289 + }
281 } 290 }
282 291
283 @Override 292 @Override
......