*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.serialization.Serialization;
-import com.google.common.base.Preconditions;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import javax.annotation.Nullable;
-import org.opendaylight.controller.cluster.access.concepts.MemberName;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.controller.cluster.datastore.DatastoreContext;
import org.opendaylight.controller.cluster.datastore.Shard;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolved;
-import org.opendaylight.controller.cluster.datastore.messages.PeerDown;
-import org.opendaylight.controller.cluster.datastore.messages.PeerUp;
import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardInitialized;
import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardReady;
import org.opendaylight.controller.cluster.raft.RaftState;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class ShardInformation {
+@VisibleForTesting
+public final class ShardInformation {
private static final Logger LOG = LoggerFactory.getLogger(ShardInformation.class);
private final Set<OnShardInitialized> onShardInitializedSet = new HashSet<>();
private final AtomicShardContextProvider schemaContextProvider = new AtomicShardContextProvider();
private ActorRef actor;
- private Optional<DataTree> localShardDataTree;
+ private Optional<ReadOnlyDataTree> localShardDataTree;
private boolean leaderAvailable = false;
// flag that determines if the actor is ready for business
}
Props newProps() {
- Preconditions.checkNotNull(builder);
- Props props = builder.id(shardId).peerAddresses(initialPeerAddresses).datastoreContext(datastoreContext)
- .schemaContextProvider(schemaContextProvider).props();
+ Props props = requireNonNull(builder).id(shardId).peerAddresses(initialPeerAddresses)
+ .datastoreContext(datastoreContext).schemaContextProvider(schemaContextProvider).props();
builder = null;
return props;
}
return shardName;
}
- @Nullable
- ActorRef getActor() {
+ @VisibleForTesting
+ @Nullable public ActorRef getActor() {
return actor;
}
return shardId;
}
- void setLocalDataTree(final Optional<DataTree> dataTree) {
+ void setLocalDataTree(final Optional<ReadOnlyDataTree> dataTree) {
this.localShardDataTree = dataTree;
}
- Optional<DataTree> getLocalShardDataTree() {
+ Optional<ReadOnlyDataTree> getLocalShardDataTree() {
return localShardDataTree;
}
notifyOnShardInitializedCallbacks();
}
- void peerDown(final MemberName memberName, final String peerId, final ActorRef sender) {
- if (actor != null) {
- actor.tell(new PeerDown(memberName, peerId), sender);
- }
- }
-
- void peerUp(final MemberName memberName, final String peerId, final ActorRef sender) {
- if (actor != null) {
- actor.tell(new PeerUp(memberName, peerId), sender);
- }
- }
-
boolean isShardReady() {
return !RaftState.Candidate.name().equals(role) && !Strings.isNullOrEmpty(role);
}
this.activeMember = isActiveMember;
}
- SchemaContext getSchemaContext() {
- return schemaContextProvider.getSchemaContext();
+ EffectiveModelContext getSchemaContext() {
+ return schemaContextProvider.getEffectiveModelContext();
+ }
+
+ void setSchemaContext(final EffectiveModelContext schemaContext) {
+ schemaContextProvider.set(requireNonNull(schemaContext));
}
- void setSchemaContext(final SchemaContext schemaContext) {
- schemaContextProvider.set(Preconditions.checkNotNull(schemaContext));
+ @VisibleForTesting
+ Shard.AbstractBuilder<?, ?> getBuilder() {
+ return builder;
}
@Override