X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmessages%2FPrimaryShardInfo.java;h=1ca06216dd1157a54727ae67c8c8124d2fc0bafa;hp=bbeb1aa84bbe728ffe073e9a3cc5402161fde676;hb=HEAD;hpb=9f17976f66bc0d3b58bcb96f325a241e34871d54 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java index bbeb1aa84b..c9d10a62e6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PrimaryShardInfo.java @@ -7,11 +7,12 @@ */ package org.opendaylight.controller.cluster.datastore.messages; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorSelection; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.data.tree.api.ReadOnlyDataTree; /** * Local message DTO that contains information about the primary shard. @@ -20,25 +21,41 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; */ public class PrimaryShardInfo { private final ActorSelection primaryShardActor; - private final Optional localShardDataTree; + private final short primaryShardVersion; + private final ReadOnlyDataTree localShardDataTree; + + public PrimaryShardInfo(final @NonNull ActorSelection primaryShardActor, final short primaryShardVersion, + final @NonNull ReadOnlyDataTree localShardDataTree) { + this.primaryShardActor = requireNonNull(primaryShardActor); + this.primaryShardVersion = primaryShardVersion; + this.localShardDataTree = requireNonNull(localShardDataTree); + } - public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, @Nonnull Optional localShardDataTree) { - this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor); - this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree); + public PrimaryShardInfo(final @NonNull ActorSelection primaryShardActor, final short primaryShardVersion) { + this.primaryShardActor = requireNonNull(primaryShardActor); + this.primaryShardVersion = primaryShardVersion; + localShardDataTree = null; } /** * Returns an ActorSelection representing the primary shard actor. */ - public @Nonnull ActorSelection getPrimaryShardActor() { + public @NonNull ActorSelection getPrimaryShardActor() { return primaryShardActor; } + /** + * Returns the version of the primary shard. + */ + public short getPrimaryShardVersion() { + return primaryShardVersion; + } + /** * Returns an Optional whose value contains the primary shard's DataTree if the primary shard is local * to the caller. Otherwise the Optional value is absent. */ - public @Nonnull Optional getLocalShardDataTree() { - return localShardDataTree; + public @NonNull Optional getLocalShardDataTree() { + return Optional.ofNullable(localShardDataTree); } }