Removed the executorservice thread that we added in async update processing 10/8810/1
authorMadhu Venugopal <mavenugo@gmail.com>
Tue, 8 Jul 2014 17:34:16 +0000 (10:34 -0700)
committerMadhu Venugopal <mavenugo@gmail.com>
Tue, 8 Jul 2014 17:34:16 +0000 (10:34 -0700)
We moved channelRead in JsonRpc Layer to its own thread in order to avoid a possible channel-lock
issue when we try to program the table in the same thread.
But this breaks a lot of assumption in the existing code in Neutron/Library layers where an update
followed by access has to be delayed.

With the earler changes made to the Monitor request resulting in synchronous MonitorResponse, the
channel lock issue for the initial monitor processing is taken care of.

Any subsequent Updates are anyways thrown to an application queue which gets processed in its own
thread.

Hence, removing the thread from the low-layer and that enables receiving the monitor tableupdates/
updating the tableCache in the same thread.

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

index 14242ea82be5c686262f4dc149021c3f55188599..171d3add24efe230ecf6476939ca31cc90852e13 100644 (file)
@@ -45,32 +45,27 @@ public class JsonRpcServiceBinderHandler extends ChannelInboundHandlerAdapter {
 
     @Override
     public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
-        executorService.execute(new Runnable() {
-            @Override
-            public void run() {
-                if (msg instanceof JsonNode) {
-                    JsonNode jsonNode = (JsonNode) msg;
-                    if (jsonNode.has("result")) {
-                        try {
-                            factory.processResult(jsonNode);
-                        } catch (NoSuchMethodException e) {
-                             /*
-                               ChannelRead is a method invoked during Netty message receive event.
-                               The only sane thing we can do is to print a meaningful error message.
-                             */
-                            logger.error("NoSuchMethodException when handling "+msg.toString(), e);
-                        }
-                    } else if (jsonNode.hasNonNull("method")) {
-                        if (jsonNode.has("id") && !Strings.isNullOrEmpty(jsonNode.get("id").asText())) {
-                            factory.processRequest(context, jsonNode);
-                        }
-                    }
-
-                    return;
+        if (msg instanceof JsonNode) {
+            JsonNode jsonNode = (JsonNode) msg;
+            if (jsonNode.has("result")) {
+                try {
+                    factory.processResult(jsonNode);
+                } catch (NoSuchMethodException e) {
+                     /*
+                       ChannelRead is a method invoked during Netty message receive event.
+                       The only sane thing we can do is to print a meaningful error message.
+                     */
+                    logger.error("NoSuchMethodException when handling "+msg.toString(), e);
+                }
+            } else if (jsonNode.hasNonNull("method")) {
+                if (jsonNode.has("id") && !Strings.isNullOrEmpty(jsonNode.get("id").asText())) {
+                    factory.processRequest(context, jsonNode);
                 }
-                ctx.channel().close();
             }
-        });
+
+            return;
+        }
+        ctx.channel().close();
     }
 
     @Override