34e7ac9768fa5dfd728d2901ee35934f85fc2759
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / ReplicatedLog.java
1 /*
2  * Copyright (c) 2014 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 java.util.List;
12
13 /**
14  * Represents the ReplicatedLog that needs to be kept in sync by the RaftActor
15  */
16 public interface ReplicatedLog {
17     /**
18      * Get a replicated log entry at the specified index
19      *
20      * @param index
21      * @return
22      */
23     ReplicatedLogEntry get(long index);
24
25
26     /**
27      * Get the last replicated log entry
28      *
29      * @return
30      */
31     ReplicatedLogEntry last();
32
33     /**
34      *
35      * @return
36      */
37     long lastIndex();
38
39     /**
40      *
41      * @return
42      */
43     long lastTerm();
44
45     /**
46      * Remove all the entries from the logs >= index
47      *
48      * @param index
49      */
50     void removeFrom(long index);
51
52     /**
53      * Append an entry to the log
54      * @param replicatedLogEntry
55      */
56     void append(ReplicatedLogEntry replicatedLogEntry);
57
58     /**
59      *
60      * @param replicatedLogEntry
61      */
62     void appendAndPersist(final ReplicatedLogEntry replicatedLogEntry);
63
64     /**
65      *
66      * @param index
67      */
68     List<ReplicatedLogEntry> getFrom(long index);
69
70
71     /**
72      *
73      * @return
74      */
75     long size();
76 }