Bug 7407 - Add request leadership functionality to shards
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / RequestLeadership.java
1 /*
2  * Copyright (c) 2017 Cisco 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
9 package org.opendaylight.controller.cluster.raft.messages;
10
11 import akka.actor.ActorRef;
12 import com.google.common.base.Preconditions;
13 import java.io.Serializable;
14
15 /**
16  * Message sent to leader to transfer leadership to a particular follower.
17  */
18 public final class RequestLeadership implements Serializable {
19     private static final long serialVersionUID = 1L;
20
21     private final String requestedFollowerId;
22     private final ActorRef replyTo;
23
24     public RequestLeadership(final String requestedFollowerId, final ActorRef replyTo) {
25         this.requestedFollowerId = Preconditions.checkNotNull(requestedFollowerId);
26         this.replyTo = Preconditions.checkNotNull(replyTo);
27     }
28
29     public String getRequestedFollowerId() {
30         return requestedFollowerId;
31     }
32
33     public ActorRef getReplyTo() {
34         return replyTo;
35     }
36
37     @Override
38     public String toString() {
39         return "RequestLeadership [requestedFollowerId=" + requestedFollowerId + ", replyTo=" + replyTo + "]";
40     }
41 }