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%2Fsharding%2FDistributedShardedDOMDataTree.java;h=e0d35580b82a2c8e35e490e660216e72465529b0;hb=66e553f2098ea61426c4a441be57395673535c2f;hp=df21b901da6676e29e2bf7352e5a734228b9d965;hpb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java index df21b901da..e0d35580b8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.sharding; import static akka.actor.ActorRef.noSender; @@ -21,8 +20,6 @@ import akka.dispatch.Mapper; import akka.dispatch.OnComplete; import akka.pattern.Patterns; import akka.util.Timeout; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.common.collect.ClassToInstanceMap; import com.google.common.collect.ForwardingObject; @@ -42,14 +39,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.GuardedBy; +import org.checkerframework.checker.lock.qual.GuardedBy; import org.opendaylight.controller.cluster.ActorSystemProvider; import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient; @@ -139,9 +135,9 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat public DistributedShardedDOMDataTree(final ActorSystemProvider actorSystemProvider, final AbstractDataStore distributedOperDatastore, final AbstractDataStore distributedConfigDatastore) { - this.actorSystem = Preconditions.checkNotNull(actorSystemProvider).getActorSystem(); - this.distributedOperDatastore = Preconditions.checkNotNull(distributedOperDatastore); - this.distributedConfigDatastore = Preconditions.checkNotNull(distributedConfigDatastore); + this.actorSystem = requireNonNull(actorSystemProvider).getActorSystem(); + this.distributedOperDatastore = requireNonNull(distributedOperDatastore); + this.distributedConfigDatastore = requireNonNull(distributedConfigDatastore); shardedDOMDataTree = new ShardedDOMDataTree(); shardedDataTreeActor = createShardedDataTreeActor(actorSystem, @@ -273,7 +269,6 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat return future; } - @Nonnull @Override public ListenerRegistration registerListener( final T listener, final Collection subtrees, @@ -287,9 +282,8 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat return ImmutableClassToInstanceMap.of(); } - @Nonnull @Override - public DOMDataTreeProducer createProducer(@Nonnull final Collection subtrees) { + public DOMDataTreeProducer createProducer(final Collection subtrees) { LOG.debug("{} - Creating producer for {}", memberName, subtrees); final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees); @@ -332,7 +326,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat final Promise shardRegistrationPromise = akka.dispatch.Futures.promise(); Futures.addCallback(writeFuture, new FutureCallback() { @Override - public void onSuccess(@Nullable final Void result) { + public void onSuccess(final Void result) { final Future ask = Patterns.ask(shardedDataTreeActor, new LookupPrefixShard(prefix), SHARD_FUTURE_TIMEOUT); @@ -435,7 +429,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat Futures.addCallback(future, new FutureCallback() { @Override - public void onSuccess(@Nullable final Void result) { + public void onSuccess(final Void result) { LOG.debug("{} - Succesfuly removed shard for {}", memberName, prefix); } @@ -457,13 +451,10 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat return shardedDOMDataTree.createProducer(prefix); } - @Nonnull @Override public ListenerRegistration registerDataTreeShard( - @Nonnull final DOMDataTreeIdentifier prefix, - @Nonnull final T shard, - @Nonnull final DOMDataTreeProducer producer) - throws DOMDataTreeShardingConflictException { + final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer) + throws DOMDataTreeShardingConflictException { LOG.debug("Registering shard[{}] at prefix: {}", shard, prefix); @@ -513,12 +504,13 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat ? distributedConfigDatastore.getActorUtils() : distributedOperDatastore.getActorUtils(); final Optional defaultLocalShardOptional = - actorUtils.findLocalShard(ClusterUtils.getCleanShardName(YangInstanceIdentifier.EMPTY)); + actorUtils.findLocalShard(ClusterUtils.getCleanShardName(YangInstanceIdentifier.empty())); if (defaultLocalShardOptional.isPresent()) { LOG.debug("{}: Default shard for {} is already started, creating just frontend", memberName, logicalDatastoreType); - createShardFrontend(new DOMDataTreeIdentifier(logicalDatastoreType, YangInstanceIdentifier.EMPTY)); + createShardFrontend(new DOMDataTreeIdentifier(logicalDatastoreType, + YangInstanceIdentifier.empty())); } // The local shard isn't present - we assume that means the local member isn't in the replica list @@ -530,7 +522,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat // final Collection names = distributedConfigDatastore.getActorUtils().getConfiguration() // .getUniqueMemberNamesForAllShards(); // Await.result(FutureConverters.toScala(createDistributedShard( -// new DOMDataTreeIdentifier(logicalDatastoreType, YangInstanceIdentifier.EMPTY), names)), +// new DOMDataTreeIdentifier(logicalDatastoreType, YangInstanceIdentifier.empty()), names)), // SHARD_FUTURE_TIMEOUT_DURATION); // } catch (DOMDataTreeShardingConflictException e) { // LOG.debug("{}: Default shard for {} already registered, possibly due to other node doing it faster", @@ -639,16 +631,14 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat this.shardTable = requireNonNull(shardLayout); } - @Nonnull @Override public DOMDataTreeCursorAwareTransaction createTransaction(final boolean isolated) { return delegate.createTransaction(isolated); } - @Nonnull @Override @SuppressWarnings("checkstyle:hiddenField") - public DOMDataTreeProducer createProducer(@Nonnull final Collection subtrees) { + public DOMDataTreeProducer createProducer(final Collection subtrees) { // TODO we probably don't need to distribute this on the remote nodes since once we have this producer // open we surely have the rights to all the subtrees. return delegate.createProducer(subtrees); @@ -676,9 +666,8 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat return delegate; } - @Nonnull @Override - public CDSShardAccess getShardAccess(@Nonnull final DOMDataTreeIdentifier subtree) { + public CDSShardAccess getShardAccess(final DOMDataTreeIdentifier subtree) { checkArgument(subtrees.stream().anyMatch(dataTreeIdentifier -> dataTreeIdentifier.contains(subtree)), "Subtree %s is not controlled by this producer %s", subtree, this);