atomic-storage: remove type dependency at segment level I/O
[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 org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.controller.cluster.notifications.LeaderStateChanged;
15 import org.opendaylight.yangtools.yang.data.tree.api.ReadOnlyDataTree;
16
17 /**
18  * A local message derived from LeaderStateChanged containing additional Shard-specific info that is sent
19  * when some state of the shard leader has changed. This message is used by the ShardManager to maintain
20  * current Shard information.
21  *
22  * @author Thomas Pantelis
23  */
24 public final class ShardLeaderStateChanged extends LeaderStateChanged {
25     private final @Nullable ReadOnlyDataTree localShardDataTree;
26
27     public ShardLeaderStateChanged(final @NonNull String memberId, final @Nullable String leaderId,
28             final @NonNull ReadOnlyDataTree localShardDataTree, final short leaderPayloadVersion) {
29         super(memberId, leaderId, leaderPayloadVersion);
30         this.localShardDataTree = requireNonNull(localShardDataTree);
31     }
32
33     public ShardLeaderStateChanged(final @NonNull String memberId, final @Nullable String leaderId,
34             final short leaderPayloadVersion) {
35         super(memberId, leaderId, leaderPayloadVersion);
36         localShardDataTree = null;
37     }
38
39     public @Nullable ReadOnlyDataTree localShardDataTree() {
40         return localShardDataTree;
41     }
42 }