5d1304fe752222214a82b9d877da996dc517feb4
[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.base.messages.ApplySnapshot;
12
13 public interface SnapshotState {
14     /**
15      * @return true when a snapshot is being captured
16      */
17     boolean isCapturing();
18
19     /**
20      * Initiate capture snapshot
21      *
22      * @param lastLogEntry the last entry in the replicated log
23      * @param replicatedToAllIndex the current replicatedToAllIndex
24      *
25      * @return true if capture was started
26      */
27     boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
28
29     /**
30      * Initiate capture snapshot for the purposing of installing that snapshot
31      *
32      * @param lastLogEntry
33      * @param replicatedToAllIndex
34      * @param targetFollower
35      *
36      * @return true if capture was started
37      */
38     boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
39
40     /**
41      * Applies a snapshot on a follower that was installed by the leader.
42      *
43      * @param snapshot the Snapshot to apply.
44      */
45     void apply(ApplySnapshot snapshot);
46
47     /**
48      * Persist the snapshot
49      *
50      * @param snapshotBytes
51      * @param currentBehavior
52      * @param totalMemory
53      */
54     void persist(byte[] snapshotBytes, long totalMemory);
55
56     /**
57      * Commit the snapshot by trimming the log
58      *
59      * @param sequenceNumber
60      */
61     void commit(long sequenceNumber);
62
63     /**
64      * Rollback the snapshot
65      */
66     void rollback();
67
68     /**
69      * Trim the log
70      *
71      * @param desiredTrimIndex
72      * @return the actual trim index
73      */
74     long trimLog(long desiredTrimIndex);
75 }