Cleanup: Remove passing around of DataPersistenceProvider
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / SnapshotState.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.raft;
10
11 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
12
13 public interface SnapshotState {
14     /**
15      * Should return true when a snapshot is being captured
16      * @return
17      */
18     boolean isCapturing();
19
20     /**
21      * Initiate capture snapshot
22      *
23      * @param lastLogEntry the last entry in the replicated log
24      * @param replicatedToAllIndex the current replicatedToAllIndex
25      *
26      * @return true if capture was started
27      */
28     boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
29
30     /**
31      * Initiate capture snapshot for the purposing of installing that snapshot
32      *
33      * @param lastLogEntry
34      * @param replicatedToAllIndex
35      * @param targetFollower
36      *
37      * @return true if capture was started
38      */
39     boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
40
41     /**
42      * Persist the snapshot
43      *
44      * @param snapshotBytes
45      * @param currentBehavior
46      * @param totalMemory
47      */
48     void persist(byte[] snapshotBytes, RaftActorBehavior currentBehavior, long totalMemory);
49
50     /**
51      * Commit the snapshot by trimming the log
52      *
53      * @param sequenceNumber
54      */
55     void commit(long sequenceNumber);
56
57     /**
58      * Rollback the snapshot
59      */
60     void rollback();
61
62     /**
63      * Trim the log
64      *
65      * @param desiredTrimIndex
66      * @return the actual trim index
67      */
68     long trimLog(long desiredTrimIndex, RaftActorBehavior currentBehavior);
69 }