2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.raft;
11 import java.util.List;
14 * Represents the ReplicatedLog that needs to be kept in sync by the RaftActor
16 public interface ReplicatedLog {
18 * Get a replicated log entry at the specified index
20 * @param index the index of the log entry
21 * @return the ReplicatedLogEntry at index. null if index less than 0 or
22 * greater than the size of the in-memory journal.
24 ReplicatedLogEntry get(long index);
28 * Get the last replicated log entry
32 ReplicatedLogEntry last();
47 * Remove all the entries from the logs >= index
49 * @param index the index of the log entry
51 void removeFrom(long index);
54 * Append an entry to the log
55 * @param replicatedLogEntry
57 void append(ReplicatedLogEntry replicatedLogEntry);
61 * @param replicatedLogEntry
63 void appendAndPersist(final ReplicatedLogEntry replicatedLogEntry);
67 * @param index the index of the log entry
69 List<ReplicatedLogEntry> getFrom(long index);
79 * Checks if the entry at the specified index is present or not
81 * @param index the index of the log entry
82 * @return true if the entry is present in the in-memory journal
84 boolean isPresent(long index);
87 * Checks if the entry is present in a snapshot
89 * @param index the index of the log entry
90 * @return true if the entry is in the snapshot. false if the entry is not
91 * in the snapshot even if the entry may be present in the replicated log
93 boolean isInSnapshot(long index);
98 * @return an object representing the snapshot if it exists. null otherwise
100 Object getSnapshot();
103 * Get the index of the snapshot
105 * @return the index from which the snapshot was created. -1 otherwise.
107 long getSnapshotIndex();
110 * Get the term of the snapshot
112 * @return the term of the index from which the snapshot was created. -1
115 long getSnapshotTerm();