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.base.messages;
11 import java.util.Collections;
12 import java.util.List;
13 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
15 public class CaptureSnapshot {
16 private final long lastAppliedIndex;
17 private final long lastAppliedTerm;
18 private final long lastIndex;
19 private final long lastTerm;
20 private final long replicatedToAllIndex;
21 private final long replicatedToAllTerm;
22 private final List<ReplicatedLogEntry> unAppliedEntries;
24 public CaptureSnapshot(long lastIndex, long lastTerm, long lastAppliedIndex,
25 long lastAppliedTerm, long replicatedToAllIndex, long replicatedToAllTerm,
26 List<ReplicatedLogEntry> unAppliedEntries) {
27 this.lastIndex = lastIndex;
28 this.lastTerm = lastTerm;
29 this.lastAppliedIndex = lastAppliedIndex;
30 this.lastAppliedTerm = lastAppliedTerm;
31 this.replicatedToAllIndex = replicatedToAllIndex;
32 this.replicatedToAllTerm = replicatedToAllTerm;
33 this.unAppliedEntries = unAppliedEntries != null ? unAppliedEntries :
34 Collections.<ReplicatedLogEntry>emptyList();
37 public long getLastAppliedIndex() {
38 return lastAppliedIndex;
41 public long getLastAppliedTerm() {
42 return lastAppliedTerm;
45 public long getLastIndex() {
49 public long getLastTerm() {
53 public long getReplicatedToAllIndex() {
54 return replicatedToAllIndex;
57 public long getReplicatedToAllTerm() {
58 return replicatedToAllTerm;
61 public List<ReplicatedLogEntry> getUnAppliedEntries() {
62 return unAppliedEntries;
66 public String toString() {
67 StringBuilder builder = new StringBuilder();
68 builder.append("CaptureSnapshot [lastAppliedIndex=").append(lastAppliedIndex).append(", lastAppliedTerm=")
69 .append(lastAppliedTerm).append(", lastIndex=").append(lastIndex).append(", lastTerm=")
70 .append(lastTerm).append(", installSnapshotInitiated=")
71 .append(", replicatedToAllIndex=").append(replicatedToAllIndex).append(", replicatedToAllTerm=")
72 .append(replicatedToAllTerm).append(", unAppliedEntries size=")
73 .append(unAppliedEntries.size()).append("]");
74 return builder.toString();