Package io.camunda.zeebe.logstreams.log
Interface LogStreamReader
- All Superinterfaces:
AutoCloseable,CloseableSilently,Iterator<LoggedEvent>
- All Known Implementing Classes:
LogStreamReaderImpl
Reads the log stream in an iterator-like pattern. Common usage:
reader.wrap(log);
// optionally seek to a position
reader.seek(position);
while(reader.hasNext())
{
final LoggedEvent event = reader.next();
// process the event..
}
-
Method Summary
Modifier and TypeMethodDescriptionlongReturns the current log position of the reader.peekNext()Peeks the next event on the log.booleanseek(long position) Seek to the given log position if exists.longSeek to the end of the log, which means after the last event.voidSeek to the log position of the first event.booleanseekToNextEvent(long position) Seeks to the event after the given position.Methods inherited from interface io.camunda.zeebe.util.CloseableSilently
closeMethods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
seekToNextEvent
boolean seekToNextEvent(long position) Seeks to the event after the given position. On negative position it seeks to the first event.- Parameters:
position- the position which should be used- Returns:
true, if the position is negative or exists
-
seek
boolean seek(long position) Seek to the given log position if exists. Otherwise, it seek to the next position after this.- Parameters:
position- the position in the log to seek to- Returns:
true, if the given position exists.
-
seekToFirstEvent
void seekToFirstEvent()Seek to the log position of the first event. -
seekToEnd
long seekToEnd()Seek to the end of the log, which means after the last event.- Returns:
- the position of the last entry
-
getPosition
long getPosition()Returns the current log position of the reader.- Returns:
- the current log position, or negative value if the log is empty or not initialized
-
peekNext
LoggedEvent peekNext()Peeks the next event on the log. It is similar toIterator.next()but it doesn't move the iterator. It should only be called ifIterator.hasNext()returnstrue.- Returns:
- return the next event on the log
- Throws:
NoSuchElementException- if there is no next event on the log
-