Interface LogStreamReader

All Superinterfaces:
AutoCloseable, CloseableSilently, Iterator<LoggedEvent>

public interface LogStreamReader extends Iterator<LoggedEvent>, CloseableSilently
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 Type
    Method
    Description
    long
    Returns the current log position of the reader.
    Peeks the next event on the log.
    boolean
    seek(long position)
    Seek to the given log position if exists.
    long
    Seek to the end of the log, which means after the last event.
    void
    Seek to the log position of the first event.
    boolean
    seekToNextEvent(long position)
    Seeks to the event after the given position.

    Methods inherited from interface io.camunda.zeebe.util.CloseableSilently

    close

    Methods 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 to Iterator.next() but it doesn't move the iterator. It should only be called if Iterator.hasNext() returns true.
      Returns:
      return the next event on the log
      Throws:
      NoSuchElementException - if there is no next event on the log