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.DataPersistenceProvider;
12 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
14 public interface SnapshotState {
16 * Should return true when a snapshot is being captured
19 boolean isCapturing();
22 * Initiate capture snapshot
24 * @param lastLogEntry the last entry in the replicated log
25 * @param replicatedToAllIndex the current replicatedToAllIndex
27 * @return true if capture was started
29 boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
32 * Initiate capture snapshot for the purposing of installing that snapshot
35 * @param replicatedToAllIndex
36 * @param targetFollower
38 * @return true if capture was started
40 boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
43 * Persist the snapshot
45 * @param persistenceProvider
46 * @param snapshotBytes
47 * @param currentBehavior
50 void persist(DataPersistenceProvider persistenceProvider, byte[] snapshotBytes, RaftActorBehavior currentBehavior
54 * Commit the snapshot by trimming the log
56 * @param persistenceProvider
57 * @param sequenceNumber
59 void commit(DataPersistenceProvider persistenceProvider, long sequenceNumber);
62 * Rollback the snapshot
69 * @param desiredTrimIndex
70 * @return the actual trim index
72 long trimLog(long desiredTrimIndex, RaftActorBehavior currentBehavior);