2ff30ec53b24fd6c3664e23a591d574c93878fe7
[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     void 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      */
36     void captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
37
38     /**
39      * Create the snapshot
40      *
41      * @param callback a procedure to be called which should create the snapshot
42      */
43     void create(Procedure<Void> callback);
44
45     /**
46      * Persist the snapshot
47      *
48      * @param persistenceProvider
49      * @param snapshotBytes
50      * @param currentBehavior
51      */
52     void persist(DataPersistenceProvider persistenceProvider, byte[] snapshotBytes, RaftActorBehavior currentBehavior);
53
54     /**
55      * Commit the snapshot by trimming the log
56      *
57      * @param persistenceProvider
58      * @param sequenceNumber
59      */
60     void commit(DataPersistenceProvider persistenceProvider, long sequenceNumber);
61
62     /**
63      * Rollback the snapshot
64      */
65     void rollback();
66
67     /**
68      * Trim the log
69      *
70      * @param desiredTrimIndex
71      * @return the actual trim index
72      */
73     long trimLog(long desiredTrimIndex);
74 }