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
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestLeadership.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestLeadership.java
new file mode 100644 (file)
index 0000000..5561085
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017 Cisco 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.raft.messages;
+
+import akka.actor.ActorRef;
+import com.google.common.base.Preconditions;
+import java.io.Serializable;
+
+/**
+ * Message sent to leader to transfer leadership to a particular follower.
+ */
+public final class RequestLeadership implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private final String requestedFollowerId;
+    private final ActorRef replyTo;
+
+    public RequestLeadership(final String requestedFollowerId, final ActorRef replyTo) {
+        this.requestedFollowerId = Preconditions.checkNotNull(requestedFollowerId);
+        this.replyTo = Preconditions.checkNotNull(replyTo);
+    }
+
+    public String getRequestedFollowerId() {
+        return requestedFollowerId;
+    }
+
+    public ActorRef getReplyTo() {
+        return replyTo;
+    }
+
+    @Override
+    public String toString() {
+        return "RequestLeadership [requestedFollowerId=" + requestedFollowerId + ", replyTo=" + replyTo + "]";
+    }
+}