Initial code/design for an Akka Raft implementation
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / RequestVote.java
1 /*
2  * Copyright (c) 2014 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 /**
12  * Invoked by candidates to gather votes (§5.2).
13  */
14 public class RequestVote {
15
16     // candidate’s term
17     private final long term;
18
19     // candidate requesting vote
20     private final String candidateId;
21
22     // index of candidate’s last log entry (§5.4)
23     private final long lastLogIndex;
24
25     // term of candidate’s last log entry (§5.4)
26     private final long lastLogTerm;
27
28     public RequestVote(long term, String candidateId, long lastLogIndex,
29         long lastLogTerm) {
30         this.term = term;
31         this.candidateId = candidateId;
32         this.lastLogIndex = lastLogIndex;
33         this.lastLogTerm = lastLogTerm;
34     }
35
36     public long getTerm() {
37         return term;
38     }
39
40     public String getCandidateId() {
41         return candidateId;
42     }
43
44     public long getLastLogIndex() {
45         return lastLogIndex;
46     }
47
48     public long getLastLogTerm() {
49         return lastLogTerm;
50     }
51 }