Package org.apache.hadoop.hbase.wal
Interface WALTailingReader
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
ProtobufWALTailingReader
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 ClassesModifier and TypeInterfaceDescriptionstatic final classstatic enum -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Override to remove the 'throws IOException' as we are just a reader.longGet the current reading position.next(long limit) Read the next entry and make sure the position after reading does not go beyond the givenlimit.voidresetTo(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 givenlimit. 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
Get the current reading position.- Throws:
IOException
-
resetTo
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 asposition, 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. Iftrue, 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-