Deprecate DOMDataTreeProducer-related classes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / sharding / PrefixedShardConfigWriter.java
index 0342a1351748aa77f2020bb179198ddf5bace2a9..6d9c8e92133a47f2042812f0bebc610c96254f87 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.sharding;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collection;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
@@ -19,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;
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
  * by {@link DistributedShardedDOMDataTree} for updating
  * prefix-shard-configuration upon creating and de-spawning prefix-based shards.
  */
+@Deprecated(forRemoval = true)
 class PrefixedShardConfigWriter {
 
     private static final Logger LOG = LoggerFactory.getLogger(PrefixedShardConfigWriter.class);
@@ -100,21 +101,22 @@ class PrefixedShardConfigWriter {
         final AsyncFunction<Boolean, Void> validateFunction = input -> cohort.preCommit();
         final AsyncFunction<Void, Void> prepareFunction = input -> cohort.commit();
 
-        final ListenableFuture<Void> prepareFuture = Futures.transform(cohort.canCommit(), validateFunction);
-        return Futures.transform(prepareFuture, prepareFunction);
+        final ListenableFuture<Void> prepareFuture = Futures.transformAsync(cohort.canCommit(), validateFunction,
+            MoreExecutors.directExecutor());
+        return Futures.transformAsync(prepareFuture, prepareFunction, MoreExecutors.directExecutor());
     }
 
     boolean checkDefaultIsPresent() {
         final NodeIdentifierWithPredicates pag =
-                new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
-                YangInstanceIdentifier.EMPTY);
+                NodeIdentifierWithPredicates.of(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
+                YangInstanceIdentifier.empty());
 
         final YangInstanceIdentifier defaultId = ClusterUtils.SHARD_LIST_PATH.node(pag);
 
         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 {
@@ -137,7 +139,7 @@ class PrefixedShardConfigWriter {
 
         final MapEntryNode newEntry = ImmutableMapEntryNodeBuilder.create()
                 .withNodeIdentifier(
-                        new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
+                        NodeIdentifierWithPredicates.of(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME,
                                 path))
                 .withChild(ImmutableLeafNodeBuilder.create()
                         .withNodeIdentifier(new NodeIdentifier(ClusterUtils.SHARD_PREFIX_QNAME))
@@ -168,7 +170,7 @@ class PrefixedShardConfigWriter {
         ClusterUtils.SHARD_LIST_PATH.getPathArguments().forEach(cursor::enter);
 
         cursor.delete(
-                new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME, path));
+                NodeIdentifierWithPredicates.of(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME, path));
         cursor.close();
 
         return tx.ready();