From be1007c357b81259110c56dccc253fd13aa7c671 Mon Sep 17 00:00:00 2001 From: "K.V Suneelu Verma" Date: Fri, 18 Nov 2016 12:51:45 +0530 Subject: [PATCH] bug 7202 upon node reboot hwvtep op ds is missing 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 --- .../ovsdb/lib/impl/OvsdbConnectionService.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java index d058ca259..0191b5c43 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java @@ -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 connectionListeners = Sets.newHashSet(); - private static Map connections = Maps.newHashMap(); + private static Map 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 -- 2.36.6