2 * Copyright 2017-present Open Networking Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package io.atomix.storage.journal;
18 import java.util.Iterator;
23 * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
25 public interface JournalReader<E> extends Iterator<Indexed<E>>, AutoCloseable {
28 * Raft log reader mode.
33 * Reads all entries from the log.
38 * Reads committed entries from the log.
44 * Returns the first index in the journal.
46 * @return the first index in the journal
51 * Returns the current reader index.
53 * @return The current reader index.
55 long getCurrentIndex();
58 * Returns the last read entry.
60 * @return The last read entry.
62 Indexed<E> getCurrentEntry();
65 * Returns the next reader index.
67 * @return The next reader index.
72 * Returns whether the reader has a next entry to read.
74 * @return Whether the reader has a next entry to read.
80 * Returns the next entry in the reader.
82 * @return The next entry in the reader.
88 * Resets the reader to the start.
93 * Resets the reader to the given index.
95 * @param index The index to which to reset the reader.
97 void reset(long index);