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.behaviors.RaftActorBehavior;
13 public interface SnapshotState {
15 * Should 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 * Persist the snapshot
44 * @param snapshotBytes
45 * @param currentBehavior
48 void persist(byte[] snapshotBytes, RaftActorBehavior currentBehavior, long totalMemory);
51 * Commit the snapshot by trimming the log
53 * @param sequenceNumber
55 void commit(long sequenceNumber);
58 * Rollback the snapshot
65 * @param desiredTrimIndex
66 * @return the actual trim index
68 long trimLog(long desiredTrimIndex, RaftActorBehavior currentBehavior);