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 akka.japi.Procedure;
12 import org.opendaylight.controller.cluster.DataPersistenceProvider;
13 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
15 public interface SnapshotState {
17 * Should return true when a snapshot is being captured
20 boolean isCapturing();
23 * Initiate capture snapshot
25 * @param lastLogEntry the last entry in the replicated log
26 * @param replicatedToAllIndex the current replicatedToAllIndex
28 * @return true if capture was started
30 boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
33 * Initiate capture snapshot for the purposing of installing that snapshot
36 * @param replicatedToAllIndex
37 * @param targetFollower
39 * @return true if capture was started
41 boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
46 * @param callback a procedure to be called which should create the snapshot
48 void create(Procedure<Void> callback);
51 * Persist the snapshot
53 * @param persistenceProvider
54 * @param snapshotBytes
55 * @param currentBehavior
58 void persist(DataPersistenceProvider persistenceProvider, byte[] snapshotBytes, RaftActorBehavior currentBehavior
62 * Commit the snapshot by trimming the log
64 * @param persistenceProvider
65 * @param sequenceNumber
67 void commit(DataPersistenceProvider persistenceProvider, long sequenceNumber);
70 * Rollback the snapshot
77 * @param desiredTrimIndex
78 * @return the actual trim index
80 long trimLog(long desiredTrimIndex, RaftActorBehavior currentBehavior);