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 akka.dispatch.ControlMessage;
12 import java.util.Collections;
13 import java.util.List;
14 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
16 public class CaptureSnapshot implements ControlMessage {
17 private final long lastAppliedIndex;
18 private final long lastAppliedTerm;
19 private final long lastIndex;
20 private final long lastTerm;
21 private final long replicatedToAllIndex;
22 private final long replicatedToAllTerm;
23 private final List<ReplicatedLogEntry> unAppliedEntries;
25 public CaptureSnapshot(long lastIndex, long lastTerm, long lastAppliedIndex,
26 long lastAppliedTerm, long replicatedToAllIndex, long replicatedToAllTerm,
27 List<ReplicatedLogEntry> unAppliedEntries) {
28 this.lastIndex = lastIndex;
29 this.lastTerm = lastTerm;
30 this.lastAppliedIndex = lastAppliedIndex;
31 this.lastAppliedTerm = lastAppliedTerm;
32 this.replicatedToAllIndex = replicatedToAllIndex;
33 this.replicatedToAllTerm = replicatedToAllTerm;
34 this.unAppliedEntries = unAppliedEntries != null ? unAppliedEntries :
35 Collections.<ReplicatedLogEntry>emptyList();
38 public long getLastAppliedIndex() {
39 return lastAppliedIndex;
42 public long getLastAppliedTerm() {
43 return lastAppliedTerm;
46 public long getLastIndex() {
50 public long getLastTerm() {
54 public long getReplicatedToAllIndex() {
55 return replicatedToAllIndex;
58 public long getReplicatedToAllTerm() {
59 return replicatedToAllTerm;
62 public List<ReplicatedLogEntry> getUnAppliedEntries() {
63 return unAppliedEntries;
67 public String toString() {
68 return "CaptureSnapshot [lastAppliedIndex=" + lastAppliedIndex
69 + ", lastAppliedTerm=" + lastAppliedTerm
70 + ", lastIndex=" + lastIndex
71 + ", lastTerm=" + lastTerm
72 + ", installSnapshotInitiated="
73 + ", replicatedToAllIndex=" + replicatedToAllIndex
74 + ", replicatedToAllTerm=" + replicatedToAllTerm
75 + ", unAppliedEntries size=" + unAppliedEntries.size() + "]";