Moving the Connection events to its own executorService thread. 14/8714/1
authorMadhu Venugopal <mavenugo@gmail.com>
Mon, 7 Jul 2014 01:26:49 +0000 (18:26 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Mon, 7 Jul 2014 01:40:49 +0000 (18:40 -0700)
During the neutron integration it is observed that connection events are immediately followed by OVSDB table
configuration events and causes a similar channel lock issue that we faced recently. Hence moving it in its
own thread to avoid the Channel locking issue.

Change-Id: Ibcf147e0ff107aecfcb7987956055f563a5a17a0
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
library/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java

index be854bea0f635f5c2a9ca6244144e25218112df2..b08933af7ce3828ffebe7a5f499b39cda02dc3a8 100644 (file)
@@ -211,14 +211,20 @@ public class OvsdbConnectionService implements OvsdbConnection {
         startOvsdbManager();
     }
 
-    private static void handleNewPassiveConnection(Channel channel) {
-        OvsdbClient client = getChannelClient(channel, ConnectionType.PASSIVE, Executors.newFixedThreadPool(NUM_THREADS));
-        for (OvsdbConnectionListener listener : connectionListeners) {
-            listener.connected(client);
-        }
+    private static ExecutorService executorService = Executors.newFixedThreadPool(10);
+    private static void handleNewPassiveConnection(final Channel channel) {
+        executorService.execute(new Runnable() {
+            @Override
+            public void run() {
+                OvsdbClient client = getChannelClient(channel, ConnectionType.PASSIVE, Executors.newFixedThreadPool(NUM_THREADS));
+                for (OvsdbConnectionListener listener : connectionListeners) {
+                    listener.connected(client);
+                }
+            }
+        });
     }
 
-    public static void channelClosed(OvsdbClient client) {
+    public static void channelClosed(final OvsdbClient client) {
         logger.info("Connection closed {}", client.getConnectionInfo().toString());
         connections.remove(client);
         for (OvsdbConnectionListener listener : connectionListeners) {