Netconf stack by default locks the data store before issuing
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / sal / tx / WriteCandidateTx.java
index 1eb47c9775ba9651de88c56556b633f7f3132164..012cbac8c50c78315468fbbba8894045958690f2 100644 (file)
@@ -52,8 +52,13 @@ public class WriteCandidateTx extends AbstractWriteTx {
 
     private static final Logger LOG  = LoggerFactory.getLogger(WriteCandidateTx.class);
 
-    public WriteCandidateTx(final RemoteDeviceId id, final NetconfBaseOps rpc, final boolean rollbackSupport) {
-        super(rpc, id, rollbackSupport);
+    public WriteCandidateTx(final RemoteDeviceId id, final NetconfBaseOps netconfOps, final boolean rollbackSupport) {
+        this(id, netconfOps, rollbackSupport, true);
+    }
+
+    public WriteCandidateTx(RemoteDeviceId id, NetconfBaseOps netconfOps, boolean rollbackSupport,
+            boolean isLockAllowed) {
+        super(id, netconfOps, rollbackSupport, isLockAllowed);
     }
 
     @Override
@@ -63,6 +68,10 @@ public class WriteCandidateTx extends AbstractWriteTx {
     }
 
     private void lock() {
+        if (!isLockAllowed) {
+            LOG.trace("Lock is not allowed.");
+            return;
+        }
         final FutureCallback<DOMRpcResult> lockCandidateCallback = new FutureCallback<DOMRpcResult>() {
             @Override
             public void onSuccess(@Nonnull final DOMRpcResult result) {
@@ -146,7 +155,11 @@ public class WriteCandidateTx extends AbstractWriteTx {
      * and its netty threadpool that is really sensitive to blocking calls.
      */
     private void unlock() {
-        netOps.unlockCandidate(new NetconfRpcFutureCallback("Unlock candidate", id));
+        if (isLockAllowed) {
+            netOps.unlockCandidate(new NetconfRpcFutureCallback("Unlock candidate", id));
+        } else {
+            LOG.trace("Unlock is not allowed: {}", id);
+        }
     }
 
 }