Adjust to mdsal DOM read/exists FluentFuture change 28/74128/8
authorTom Pantelis <tompantelis@gmail.com>
Tue, 17 Jul 2018 15:05:41 +0000 (11:05 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Thu, 19 Jul 2018 03:49:15 +0000 (23:49 -0400)
This patch needs to be coordinated with
https://git.opendaylight.org/gerrit/#/c/74127/.

Change-Id: Iceeff9f9f75ca40ebc31bd839b5e6a5c8639aa4c
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
52 files changed:
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccess.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessProxyV1.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessNoDataTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessTest.java
opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadOnlyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientSnapshot.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalReadWriteProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendReadOnlyTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/LegacyDOMStoreAdapter.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/AbstractRead.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExists.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/ReadData.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/PrefixedShardConfigWriter.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ClientBackedReadWriteTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientSnapshotTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/LocalProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregatorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/legacy/sharded/adapter/ShardedDOMDataBrokerDelegatingReadTransaction.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMStoreReadTransactionAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java
opendaylight/md-sal/sal-dom-compat/src/test/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapterTest.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/MdsalLowLevelTestProvider.java

index 77bd430..8fe4b0b 100644 (file)
@@ -8,8 +8,9 @@
 package org.opendaylight.controller.cluster.access.commands;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Optional;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 import org.opendaylight.controller.cluster.access.concepts.SliceableMessage;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
@@ -22,6 +23,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
  * @author Robert Varga
  */
 @Beta
+@SuppressFBWarnings("SE_BAD_FIELD")
 public final class ReadTransactionSuccess extends TransactionSuccess<ReadTransactionSuccess>
         implements SliceableMessage {
     private static final long serialVersionUID = 1L;
index dafc26b..24a305b 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import com.google.common.base.Optional;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.Optional;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
@@ -59,7 +59,7 @@ final class ReadTransactionSuccessProxyV1 extends AbstractTransactionSuccessProx
         if (in.readBoolean()) {
             data = Optional.of(NormalizedNodeInputOutput.newDataInput(in).readNormalizedNode());
         } else {
-            data = Optional.absent();
+            data = Optional.empty();
         }
     }
 
index 5259fe4..a24539f 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
@@ -15,7 +15,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 public class ReadTransactionSuccessNoDataTest extends AbstractTransactionSuccessTest<ReadTransactionSuccess> {
     private static final ReadTransactionSuccess OBJECT = new ReadTransactionSuccess(
-            TRANSACTION_IDENTIFIER, 0, Optional.absent());
+            TRANSACTION_IDENTIFIER, 0, Optional.empty());
 
     @Override
     protected ReadTransactionSuccess object() {
@@ -39,4 +39,4 @@ public class ReadTransactionSuccessNoDataTest extends AbstractTransactionSuccess
         Assert.assertTrue(deserialize instanceof ReadTransactionSuccess);
         Assert.assertEquals(OBJECT.getData(), ((ReadTransactionSuccess) deserialize).getData());
     }
-}
\ No newline at end of file
+}
index a76e6d3..812a366 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
@@ -46,4 +46,4 @@ public class ReadTransactionSuccessTest extends AbstractTransactionSuccessTest<R
         Assert.assertTrue(deserialize instanceof ReadTransactionSuccess);
         Assert.assertEquals(OBJECT.getData(), ((ReadTransactionSuccess) deserialize).getData());
     }
-}
\ No newline at end of file
+}
index a2806bb..6aebe06 100644 (file)
@@ -454,7 +454,7 @@ public class ClusterAdminRpcServiceTest {
 
     private static void readCarsNodeAndVerify(final AbstractDataStore readFromStore,
             final NormalizedNode<?, ?> expCarsNode) throws Exception {
-        Optional<NormalizedNode<?, ?>> optional = readFromStore.newReadOnlyTransaction()
+        java.util.Optional<NormalizedNode<?, ?>> optional = readFromStore.newReadOnlyTransaction()
                 .read(CarsModel.BASE_PATH).get(15, TimeUnit.SECONDS);
         assertTrue("isPresent", optional.isPresent());
         assertEquals("Data node", expCarsNode, optional.get());
index 2a05519..de4ae32 100644 (file)
@@ -7,13 +7,11 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-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.FluentFuture;
+import java.util.Optional;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -40,13 +38,13 @@ final class ClientBackedReadTransaction extends ClientBackedTransaction<ClientSn
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
-        return Futures.makeChecked(delegate().read(path), ReadFailedException.MAPPER);
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
+        return delegate().read(path);
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
-        return Futures.makeChecked(delegate().exists(path), ReadFailedException.MAPPER);
+    public FluentFuture<Boolean> exists(final YangInstanceIdentifier path) {
+        return delegate().exists(path);
     }
 
     @Override
index 0e673e7..cfc251d 100644 (file)
@@ -7,12 +7,10 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-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.FluentFuture;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -30,12 +28,12 @@ final class ClientBackedReadWriteTransaction extends ClientBackedWriteTransactio
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
-        return Futures.makeChecked(delegate().read(path), ReadFailedException.MAPPER);
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
+        return delegate().read(path);
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
-        return Futures.makeChecked(delegate().exists(path), ReadFailedException.MAPPER);
+    public FluentFuture<Boolean> exists(final YangInstanceIdentifier path) {
+        return delegate().exists(path);
     }
 }
index 0dccb42..afce5c0 100644 (file)
@@ -8,11 +8,10 @@
 
 package org.opendaylight.controller.cluster.databroker;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Map;
+import java.util.Optional;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
@@ -33,15 +32,13 @@ public class DOMBrokerReadOnlyTransaction
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(
-            final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final LogicalDatastoreType store,
+            final YangInstanceIdentifier path) {
         return getSubtransaction(store).read(path);
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> exists(
-            final LogicalDatastoreType store,
-            final YangInstanceIdentifier path) {
+    public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
         return getSubtransaction(store).exists(path);
     }
 
index d5a0939..b160d5b 100644 (file)
@@ -8,11 +8,10 @@
 
 package org.opendaylight.controller.cluster.databroker;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Map;
+import java.util.Optional;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
@@ -35,15 +34,13 @@ public class DOMBrokerReadWriteTransaction extends AbstractDOMBrokerWriteTransac
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(
-            final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+    public FluentFuture<Optional<NormalizedNode<?,?>>> read(final LogicalDatastoreType store,
+            final YangInstanceIdentifier path) {
         return getSubtransaction(store).read(path);
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> exists(
-            final LogicalDatastoreType store,
-            final YangInstanceIdentifier path) {
+    public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
         return getSubtransaction(store).exists(path);
     }
 
index 8e09411..dab0c9f 100644 (file)
@@ -9,16 +9,16 @@ package org.opendaylight.controller.cluster.databroker.actors.dds;
 
 import akka.actor.ActorRef;
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.ArrayDeque;
 import java.util.Deque;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
@@ -45,7 +45,6 @@ import org.opendaylight.controller.cluster.access.concepts.Request;
 import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
 import org.opendaylight.controller.cluster.access.concepts.Response;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -305,12 +304,12 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
         doWrite(path, data);
     }
 
-    final CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
+    final FluentFuture<Boolean> exists(final YangInstanceIdentifier path) {
         checkNotSealed();
         return doExists(path);
     }
 
-    final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
+    final FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
         checkNotSealed();
         return doRead(path);
     }
@@ -335,7 +334,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
         final boolean success = markSealed();
         Preconditions.checkState(success, "Proxy %s was already sealed", getIdentifier());
 
-        if (!sealAndSend(Optional.absent())) {
+        if (!sealAndSend(Optional.empty())) {
             sealSuccessor();
         }
     }
@@ -359,7 +358,7 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
     }
 
     private void predecessorSealed() {
-        if (markSealed() && !sealAndSend(Optional.absent())) {
+        if (markSealed() && !sealAndSend(Optional.empty())) {
             sealSuccessor();
         }
     }
@@ -797,9 +796,9 @@ abstract class AbstractProxyTransaction implements Identifiable<TransactionIdent
 
     abstract void doWrite(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
 
-    abstract CheckedFuture<Boolean, ReadFailedException> doExists(YangInstanceIdentifier path);
+    abstract FluentFuture<Boolean> doExists(YangInstanceIdentifier path);
 
-    abstract CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> doRead(YangInstanceIdentifier path);
+    abstract FluentFuture<Optional<NormalizedNode<?, ?>>> doRead(YangInstanceIdentifier path);
 
     @GuardedBy("this")
     abstract java.util.Optional<ModifyTransactionRequest> flushState();
index ac9a709..74c4ae4 100644 (file)
@@ -8,10 +8,9 @@
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Optional;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
@@ -36,12 +35,11 @@ public class ClientSnapshot extends AbstractClientHandle<AbstractProxyTransactio
         return ensureProxy(path, this::createProxy);
     }
 
-    public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
+    public FluentFuture<Boolean> exists(final YangInstanceIdentifier path) {
         return ensureSnapshotProxy(path).exists(path);
     }
 
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
-            final YangInstanceIdentifier path) {
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
         return ensureSnapshotProxy(path).read(path);
     }
 }
