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