X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionProxy.java;h=019b0dbebe20c18f964b6f8c5f0f385bf59d3a76;hb=33877f41ffc3f8eb36ad8490315419b90817d26e;hp=83863de00dd7dbfeebe96235a874da057bfd4a52;hpb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java index 83863de00d..019b0dbebe 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java @@ -7,11 +7,11 @@ */ package org.opendaylight.controller.cluster.datastore; +import static com.google.common.base.Preconditions.checkState; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorSelection; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Preconditions; -import com.google.common.base.Supplier; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.Futures; @@ -71,7 +71,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction FluentFuture executeRead(final String shardName, final AbstractRead readCmd) { - Preconditions.checkState(type != TransactionType.WRITE_ONLY, - "Reads from write-only transactions are not allowed"); + checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed"); LOG.trace("Tx {} {} {}", getIdentifier(), readCmd.getClass().getSimpleName(), readCmd.getPath()); @@ -101,9 +100,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction>> 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"); + checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed"); + requireNonNull(path, "path should not be null"); LOG.trace("Tx {} read {}", getIdentifier(), path); return path.isEmpty() ? readAllData() : singleShardRead(shardNameFromIdentifier(path), path); @@ -119,22 +117,21 @@ public class TransactionProxy extends AbstractDOMStoreTransaction>>> futures = new ArrayList<>(allShardNames.size()); for (String shardName : allShardNames) { - futures.add(singleShardRead(shardName, YangInstanceIdentifier.EMPTY)); + futures.add(singleShardRead(shardName, YangInstanceIdentifier.empty())); } final ListenableFuture>>> listFuture = Futures.allAsList(futures); final ListenableFuture>> aggregateFuture; - aggregateFuture = Futures.transform(listFuture, - (Function>>, Optional>>) input -> { - try { - return NormalizedNodeAggregator.aggregate(YangInstanceIdentifier.EMPTY, input, - txContextFactory.getActorUtils().getSchemaContext(), - txContextFactory.getActorUtils().getDatastoreContext().getLogicalStoreType()); - } catch (DataValidationFailedException e) { - throw new IllegalArgumentException("Failed to aggregate", e); - } - }, MoreExecutors.directExecutor()); + aggregateFuture = Futures.transform(listFuture, input -> { + try { + return NormalizedNodeAggregator.aggregate(YangInstanceIdentifier.empty(), input, + txContextFactory.getActorUtils().getSchemaContext(), + txContextFactory.getActorUtils().getDatastoreContext().getLogicalStoreType()); + } catch (DataValidationFailedException e) { + throw new IllegalArgumentException("Failed to aggregate", e); + } + }, MoreExecutors.directExecutor()); return FluentFuture.from(aggregateFuture); } @@ -170,10 +167,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction ready() { - Preconditions.checkState(type != TransactionType.READ_ONLY, "Read-only transactions cannot be readied"); + checkState(type != TransactionType.READ_ONLY, "Read-only transactions cannot be readied"); final boolean success = seal(TransactionState.READY); - Preconditions.checkState(success, "Transaction %s is %s, it cannot be readied", getIdentifier(), state); + checkState(success, "Transaction %s is %s, it cannot be readied", getIdentifier(), state); LOG.debug("Tx {} Readying {} components for commit", getIdentifier(), txContextWrappers.size()); @@ -287,10 +282,8 @@ public class TransactionProxy extends AbstractDOMStoreTransaction txVersionSupplier = () -> wrapper.getTransactionContext().getTransactionVersion(); - cohorts.add(new ThreePhaseCommitCohortProxy.CohortInfo(wrapper.readyTransaction(shardNames), - txVersionSupplier)); + () -> wrapper.getTransactionContext().getTransactionVersion())); } return new ThreePhaseCommitCohortProxy(txContextFactory.getActorUtils(), cohorts, getIdentifier());