* 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;
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;
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;
import org.opendaylight.controller.cluster.databroker.actors.dds.SimpleDataStoreClientActor;
-import org.opendaylight.controller.cluster.datastore.AbstractDataStore;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
import org.opendaylight.controller.cluster.datastore.Shard;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration;
* A layer on top of DOMDataTreeService that distributes producer/shard registrations to remote nodes via
* {@link ShardedDataTreeActor}. Also provides QoL method for addition of prefix based clustered shard into the system.
*/
+@Deprecated(forRemoval = true)
public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService,
DistributedShardFactory {
private final ShardedDOMDataTree shardedDOMDataTree;
private final ActorSystem actorSystem;
- private final AbstractDataStore distributedOperDatastore;
- private final AbstractDataStore distributedConfigDatastore;
+ private final DistributedDataStoreInterface distributedOperDatastore;
+ private final DistributedDataStoreInterface distributedConfigDatastore;
private final ActorRef shardedDataTreeActor;
private final MemberName memberName;
private final PrefixedShardConfigUpdateHandler updateHandler;
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);
+ final DistributedDataStoreInterface distributedOperDatastore,
+ final DistributedDataStoreInterface distributedConfigDatastore) {
+ this.actorSystem = requireNonNull(actorSystemProvider).getActorSystem();
+ this.distributedOperDatastore = requireNonNull(distributedOperDatastore);
+ this.distributedConfigDatastore = requireNonNull(distributedConfigDatastore);
shardedDOMDataTree = new ShardedDOMDataTree();
shardedDataTreeActor = createShardedDataTreeActor(actorSystem,
createPrefixConfigShard(distributedOperDatastore);
}
- private static void createPrefixConfigShard(final AbstractDataStore dataStore) {
+ private static void createPrefixConfigShard(final DistributedDataStoreInterface dataStore) {
Configuration configuration = dataStore.getActorUtils().getConfiguration();
Collection<MemberName> memberNames = configuration.getUniqueMemberNamesForAllShards();
CreateShard createShardMessage =
final Future<Object> ask =
Patterns.ask(shardedDataTreeActor, new StartConfigShardLookup(type), SHARD_FUTURE_TIMEOUT);
- ask.onComplete(new OnComplete<Object>() {
+ ask.onComplete(new OnComplete<>() {
@Override
public void onComplete(final Throwable throwable, final Object result) {
if (throwable != null) {
return future;
}
- @Nonnull
@Override
public <T extends DOMDataTreeListener> ListenerRegistration<T> registerListener(
final T listener, final Collection<DOMDataTreeIdentifier> subtrees,
return ImmutableClassToInstanceMap.of();
}
- @Nonnull
@Override
- public DOMDataTreeProducer createProducer(@Nonnull final Collection<DOMDataTreeIdentifier> subtrees) {
+ public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) {
LOG.debug("{} - Creating producer for {}", memberName, subtrees);
final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees);
final Promise<DistributedShardRegistration> shardRegistrationPromise = akka.dispatch.Futures.promise();
Futures.addCallback(writeFuture, new FutureCallback<Void>() {
@Override
- public void onSuccess(@Nullable final Void result) {
+ public void onSuccess(final Void result) {
final Future<Object> ask =
Patterns.ask(shardedDataTreeActor, new LookupPrefixShard(prefix), SHARD_FUTURE_TIMEOUT);
private void createShardFrontend(final DOMDataTreeIdentifier prefix) {
LOG.debug("{}: Creating CDS shard for prefix: {}", memberName, prefix);
final String shardName = ClusterUtils.getCleanShardName(prefix.getRootIdentifier());
- final AbstractDataStore distributedDataStore =
- prefix.getDatastoreType().equals(org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION)
+ final DistributedDataStoreInterface distributedDataStore =
+ prefix.getDatastoreType().equals(LogicalDatastoreType.CONFIGURATION)
? distributedConfigDatastore : distributedOperDatastore;
try (DOMDataTreeProducer producer = localCreateProducer(Collections.singletonList(prefix))) {
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
- public void onSuccess(@Nullable final Void result) {
+ public void onSuccess(final Void result) {
LOG.debug("{} - Succesfuly removed shard for {}", memberName, prefix);
}
return shardedDOMDataTree.createProducer(prefix);
}
- @Nonnull
@Override
public <T extends DOMDataTreeShard> ListenerRegistration<T> 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);
? distributedConfigDatastore.getActorUtils() : distributedOperDatastore.getActorUtils();
final Optional<ActorRef> 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
// final Collection<MemberName> 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",
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<DOMDataTreeIdentifier> subtrees) {
+ public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> 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);
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);