Use SnapshotManager
[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 akka.japi.Procedure;
12 import org.opendaylight.controller.cluster.DataPersistenceProvider;
13 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
14
15 public interface SnapshotState {
16     /**
17      * Should return true when a snapshot is being captured
18      * @return
19      */
20     boolean isCapturing();
21
22     /**
23      * Initiate capture snapshot
24      *
25      * @param lastLogEntry the last entry in the replicated log
26      * @param replicatedToAllIndex the current replicatedToAllIndex
27      *
28      * @return true if capture was started
29      */
30     boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
31
32     /**
33      * Initiate capture snapshot for the purposing of installing that snapshot
34      *
35      * @param lastLogEntry
36      * @param replicatedToAllIndex
37      * @param targetFollower
38      *
39      * @return true if capture was started
40      */
41     boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
42
43     /**
44      * Create the snapshot
45      *
46      * @param callback a procedure to be called which should create the snapshot
47      */
48     void create(Procedure<Void> callback);
49
50     /**
51      * Persist the snapshot
52      *
53      * @param persistenceProvider
54      * @param snapshotBytes
55      * @param currentBehavior
56      * @param totalMemory
57      */
58     void persist(DataPersistenceProvider persistenceProvider, byte[] snapshotBytes, RaftActorBehavior currentBehavior
59             ,long totalMemory);
60
61     /**
62      * Commit the snapshot by trimming the log
63      *
64      * @param persistenceProvider
65      * @param sequenceNumber
66      */
67     void commit(DataPersistenceProvider persistenceProvider, long sequenceNumber);
68
69     /**
70      * Rollback the snapshot
71      */
72     void rollback();
73
74     /**
75      * Trim the log
76      *
77      * @param desiredTrimIndex
78      * @return the actual trim index
79      */
80     long trimLog(long desiredTrimIndex, RaftActorBehavior currentBehavior);
81 }