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;
13 public interface SnapshotState {
15 * @return true when a snapshot is being captured
17 boolean isCapturing();
20 * Initiate capture snapshot
22 * @param lastLogEntry the last entry in the replicated log
23 * @param replicatedToAllIndex the current replicatedToAllIndex
25 * @return true if capture was started
27 boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
30 * Initiate capture snapshot for the purposing of installing that snapshot
33 * @param replicatedToAllIndex
34 * @param targetFollower
36 * @return true if capture was started
38 boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
41 * Applies a snapshot on a follower that was installed by the leader.
43 * @param snapshot the Snapshot to apply.
45 void apply(ApplySnapshot snapshot);
48 * Persist the snapshot
50 * @param snapshotBytes
51 * @param currentBehavior
54 void persist(byte[] snapshotBytes, long totalMemory);
57 * Commit the snapshot by trimming the log
59 * @param sequenceNumber
62 void commit(long sequenceNumber, long timeStamp);
65 * Rollback the snapshot
72 * @param desiredTrimIndex
73 * @return the actual trim index
75 long trimLog(long desiredTrimIndex);