Integrate MRI projects for Neon
[controller.git] / benchmark / dsbenchmark / src / main / java / org / opendaylight / dsbenchmark / txchain / TxchainBaRead.java
index 20694ca5d36671f7f1d1a1bd89972d84d964d4de..4394daacb6370929a246dd89a0ce220aa32ab007 100644 (file)
@@ -5,19 +5,18 @@
  * 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.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-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.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.dsbenchmark.DatastoreAbstractWriter;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.Transaction;
+import org.opendaylight.mdsal.binding.api.TransactionChain;
+import org.opendaylight.mdsal.binding.api.TransactionChainListener;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 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;
@@ -45,12 +44,8 @@ public class TxchainBaRead extends DatastoreAbstractWriter implements Transactio
 
         // Dump the whole list into the data store in a single transaction
         // with <outerListElem> PUTs on the transaction
-        TxchainBaWrite dd = new TxchainBaWrite(bindingDataBroker,
-                                               StartTestInput.Operation.PUT,
-                                               outerListElem,
-                                               innerListElem,
-                                               outerListElem,
-                                               dataStore);
+        TxchainBaWrite dd = new TxchainBaWrite(bindingDataBroker, StartTestInput.Operation.PUT, outerListElem,
+            innerListElem, outerListElem, dataStore);
         dd.createList();
         dd.executeList();
     }
@@ -59,16 +54,15 @@ public class TxchainBaRead extends DatastoreAbstractWriter implements Transactio
     public void executeList() {
         final LogicalDatastoreType dsType = getDataStoreType();
 
-        try (ReadOnlyTransaction tx = bindingDataBroker.newReadOnlyTransaction()) {
+        try (ReadTransaction tx = bindingDataBroker.newReadOnlyTransaction()) {
             for (long l = 0; l < outerListElem; l++) {
 
                 InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class)
                         .child(OuterList.class, new OuterListKey((int) l));
-                CheckedFuture<Optional<OuterList>, ReadFailedException> submitFuture =
-                        tx.read(dsType, iid);
+                FluentFuture<Optional<OuterList>> submitFuture = tx.read(dsType, iid);
 
                 try {
-                    Optional<OuterList> optionalDataObject = submitFuture.checkedGet();
+                    Optional<OuterList> optionalDataObject = submitFuture.get();
                     if (optionalDataObject != null && optionalDataObject.isPresent()) {
                         OuterList outerList = optionalDataObject.get();
 
@@ -91,7 +85,7 @@ public class TxchainBaRead extends DatastoreAbstractWriter implements Transactio
                     } else {
                         txError++;
                     }
-                } catch (final ReadFailedException e) {
+                } catch (final InterruptedException | ExecutionException e) {
                     LOG.warn("failed to ....", e);
                     txError++;
                 }
@@ -100,15 +94,14 @@ public class TxchainBaRead extends DatastoreAbstractWriter implements Transactio
     }
 
     @Override
-    public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
-                                         final AsyncTransaction<?, ?> transaction, final Throwable cause) {
-        LOG.error("Broken chain {} in TxchainBaDelete, transaction {}, cause {}",
-                chain, transaction.getIdentifier(), cause);
+    public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction,
+            final Throwable cause) {
+        LOG.error("Broken chain {} in TxchainBaDelete, transaction {}, cause {}", chain, transaction.getIdentifier(),
+            cause);
     }
 
     @Override
-    public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+    public void onTransactionChainSuccessful(final TransactionChain chain) {
         LOG.debug("TxchainBaDelete closed successfully, chain {}", chain);
     }
-
 }