Add RaftActorServerConfigurationSupport.raftActor
[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 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
13
14 public interface SnapshotState {
15     /**
16      * @return true when a snapshot is being captured
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      * Applies a snapshot on a follower that was installed by the leader.
43      *
44      * @param snapshot the Snapshot to apply.
45      */
46     void apply(ApplySnapshot snapshot);
47
48     /**
49      * Persist the snapshot
50      *
51      * @param snapshotBytes
52      * @param currentBehavior
53      * @param totalMemory
54      */
55     void persist(byte[] snapshotBytes, RaftActorBehavior currentBehavior, long totalMemory);
56
57     /**
58      * Commit the snapshot by trimming the log
59      *
60      * @param sequenceNumber
61      */
62     void commit(long sequenceNumber, RaftActorBehavior currentBehavior);
63
64     /**
65      * Rollback the snapshot
66      */
67     void rollback();
68
69     /**
70      * Trim the log
71      *
72      * @param desiredTrimIndex
73      * @return the actual trim index
74      */
75     long trimLog(long desiredTrimIndex, RaftActorBehavior currentBehavior);
76 }