X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fsal%2Ftx%2FWriteCandidateRunningTx.java;h=be30658fdb34d6e89948f96cfc5e0fdd902e4c97;hb=1dba5b2651d7fc60af0263cc0640d5ebeda8e454;hp=a693e8c59c3db5a07fc0538a675e72f550582b86;hpb=19a2ef01da926cf611f18ef6ad83305925821da0;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTx.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTx.java index a693e8c59c..be30658fdb 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTx.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateRunningTx.java @@ -5,30 +5,32 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.netconf.sal.connect.netconf.sal.tx; -import com.google.common.util.concurrent.FutureCallback; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; +import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId; import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps; import org.opendaylight.netconf.sal.connect.netconf.util.NetconfRpcFutureCallback; -import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Tx implementation for netconf devices that support only candidate datastore and writable running + * Tx implementation for netconf devices that support only candidate datastore and writable running. * The sequence goes exactly as with only candidate supported, with one addition: * */ public class WriteCandidateRunningTx extends WriteCandidateTx { - private static final Logger LOG = LoggerFactory.getLogger(WriteCandidateRunningTx.class); - public WriteCandidateRunningTx(final RemoteDeviceId id, final NetconfBaseOps netOps, final boolean rollbackSupport) { - super(id, netOps, rollbackSupport); + public WriteCandidateRunningTx(final RemoteDeviceId id, final NetconfBaseOps netOps, + final boolean rollbackSupport) { + this(id, netOps, rollbackSupport, true); + } + + public WriteCandidateRunningTx(final RemoteDeviceId id, final NetconfBaseOps netconfOps, + final boolean rollbackSupport, final boolean isLockAllowed) { + super(id, netconfOps, rollbackSupport, isLockAllowed); } @Override @@ -44,31 +46,22 @@ public class WriteCandidateRunningTx extends WriteCandidateTx { } private void lockRunning() { - final FutureCallback lockRunningCallback = new FutureCallback() { - @Override - public void onSuccess(DOMRpcResult result) { - if (isSuccess(result)) { - if (LOG.isTraceEnabled()) { - LOG.trace("Lock running succesfull"); - } - } else { - LOG.warn("{}: lock running invoked unsuccessfully: {}", id, result.getErrors()); - } - } - - @Override - public void onFailure(Throwable t) { - LOG.warn("{}: Failed to lock running. Failed to initialize transaction", id, t); - throw new RuntimeException(id + ": Failed to lock running. Failed to initialize transaction", t); - } - }; - netOps.lockRunning(lockRunningCallback); + if (isLockAllowed) { + resultsFutures.add(netOps.lockRunning(new NetconfRpcFutureCallback("Lock running", id))); + } else { + LOG.trace("Lock is not allowed: {}", id); + } } /** - * This has to be non blocking since it is called from a callback on commit and its netty threadpool that is really sensitive to blocking calls + * This has to be non blocking since it is called from a callback on commit + * and its netty threadpool that is really sensitive to blocking calls. */ private void unlockRunning() { - netOps.unlockRunning(new NetconfRpcFutureCallback("Unlock running", id)); + if (isLockAllowed) { + netOps.unlockRunning(new NetconfRpcFutureCallback("Unlock running", id)); + } else { + LOG.trace("Unlock is not allowed: {}", id); + } } }