From 4c0cc4831e7ecc2d5f745a42ba7a390361432fd2 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Sat, 26 Sep 2015 21:35:54 -0400 Subject: [PATCH] Add Raft AddServer message and reply Change-Id: I59499ab0f0b7c202a309af0412a0c0ae38494d8b Signed-off-by: Tom Pantelis --- .../messages/AbstractServerChangeReply.java | 44 +++++++++++++++++ .../cluster/raft/messages/AddServer.java | 47 +++++++++++++++++++ .../cluster/raft/messages/AddServerReply.java | 21 +++++++++ .../raft/messages/ServerChangeStatus.java | 19 ++++++++ 4 files changed, 131 insertions(+) create mode 100644 opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java create mode 100644 opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServer.java create mode 100644 opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServerReply.java create mode 100644 opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ServerChangeStatus.java 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 index 0000000000..49bd94e6c4 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AbstractServerChangeReply.java @@ -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 index 0000000000..511aefdc00 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServer.java @@ -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 index 0000000000..40d39f45d6 --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/AddServerReply.java @@ -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 index 0000000000..b5caa1656c --- /dev/null +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/ServerChangeStatus.java @@ -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 +} -- 2.36.6