index 02ccde2..9c09838 100644 (file)
@@ -8,14 +8,13 @@
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
 import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Collection;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeCursor;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
@@ -75,12 +74,11 @@ public class ClientTransaction extends AbstractClientHandle<AbstractProxyTransac
         return cursor;
     }
 
-    public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
+    public FluentFuture<Boolean> exists(final YangInstanceIdentifier path) {
         return ensureTransactionProxy(path).exists(path);
     }
 
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
-            final YangInstanceIdentifier path) {
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
         return ensureTransactionProxy(path).read(path);
     }
 
index 8940209..2a81e1d 100644 (file)
@@ -7,10 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Optional;
 import java.util.function.Consumer;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -29,7 +28,7 @@ import org.opendaylight.controller.cluster.access.commands.TransactionRequest;
 import org.opendaylight.controller.cluster.access.concepts.Response;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -79,13 +78,13 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
             @Nullable Consumer<Response<?, ?>> callback, long enqueuedTicks);
 
     @Override
-    final CheckedFuture<Boolean, ReadFailedException> doExists(final YangInstanceIdentifier path) {
-        return Futures.immediateCheckedFuture(readOnlyView().readNode(path).isPresent());
+    final FluentFuture<Boolean> doExists(final YangInstanceIdentifier path) {
+        return FluentFutures.immediateFluentFuture(readOnlyView().readNode(path).isPresent());
     }
 
     @Override
-    final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> doRead(final YangInstanceIdentifier path) {
-        return Futures.immediateCheckedFuture(Optional.fromJavaUtil(readOnlyView().readNode(path)));
+    final FluentFuture<Optional<NormalizedNode<?, ?>>> doRead(final YangInstanceIdentifier path) {
+        return FluentFutures.immediateFluentFuture(readOnlyView().readNode(path));
     }
 
     @Override
@@ -109,7 +108,7 @@ abstract class LocalProxyTransaction extends AbstractProxyTransaction {
         // listeners, which we do not want to execute while we are reconnecting.
         if (request instanceof ReadTransactionRequest) {
             final YangInstanceIdentifier path = ((ReadTransactionRequest) request).getPath();
-            final Optional<NormalizedNode<?, ?>> result = Optional.fromJavaUtil(readOnlyView().readNode(path));
+            final Optional<NormalizedNode<?, ?>> result = readOnlyView().readNode(path);
             if (callback != null) {
                 // XXX: FB does not see that callback is final, on stack and has be check for non-null.
                 final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
index c4db9d8..ccce603 100644 (file)
@@ -191,7 +191,7 @@ final class LocalReadWriteProxyTransaction extends LocalProxyTransaction {
     }
 
     @Override
-    boolean sealAndSend(final com.google.common.base.Optional<Long> enqueuedTicks) {
+    boolean sealAndSend(final Optional<Long> enqueuedTicks) {
         sealModification();
         return super.sealAndSend(enqueuedTicks);
     }
index 3063a35..e12c724 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.Optional;
 import java.util.function.Consumer;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
@@ -40,8 +40,8 @@ import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
 import org.opendaylight.controller.cluster.access.concepts.Response;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.util.AbstractDataTreeModificationCursor;
-import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
 import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -66,6 +66,8 @@ import org.slf4j.LoggerFactory;
 final class RemoteProxyTransaction extends AbstractProxyTransaction {
     private static final Logger LOG = LoggerFactory.getLogger(RemoteProxyTransaction.class);
 
+    private static final Function<Exception, Exception> NOOP_EXCEPTION_MAPPER = ex -> ex;
+
     // FIXME: make this tuneable
     private static final int REQUEST_MAX_MODIFICATIONS = 1000;
 
@@ -97,42 +99,43 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
 
     @Override
     void doDelete(final YangInstanceIdentifier path) {
-        appendModification(new TransactionDelete(path), Optional.absent());
+        appendModification(new TransactionDelete(path), Optional.empty());
     }
 
     @Override
     void doMerge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
-        appendModification(new TransactionMerge(path, data), Optional.absent());
+        appendModification(new TransactionMerge(path, data), Optional.empty());
     }
 
     @Override
     void doWrite(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
-        appendModification(new TransactionWrite(path, data), Optional.absent());
+        appendModification(new TransactionWrite(path, data), Optional.empty());
     }
 
-    private <T> CheckedFuture<T, ReadFailedException> sendReadRequest(final AbstractReadTransactionRequest<?> request,
+    private <T> FluentFuture<T> sendReadRequest(final AbstractReadTransactionRequest<?> request,
             final Consumer<Response<?, ?>> completer, final ListenableFuture<T> future) {
         // Check if a previous operation failed. If it has, do not bother sending anything and report a failure
         final Exception local = operationFailure;
         if (local != null) {
-            return Futures.immediateFailedCheckedFuture(new ReadFailedException("Previous operation failed", local));
+            return FluentFutures.immediateFailedFluentFuture(
+                    new ReadFailedException("Previous operation failed", local));
         }
 
         // Make sure we send any modifications before issuing a read
         ensureFlushedBuider();
         sendRequest(request, completer);
-        return MappingCheckedFuture.create(future, ReadFailedException.MAPPER);
+        return FluentFuture.from(future);
     }
 
     @Override
-    CheckedFuture<Boolean, ReadFailedException> doExists(final YangInstanceIdentifier path) {
+    FluentFuture<Boolean> doExists(final YangInstanceIdentifier path) {
         final SettableFuture<Boolean> future = SettableFuture.create();
         return sendReadRequest(new ExistsTransactionRequest(getIdentifier(), nextSequence(), localActor(), path,
             isSnapshotOnly()), t -> completeExists(future, t), future);
     }
 
     @Override
-    CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> doRead(final YangInstanceIdentifier path) {
+    FluentFuture<Optional<NormalizedNode<?, ?>>> doRead(final YangInstanceIdentifier path) {
         final SettableFuture<Optional<NormalizedNode<?, ?>>> future = SettableFuture.create();
         return sendReadRequest(new ReadTransactionRequest(getIdentifier(), nextSequence(), localActor(), path,
             isSnapshotOnly()), t -> completeRead(future, t), future);
@@ -146,7 +149,7 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
     }
 
     private void ensureFlushedBuider() {
-        ensureFlushedBuider(Optional.absent());
+        ensureFlushedBuider(Optional.empty());
     }
 
     private void ensureFlushedBuider(final Optional<Long> enqueuedTicks) {
@@ -171,7 +174,7 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
     }
 
     private void appendModification(final TransactionModification modification) {
-        appendModification(modification, Optional.absent());
+        appendModification(modification, Optional.empty());
     }
 
     private void appendModification(final TransactionModification modification, final Optional<Long> enqueuedTicks) {
@@ -194,11 +197,12 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
             // Happy path
             recordSuccessfulRequest(request);
         } else {
-            recordFailedResponse(response);
+            recordFailedResponse(response, NOOP_EXCEPTION_MAPPER);
         }
     }
 
-    private Exception recordFailedResponse(final Response<?, ?> response) {
+    private <X extends Exception> X recordFailedResponse(final Response<?, ?> response,
+            final Function<Exception, X> exMapper) {
         final Exception failure;
         if (response instanceof RequestFailure) {
             failure = ((RequestFailure<?, ?>) response).getCause();
@@ -211,11 +215,11 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
             LOG.debug("Transaction {} failed", getIdentifier(), failure);
             operationFailure = failure;
         }
-        return failure;
+        return exMapper.apply(failure);
     }
 
-    private void failFuture(final SettableFuture<?> future, final Response<?, ?> response) {
-        future.setException(recordFailedResponse(response));
+    private void failReadFuture(final SettableFuture<?> future, final Response<?, ?> response) {
+        future.setException(recordFailedResponse(response, ReadFailedException.MAPPER));
     }
 
     private void completeExists(final SettableFuture<Boolean> future, final Response<?, ?> response) {
@@ -224,7 +228,7 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
         if (response instanceof ExistsTransactionSuccess) {
             future.set(((ExistsTransactionSuccess) response).getExists());
         } else {
-            failFuture(future, response);
+            failReadFuture(future, response);
         }
 
         recordFinishedRequest(response);
@@ -237,7 +241,7 @@ final class RemoteProxyTransaction extends AbstractProxyTransaction {
         if (response instanceof ReadTransactionSuccess) {
             future.set(((ReadTransactionSuccess) response).getData());
         } else {
-            failFuture(future, response);
+            failReadFuture(future, response);
         }
 
         recordFinishedRequest(response);
index 8815183..fb9fbdc 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest;
@@ -84,16 +84,14 @@ final class FrontendReadOnlyTransaction extends FrontendTransaction {
 
     private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(openTransaction.getSnapshot()
-            .readNode(request.getPath()));
+        final Optional<NormalizedNode<?, ?>> data = openTransaction.getSnapshot().readNode(request.getPath());
         return recordSuccess(request.getSequence(), new ExistsTransactionSuccess(openTransaction.getIdentifier(),
             request.getSequence(), data.isPresent()));
     }
 
     private ReadTransactionSuccess handleReadTransaction(final ReadTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(openTransaction.getSnapshot().readNode(
-            request.getPath()));
+        final Optional<NormalizedNode<?, ?>> data = openTransaction.getSnapshot().readNode(request.getPath());
         return recordSuccess(request.getSequence(), new ReadTransactionSuccess(openTransaction.getIdentifier(),
             request.getSequence(), data));
     }
index d5fcc5e..9c39d82 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import java.util.Collection;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
@@ -526,16 +526,14 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
 
     private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(checkOpen().getSnapshot().readNode(
-            request.getPath()));
+        final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
         return recordSuccess(request.getSequence(), new ExistsTransactionSuccess(getIdentifier(), request.getSequence(),
             data.isPresent()));
     }
 
     private ReadTransactionSuccess handleReadTransaction(final ReadTransactionRequest request)
             throws RequestException {
-        final Optional<NormalizedNode<?, ?>> data = Optional.fromJavaUtil(checkOpen().getSnapshot().readNode(
-            request.getPath()));
+        final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
         return recordSuccess(request.getSequence(), new ReadTransactionSuccess(getIdentifier(), request.getSequence(),
             data));
     }
index f4ade4f..da6d6d1 100644 (file)
@@ -18,6 +18,7 @@ import java.util.SortedSet;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.AbstractRead;
 import org.opendaylight.controller.cluster.datastore.modification.AbstractModification;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
@@ -69,7 +70,8 @@ abstract class LocalTransactionContext extends AbstractTransactionContext {
 
             @Override
             public void onFailure(final Throwable failure) {
-                proxyFuture.setException(failure);
+                proxyFuture.setException(failure instanceof Exception
+                        ? ReadFailedException.MAPPER.apply((Exception) failure) : failure);
             }
         }, MoreExecutors.directExecutor());
     }
index ce4bda7..52057fa 100644 (file)
@@ -22,7 +22,7 @@ import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
 import org.opendaylight.controller.cluster.datastore.modification.AbstractModification;
 import org.opendaylight.controller.cluster.datastore.modification.Modification;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
index 5b9c95f..ffdf126 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.controller.cluster.datastore.messages.DataExistsReply;
 import org.opendaylight.controller.cluster.datastore.messages.PersistAbortTransactionPayload;
 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
 import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 /**
index b04dd29..d6d44b8 100644 (file)
@@ -10,11 +10,10 @@ package org.opendaylight.controller.cluster.datastore;
 import akka.actor.ActorSelection;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Supplier;
 import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
@@ -24,6 +23,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeMap;
@@ -38,8 +38,6 @@ import org.opendaylight.controller.cluster.datastore.modification.MergeModificat
 import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.cluster.datastore.utils.NormalizedNodeAggregator;
-import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTransaction;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -79,12 +77,11 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
+    public FluentFuture<Boolean> exists(final YangInstanceIdentifier path) {
         return executeRead(shardNameFromIdentifier(path), new DataExists(path, DataStoreVersions.CURRENT_VERSION));
     }
 
-    private <T> CheckedFuture<T, ReadFailedException> executeRead(final String shardName,
-            final AbstractRead<T> readCmd) {
+    private <T> FluentFuture<T> executeRead(final String shardName, final AbstractRead<T> readCmd) {
         Preconditions.checkState(type != TransactionType.WRITE_ONLY,
                 "Reads from write-only transactions are not allowed");
 
@@ -99,11 +96,11 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
             }
         });
 
-        return MappingCheckedFuture.create(proxyFuture, ReadFailedException.MAPPER);
+        return FluentFuture.from(proxyFuture);
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
         Preconditions.checkState(type != TransactionType.WRITE_ONLY,
                 "Reads from write-only transactions are not allowed");
         Preconditions.checkNotNull(path, "path should not be null");
@@ -112,15 +109,14 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
         return path.isEmpty() ? readAllData() :  singleShardRead(shardNameFromIdentifier(path), path);
     }
 
-    private CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> singleShardRead(
+    private FluentFuture<Optional<NormalizedNode<?, ?>>> singleShardRead(
             final String shardName, final YangInstanceIdentifier path) {
         return executeRead(shardName, new ReadData(path, DataStoreVersions.CURRENT_VERSION));
     }
 
-    private CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readAllData() {
+    private FluentFuture<Optional<NormalizedNode<?, ?>>> readAllData() {
         final Set<String> allShardNames = txContextFactory.getActorContext().getConfiguration().getAllShardNames();
-        final Collection<CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException>> futures =
-                new ArrayList<>(allShardNames.size());
+        final Collection<FluentFuture<Optional<NormalizedNode<?, ?>>>> futures = new ArrayList<>(allShardNames.size());
 
         for (String shardName : allShardNames) {
             futures.add(singleShardRead(shardName, YangInstanceIdentifier.EMPTY));
@@ -140,7 +136,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
                 }
             }, MoreExecutors.directExecutor());
 
-        return MappingCheckedFuture.create(aggregateFuture, ReadFailedException.MAPPER);
+        return FluentFuture.from(aggregateFuture);
     }
 
     @Override
index 389750e..ae1c848 100644 (file)
@@ -11,7 +11,9 @@ import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ForwardingObject;
 import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
@@ -171,7 +173,9 @@ public class LegacyDOMStoreAdapter extends ForwardingObject implements DOMStore,
 
         @Override
         public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(YangInstanceIdentifier path) {
-            return MappingCheckedFuture.create(readDelegate.read(path), ReadFailedExceptionAdapter.INSTANCE);
+            return MappingCheckedFuture.create(readDelegate.read(path).transformAsync(optional ->
+                Futures.immediateFuture(Optional.fromJavaUtil(optional)), MoreExecutors.directExecutor()),
+                ReadFailedExceptionAdapter.INSTANCE);
         }
 
         @Override
index bee9c11..94e1a37 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
@@ -57,7 +56,7 @@ public abstract class AbstractRead<T> extends VersionedExternalizableMessage {
         return version == getVersion() ? this : newInstance(version);
     }
 
-    public abstract CheckedFuture<T, ReadFailedException> apply(DOMStoreReadTransaction readDelegate);
+    public abstract FluentFuture<T> apply(DOMStoreReadTransaction readDelegate);
 
     public abstract void processResponse(Object reponse, SettableFuture<T> promise);
 
index 435b759..b7e38d5 100644 (file)
@@ -9,7 +9,7 @@
 package org.opendaylight.controller.cluster.datastore.messages;
 
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
@@ -26,7 +26,7 @@ public class DataExists extends AbstractRead<Boolean> {
     }
 
     @Override
-    public CheckedFuture<Boolean, ReadFailedException> apply(DOMStoreReadTransaction readDelegate) {
+    public FluentFuture<Boolean> apply(DOMStoreReadTransaction readDelegate) {
         return readDelegate.exists(getPath());
     }
 
index 74d435a..6352b57 100644 (file)
@@ -8,10 +8,10 @@
 
 package org.opendaylight.controller.cluster.datastore.messages;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.Optional;
 import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -28,8 +28,7 @@ public class ReadData extends AbstractRead<Optional<NormalizedNode<?, ?>>> {
     }
 
     @Override
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> apply(
-            DOMStoreReadTransaction readDelegate) {
+    public FluentFuture<Optional<NormalizedNode<?, ?>>> apply(DOMStoreReadTransaction readDelegate) {
         return readDelegate.read(getPath());
     }
 
@@ -37,7 +36,7 @@ public class ReadData extends AbstractRead<Optional<NormalizedNode<?, ?>>> {
     public void processResponse(Object readResponse, SettableFuture<Optional<NormalizedNode<?, ?>>> returnFuture) {
         if (ReadDataReply.isSerializedType(readResponse)) {
             ReadDataReply reply = ReadDataReply.fromSerializable(readResponse);
-            returnFuture.set(Optional.<NormalizedNode<?, ?>>fromNullable(reply.getNormalizedNode()));
+            returnFuture.set(Optional.<NormalizedNode<?, ?>>ofNullable(reply.getNormalizedNode()));
         } else {
             returnFuture.setException(new ReadFailedException("Invalid response reading data for path " + getPath()));
         }
index edbfa1f..8d5994e 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.utils;
 
-import com.google.common.base.Optional;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -66,6 +66,6 @@ public final class NormalizedNodeAggregator {
     }
 
     private Optional<NormalizedNode<?, ?>> getRootNode() {
-        return Optional.fromJavaUtil(dataTree.takeSnapshot().readNode(rootIdentifier));
+        return dataTree.takeSnapshot().readNode(rootIdentifier);
     }
 }
index 2342e5e..5e7f83e 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
 import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient;
 import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -115,8 +114,8 @@ class PrefixedShardConfigWriter {
 
         final ClientSnapshot snapshot = history.takeSnapshot();
         try {
-            return snapshot.exists(defaultId).checkedGet();
-        } catch (final ReadFailedException e) {
+            return snapshot.exists(defaultId).get();
+        } catch (InterruptedException | ExecutionException e) {
             LOG.error("Presence check of default shard in configuration failed.", e);
             return false;
         } finally {
index 8333b48..7d41885 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -65,4 +65,4 @@ public class ClientBackedReadTransactionTest extends ClientBackedTransactionTest
         final ListenableFuture<Boolean> result = object().exists(YangInstanceIdentifier.EMPTY);
         Assert.assertTrue(result.get());
     }
-}
\ No newline at end of file
+}
index e369fd5..97adcb3 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.Futures;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -17,7 +17,6 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -55,8 +54,7 @@ public class ClientBackedReadWriteTransactionTest
 
     @Test
     public void testRead() throws Exception {
-        final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> result = object().read(
-                YangInstanceIdentifier.EMPTY);
+        final FluentFuture<Optional<NormalizedNode<?, ?>>> result = object().read(YangInstanceIdentifier.EMPTY);
         final Optional<NormalizedNode<?, ?>> resultData = result.get();
         Assert.assertTrue(resultData.isPresent());
         Assert.assertEquals(data, resultData.get());
index 8162484..9e3f57e 100644 (file)
@@ -11,8 +11,8 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.getWithTimeout;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -54,4 +54,4 @@ public class ClientSnapshotTest extends AbstractClientHandleTest<ClientSnapshot>
         Assert.assertFalse(getWithTimeout(exists).isPresent());
     }
 
-}
\ No newline at end of file
+}
index 04f706d..9dd5d7b 100644 (file)
@@ -14,16 +14,15 @@ import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtil
 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.assertOperationThrowsException;
 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.getWithTimeout;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.opendaylight.controller.cluster.access.commands.CommitLocalTransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.TransactionCommitSuccess;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -78,14 +77,14 @@ public class ClientTransactionTest extends AbstractClientHandleTest<ClientTransa
 
     @Test
     public void testExists() throws Exception {
-        final CheckedFuture<Boolean, ReadFailedException> exists = getHandle().exists(PATH);
+        final FluentFuture<Boolean> exists = getHandle().exists(PATH);
         verify(modification).readNode(PATH);
         Assert.assertTrue(getWithTimeout(exists));
     }
 
     @Test
     public void testRead() throws Exception {
-        final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> resultFuture = getHandle().read(PATH);
+        final FluentFuture<Optional<NormalizedNode<?, ?>>> resultFuture = getHandle().read(PATH);
         verify(modification).readNode(PATH);
         final Optional<NormalizedNode<?, ?>> result = getWithTimeout(resultFuture);
         Assert.assertTrue(result.isPresent());
@@ -138,4 +137,4 @@ public class ClientTransactionTest extends AbstractClientHandleTest<ClientTransa
         checkClosed();
     }
 
-}
\ No newline at end of file
+}
index d033951..a4405de 100644 (file)
@@ -15,6 +15,7 @@ import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtil
 
 import akka.testkit.TestProbe;
 import com.google.common.base.Ticker;
+import java.util.Optional;
 import java.util.function.Consumer;
 import org.junit.Assert;
 import org.junit.Test;
@@ -50,8 +51,8 @@ public abstract class LocalProxyTransactionTest<T extends LocalProxyTransaction>
     @Override
     @Test
     public void testRead() throws Exception {
-        assertFutureEquals(com.google.common.base.Optional.of(DATA_1), transaction.read(PATH_1));
-        assertFutureEquals(com.google.common.base.Optional.absent(), transaction.read(PATH_3));
+        assertFutureEquals(Optional.of(DATA_1), transaction.read(PATH_1));
+        assertFutureEquals(Optional.empty(), transaction.read(PATH_3));
     }
 
     @Test
index c8bdd27..e159cf0 100644 (file)
@@ -13,10 +13,10 @@ import static org.hamcrest.CoreMatchers.isA;
 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.assertFutureEquals;
 
 import akka.testkit.TestProbe;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
+import java.util.Optional;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest;
@@ -37,7 +37,6 @@ import org.opendaylight.controller.cluster.access.commands.TransactionPreCommitR
 import org.opendaylight.controller.cluster.access.commands.TransactionPreCommitSuccess;
 import org.opendaylight.controller.cluster.access.commands.TransactionWrite;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
@@ -54,7 +53,7 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
     @Test
     public void testExists() throws Exception {
         final TransactionTester<RemoteProxyTransaction> tester = getTester();
-        final CheckedFuture<Boolean, ReadFailedException> exists = transaction.exists(PATH_1);
+        final FluentFuture<Boolean> exists = transaction.exists(PATH_1);
         final ExistsTransactionRequest req = tester.expectTransactionRequest(ExistsTransactionRequest.class);
         final boolean existsResult = true;
         tester.replySuccess(new ExistsTransactionSuccess(TRANSACTION_ID, req.getSequence(), existsResult));
@@ -65,7 +64,7 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
     @Test
     public void testRead() throws Exception {
         final TransactionTester<RemoteProxyTransaction> tester = getTester();
-        final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read = transaction.read(PATH_2);
+        final FluentFuture<Optional<NormalizedNode<?, ?>>> read = transaction.read(PATH_2);
         final ReadTransactionRequest req = tester.expectTransactionRequest(ReadTransactionRequest.class);
         final Optional<NormalizedNode<?, ?>> result = Optional.of(DATA_1);
         tester.replySuccess(new ReadTransactionSuccess(TRANSACTION_ID, req.getSequence(), result));
@@ -233,4 +232,4 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         Assert.assertThat(modifications, hasItem(both(isA(cls)).and(hasPath(expectedPath))));
     }
 
-}
\ No newline at end of file
+}
index a998fbf..482f696 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.datastore;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.argThat;
@@ -29,7 +30,7 @@ import com.codahale.metrics.MetricRegistry;
 import com.codahale.metrics.Timer;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
 import java.io.IOException;
@@ -38,6 +39,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -386,23 +388,15 @@ public abstract class AbstractTransactionProxyTest extends AbstractTest {
                 shardName);
     }
 
-    @SuppressWarnings("checkstyle:avoidHidingCauseException")
-    protected void propagateReadFailedExceptionCause(final CheckedFuture<?, ReadFailedException> future)
-            throws Exception {
+    @SuppressWarnings({"checkstyle:avoidHidingCauseException", "checkstyle:IllegalThrows"})
+    protected void propagateReadFailedExceptionCause(final FluentFuture<?> future) throws Throwable {
         try {
-            future.checkedGet(5, TimeUnit.SECONDS);
+            future.get(5, TimeUnit.SECONDS);
             fail("Expected ReadFailedException");
-        } catch (ReadFailedException e) {
-            assertNotNull("Expected a cause", e.getCause());
-            Throwable cause;
-            if (e.getCause().getCause() != null) {
-                cause = e.getCause().getCause();
-            } else {
-                cause = e.getCause();
-            }
-
-            Throwables.propagateIfPossible(cause, Exception.class);
-            throw new RuntimeException(cause);
+        } catch (ExecutionException e) {
+            final Throwable cause = e.getCause();
+            assertTrue("Unexpected cause: " + cause.getClass(), cause instanceof ReadFailedException);
+            throw Throwables.getRootCause(cause);
         }
     }
 
index 482021a..fe8ffe3 100644 (file)
@@ -22,10 +22,9 @@ import akka.actor.Address;
 import akka.actor.AddressFromURIString;
 import akka.cluster.Cluster;
 import akka.testkit.javadsl.TestKit;
-import com.google.common.base.Optional;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
@@ -37,6 +36,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -212,7 +212,7 @@ public class DistributedDataStoreIntegrationTest {
                     readWriteTx.write(nodePath, nodeToWrite);
 
                     // 3. Read the data from Tx
-                    final Boolean exists = readWriteTx.exists(nodePath).checkedGet(5, TimeUnit.SECONDS);
+                    final Boolean exists = readWriteTx.exists(nodePath).get(5, TimeUnit.SECONDS);
                     assertEquals("exists", true, exists);
 
                     Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(nodePath).get(5, TimeUnit.SECONDS);
@@ -268,7 +268,7 @@ public class DistributedDataStoreIntegrationTest {
                     final YangInstanceIdentifier personPath = PeopleModel.newPersonPath("jack");
                     readWriteTx.write(personPath, person);
 
-                    final Boolean exists = readWriteTx.exists(carPath).checkedGet(5, TimeUnit.SECONDS);
+                    final Boolean exists = readWriteTx.exists(carPath).get(5, TimeUnit.SECONDS);
                     assertEquals("exists", true, exists);
 
                     Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(carPath).get(5, TimeUnit.SECONDS);
@@ -445,9 +445,8 @@ public class DistributedDataStoreIntegrationTest {
                     assertNotNull("newReadWriteTransaction returned null", readWriteTx);
 
                     // Do some reads on the Tx on a separate thread.
-                    final AtomicReference<CheckedFuture<Boolean, ReadFailedException>> txExistsFuture =
-                            new AtomicReference<>();
-                    final AtomicReference<CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException>>
+                    final AtomicReference<FluentFuture<Boolean>> txExistsFuture = new AtomicReference<>();
+                    final AtomicReference<FluentFuture<Optional<NormalizedNode<?, ?>>>>
                             txReadFuture = new AtomicReference<>();
                     final AtomicReference<Exception> caughtEx = new AtomicReference<>();
                     final CountDownLatch txReadsDone = new CountDownLatch(1);
@@ -482,8 +481,8 @@ public class DistributedDataStoreIntegrationTest {
                     blockRecoveryLatch.countDown();
 
                     // Wait for the reads to complete and verify.
-                    assertEquals("exists", true, txExistsFuture.get().checkedGet(5, TimeUnit.SECONDS));
-                    assertEquals("read", true, txReadFuture.get().checkedGet(5, TimeUnit.SECONDS).isPresent());
+                    assertEquals("exists", true, txExistsFuture.get().get(5, TimeUnit.SECONDS));
+                    assertEquals("read", true, txReadFuture.get().get(5, TimeUnit.SECONDS).isPresent());
 
                     readWriteTx.close();
                 }
@@ -588,7 +587,7 @@ public class DistributedDataStoreIntegrationTest {
                     assertNotNull("newReadWriteTransaction returned null", readWriteTx);
 
                     // Do a read on the Tx on a separate thread.
-                    final AtomicReference<CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException>>
+                    final AtomicReference<FluentFuture<Optional<NormalizedNode<?, ?>>>>
                             txReadFuture = new AtomicReference<>();
                     final AtomicReference<Exception> caughtEx = new AtomicReference<>();
                     final CountDownLatch txReadDone = new CountDownLatch(1);
@@ -621,9 +620,10 @@ public class DistributedDataStoreIntegrationTest {
                     // initialized, the Tx should
                     // have timed out and throw an appropriate exception cause.
                     try {
-                        txReadFuture.get().checkedGet(5, TimeUnit.SECONDS);
-                        fail("Expected NotInitializedException");
-                    } catch (final ReadFailedException e) {
+                        txReadFuture.get().get(5, TimeUnit.SECONDS);
+                    } catch (ExecutionException e) {
+                        assertTrue("Expected ReadFailedException cause: " + e.getCause(),
+                                e.getCause() instanceof ReadFailedException);
                         final Throwable root = Throwables.getRootCause(e);
                         Throwables.throwIfUnchecked(root);
                         throw new RuntimeException(root);
@@ -1045,10 +1045,10 @@ public class DistributedDataStoreIntegrationTest {
                     final DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
 
                     // Create read-only tx's and issue a read.
-                    CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture1 = txChain
+                    FluentFuture<Optional<NormalizedNode<?, ?>>> readFuture1 = txChain
                             .newReadOnlyTransaction().read(TestModel.TEST_PATH);
 
-                    CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture2 = txChain
+                    FluentFuture<Optional<NormalizedNode<?, ?>>> readFuture2 = txChain
                             .newReadOnlyTransaction().read(TestModel.TEST_PATH);
 
                     // Create another write tx and issue the write.
@@ -1058,8 +1058,8 @@ public class DistributedDataStoreIntegrationTest {
 
                     // Ensure the reads succeed.
 
-                    assertEquals("isPresent", true, readFuture1.checkedGet(5, TimeUnit.SECONDS).isPresent());
-                    assertEquals("isPresent", true, readFuture2.checkedGet(5, TimeUnit.SECONDS).isPresent());
+                    assertEquals("isPresent", true, readFuture1.get(5, TimeUnit.SECONDS).isPresent());
+                    assertEquals("isPresent", true, readFuture2.get(5, TimeUnit.SECONDS).isPresent());
 
                     // Ensure the writes succeed.
                     DOMStoreThreePhaseCommitCohort cohort2 = writeTx2.ready();
@@ -1068,7 +1068,7 @@ public class DistributedDataStoreIntegrationTest {
                     doCommit(cohort2);
 
                     assertEquals("isPresent", true, txChain.newReadOnlyTransaction().read(TestModel.OUTER_LIST_PATH)
-                            .checkedGet(5, TimeUnit.SECONDS).isPresent());
+                            .get(5, TimeUnit.SECONDS).isPresent());
                 }
             }
         };
index 4f0f929..526b1d4 100644 (file)
@@ -25,7 +25,6 @@ import akka.cluster.Cluster;
 import akka.dispatch.Futures;
 import akka.pattern.Patterns;
 import akka.testkit.javadsl.TestKit;
-import com.google.common.base.Optional;
 import com.google.common.base.Stopwatch;
 import com.google.common.base.Supplier;
 import com.google.common.base.Throwables;
@@ -40,6 +39,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
@@ -636,8 +636,8 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         initDatastoresWithCars("testReadyLocalTransactionForwardedToLeader");
         followerTestKit.waitUntilLeader(followerDistributedDataStore.getActorContext(), "cars");
 
-        final Optional<ActorRef> carsFollowerShard = followerDistributedDataStore.getActorContext()
-                .findLocalShard("cars");
+        final com.google.common.base.Optional<ActorRef> carsFollowerShard =
+                followerDistributedDataStore.getActorContext().findLocalShard("cars");
         assertEquals("Cars follower shard found", true, carsFollowerShard.isPresent());
 
         final DataTree dataTree = new InMemoryDataTreeFactory().create(
@@ -704,8 +704,8 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         initDatastoresWithCars("testForwardedReadyTransactionForwardedToLeader");
         followerTestKit.waitUntilLeader(followerDistributedDataStore.getActorContext(), "cars");
 
-        final Optional<ActorRef> carsFollowerShard = followerDistributedDataStore.getActorContext()
-                .findLocalShard("cars");
+        final com.google.common.base.Optional<ActorRef> carsFollowerShard =
+                followerDistributedDataStore.getActorContext().findLocalShard("cars");
         assertEquals("Cars follower shard found", true, carsFollowerShard.isPresent());
 
         carsFollowerShard.get().tell(GetShardDataTree.INSTANCE, followerTestKit.getRef());
@@ -1009,7 +1009,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         // Do an initial read to get the primary shard info cached.
 
         final DOMStoreReadTransaction readTx = followerDistributedDataStore.newReadOnlyTransaction();
-        readTx.read(CarsModel.BASE_PATH).checkedGet(5, TimeUnit.SECONDS);
+        readTx.read(CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS);
 
         // Shutdown the leader and try to create a new tx.
 
@@ -1044,7 +1044,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         // Do an initial read to get the primary shard info cached.
 
         final DOMStoreReadTransaction readTx = followerDistributedDataStore.newReadOnlyTransaction();
-        readTx.read(CarsModel.BASE_PATH).checkedGet(5, TimeUnit.SECONDS);
+        readTx.read(CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS);
 
         // Shutdown the leader and try to create a new tx.
 
@@ -1095,7 +1095,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
             // Do an initial read to get the primary shard info cached.
 
             final DOMStoreReadTransaction readTx = followerDistributedDataStore.newReadOnlyTransaction();
-            readTx.read(CarsModel.BASE_PATH).checkedGet(5, TimeUnit.SECONDS);
+            readTx.read(CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS);
 
             // Shutdown the leader and try to create a new tx.
 
@@ -1142,7 +1142,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest {
         initDatastoresWithCars(testName);
 
         final Optional<NormalizedNode<?, ?>> readOptional = leaderDistributedDataStore.newReadOnlyTransaction().read(
-                CarsModel.BASE_PATH).checkedGet(5, TimeUnit.SECONDS);
+                CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS);
         assertEquals("isPresent", true, readOptional.isPresent());
         assertEquals("Node", carsNode, readOptional.get());
 
index 82d0535..a7b9ae8 100644 (file)
@@ -17,12 +17,12 @@ import akka.cluster.Cluster;
 import akka.cluster.ClusterEvent.CurrentClusterState;
 import akka.cluster.Member;
 import akka.cluster.MemberStatus;
-import com.google.common.base.Optional;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.lang.reflect.Constructor;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
@@ -250,7 +250,7 @@ public class IntegrationTestKit extends ShardTestKit {
         ActorRef shard = null;
         for (int i = 0; i < 20 * 5 && shard == null; i++) {
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
-            Optional<ActorRef> shardReply = actorContext.findLocalShard(shardName);
+            com.google.common.base.Optional<ActorRef> shardReply = actorContext.findLocalShard(shardName);
             if (shardReply.isPresent()) {
                 shard = shardReply.get();
             }
@@ -262,7 +262,7 @@ public class IntegrationTestKit extends ShardTestKit {
         for (int i = 0; i < 20 * 5 ; i++) {
             LOG.debug("Waiting for shard down {}", shardName);
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
-            Optional<ActorRef> shardReply = actorContext.findLocalShard(shardName);
+            com.google.common.base.Optional<ActorRef> shardReply = actorContext.findLocalShard(shardName);
             if (!shardReply.isPresent()) {
                 return;
             }
index 881429b..580c805 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats
 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
index 4fa4fcd..62c03d7 100644 (file)
@@ -29,16 +29,16 @@ import akka.actor.ActorSystem;
 import akka.actor.Props;
 import akka.dispatch.Futures;
 import akka.util.Timeout;
-import com.google.common.base.Optional;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableSortedSet;
 import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 import java.util.SortedSet;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -82,7 +82,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.Promise;
 
-@SuppressWarnings("resource")
+@SuppressWarnings({"resource", "checkstyle:IllegalThrows", "checkstyle:AvoidHidingCauseException"})
 public class TransactionProxyTest extends AbstractTransactionProxyTest {
 
     @SuppressWarnings("serial")
@@ -90,7 +90,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
     }
 
     interface Invoker {
-        CheckedFuture<?, ReadFailedException> invoke(TransactionProxy proxy) throws Exception;
+        FluentFuture<?> invoke(TransactionProxy proxy) throws Exception;
     }
 
     @Test
@@ -120,7 +120,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
     }
 
     @Test(expected = ReadFailedException.class)
-    public void testReadWithInvalidReplyMessageType() throws Exception {
+    public void testReadWithInvalidReplyMessageType() throws Throwable {
         ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY);
 
         doReturn(Futures.successful(new Object())).when(mockActorContext)
@@ -128,11 +128,15 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
 
         TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY);
 
-        transactionProxy.read(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
+        try {
+            transactionProxy.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
+        } catch (ExecutionException e) {
+            throw e.getCause();
+        }
     }
 
     @Test(expected = TestException.class)
-    public void testReadWithAsyncRemoteOperatonFailure() throws Exception {
+    public void testReadWithAsyncRemoteOperatonFailure() throws Throwable {
         ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY);
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext)
@@ -144,7 +148,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
     }
 
     private void testExceptionOnInitialCreateTransaction(final Exception exToThrow, final Invoker invoker)
-            throws Exception {
+            throws Throwable {
         ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));
 
         if (exToThrow instanceof PrimaryNotFoundException) {
@@ -162,23 +166,23 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
         propagateReadFailedExceptionCause(invoker.invoke(transactionProxy));
     }
 
-    private void testReadWithExceptionOnInitialCreateTransaction(final Exception exToThrow) throws Exception {
+    private void testReadWithExceptionOnInitialCreateTransaction(final Exception exToThrow) throws Throwable {
         testExceptionOnInitialCreateTransaction(exToThrow, proxy -> proxy.read(TestModel.TEST_PATH));
     }
 
     @Test(expected = PrimaryNotFoundException.class)
-    public void testReadWhenAPrimaryNotFoundExceptionIsThrown() throws Exception {
+    public void testReadWhenAPrimaryNotFoundExceptionIsThrown() throws Throwable {
         testReadWithExceptionOnInitialCreateTransaction(new PrimaryNotFoundException("test"));
     }
 
-    @Test(expected = TimeoutException.class)
-    public void testReadWhenATimeoutExceptionIsThrown() throws Exception {
+    @Test(expected = TestException.class)
+    public void testReadWhenATimeoutExceptionIsThrown() throws Throwable {
         testReadWithExceptionOnInitialCreateTransaction(new TimeoutException("test",
-                new Exception("reason")));
+                new TestException()));
     }
 
     @Test(expected = TestException.class)
-    public void testReadWhenAnyOtherExceptionIsThrown() throws Exception {
+    public void testReadWhenAnyOtherExceptionIsThrown() throws Throwable {
         testReadWithExceptionOnInitialCreateTransaction(new TestException());
     }
 
@@ -218,7 +222,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
     }
 
     @Test(expected = IllegalArgumentException.class)
-    public void testInvalidCreateTransactionReply() throws Exception {
+    public void testInvalidCreateTransactionReply() throws Throwable {
         ActorRef actorRef = getSystem().actorOf(Props.create(DoNothingActor.class));
 
         doReturn(getSystem().actorSelection(actorRef.path())).when(mockActorContext)
@@ -245,26 +249,26 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
         doReturn(dataExistsReply(false)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDataExists(), any(Timeout.class));
 
-        Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet();
+        Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).get();
 
         assertEquals("Exists response", false, exists);
 
         doReturn(dataExistsReply(true)).when(mockActorContext).executeOperationAsync(
                 eq(actorSelection(actorRef)), eqDataExists(), any(Timeout.class));
 
-        exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet();
+        exists = transactionProxy.exists(TestModel.TEST_PATH).get();
 
         assertEquals("Exists response", true, exists);
     }
 
     @Test(expected = PrimaryNotFoundException.class)
-    public void testExistsWhenAPrimaryNotFoundExceptionIsThrown() throws Exception {
+    public void testExistsWhenAPrimaryNotFoundExceptionIsThrown() throws Throwable {
         testExceptionOnInitialCreateTransaction(new PrimaryNotFoundException("test"),
             proxy -> proxy.exists(TestModel.TEST_PATH));
     }
 
     @Test(expected = ReadFailedException.class)
-    public void testExistsWithInvalidReplyMessageType() throws Exception {
+    public void testExistsWithInvalidReplyMessageType() throws Throwable {
         ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY);
 
         doReturn(Futures.successful(new Object())).when(mockActorContext)
@@ -272,11 +276,15 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
 
         TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY);
 
-        transactionProxy.exists(TestModel.TEST_PATH).checkedGet(5, TimeUnit.SECONDS);
+        try {
+            transactionProxy.exists(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
+        } catch (ExecutionException e) {
+            throw e.getCause();
+        }
     }
 
     @Test(expected = TestException.class)
-    public void testExistsWithAsyncRemoteOperatonFailure() throws Exception {
+    public void testExistsWithAsyncRemoteOperatonFailure() throws Throwable {
         ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY);
 
         doReturn(Futures.failed(new TestException())).when(mockActorContext)
@@ -302,7 +310,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
 
         transactionProxy.write(TestModel.TEST_PATH, nodeToWrite);
 
-        Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet();
+        Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).get();
 
         assertEquals("Exists response", true, exists);
 
@@ -1415,7 +1423,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
 
         transactionProxy.delete(deletePath);
 
-        Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).checkedGet();
+        Boolean exists = transactionProxy.exists(TestModel.TEST_PATH).get();
         assertEquals("Exists response", true, exists);
 
         assertEquals("NormalizedNode isPresent", true, readOptional.isPresent());
index 9bdacd7..78dc8f3 100644 (file)
@@ -29,7 +29,6 @@ import akka.actor.Status.Success;
 import akka.cluster.Cluster;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Optional;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
@@ -39,6 +38,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 import org.junit.After;
 import org.junit.Before;
@@ -540,10 +540,11 @@ public class DistributedEntityOwnershipIntegrationTest {
         boolean passed = false;
         for (int i = 0; i < 100; i++) {
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
-            final Optional<EntityOwnershipState> leaderState = leaderEntityOwnershipService.getOwnershipState(ENTITY1);
-            final Optional<EntityOwnershipState> follower1State =
+            final com.google.common.base.Optional<EntityOwnershipState> leaderState =
+                    leaderEntityOwnershipService.getOwnershipState(ENTITY1);
+            final com.google.common.base.Optional<EntityOwnershipState> follower1State =
                     follower1EntityOwnershipService.getOwnershipState(ENTITY1);
-            final Optional<EntityOwnershipState> follower2State =
+            final com.google.common.base.Optional<EntityOwnershipState> follower2State =
                     follower2EntityOwnershipService.getOwnershipState(ENTITY1);
             final Optional<DOMEntityOwnershipChange> leaderChange = getValueSafely(leaderChangeCaptor);
             final Optional<DOMEntityOwnershipChange> follower1Change = getValueSafely(follower1ChangeCaptor);
@@ -564,10 +565,10 @@ public class DistributedEntityOwnershipIntegrationTest {
 
     private static Optional<DOMEntityOwnershipChange> getValueSafely(ArgumentCaptor<DOMEntityOwnershipChange> captor) {
         try {
-            return Optional.fromNullable(captor.getValue());
+            return Optional.ofNullable(captor.getValue());
         } catch (MockitoException e) {
             // No value was captured
-            return Optional.absent();
+            return Optional.empty();
         }
     }
 
@@ -837,7 +838,7 @@ public class DistributedEntityOwnershipIntegrationTest {
 
     private static void verifyGetOwnershipState(final DOMEntityOwnershipService service, final DOMEntity entity,
             final EntityOwnershipState expState) {
-        Optional<EntityOwnershipState> state = service.getOwnershipState(entity);
+        com.google.common.base.Optional<EntityOwnershipState> state = service.getOwnershipState(entity);
         assertEquals("getOwnershipState present", true, state.isPresent());
         assertEquals("EntityOwnershipState", expState, state.get());
     }
index ac06dc2..9daa342 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.controller.cluster.datastore.modification;
 
-import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Optional;
 import org.junit.Before;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
index 2974e91..96438c4 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.controller.cluster.datastore.modification;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.apache.commons.lang.SerializationUtils;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
index 5687755..7ae05bd 100644 (file)
@@ -11,10 +11,10 @@ package org.opendaylight.controller.cluster.datastore.utils;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 import org.junit.Test;
@@ -75,7 +75,7 @@ public class NormalizedNodeAggregatorTest {
     }
 
     public static NormalizedNode<?, ?> getRootNode(NormalizedNode<?, ?> moduleNode, SchemaContext schemaContext)
-            throws ReadFailedException, ExecutionException, InterruptedException {
+            throws ExecutionException, InterruptedException {
         try (InMemoryDOMDataStore store = new InMemoryDOMDataStore("test", Executors.newSingleThreadExecutor())) {
             store.onGlobalContextUpdated(schemaContext);
 
@@ -91,10 +91,9 @@ public class NormalizedNodeAggregatorTest {
 
             DOMStoreReadTransaction readTransaction = store.newReadOnlyTransaction();
 
-            CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read = readTransaction
-                    .read(YangInstanceIdentifier.EMPTY);
+            FluentFuture<Optional<NormalizedNode<?, ?>>> read = readTransaction.read(YangInstanceIdentifier.EMPTY);
 
-            Optional<NormalizedNode<?, ?>> nodeOptional = read.checkedGet();
+            Optional<NormalizedNode<?, ?>> nodeOptional = read.get();
 
             return nodeOptional.get();
         }
index 7545cd5..8d5351c 100644 (file)
@@ -29,15 +29,16 @@ import akka.actor.AddressFromURIString;
 import akka.actor.Props;
 import akka.cluster.Cluster;
 import akka.testkit.javadsl.TestKit;
-import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import com.typesafe.config.ConfigFactory;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.TimeUnit;
@@ -269,11 +270,9 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest {
 
         final ClientLocalHistory localHistory = distributedDataStoreClient.createLocalHistory();
         final ClientTransaction tx2 = localHistory.createTransaction();
-        final CheckedFuture<Optional<NormalizedNode<?, ?>>,
-                org.opendaylight.mdsal.common.api.ReadFailedException> read =
-                tx2.read(YangInstanceIdentifier.EMPTY);
+        final FluentFuture<Optional<NormalizedNode<?, ?>>> read = tx2.read(YangInstanceIdentifier.EMPTY);
 
-        final Optional<NormalizedNode<?, ?>> optional = read.checkedGet();
+        final Optional<NormalizedNode<?, ?>> optional = read.get();
         tx2.abort();
         localHistory.close();
 
index 42daf16..2e29c25 100644 (file)
@@ -9,10 +9,12 @@
 package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+import static org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter.LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType;
 
 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.MoreExecutors;
 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.dom.api.DOMDataReadOnlyTransaction;
@@ -43,9 +45,9 @@ class ShardedDOMDataBrokerDelegatingReadTransaction implements DOMDataReadOnlyTr
     @Override
     public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
                                                                                    final YangInstanceIdentifier path) {
-        return Futures.makeChecked(
-                delegateTx.read(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path),
-                ReadFailedException.MAPPER);
+        return Futures.makeChecked(delegateTx.read(translateDataStoreType(store), path).transformAsync(
+            optional -> Futures.immediateFuture(Optional.fromJavaUtil(optional)), MoreExecutors.directExecutor()),
+            ReadFailedException.MAPPER);
     }
 
     @Override
index 60b858f..0e5efa2 100644 (file)
@@ -9,8 +9,11 @@ package org.opendaylight.controller.sal.core.compat;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.base.Optional;
 import com.google.common.collect.ForwardingObject;
 import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
 import org.opendaylight.mdsal.common.api.MappingCheckedFuture;
@@ -43,7 +46,9 @@ public class DOMStoreReadTransactionAdapter<T extends org.opendaylight.mdsal.dom
     @Override
     public CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
             final YangInstanceIdentifier path) {
-        return MappingCheckedFuture.create(delegate.read(path), ReadFailedExceptionAdapter.INSTANCE);
+        return MappingCheckedFuture.create(delegate.read(path).transformAsync(
+            optional -> Futures.immediateFuture(Optional.fromJavaUtil(optional)), MoreExecutors.directExecutor()),
+            ReadFailedExceptionAdapter.INSTANCE);
     }
 
     @Override
index dfd0f14..7f11d5f 100644 (file)
@@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableClassToInstanceMap.Builder;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
 import java.util.Map;
@@ -253,8 +254,9 @@ public class LegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMD
         @Override
         public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(LogicalDatastoreType store,
                 YangInstanceIdentifier path) {
-            return MappingCheckedFuture.create(readDelegate().read(convert(store), path),
-                    ReadFailedExceptionAdapter.INSTANCE);
+            return MappingCheckedFuture.create(readDelegate().read(convert(store), path).transformAsync(
+                optional -> Futures.immediateFuture(Optional.fromJavaUtil(optional)), MoreExecutors.directExecutor()),
+                ReadFailedExceptionAdapter.INSTANCE);
         }
 
         @Override
index 3c752c2..ce375ed 100644 (file)
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
-import com.google.common.base.Optional;
 import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.collect.ImmutableMap;
@@ -30,6 +29,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
@@ -67,6 +67,7 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -152,13 +153,14 @@ public class LegacyDOMDataBrokerAdapterTest {
         doReturn(mockConfigCommitCohort).when(mockConfigWriteTx).ready();
 
         doReturn(mockConfigReadTx).when(mockConfigStore).newReadOnlyTransaction();
-        doReturn(Futures.immediateCheckedFuture(Optional.of(dataNode))).when(mockConfigReadTx).read(TEST_PATH);
-        doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(mockConfigReadTx).exists(TEST_PATH);
+        doReturn(FluentFutures.immediateFluentFuture(Optional.of(dataNode))).when(mockConfigReadTx).read(TEST_PATH);
+        doReturn(FluentFutures.immediateFluentFuture(Boolean.TRUE)).when(mockConfigReadTx).exists(TEST_PATH);
 
         doReturn(mockConfigReadWriteTx).when(mockConfigStore).newReadWriteTransaction();
         doNothing().when(mockConfigReadWriteTx).write(TEST_PATH, dataNode);
         doReturn(mockConfigCommitCohort).when(mockConfigReadWriteTx).ready();
-        doReturn(Futures.immediateCheckedFuture(Optional.of(dataNode))).when(mockConfigReadWriteTx).read(TEST_PATH);
+        doReturn(FluentFutures.immediateFluentFuture(Optional.of(dataNode)))
+                .when(mockConfigReadWriteTx).read(TEST_PATH);
 
         DOMStoreTransactionChain mockTxChain = mock(DOMStoreTransactionChain.class);
         doReturn(mockConfigReadTx).when(mockTxChain).newReadOnlyTransaction();
@@ -194,9 +196,9 @@ public class LegacyDOMDataBrokerAdapterTest {
 
         // Test successful read
 
-        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
+        CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
                 tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
-        Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
+        com.google.common.base.Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
         assertEquals("isPresent", true, readOptional.isPresent());
         assertEquals("NormalizedNode", dataNode, readOptional.get());
 
@@ -324,9 +326,9 @@ public class LegacyDOMDataBrokerAdapterTest {
     public void testReadWriteTransaction() throws Exception {
         DOMDataReadWriteTransaction tx = adapter.newReadWriteTransaction();
 
-        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
+        CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
                 tx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
-        Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
+        com.google.common.base.Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
         assertEquals("isPresent", true, readOptional.isPresent());
         assertEquals("NormalizedNode", dataNode, readOptional.get());
 
@@ -354,9 +356,9 @@ public class LegacyDOMDataBrokerAdapterTest {
 
         DOMDataReadOnlyTransaction readTx = chain.newReadOnlyTransaction();
 
-        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
+        CheckedFuture<com.google.common.base.Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture =
                 readTx.read(LogicalDatastoreType.CONFIGURATION, TEST_PATH);
-        Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
+        com.google.common.base.Optional<NormalizedNode<?, ?>> readOptional = readFuture.get();
         assertEquals("isPresent", true, readOptional.isPresent());
         assertEquals("NormalizedNode", dataNode, readOptional.get());
 
index 9075a56..0c0a3b2 100644 (file)
@@ -793,13 +793,13 @@ public class MdsalLowLevelTestProvider implements OdlMdsalLowlevelControlService
 
         final ClientLocalHistory localHistory = distributedDataStoreClient.createLocalHistory();
         final ClientTransaction tx = localHistory.createTransaction();
-        final ListenableFuture<Optional<NormalizedNode<?, ?>>> read =
+        final ListenableFuture<java.util.Optional<NormalizedNode<?, ?>>> read =
                 tx.read(YangInstanceIdentifier.of(ProduceTransactionsHandler.ID_INT));
 
         tx.abort();
         localHistory.close();
         try {
-            final Optional<NormalizedNode<?, ?>> optional = read.get();
+            final java.util.Optional<NormalizedNode<?, ?>> optional = read.get();
             if (!optional.isPresent()) {
                 LOG.warn("Final read from client is empty.");
                 final RpcError error = RpcResultBuilder.newError(

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.