Bug 8152: Add way to configure idle timeout 75/55975/1
authorAndrej Mak <andrej.mak@pantheon.tech>
Wed, 19 Apr 2017 08:32:18 +0000 (10:32 +0200)
committerJakub Morvay <jmorvay@cisco.com>
Tue, 25 Apr 2017 10:50:37 +0000 (10:50 +0000)
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 734461ac9c00c14abd980958f119dd5095f8405d..0ca6325f6293308ff8a11582173d713c4b33770a 100644 (file)
@@ -41,6 +41,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;
@@ -83,9 +84,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);
@@ -97,7 +98,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 0997ea5af2daa94ee7114a4079f7564946ac94f1..977018f62c57d8689f0f81042e76e3814062137d 100644 (file)
@@ -35,6 +35,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <reference id="clientDispatcherDependency"
                interface="org.opendaylight.netconf.client.NetconfClientDispatcher"
                odl:type="netconf-client-dispatcher"/>
+    <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"
@@ -50,7 +54,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 99ef75f2a4a488b304269a0c1a061bf09b1d8a17..060ed0e987c964b666864add576c872dafc26773 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