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;
12 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
14 public interface SnapshotState {
16 * @return true when a snapshot is being captured
18 boolean isCapturing();
21 * Initiate capture snapshot
23 * @param lastLogEntry the last entry in the replicated log
24 * @param replicatedToAllIndex the current replicatedToAllIndex
26 * @return true if capture was started
28 boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
31 * Initiate capture snapshot for the purposing of installing that snapshot
34 * @param replicatedToAllIndex
35 * @param targetFollower
37 * @return true if capture was started
39 boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
42 * Applies a snapshot on a follower that was installed by the leader.
44 * @param snapshot the Snapshot to apply.
46 void apply(ApplySnapshot snapshot);
49 * Persist the snapshot
51 * @param snapshotBytes
52 * @param currentBehavior
55 void persist(byte[] snapshotBytes, RaftActorBehavior currentBehavior, long totalMemory);
58 * Commit the snapshot by trimming the log
60 * @param sequenceNumber
62 void commit(long sequenceNumber, RaftActorBehavior currentBehavior);
65 * Rollback the snapshot
72 * @param desiredTrimIndex
73 * @return the actual trim index
75 long trimLog(long desiredTrimIndex, RaftActorBehavior currentBehavior);