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%2FWriteRunningTx.java;h=940ea1a6b9fe6f9799caee811c79bbf9a165ebd3;hb=a0833fb27c69d919a4420c6ecbd11a3b2a1119cb;hp=af51c824ef1883eac9b2252756a1df309afbe351;hpb=105edbab58dcf55b260ba4d83e7ffa371ef1ec45;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java index af51c824ef..940ea1a6b9 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/tx/WriteRunningTx.java @@ -5,19 +5,13 @@ * 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.base.Function; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; +import java.util.Optional; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; 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; @@ -53,7 +47,12 @@ public class WriteRunningTx extends AbstractWriteTx { public WriteRunningTx(final RemoteDeviceId id, final NetconfBaseOps netOps, final boolean rollbackSupport) { - super(netOps, id, rollbackSupport); + this(id, netOps, rollbackSupport, true); + } + + public WriteRunningTx(RemoteDeviceId id, NetconfBaseOps netconfOps, boolean rollbackSupport, + boolean isLockAllowed) { + super(id, netconfOps, rollbackSupport, isLockAllowed); } @Override @@ -62,7 +61,11 @@ public class WriteRunningTx extends AbstractWriteTx { } private void lock() { - resultsFutures.add(netOps.lockRunning(new NetconfRpcFutureCallback("Lock running", id))); + if (isLockAllowed) { + resultsFutures.add(netOps.lockRunning(new NetconfRpcFutureCallback("Lock running", id))); + } else { + LOG.trace("Lock is not allowed: {}", id); + } } @Override @@ -71,17 +74,7 @@ public class WriteRunningTx extends AbstractWriteTx { } @Override - public synchronized CheckedFuture submit() { - final ListenableFuture commmitFutureAsVoid = Futures.transform(commit(), - (Function, Void>) input -> null); - - return Futures.makeChecked(commmitFutureAsVoid, - input -> new TransactionCommitFailedException("Submit of transaction " + getIdentifier() + " failed", - input)); - } - - @Override - public synchronized ListenableFuture> performCommit() { + public synchronized ListenableFuture> performCommit() { for (final Change change : changes) { resultsFutures.add(change.execute(id, netOps, rollbackSupport)); } @@ -99,15 +92,19 @@ public class WriteRunningTx extends AbstractWriteTx { } private void unlock() { - netOps.unlockRunning(new NetconfRpcFutureCallback("Unlock running", id)); + if (isLockAllowed) { + netOps.unlockRunning(new NetconfRpcFutureCallback("Unlock running", id)); + } else { + LOG.trace("Unlock is not allowed: {}", id); + } } - private static class Change { + private static final class Change { private final DataContainerChild editStructure; private final Optional defaultOperation; - private Change(final DataContainerChild editStructure, final Optional defaultOperation) { + Change(final DataContainerChild editStructure, final Optional defaultOperation) { this.editStructure = editStructure; this.defaultOperation = defaultOperation; }