2 * Copyright (c) 2015 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;
11 import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot;
14 * Interface for a snapshot phase state.
17 * @author Thomas Pantelis
19 public interface SnapshotState {
21 * @return true when a snapshot is being captured
23 boolean isCapturing();
26 * Initiate capture snapshot
28 * @param lastLogEntry the last entry in the replicated log
29 * @param replicatedToAllIndex the current replicatedToAllIndex
31 * @return true if capture was started
33 boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
36 * Initiate capture snapshot for the purposing of installing that snapshot
39 * @param replicatedToAllIndex
40 * @param targetFollower
42 * @return true if capture was started
44 boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
47 * Applies a snapshot on a follower that was installed by the leader.
49 * @param snapshot the Snapshot to apply.
51 void apply(ApplySnapshot snapshot);
54 * Persist the snapshot
56 * @param snapshotBytes
57 * @param currentBehavior
60 void persist(byte[] snapshotBytes, long totalMemory);
63 * Commit the snapshot by trimming the log
65 * @param sequenceNumber
68 void commit(long sequenceNumber, long timeStamp);
71 * Rollback the snapshot
78 * @param desiredTrimIndex
79 * @return the actual trim index
81 long trimLog(long desiredTrimIndex);