Add Raft AddServer message and reply 14/27514/4
authorTom Pantelis <tpanteli@brocade.com>
Sun, 27 Sep 2015 01:35:54 +0000 (21:35 -0400)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 29 Sep 2015 11:33:17 +0000 (11:33 +0000)
Change-Id: I59499ab0f0b7c202a309af0412a0c0ae38494d8b
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServer.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServerReply.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ServerChangeStatus.java [new file with mode: 0644]

diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java
new file mode 100644 (file)
index 0000000..49bd94e
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.raft.messages;
+
+import java.io.Serializable;
+
+/**
+ * Abstract base class for a server configuration change reply.
+ *
+ * @author Thomas Pantelis
+ */
+public class AbstractServerChangeReply implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private final String leaderHint;
+    private final ServerChangeStatus status;
+
+    public AbstractServerChangeReply(ServerChangeStatus status, String leaderHint) {
+        this.status = status;
+        this.leaderHint = leaderHint;
+    }
+
+    public static long getSerialversionuid() {
+        return serialVersionUID;
+    }
+
+    public String getLeaderHint() {
+        return leaderHint;
+    }
+
+    public ServerChangeStatus getStatus() {
+        return status;
+    }
+
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + " [status=" + status + ", leaderHint=" + leaderHint + "]";
+    }
+}
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServer.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServer.java
new file mode 100644 (file)
index 0000000..511aefd
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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.raft.messages;
+
+import java.io.Serializable;
+
+/**
+ * Message sent to add a new server/replica (§4.1).
+ *
+ * @author Thomas Pantelis
+ */
+public class AddServer implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private final String newServerId;
+    private final String newServerAddress;
+    private final boolean votingMember;
+
+    public AddServer(String newServerId, String newServerAddress, boolean votingMember) {
+        this.newServerId = newServerId;
+        this.newServerAddress = newServerAddress;
+        this.votingMember = votingMember;
+    }
+
+    public String getNewServerId() {
+        return newServerId;
+    }
+
+    public String getNewServerAddress() {
+        return newServerAddress;
+    }
+
+    public boolean isVotingMember() {
+        return votingMember;
+    }
+
+    @Override
+    public String toString() {
+        return "AddServer [newServerId=" + newServerId + ", newServerAddress=" + newServerAddress + ", votingMember="
+                + votingMember + "]";
+    }
+}
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServerReply.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServerReply.java
new file mode 100644 (file)
index 0000000..40d39f4
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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.raft.messages;
+
+/**
+ * Reply to an AddServer message (§4.1).
+ *
+ * @author Thomas Pantelis
+ */
+public class AddServerReply extends AbstractServerChangeReply {
+    private static final long serialVersionUID = 1L;
+
+    public AddServerReply(ServerChangeStatus status, String leaderHint) {
+        super(status, leaderHint);
+    }
+}
diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ServerChangeStatus.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ServerChangeStatus.java
new file mode 100644 (file)
index 0000000..b5caa16
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * 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.raft.messages;
+
+/**
+ * Enumerates server configuration change status reply codes.
+ *
+ * @author Thomas Pantelis
+ */
+public enum ServerChangeStatus {
+    OK,
+    NO_LEADER,
+    TIMEOUT
+}