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 void capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
31 * Initiate capture snapshot for the purposing of installing that snapshot
34 * @param replicatedToAllIndex
36 void captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
41 * @param callback a procedure to be called which should create the snapshot
43 void create(Procedure<Void> callback);
46 * Persist the snapshot
48 * @param persistenceProvider
49 * @param snapshotBytes
50 * @param currentBehavior
52 void persist(DataPersistenceProvider persistenceProvider, byte[] snapshotBytes, RaftActorBehavior currentBehavior);
55 * Commit the snapshot by trimming the log
57 * @param persistenceProvider
58 * @param sequenceNumber
60 void commit(DataPersistenceProvider persistenceProvider, long sequenceNumber);
63 * Rollback the snapshot
70 * @param desiredTrimIndex
71 * @return the actual trim index
73 long trimLog(long desiredTrimIndex);