2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore.messages;
10 import akka.actor.ActorSelection;
11 import com.google.common.base.Preconditions;
12 import java.util.Optional;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
17 * Local message DTO that contains information about the primary shard.
19 * @author Thomas Pantelis
21 public class PrimaryShardInfo {
22 private final ActorSelection primaryShardActor;
23 private final short primaryShardVersion;
24 private final DataTree localShardDataTree;
26 public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion,
27 @Nonnull DataTree localShardDataTree) {
28 this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
29 this.primaryShardVersion = primaryShardVersion;
30 this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree);
33 public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion) {
34 this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
35 this.primaryShardVersion = primaryShardVersion;
36 this.localShardDataTree = null;
40 * Returns an ActorSelection representing the primary shard actor.
42 public @Nonnull ActorSelection getPrimaryShardActor() {
43 return primaryShardActor;
47 * Returns the version of the primary shard.
49 public short getPrimaryShardVersion() {
50 return primaryShardVersion;
54 * Returns an Optional whose value contains the primary shard's DataTree if the primary shard is local
55 * to the caller. Otherwise the Optional value is absent.
57 public @Nonnull Optional<DataTree> getLocalShardDataTree() {
58 return Optional.ofNullable(localShardDataTree);