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
9 package org.opendaylight.controller.cluster.raft.messages;
12 * Reply for the AppendEntriesRpc message
14 public class AppendEntriesReply extends AbstractRaftRPC {
15 private static final long serialVersionUID = -7487547356392536683L;
17 // true if follower contained entry matching
18 // prevLogIndex and prevLogTerm
19 private final boolean success;
21 // The index of the last entry in the followers log
22 // This will be used to set the matchIndex for the follower on the
24 private final long logLastIndex;
26 private final long logLastTerm;
28 // The followerId - this will be used to figure out which follower is
30 private final String followerId;
32 private final short payloadVersion;
34 private final boolean forceInstallSnapshot;
36 public AppendEntriesReply(String followerId, long term, boolean success, long logLastIndex, long logLastTerm,
37 short payloadVersion) {
38 this(followerId, term, success, logLastIndex, logLastTerm, payloadVersion, false);
41 public AppendEntriesReply(String followerId, long term, boolean success, long logLastIndex, long logLastTerm,
42 short payloadVersion, boolean forceInstallSnapshot) {
45 this.followerId = followerId;
46 this.success = success;
47 this.logLastIndex = logLastIndex;
48 this.logLastTerm = logLastTerm;
49 this.payloadVersion = payloadVersion;
50 this.forceInstallSnapshot = forceInstallSnapshot;
55 public long getTerm() {
59 public boolean isSuccess() {
63 public long getLogLastIndex() {
67 public long getLogLastTerm() {
71 public String getFollowerId() {
75 public short getPayloadVersion() {
76 return payloadVersion;
80 public String toString() {
81 StringBuilder builder = new StringBuilder();
82 builder.append("AppendEntriesReply [success=").append(success).append(", logLastIndex=").append(logLastIndex)
83 .append(", logLastTerm=").append(logLastTerm).append(", followerId=").append(followerId)
84 .append(", payloadVersion=").append(", forceInstallSnapshot=").append(forceInstallSnapshot)
85 .append(payloadVersion).append("]");
86 return builder.toString();
89 public boolean isForceInstallSnapshot() {
90 return forceInstallSnapshot;