Merge "Created Sample Feature Test Class for Base Feature Repository"
[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 /**
12  * Reply for the AppendEntriesRpc message
13  */
14 public class AppendEntriesReply extends AbstractRaftRPC {
15
16     // true if follower contained entry matching
17     // prevLogIndex and prevLogTerm
18     private final boolean success;
19
20     // The index of the last entry in the followers log
21     // This will be used to set the matchIndex for the follower on the
22     // Leader
23     private final long logLastIndex;
24
25     private final long logLastTerm;
26
27     // The followerId - this will be used to figure out which follower is
28     // responding
29     private final String followerId;
30
31     public AppendEntriesReply(String followerId, long term, boolean success, long logLastIndex, long logLastTerm) {
32         super(term);
33
34         this.followerId = followerId;
35         this.success = success;
36         this.logLastIndex = logLastIndex;
37         this.logLastTerm = logLastTerm;
38     }
39
40     public long getTerm() {
41         return term;
42     }
43
44     public boolean isSuccess() {
45         return success;
46     }
47
48     public long getLogLastIndex() {
49         return logLastIndex;
50     }
51
52     public long getLogLastTerm() {
53         return logLastTerm;
54     }
55
56     public String getFollowerId() {
57         return followerId;
58     }
59
60     @Override public String toString() {
61         final StringBuilder sb =
62             new StringBuilder("AppendEntriesReply{");
63         sb.append("term=").append(term);
64         sb.append(", success=").append(success);
65         sb.append(", logLastIndex=").append(logLastIndex);
66         sb.append(", logLastTerm=").append(logLastTerm);
67         sb.append(", followerId='").append(followerId).append('\'');
68         sb.append('}');
69         return sb.toString();
70     }
71 }