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