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.ReplicatedLogEntry;
13 import java.util.List;
16 * Invoked by leader to replicate log entries (§5.3); also used as
19 public class AppendEntries extends AbstractRaftRPC {
20 // So that follower can redirect clients
21 private final String leaderId;
23 // Index of log entry immediately preceding new ones
24 private final long prevLogIndex;
26 // term of prevLogIndex entry
27 private final long prevLogTerm;
29 // log entries to store (empty for heartbeat;
30 // may send more than one for efficiency)
31 private final List<ReplicatedLogEntry> entries;
33 // leader's commitIndex
34 private final long leaderCommit;
36 public AppendEntries(long term, String leaderId, long prevLogIndex,
37 long prevLogTerm, List<ReplicatedLogEntry> entries, long leaderCommit) {
39 this.leaderId = leaderId;
40 this.prevLogIndex = prevLogIndex;
41 this.prevLogTerm = prevLogTerm;
42 this.entries = entries;
43 this.leaderCommit = leaderCommit;
46 public String getLeaderId() {
50 public long getPrevLogIndex() {
54 public long getPrevLogTerm() {
58 public List<ReplicatedLogEntry> getEntries() {
62 public long getLeaderCommit() {