bug 7202 upon node reboot hwvtep op ds is missing 64/48464/5
authorK.V Suneelu Verma <k.v.suneelu.verma@ericsson.com>
Fri, 18 Nov 2016 07:21:45 +0000 (12:51 +0530)
committersuneel verma <k.v.suneelu.verma@ericsson.com>
Tue, 22 Nov 2016 16:12:59 +0000 (16:12 +0000)
When the cluster is rebooted hwvtep operational datastore is not populated
for the existing clients.
Existing clients keep retrying , the moment 6640 port is up they establish
connection.
But by that time hwtep bundle is not up.
Eventually when the bundle is up it is only notified of future clients
only and not the already existing clients.

Change-Id: Ic816aea61c43000d7c8fbf14e51e0bcc5661664e
Signed-off-by: K.V Suneelu Verma <k.v.suneelu.verma@ericsson.com>
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java

index d058ca2595a6e52e918482fa620b1cc9e4f5722e..0191b5c439ae61b73d37b1f40eb2f20f99b81852 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.ovsdb.lib.impl;
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -43,6 +42,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -96,7 +96,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
             = Executors.newCachedThreadPool(connectionNotifierThreadFactory);
 
     private static Set<OvsdbConnectionListener> connectionListeners = Sets.newHashSet();
-    private static Map<OvsdbClient, Channel> connections = Maps.newHashMap();
+    private static Map<OvsdbClient, Channel> connections = new ConcurrentHashMap<>();
     private static OvsdbConnection connectionService;
     private static volatile boolean singletonCreated = false;
     private static final int IDLE_READER_TIMEOUT = 30;
@@ -176,6 +176,19 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
     public void registerConnectionListener(OvsdbConnectionListener listener) {
         LOG.info("registerConnectionListener: registering {}", listener.getClass().getSimpleName());
         connectionListeners.add(listener);
+        notifyAlreadyExistingConnectionsToListener(listener);
+    }
+
+    private void notifyAlreadyExistingConnectionsToListener(final OvsdbConnectionListener listener) {
+        for (final OvsdbClient client : getConnections()) {
+            connectionNotifierService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    LOG.trace("Connection {} notified to listener {}", client.getConnectionInfo(), listener);
+                    listener.connected(client);
+                }
+            });
+        }
     }
 
     @Override