BUG-5280: remove support for talking to pre-Boron clients
[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.Preconditions;
12 import java.util.Optional;
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 short primaryShardVersion;
24     private final DataTree localShardDataTree;
25
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);
31     }
32
33     public PrimaryShardInfo(@Nonnull ActorSelection primaryShardActor, short primaryShardVersion) {
34         this.primaryShardActor = Preconditions.checkNotNull(primaryShardActor);
35         this.primaryShardVersion = primaryShardVersion;
36         this.localShardDataTree = null;
37     }
38
39     /**
40      * Returns an ActorSelection representing the primary shard actor.
41      */
42     public @Nonnull ActorSelection getPrimaryShardActor() {
43         return primaryShardActor;
44     }
45
46     /**
47      * Returns the version of the primary shard.
48      */
49     public short getPrimaryShardVersion() {
50         return primaryShardVersion;
51     }
52
53     /**
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.
56      */
57     public @Nonnull Optional<DataTree> getLocalShardDataTree() {
58         return Optional.ofNullable(localShardDataTree);
59     }
60 }