From: Robert Varga Date: Fri, 3 Aug 2018 15:12:49 +0000 (+0200) Subject: Reduce use of deprecated methods X-Git-Tag: release/fluorine~8 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=cfd2e240178039a439001c4d3f1ca5f26097dcdd Reduce use of deprecated methods We do not really need the old semantics in a lot of sites, so migrate them over to replacement methods. Change-Id: Ib60e395dd9da82934d1591555c9ad46c05dac0e7 Signed-off-by: Robert Varga --- diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java index 160f4888d0..ec23f9a1f4 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java @@ -10,11 +10,11 @@ package org.opendaylight.dsbenchmark; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collections; +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicReference; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.dsbenchmark.listener.DsbenchmarkListenerProvider; import org.opendaylight.dsbenchmark.simpletx.SimpletxBaDelete; @@ -175,8 +175,8 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { tx.put(LogicalDatastoreType.OPERATIONAL, TEST_STATUS_IID, status); try { - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { throw new IllegalStateException(e); } @@ -191,9 +191,9 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID, data); try { - tx.submit().checkedGet(); + tx.commit().get(); LOG.debug("DataStore config test data cleaned up"); - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.info("Failed to cleanup DataStore configtest data"); throw new IllegalStateException(e); } @@ -201,9 +201,9 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable { tx = simpleTxDataBroker.newWriteOnlyTransaction(); tx.put(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID, data); try { - tx.submit().checkedGet(); + tx.commit().get(); LOG.debug("DataStore operational test data cleaned up"); - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.info("Failed to cleanup DataStore operational test data"); throw new IllegalStateException(e); } diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaDelete.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaDelete.java index a165ea0a03..85a41244bf 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaDelete.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaDelete.java @@ -5,14 +5,12 @@ * 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.dsbenchmark.simpletx; - +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore; @@ -63,9 +61,9 @@ public class SimpletxBaDelete extends DatastoreAbstractWriter { putCnt++; if (putCnt == writesPerTx) { try { - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed: {}", e); txError++; } @@ -75,8 +73,8 @@ public class SimpletxBaDelete extends DatastoreAbstractWriter { } if (putCnt != 0) { try { - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed: {}", e); } } diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java index 1fef7f8938..ed4d0a4bf3 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxBaWrite.java @@ -9,10 +9,10 @@ package org.opendaylight.dsbenchmark.simpletx; import java.util.List; +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.dsbenchmark.BaListBuilder; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput; @@ -60,9 +60,9 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter { if (writeCnt == writesPerTx) { try { - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed: {}", e); txError++; } @@ -74,8 +74,8 @@ public class SimpletxBaWrite extends DatastoreAbstractWriter { if (writeCnt != 0) { try { - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed: {}", e); } } diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java index 58baedb9c6..af9ad559e5 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomDelete.java @@ -8,8 +8,8 @@ package org.opendaylight.dsbenchmark.simpletx; +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; @@ -67,9 +67,9 @@ public class SimpletxDomDelete extends DatastoreAbstractWriter { writeCnt++; if (writeCnt == writesPerTx) { try { - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed: {}", e); txError++; } @@ -79,8 +79,8 @@ public class SimpletxDomDelete extends DatastoreAbstractWriter { } if (writeCnt != 0) { try { - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed: {}", e); } } diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java index e55724d54b..49765b3b94 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java @@ -9,8 +9,8 @@ package org.opendaylight.dsbenchmark.simpletx; import java.util.List; +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; @@ -65,9 +65,9 @@ public class SimpletxDomWrite extends DatastoreAbstractWriter { if (writeCnt == writesPerTx) { try { - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); txError++; } @@ -78,12 +78,10 @@ public class SimpletxDomWrite extends DatastoreAbstractWriter { if (writeCnt != 0) { try { - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); } } - } - } diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java index a8363df679..44fcc9744f 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java @@ -9,7 +9,8 @@ package org.opendaylight.dsbenchmark.txchain; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.MoreExecutors; +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; @@ -17,8 +18,8 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec; @@ -73,9 +74,9 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact if (writeCnt == writesPerTx) { txSubmitted++; - Futures.addCallback(tx.submit(), new FutureCallback() { + tx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { txOk++; } @@ -84,7 +85,7 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact LOG.error("Transaction failed, {}", t); txError++; } - }); + }, MoreExecutors.directExecutor()); tx = chain.newWriteOnlyTransaction(); writeCnt = 0; } @@ -96,8 +97,8 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact if (writeCnt > 0) { txSubmitted++; } - tx.submit().checkedGet(); - } catch (final TransactionCommitFailedException e) { + tx.commit().get(); + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); } try { @@ -105,7 +106,7 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact } catch (final IllegalStateException e) { LOG.error("Transaction close failed,", e); } - LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError)); + LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, txOk + txError); } @Override diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java index b36404d52c..927ec45e4a 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java @@ -9,9 +9,9 @@ package org.opendaylight.dsbenchmark.txchain; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import java.util.List; +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; @@ -19,9 +19,9 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.dsbenchmark.BaListBuilder; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.Operation; @@ -71,9 +71,9 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti if (writeCnt == writesPerTx) { txSubmitted++; - Futures.addCallback(tx.submit(), new FutureCallback() { + tx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { txOk++; } @@ -93,9 +93,9 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti // We need to empty the transaction chain before closing it try { txSubmitted++; - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); txError++; } diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomDelete.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomDelete.java index 8e32897a04..a1efbfa2f8 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomDelete.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomDelete.java @@ -5,20 +5,20 @@ * 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.dsbenchmark.txchain; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.MoreExecutors; +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec; @@ -76,9 +76,9 @@ public class TxchainDomDelete extends DatastoreAbstractWriter implements Transac if (writeCnt == writesPerTx) { txSubmitted++; - Futures.addCallback(tx.submit(), new FutureCallback() { + tx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { txOk++; } @@ -87,7 +87,7 @@ public class TxchainDomDelete extends DatastoreAbstractWriter implements Transac LOG.error("Transaction failed, {}", t); txError++; } - }); + }, MoreExecutors.directExecutor()); tx = chain.newWriteOnlyTransaction(); writeCnt = 0; } @@ -98,9 +98,9 @@ public class TxchainDomDelete extends DatastoreAbstractWriter implements Transac // We need to empty the transaction chain before closing it try { txSubmitted++; - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); txError++; } @@ -109,7 +109,7 @@ public class TxchainDomDelete extends DatastoreAbstractWriter implements Transac } catch (final IllegalStateException e) { LOG.error("Transaction close failed,", e); } - LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError)); + LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, txOk + txError); } @Override diff --git a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java index 52f574ab1c..e26f284ef2 100644 --- a/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java +++ b/benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java @@ -9,18 +9,19 @@ package org.opendaylight.dsbenchmark.txchain; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.MoreExecutors; import java.util.List; +import java.util.concurrent.ExecutionException; import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.dsbenchmark.DatastoreAbstractWriter; import org.opendaylight.dsbenchmark.DomListBuilder; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestInput.DataStore; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec; @@ -74,9 +75,9 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact // Start performing the operation; submit the transaction at every n-th operation if (writeCnt == writesPerTx) { txSubmitted++; - Futures.addCallback(tx.submit(), new FutureCallback() { + tx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { txOk++; } @@ -85,7 +86,7 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact LOG.error("Transaction failed, {}", t); txError++; } - }); + }, MoreExecutors.directExecutor()); tx = chain.newWriteOnlyTransaction(); writeCnt = 0; } @@ -97,9 +98,9 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact try { txSubmitted++; - tx.submit().checkedGet(); + tx.commit().get(); txOk++; - } catch (final TransactionCommitFailedException e) { + } catch (final InterruptedException | ExecutionException e) { LOG.error("Transaction failed", e); txError++; } @@ -109,7 +110,7 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact LOG.error("Transaction close failed,", e); } - LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError)); + LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, txOk + txError); } @Override diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java index 8c4ac638bb..5ee9c43f31 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadWriteTransaction.java @@ -11,7 +11,6 @@ package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapte import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; @@ -144,10 +143,8 @@ class ShardedDOMDataBrokerDelegatingReadWriteTransaction implements DOMDataReadW final YangInstanceIdentifier path) { checkState(root != null, "A modify operation (put, merge or delete) must be performed prior to an exists operation"); - return Futures.makeChecked(Futures.transform(read(store, path), - (Function>, Boolean>) - Optional::isPresent), - ReadFailedException.MAPPER); + return Futures.makeChecked(Futures.transform(read(store, path), Optional::isPresent, + MoreExecutors.directExecutor()), ReadFailedException.MAPPER); } @Override diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java index 72a3c2e962..640d603039 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java @@ -148,7 +148,7 @@ public class DOMBrokerPerformanceTest { List> allFutures = measure(txNum + " Submits", () -> { List> builder = new ArrayList<>(txNum); for (DOMDataReadWriteTransaction tx : transactions) { - builder.add(tx.submit()); + builder.add(tx.commit()); } return builder; }); @@ -213,7 +213,7 @@ public class DOMBrokerPerformanceTest { }); measure("Txs:1 Submit, Finish", (Callable) () -> { - measure("Txs:1 Submit", (Callable>) writeTx::submit).get(); + measure("Txs:1 Submit", (Callable>) writeTx::commit).get(); return null; }); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java index bad492769f..51f0c04826 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -31,7 +32,6 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; @@ -133,7 +133,7 @@ public class DOMDataTreeListenerTest { final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -149,7 +149,7 @@ public class DOMDataTreeListenerTest { } @Test - public void replaceContainerContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException { + public void replaceContainerContainerInTreeTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -157,14 +157,14 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener); writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -188,7 +188,7 @@ public class DOMDataTreeListenerTest { } @Test - public void deleteContainerContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException { + public void deleteContainerContainerInTreeTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -196,7 +196,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -204,7 +204,7 @@ public class DOMDataTreeListenerTest { writeTx = domBroker.newWriteOnlyTransaction(); writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -228,7 +228,7 @@ public class DOMDataTreeListenerTest { } @Test - public void replaceChildListContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException { + public void replaceChildListContainerInTreeTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -236,7 +236,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -244,7 +244,7 @@ public class DOMDataTreeListenerTest { writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH, OUTER_LIST_2); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -272,7 +272,7 @@ public class DOMDataTreeListenerTest { } @Test - public void rootModificationChildListenerTest() throws InterruptedException, TransactionCommitFailedException { + public void rootModificationChildListenerTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -280,7 +280,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -288,7 +288,7 @@ public class DOMDataTreeListenerTest { writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2); - writeTx.submit().checkedGet(); + writeTx.commit().get(); latch.await(1, TimeUnit.SECONDS); @@ -312,7 +312,7 @@ public class DOMDataTreeListenerTest { } @Test - public void listEntryChangeNonRootRegistrationTest() throws InterruptedException, TransactionCommitFailedException { + public void listEntryChangeNonRootRegistrationTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -320,7 +320,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -349,7 +349,7 @@ public class DOMDataTreeListenerTest { outerListEntry2); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId3), outerListEntry3); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java index f36a75d668..5815faeaa3 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java @@ -73,7 +73,7 @@ public class DOMTransactionChainTest { * First transaction is marked as ready, we are able to allocate chained * transactions. */ - ListenableFuture firstWriteTxFuture = firstTx.submit(); + ListenableFuture firstWriteTxFuture = firstTx.commit(); /** * We alocate chained transaction - read transaction. @@ -114,7 +114,7 @@ public class DOMTransactionChainTest { /** * third transaction is sealed and commited. */ - ListenableFuture thirdDeleteTxFuture = thirdDeleteTx.submit(); + ListenableFuture thirdDeleteTxFuture = thirdDeleteTx.commit(); assertCommitSuccessful(thirdDeleteTxFuture); /** @@ -168,27 +168,27 @@ public class DOMTransactionChainTest { return tx; } - private static DOMDataReadWriteTransaction allocateAndWrite( - final DOMTransactionChain txChain) throws InterruptedException, ExecutionException { + private static DOMDataReadWriteTransaction allocateAndWrite(final DOMTransactionChain txChain) + throws InterruptedException, ExecutionException { DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction(); assertTestContainerWrite(tx); return tx; } - private static void assertCommitSuccessful( - final ListenableFuture future) throws InterruptedException, ExecutionException { + private static void assertCommitSuccessful(final ListenableFuture future) + throws InterruptedException, ExecutionException { future.get(); } - private static void assertTestContainerExists( - final DOMDataReadTransaction readTx) throws InterruptedException, ExecutionException { + private static void assertTestContainerExists(final DOMDataReadTransaction readTx) + throws InterruptedException, ExecutionException { ListenableFuture>> readFuture = readTx.read(OPERATIONAL, TestModel.TEST_PATH); Optional> readedData = readFuture.get(); assertTrue(readedData.isPresent()); } - private static void assertTestContainerWrite( - final DOMDataReadWriteTransaction tx) throws InterruptedException, ExecutionException { + private static void assertTestContainerWrite(final DOMDataReadWriteTransaction tx) + throws InterruptedException, ExecutionException { tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); assertTestContainerExists(tx); }