Bug 8152: Add way to configure idle timeout 78/55978/1
authorAndrej Mak <andrej.mak@pantheon.tech>
Wed, 19 Apr 2017 08:32:18 +0000 (10:32 +0200)
committerAndrej Mak <andrej.mak@pantheon.tech>
Tue, 25 Apr 2017 10:55:15 +0000 (12:55 +0200)
Clustered apps should be configurable via datastore
to allow config distribution to all nodes according to
https://wiki.opendaylight.org/view/Using_Blueprint#Using_the_Datastore
Add such configuration for clustered topology.

Change-Id: I1a318590c75c6c95da48cb1e0521994f0b83dfe4
Signed-off-by: Andrej Mak <andrej.mak@pantheon.tech>
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java
netconf/netconf-topology-singleton/src/main/resources/org/opendaylight/blueprint/netconf-topology-singleton.xml
netconf/netconf-topology-singleton/src/main/yang/netconf-clustered-topology-config.yang [new file with mode: 0644]
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManagerTest.java

index eeff4d2c59756594f3e372c84de88e260709a5a4..3f4721ee75ea300db62fd839dbbf7d136c9ffc56 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySet
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup.NetconfTopologySetupBuilder;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -82,9 +83,9 @@ public class NetconfTopologyManager
                                   final ClusterSingletonServiceProvider clusterSingletonServiceProvider,
                                   final BindingAwareBroker bindingAwareBroker,
                                   final ScheduledThreadPool keepaliveExecutor, final ThreadPool processingExecutor,
-                                  final Broker domBroker, final ActorSystemProvider actorSystemProvider, final EventExecutor eventExecutor,
-                                  final NetconfClientDispatcher clientDispatcher, final String topologyId,
-                                  final int writeTxIdleTimeout) {
+                                  final Broker domBroker, final ActorSystemProvider actorSystemProvider,
+                                  final EventExecutor eventExecutor, final NetconfClientDispatcher clientDispatcher,
+                                  final String topologyId, final Config config) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         this.rpcProviderRegistry = Preconditions.checkNotNull(rpcProviderRegistry);
         this.clusterSingletonServiceProvider = Preconditions.checkNotNull(clusterSingletonServiceProvider);
@@ -96,7 +97,7 @@ public class NetconfTopologyManager
         this.eventExecutor = Preconditions.checkNotNull(eventExecutor);
         this.clientDispatcher = Preconditions.checkNotNull(clientDispatcher);
         this.topologyId = Preconditions.checkNotNull(topologyId);
-        this.writeTxIdleTimeout = Duration.apply(writeTxIdleTimeout, TimeUnit.SECONDS);
+        this.writeTxIdleTimeout = Duration.apply(config.getWriteTransactionIdleTimeout(), TimeUnit.SECONDS);
     }
 
     // Blueprint init method
index c9811be00c30b8dd8d2a6235658e7b4416f39f7f..699fad7c37fcb0d5ee78d1ede78603511b6e4ad4 100644 (file)
@@ -32,6 +32,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
                odl:type="global-event-executor"/>
     <reference id="clientDispatcherDependency"
                interface="org.opendaylight.netconf.client.NetconfClientDispatcher"/>
+    <odl:clustered-app-config
+            id="singletonConfig"
+            binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config"
+    />
 
     <bean id="netconfTopologyManager"
           class="org.opendaylight.netconf.topology.singleton.impl.NetconfTopologyManager"
@@ -47,7 +51,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         <argument ref="eventExecutor"/>
         <argument ref="clientDispatcherDependency"/>
         <argument value="topology-netconf"/>
-        <argument value="0"/>
+        <argument ref="singletonConfig"/>
     </bean>
     <service ref="netconfTopologyManager"
              interface="org.opendaylight.netconf.topology.singleton.api.NetconfTopologySingletonService"/>
diff --git a/netconf/netconf-topology-singleton/src/main/yang/netconf-clustered-topology-config.yang b/netconf/netconf-topology-singleton/src/main/yang/netconf-clustered-topology-config.yang
new file mode 100644 (file)
index 0000000..b8cf643
--- /dev/null
@@ -0,0 +1,22 @@
+module netconf-clustered-topology-config {
+    yang-version 1;
+    namespace "urn:opendaylight:netconf:topology:singleton:config";
+    prefix nctc;
+
+    description
+      "Configuration for Netconf Clustered Topology";
+
+    revision "2017-04-19" {
+        description
+            "Initial revision.";
+    }
+
+    container config {
+        leaf write-transaction-idle-timeout {
+            type uint16;
+            default 0;
+            description "Idle time in seconds after which write transaction is cancelled
+            automatically. If 0, automatic cancellation is turned off.";
+        }
+    }
+}
\ No newline at end of file
index beb3f277bbb758043b2cb2b57c9802b1e4a67157..f2c30a3e30c2f9eb8f260d3abb387c8e9b1ed33e 100644 (file)
@@ -53,6 +53,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
@@ -84,9 +86,10 @@ public class NetconfTopologyManagerTest {
         final EventExecutor eventExecutor = mock(EventExecutor.class);
         final NetconfClientDispatcher clientDispatcher = mock(NetconfClientDispatcher.class);
 
+        final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(0).build();
         netconfTopologyManager = new NetconfTopologyManager(dataBroker, rpcProviderRegistry,
                 clusterSingletonServiceProvider, bindingAwareBroker, keepaliveExecutor, processingExecutor, domBroker,
-                actorSystemProvider, eventExecutor, clientDispatcher, topologyId, 0);
+                actorSystemProvider, eventExecutor, clientDispatcher, topologyId, config);
     }
 
     @Test