Fix warnings and javadocs in sal-akka-raft
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActorRecoveryCohort.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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 package org.opendaylight.controller.cluster.raft;
9
10 import javax.annotation.Nullable;
11 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
12
13 /**
14  * Interface for a class that participates in raft actor persistence recovery.
15  *
16  * @author Thomas Pantelis
17  */
18 public interface RaftActorRecoveryCohort {
19
20     /**
21      * This method is called during recovery at the start of a batch of state entries. Derived
22      * classes should perform any initialization needed to start a batch.
23      *
24      * @param maxBatchSize the maximum batch size.
25      */
26     void startLogRecoveryBatch(int maxBatchSize);
27
28     /**
29      * This method is called during recovery to append state data to the current batch. This method
30      * is called 1 or more times after {@link #startLogRecoveryBatch}.
31      *
32      * @param data the state data
33      */
34     void appendRecoveredLogEntry(Payload data);
35
36     /**
37      * This method is called during recovery to reconstruct the state of the actor.
38      *
39      * @param snapshotBytes A snapshot of the state of the actor
40      */
41     void applyRecoverySnapshot(byte[] snapshotBytes);
42
43     /**
44      * This method is called during recovery at the end of a batch to apply the current batched
45      * log entries. This method is called after {@link #appendRecoveredLogEntry}.
46      */
47     void applyCurrentLogRecoveryBatch();
48
49     /**
50      * Returns the state snapshot to restore from on recovery.
51      *
52      * @return the snapshot bytes or null if there's no snapshot to restore
53      */
54     @Nullable
55     byte[] getRestoreFromSnapshot();
56 }