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%2FWriteCandidateTx.java;h=23803f575129cebf226c0f98f891ef03d695574e;hb=74f902f0d61c2077a50c57f40c5f7b040fdddc29;hp=2038d10ee4484ed283af39c1515af6018f100879;hpb=ddfdd7b56162e9c45639388b10407d45f5f0ba13;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 2038d10ee4..23803f5751 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 @@ -15,8 +15,8 @@ import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import javax.annotation.Nullable; -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 org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps; @@ -95,23 +95,15 @@ public class WriteCandidateTx extends AbstractWriteTx { @Override public synchronized CheckedFuture submit() { - final ListenableFuture commitFutureAsVoid = Futures.transform(commit(), - new Function, Void>() { - @Override - public Void apply(final RpcResult input) { - Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(), - "Submit failed with errors: %s", input.getErrors()); - return null; - } - }); - - return Futures.makeChecked(commitFutureAsVoid, new Function() { - @Override - public TransactionCommitFailedException apply(final Exception input) { - return new TransactionCommitFailedException( - "Submit of transaction " + getIdentifier() + " failed", input); - } - }); + final ListenableFuture commitFutureAsVoid = Futures.transform(commitConfiguration(), + (Function, Void>) input -> { + Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(), + "Submit failed with errors: %s", input.getErrors()); + return null; + }, MoreExecutors.directExecutor()); + + return Futures.makeChecked(commitFutureAsVoid, input -> new TransactionCommitFailedException( + "Submit of transaction " + getIdentifier() + " failed", input)); } /** @@ -123,13 +115,13 @@ public class WriteCandidateTx extends AbstractWriteTx { } @Override - public synchronized ListenableFuture> performCommit() { + public synchronized ListenableFuture> performCommit() { resultsFutures.add(netOps.commit(new NetconfRpcFutureCallback("Commit", id))); - final ListenableFuture> txResult = resultsToTxStatus(); + final ListenableFuture> txResult = resultsToTxStatus(); - Futures.addCallback(txResult, new FutureCallback>() { + Futures.addCallback(txResult, new FutureCallback>() { @Override - public void onSuccess(@Nullable final RpcResult result) { + public void onSuccess(@Nullable final RpcResult result) { cleanupOnSuccess(); } @@ -139,7 +131,7 @@ public class WriteCandidateTx extends AbstractWriteTx { // cleanup is trying to do unlock, but this will fail cleanup(); } - }); + }, MoreExecutors.directExecutor()); return txResult; }