Interface WALTailingReader

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ProtobufWALTailingReader

@Private public interface WALTailingReader extends Closeable
A WAL reader which is designed for be able to tailing the WAL file which is currently being written. It adds support
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
     
    static enum 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Override to remove the 'throws IOException' as we are just a reader.
    long
    Get the current reading position.
    next(long limit)
    Read the next entry and make sure the position after reading does not go beyond the given limit.
    void
    resetTo(long position, boolean resetCompression)
    Reopen the reader to see if there is new data arrives, and also seek(or skip) to the given position.
  • Method Details

    • next

      Read the next entry and make sure the position after reading does not go beyond the given limit.

      Notice that we will not throw any checked exception out, all the states are represented by the return value. Of course we will log the exceptions out. The reason why we do this is that, for tailing a WAL file which is currently being written, we will hit EOFException many times, so it should not be considered as an 'exception' and also, creating an Exception is a bit expensive.

      Parameters:
      limit - the position limit. See HBASE-14004 for more details about why we need this limitation. -1 means no limit.
    • getPosition

      long getPosition() throws IOException
      Get the current reading position.
      Throws:
      IOException
    • resetTo

      void resetTo(long position, boolean resetCompression) throws IOException
      Reopen the reader to see if there is new data arrives, and also seek(or skip) to the given position.

      If you want to read from the beginning instead of a given position, please pass -1 as position, then the reader will locate to the first entry. Notice that, since we have a magic header and a pb header, the first WAL entry is not located at position 0, so passing 0 will cause trouble.

      Parameters:
      position - the position we want to start reading from after resetting, or -1 if you want to start reading from the beginning.
      resetCompression - whether we also need to clear the compression context. If true, we will use skip instead of seek after resetting.
      Throws:
      IOException
    • close

      void close()
      Override to remove the 'throws IOException' as we are just a reader.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable