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;
11 import org.opendaylight.controller.cluster.raft.RaftVersions;
14 * Reply for the AppendEntriesRpc message
16 public class AppendEntriesReply extends AbstractRaftRPC {
17 private static final long serialVersionUID = -7487547356392536683L;
19 // true if follower contained entry matching
20 // prevLogIndex and prevLogTerm
21 private final boolean success;
23 // The index of the last entry in the followers log
24 // This will be used to set the matchIndex for the follower on the
26 private final long logLastIndex;
28 private final long logLastTerm;
30 // The followerId - this will be used to figure out which follower is
32 private final String followerId;
34 private final short payloadVersion;
36 private final short raftVersion = RaftVersions.CURRENT_VERSION;
38 private final boolean forceInstallSnapshot;
40 public AppendEntriesReply(String followerId, long term, boolean success, long logLastIndex, long logLastTerm,
41 short payloadVersion) {
42 this(followerId, term, success, logLastIndex, logLastTerm, payloadVersion, false);
45 public AppendEntriesReply(String followerId, long term, boolean success, long logLastIndex, long logLastTerm,
46 short payloadVersion, boolean forceInstallSnapshot) {
49 this.followerId = followerId;
50 this.success = success;
51 this.logLastIndex = logLastIndex;
52 this.logLastTerm = logLastTerm;
53 this.payloadVersion = payloadVersion;
54 this.forceInstallSnapshot = forceInstallSnapshot;
57 public boolean isSuccess() {
61 public long getLogLastIndex() {
65 public long getLogLastTerm() {
69 public String getFollowerId() {
73 public short getPayloadVersion() {
74 return payloadVersion;
77 public short getRaftVersion() {
81 public boolean isForceInstallSnapshot() {
82 return forceInstallSnapshot;
86 public String toString() {
87 return "AppendEntriesReply [term=" + getTerm() + ", success=" + success + ", followerId=" + followerId
88 + ", logLastIndex=" + logLastIndex + ", logLastTerm=" + logLastTerm + ", forceInstallSnapshot="
89 + forceInstallSnapshot + ", payloadVersion=" + payloadVersion + ", raftVersion=" + raftVersion + "]";