2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.raft.messages;
11 * Invoked by candidates to gather votes (§5.2).
13 public final class RequestVote extends AbstractRaftRPC {
15 private static final long serialVersionUID = -6967509186297108657L;
17 // candidate requesting vote
18 private final String candidateId;
20 // index of candidate’s last log entry (§5.4)
21 private final long lastLogIndex;
23 // term of candidate’s last log entry (§5.4)
24 private final long lastLogTerm;
26 public RequestVote(final long term, final String candidateId, final long lastLogIndex, final long lastLogTerm) {
28 this.candidateId = candidateId;
29 this.lastLogIndex = lastLogIndex;
30 this.lastLogTerm = lastLogTerm;
33 public String getCandidateId() {
37 public long getLastLogIndex() {
41 public long getLastLogTerm() {
46 public String toString() {
47 return "RequestVote [term=" + getTerm()
48 + ", candidateId=" + candidateId
49 + ", lastLogIndex=" + lastLogIndex
50 + ", lastLogTerm=" + lastLogTerm
55 Object writeReplace() {