Bug 6352 - [SR3] RPC timeout in JsonRPCEndpoint is not configurable 76/43276/3
authorAnil Vishnoi <vishnoianil@gmail.com>
Sun, 7 Aug 2016 02:23:41 +0000 (19:23 -0700)
committerAnil Vishnoi <vishnoianil@gmail.com>
Mon, 8 Aug 2016 08:01:52 +0000 (01:01 -0700)
Change-Id: I4d35c64d61a6732441a942abd4a766551506f2d5
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
library/features/pom.xml
library/features/src/main/features/features.xml
library/impl/pom.xml
library/impl/src/main/java/org/opendaylight/ovsdb/lib/impl/OvsdbConnectionService.java
library/impl/src/main/java/org/opendaylight/ovsdb/lib/jsonrpc/JsonRpcEndpoint.java
library/impl/src/main/resources/initial/library.cfg [new file with mode: 0644]
library/impl/src/main/resources/org/opendaylight/blueprint/library.xml
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactInvokerImpl.java

index 4e7940f58e2302f2c2efc1491c0f5ace3a59f9f0..eba660a8659b4d82204abb039bb5624e521232fc 100644 (file)
@@ -68,6 +68,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>library</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>library</artifactId>
+      <version>${project.version}</version>
+      <type>cfg</type>
+      <classifier>config</classifier>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>utils.servicehelper</artifactId>
index 7e2c530fa6d30de55d2b96e034eb9c68ba16bbd6..36995ad0e714082f9cf75bd605430416b29d0230 100644 (file)
@@ -25,5 +25,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-annotations/{{VERSION}}</bundle>
     <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-core/{{VERSION}}</bundle>
     <bundle start="true">mvn:com.fasterxml.jackson.core/jackson-databind/{{VERSION}}</bundle>
+    <configfile finalname="etc/org.opendaylight.ovsdb.library.cfg">mvn:org.opendaylight.ovsdb/library/{{VERSION}}/cfg/config</configfile>
   </feature>
 </features>
index aac3f873ad6f9d457be25e01c43fccb66ca5e486..6e668742cfad0b6cd6ce32453940daa3d2df6db7 100644 (file)
@@ -136,6 +136,28 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
       </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-artifacts</id>
+            <goals>
+              <goal>attach-artifact</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <artifacts>
+                <artifact>
+                  <file>${project.build.directory}/classes/initial/library.cfg</file>
+                  <type>cfg</type>
+                  <classifier>config</classifier>
+                </artifact>
+              </artifacts>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 
index 0b032e5df61286d949cb8e455064e2e67240bbb8..a8c380470f900a7109d0ff8fe02acd6f2eedd056 100644 (file)
@@ -101,6 +101,7 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
     private static volatile boolean singletonCreated = false;
     private static final int IDLE_READER_TIMEOUT = 30;
     private static final int READ_TIMEOUT = 180;
+    private static final String OVSDB_RPC_TASK_TIMEOUT_PARAM = "ovsdb-rpc-task-timeout";
 
     private static final StalePassiveConnectionService STALE_PASSIVE_CONNECTION_SERVICE =
             new StalePassiveConnectionService(executorService);
@@ -498,4 +499,18 @@ public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
             });
         }
     }
+
+    public void updateConfigParameter(Map<String, Object> configParameters) {
+        LOG.debug("Config parameters received : {}", configParameters.entrySet());
+        if (configParameters != null && !configParameters.isEmpty()) {
+            for (Map.Entry<String, Object> paramEntry : configParameters.entrySet()) {
+                if (paramEntry.getKey().equalsIgnoreCase(OVSDB_RPC_TASK_TIMEOUT_PARAM)) {
+                    JsonRpcEndpoint.setReaperInterval(Integer.parseInt((String)paramEntry.getValue()));
+
+                    //Please remove the break if you add more config nobs.
+                    break;
+                }
+            }
+        }
+    }
 }
index d9f6dfdb40c87e469999865b1c9c8619dc08c68e..ad8f078aa69eb2b76f9e3c22e750363ae796f7ec 100644 (file)
@@ -41,13 +41,14 @@ import org.slf4j.LoggerFactory;
 public class JsonRpcEndpoint {
 
     private static final Logger LOG = LoggerFactory.getLogger(JsonRpcEndpoint.class);
-    private static final int REAPER_INTERVAL = 300;
     private static final int REAPER_THREADS = 3;
     private static final ThreadFactory FUTURE_REAPER_THREAD_FACTORY = new ThreadFactoryBuilder()
             .setNameFormat("OVSDB-Lib-Future-Reaper-%d").build();
     private static final ScheduledExecutorService FUTURE_REAPER_SERVICE
             = Executors.newScheduledThreadPool(REAPER_THREADS, FUTURE_REAPER_THREAD_FACTORY);
 
+    private static int reaperInterval = 1000;
+
     public class CallContext {
         Method method;
         JsonRpc10Request request;
@@ -131,7 +132,7 @@ public class JsonRpcEndpoint {
                             cc.getFuture().cancel(false);
                         }
                     }
-                },REAPER_INTERVAL, TimeUnit.MILLISECONDS);
+                }, reaperInterval, TimeUnit.MILLISECONDS);
 
                 nettyChannel.writeAndFlush(requestString);
 
@@ -229,4 +230,9 @@ public class JsonRpcEndpoint {
     public Map<String, CallContext> getMethodContext() {
         return methodContext;
     }
+
+    public static void setReaperInterval(int interval) {
+        reaperInterval = interval;
+        LOG.info("Ovsdb Rpc Task interval is set to {} millisecond", reaperInterval);
+    }
 }
diff --git a/library/impl/src/main/resources/initial/library.cfg b/library/impl/src/main/resources/initial/library.cfg
new file mode 100644 (file)
index 0000000..79ba8a7
--- /dev/null
@@ -0,0 +1,4 @@
+#Timeout value (in millisecond) after which OVSDB rpc task will be cancelled.
+#Default value is set to 1000ms, please uncomment and override the value if requires
+#Changing the value don't require controller restart.
+#ovsdb-rpc-task-timeout = 1000
\ No newline at end of file
index 1bdd859ebdad404ba5a1dcea2171ffcc8570da25..d3910163c64a78b559c1b6fe26fa557f62a810f3 100644 (file)
@@ -1,9 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-  xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
-  odl:use-default-for-reference-types="true">
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+           odl:use-default-for-reference-types="true">
 
   <bean id="ovsdbConnectionService" class="org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService">
+    <cm:managed-properties persistent-id="org.opendaylight.ovsdb.library"
+                           update-strategy="component-managed"
+                           update-method="updateConfigParameter"/>
   </bean>
   <service ref="ovsdbConnectionService" interface="org.opendaylight.ovsdb.lib.OvsdbConnection"
     odl:type="default" />
index 92ba86b2aff44d71cacdb2e30a74a512ca0bb34d..3012832951f62a3c85ee8dc058f88ae7db0ca41d 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
@@ -61,7 +62,7 @@ public class TransactInvokerImpl implements TransactInvoker {
                 } else {
                     LOG.debug("Operation task cancelled for transaction : {}", tb);
                 }
-            } catch (InterruptedException | ExecutionException e) {
+            } catch (InterruptedException | ExecutionException | CancellationException e) {
                 LOG.warn("Transact execution exception: ", e);
             }
             LOG.trace("invoke exit command: {}, tb: {}", command, tb);