Define DataStoreVersions.MAGNESIUM_VERSION
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ShardLeaderStateChanged.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 static java.util.Objects.requireNonNull;
11
12 import java.util.Optional;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.controller.cluster.notifications.LeaderStateChanged;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
17
18 /**
19  * A local message derived from LeaderStateChanged containing additional Shard-specific info that is sent
20  * when some state of the shard leader has changed. This message is used by the ShardManager to maintain
21  * current Shard information.
22  *
23  * @author Thomas Pantelis
24  */
25 public class ShardLeaderStateChanged extends LeaderStateChanged {
26     private final ReadOnlyDataTree localShardDataTree;
27
28     public ShardLeaderStateChanged(@NonNull String memberId, @Nullable String leaderId,
29             @NonNull ReadOnlyDataTree localShardDataTree, short leaderPayloadVersion) {
30         super(memberId, leaderId, leaderPayloadVersion);
31         this.localShardDataTree = requireNonNull(localShardDataTree);
32     }
33
34     public ShardLeaderStateChanged(@NonNull String memberId, @Nullable String leaderId,
35             short leaderPayloadVersion) {
36         super(memberId, leaderId, leaderPayloadVersion);
37         this.localShardDataTree = null;
38     }
39
40     public @NonNull Optional<ReadOnlyDataTree> getLocalShardDataTree() {
41         return Optional.ofNullable(localShardDataTree);
42     }
43 }