Class ProtobufWALTailingReader
java.lang.Object
org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufWALReader
org.apache.hadoop.hbase.regionserver.wal.ProtobufWALTailingReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AbstractFSWALProvider.Initializer
,WALTailingReader
@Private
public class ProtobufWALTailingReader
extends AbstractProtobufWALReader
implements WALTailingReader
A WAL reader for replication. It supports reset so can be used to tail a WAL file which is being
written currently.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final class
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.wal.WALTailingReader
WALTailingReader.Result, WALTailingReader.State
-
Field Summary
Modifier and TypeFieldDescriptionprivate DelegatingInputStream
private static final ProtobufWALTailingReader.ReadWALKeyResult
private static final ProtobufWALTailingReader.ReadWALKeyResult
private static final org.slf4j.Logger
Fields inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufWALReader
byteStringUncompressor, cellDecoder, codecClsName, compressionCtx, conf, decryptor, DEFAULT_WAL_TRAILER_WARN_SIZE, fileLength, fs, hasCompression, hasTagCompression, hasValueCompression, inputStream, path, PB_WAL_COMPLETE_MAGIC, PB_WAL_MAGIC, trailer, trailerPresent, trailerWarnSize, valueCompressionType, WAL_TRAILER_WARN_SIZE, walEditsStopOffset
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate WALTailingReader.Result
editEof()
private WALTailingReader.Result
protected InputStream
getCellCodecInputStream
(org.apache.hadoop.fs.FSDataInputStream stream) Get or create the input stream used by cell decoder.next
(long limit) Read the next entry and make sure the position after reading does not go beyond the givenlimit
.private WALTailingReader.Result
readWALEdit
(WAL.Entry entry, int followingKvCount) readWALKey
(long originalPosition) 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.private void
skipHeader
(org.apache.hadoop.fs.FSDataInputStream stream) protected void
skipTo
(long position) Skip to the given position.private IOException
Methods inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufWALReader
close, extractHiddenEof, getCodecClsName, getPosition, getPositionQuietly, getWriterClsNames, init, initWALCellCodec, isWALTrailer, open, reachWALEditsStopOffset, readHeader, readTrailer, trailerSize
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.wal.WALTailingReader
close, getPosition
-
Field Details
-
LOG
-
delegatingInput
-
KEY_ERROR_AND_RESET
-
KEY_EOF_AND_RESET
-
-
Constructor Details
-
ProtobufWALTailingReader
public ProtobufWALTailingReader()
-
-
Method Details
-
unwrapIPBE
-
readWALKey
-
editEof
-
editError
-
readWALEdit
-
next
Description copied from interface:WALTailingReader
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.- Specified by:
next
in interfaceWALTailingReader
- Parameters:
limit
- the position limit. See HBASE-14004 for more details about why we need this limitation. -1 means no limit.
-
skipHeader
- Throws:
IOException
-
resetTo
Description copied from interface:WALTailingReader
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.- Specified by:
resetTo
in interfaceWALTailingReader
- 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
-
getCellCodecInputStream
Description copied from class:AbstractProtobufWALReader
Get or create the input stream used by cell decoder. For implementing replication, we may need to limit the bytes we can read, so here we provide a method so subclasses can wrap the original input stream.- Specified by:
getCellCodecInputStream
in classAbstractProtobufWALReader
-
skipTo
Description copied from class:AbstractProtobufWALReader
Skip to the given position.- Specified by:
skipTo
in classAbstractProtobufWALReader
- Throws:
IOException
-