2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.messages;
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;
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.
22 * @author Thomas Pantelis
24 public class ShardLeaderStateChanged extends LeaderStateChanged {
26 private final DataTree localShardDataTree;
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);
34 public ShardLeaderStateChanged(@Nonnull String memberId, @Nullable String leaderId,
35 short leaderPayloadVersion) {
36 super(memberId, leaderId, leaderPayloadVersion);
37 this.localShardDataTree = null;
41 public Optional<DataTree> getLocalShardDataTree() {
42 return Optional.ofNullable(localShardDataTree);