package org.opendaylight.controller.cluster.datastore.messages;
import akka.actor.ActorSelection;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
*/
public class PrimaryShardInfo {
private final ActorSelection primaryShardActor;
- private final Optional<DataTree> localShardDataTree;
+ private final short primaryShardVersion;
+ private final DataTree localShardDataTree;
- public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, @Nonnull Optional<DataTree> localShardDataTree) {
+ public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion,
+ @Nonnull DataTree localShardDataTree) {
this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
+ this.primaryShardVersion = primaryShardVersion;
this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree);
}
+ public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion) {
+ this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
+ this.primaryShardVersion = primaryShardVersion;
+ this.localShardDataTree = null;
+ }
+
/**
* Returns an ActorSelection representing the primary shard actor.
*/
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<DataTree> getLocalShardDataTree() {
- return localShardDataTree;
+ return Optional.ofNullable(localShardDataTree);
}
}