Make Raft messages serializable
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / AppendEntriesReply.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.io.Serializable;
12
13 /**
14  * Reply for the AppendEntriesRpc message
15  */
16 public class AppendEntriesReply extends AbstractRaftRPC implements Serializable {
17
18     // true if follower contained entry matching
19     // prevLogIndex and prevLogTerm
20     private final boolean success;
21
22     // The index of the last entry in the followers log
23     // This will be used to set the matchIndex for the follower on the
24     // Leader
25     private final long logLastIndex;
26
27     private final long logLastTerm;
28
29     // The followerId - this will be used to figure out which follower is
30     // responding
31     private final String followerId;
32
33     public AppendEntriesReply(String followerId, long term, boolean success, long logLastIndex, long logLastTerm) {
34         super(term);
35
36         this.followerId = followerId;
37         this.success = success;
38         this.logLastIndex = logLastIndex;
39         this.logLastTerm = logLastTerm;
40     }
41
42     public long getTerm() {
43         return term;
44     }
45
46     public boolean isSuccess() {
47         return success;
48     }
49
50     public long getLogLastIndex() {
51         return logLastIndex;
52     }
53
54     public long getLogLastTerm() {
55         return logLastTerm;
56     }
57
58     public String getFollowerId() {
59         return followerId;
60     }
61 }