fd4e0a274c6f9122e40809e7b120f6a7a8b936bd
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / AppendEntries.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 import java.util.List;
12
13 /**
14  * Invoked by leader to replicate log entries (§5.3); also used as
15  * heartbeat (§5.2).
16  */
17 public class AppendEntries extends AbstractRaftRPC {
18     // So that follower can redirect clients
19     private final String leaderId;
20
21     // Index of log entry immediately preceding new ones
22     private final long prevLogIndex;
23
24     // term of prevLogIndex entry
25     private final long prevLogTerm;
26
27     // log entries to store (empty for heartbeat;
28     // may send more than one for efficiency)
29     private final List<Object> entries;
30
31     // leader's commitIndex
32     private final long leaderCommit;
33
34     public AppendEntries(long term, String leaderId, long prevLogIndex,
35         long prevLogTerm, List<Object> entries, long leaderCommit) {
36         super(term);
37         this.leaderId = leaderId;
38         this.prevLogIndex = prevLogIndex;
39         this.prevLogTerm = prevLogTerm;
40         this.entries = entries;
41         this.leaderCommit = leaderCommit;
42     }
43
44     public String getLeaderId() {
45         return leaderId;
46     }
47
48     public long getPrevLogIndex() {
49         return prevLogIndex;
50     }
51
52     public long getPrevLogTerm() {
53         return prevLogTerm;
54     }
55
56     public List<Object> getEntries() {
57         return entries;
58     }
59
60     public long getLeaderCommit() {
61         return leaderCommit;
62     }
63 }