/*
 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.notifications;

import java.io.Serializable;

/**
 * A message initiated internally from the RaftActor when some state of a leader has changed
 *
 * @author Thomas Pantelis
 */
public class LeaderStateChanged implements Serializable {
    private static final long serialVersionUID = 1L;

    private final String memberId;
    private final String leaderId;

    public LeaderStateChanged(String memberId, String leaderId) {
        this.memberId = memberId;
        this.leaderId = leaderId;
    }

    public String getMemberId() {
        return memberId;
    }

    public String getLeaderId() {
        return leaderId;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("LeaderStateChanged [memberId=").append(memberId).append(", leaderId=").append(leaderId)
                .append("]");
        return builder.toString();
    }
}

/*
 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.notifications;

import com.google.common.base.Preconditions;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;


/**
 * A local message initiated internally from the RaftActor when some state of a leader has changed.
 *
 * @author Thomas Pantelis
 */
public class LeaderStateChanged {
    private final String memberId;
    private final String leaderId;

    public LeaderStateChanged(@Nonnull String memberId, @Nullable String leaderId) {
        this.memberId = Preconditions.checkNotNull(memberId);
        this.leaderId = leaderId;
    }

    public @Nonnull String getMemberId() {
        return memberId;
    }

    public @Nullable String getLeaderId() {
        return leaderId;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("LeaderStateChanged [memberId=").append(memberId).append(", leaderId=").append(leaderId)
                .append("]");
        return builder.toString();
    }
}

Return local shard tree from FindPrimaryShard
Return local shard tree from FindPrimaryShard

Added a new ShardLeaderStateChanged message that includes the Shard's
DataTree as an Optional. If the shard is the leader, it returns it's
local DataTree, oherwise returns absent.

The ShardManager now returns a LocalPrimaryShardFound response to
FindPrimary if the shard's DataTree is present. Otherwise it returns
RemotePrimaryShardFound (renamed from PrimaryFound).

Change-Id: I4413aacfff3d3d2ee89df7c4a3a1d7f7c3d2c486
Signed-off-by: Tom Pantelis <8fc992100aff336363d341c5498f75ab4da389ae@brocade.com>
(cherry picked from commit fdddb482b07c3ee2f3ca853d09ee9a6ecdd7eb2a)
