Merge "Add missing copyright text"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / PrimaryShardInfo.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.datastore.messages;
9
10 import akka.actor.ActorSelection;
11 import com.google.common.base.Optional;
12 import com.google.common.base.Preconditions;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
15
16 /**
17  * Local message DTO that contains information about the primary shard.
18  *
19  * @author Thomas Pantelis
20  */
21 public class PrimaryShardInfo {
22     private final ActorSelection primaryShardActor;
23     private final Optional<DataTree> localShardDataTree;
24
25     public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, @Nonnull Optional<DataTree> localShardDataTree) {
26         this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
27         this.localShardDataTree = Preconditions.checkNotNull(localShardDataTree);
28     }
29
30     /**
31      * Returns an ActorSelection representing the primary shard actor.
32      */
33     public @Nonnull ActorSelection getPrimaryShardActor() {
34         return primaryShardActor;
35     }
36
37     /**
38      * Returns an Optional whose value contains the primary shard's DataTree if the primary shard is local
39      * to the caller. Otherwise the Optional value is absent.
40      */
41     public @Nonnull Optional<DataTree> getLocalShardDataTree() {
42         return localShardDataTree;
43     }
44 }