X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fsal%2Ftx%2FWriteCandidateTx.java;h=eeb41f72985dd24d41f9b484fd06cc7e51a685cc;hb=68d52ef8ea8ee2ee6cda8bbc4a864c3fa897297e;hp=13567b12258eee328d476f973a1d363e060f1158;hpb=4e99f8da93b99168e8f43f68e238ff4e1fdda8cd;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTx.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTx.java index 13567b1225..eeb41f7298 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTx.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteCandidateTx.java @@ -5,7 +5,6 @@ * 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; @@ -14,11 +13,11 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.Optional; import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.netconf.api.ModifyAction; 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.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.ModifyAction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -50,8 +49,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(final RemoteDeviceId id, final NetconfBaseOps netconfOps, final boolean rollbackSupport, + final boolean isLockAllowed) { + super(id, netconfOps, rollbackSupport, isLockAllowed); } @Override @@ -61,7 +65,11 @@ public class WriteCandidateTx extends AbstractWriteTx { } private void lock() { - final FutureCallback lockCandidateCallback = new FutureCallback() { + if (!isLockAllowed) { + LOG.trace("Lock is not allowed."); + return; + } + final var lockCandidateCallback = new FutureCallback() { @Override public void onSuccess(final DOMRpcResult result) { if (isSuccess(result)) { @@ -69,13 +77,13 @@ public class WriteCandidateTx extends AbstractWriteTx { LOG.trace("Lock candidate successful"); } } else { - LOG.warn("{}: lock candidate invoked unsuccessfully: {}", id, result.getErrors()); + LOG.warn("{}: lock candidate invoked unsuccessfully: {}", id, result.errors()); } } @Override public void onFailure(final Throwable throwable) { - LOG.warn("Lock candidate operation failed. {}", throwable); + LOG.warn("Lock candidate operation failed", throwable); discardChanges(); } }; @@ -123,10 +131,8 @@ public class WriteCandidateTx extends AbstractWriteTx { } @Override - protected void editConfig(final YangInstanceIdentifier path, - final Optional> data, - final DataContainerChild editStructure, - final Optional defaultOperation, + protected void editConfig(final YangInstanceIdentifier path, final Optional data, + final DataContainerChild editStructure, final Optional defaultOperation, final String operation) { final NetconfRpcFutureCallback editConfigCallback = new NetconfRpcFutureCallback("Edit candidate", id); @@ -144,7 +150,10 @@ 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); + } } - }