BUG-2138: Create DistributedShardFrontend
[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 com.google.common.base.Preconditions;
11 import java.util.Optional;
12 import javax.annotation.Nonnull;
13 import javax.annotation.Nullable;
14 import org.opendaylight.controller.cluster.notifications.LeaderStateChanged;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
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 class ShardLeaderStateChanged extends LeaderStateChanged {
25
26     private final DataTree localShardDataTree;
27
28     public ShardLeaderStateChanged(@Nonnull String memberId, @Nullable String leaderId,
29             @Nonnull DataTree localShardDataTree, short leaderPayloadVersion) {
30         super(memberId, leaderId, leaderPayloadVersion);
31         this.localShardDataTree = Preconditions.checkNotNull(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<DataTree> getLocalShardDataTree() {
41         return Optional.ofNullable(localShardDataTree);
42     }
43 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.