@InterfaceAudience.Private public class ProtobufWALTailingReader extends AbstractProtobufWALReader implements WALTailingReader
Modifier and Type | Class and Description |
---|---|
private static class |
ProtobufWALTailingReader.ReadWALKeyResult |
WALTailingReader.Result, WALTailingReader.State
Modifier and Type | Field and Description |
---|---|
private DelegatingInputStream |
delegatingInput |
private static ProtobufWALTailingReader.ReadWALKeyResult |
KEY_EOF_AND_RESET |
private static ProtobufWALTailingReader.ReadWALKeyResult |
KEY_ERROR_AND_RESET |
private static org.slf4j.Logger |
LOG |
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 and Description |
---|
ProtobufWALTailingReader() |
Modifier and Type | Method and Description |
---|---|
private WALTailingReader.Result |
editEof() |
private WALTailingReader.Result |
editError() |
protected InputStream |
getCellCodecInputStream(org.apache.hadoop.fs.FSDataInputStream stream)
Get or create the input stream used by cell decoder.
|
WALTailingReader.Result |
next(long limit)
Read the next entry and make sure the position after reading does not go beyond the given
limit . |
private WALTailingReader.Result |
readWALEdit(WAL.Entry entry,
int followingKvCount) |
private ProtobufWALTailingReader.ReadWALKeyResult |
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 |
unwrapIPBE(IOException e) |
close, extractHiddenEof, getCodecClsName, getPosition, getPositionQuietly, getWriterClsNames, init, initWALCellCodec, isWALTrailer, open, reachWALEditsStopOffset, readHeader, readTrailer, trailerSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getPosition
private static final org.slf4j.Logger LOG
private DelegatingInputStream delegatingInput
private static final ProtobufWALTailingReader.ReadWALKeyResult KEY_ERROR_AND_RESET
private static final ProtobufWALTailingReader.ReadWALKeyResult KEY_EOF_AND_RESET
public ProtobufWALTailingReader()
private IOException unwrapIPBE(IOException e)
private ProtobufWALTailingReader.ReadWALKeyResult readWALKey(long originalPosition)
private WALTailingReader.Result editEof()
private WALTailingReader.Result editError()
private WALTailingReader.Result readWALEdit(WAL.Entry entry, int followingKvCount)
public WALTailingReader.Result next(long limit)
WALTailingReader
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.next
in interface WALTailingReader
limit
- the position limit. See HBASE-14004 for more details about why we need this
limitation. -1 means no limit.private void skipHeader(org.apache.hadoop.fs.FSDataInputStream stream) throws IOException
IOException
public void resetTo(long position, boolean resetCompression) throws IOException
WALTailingReader
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.resetTo
in interface WALTailingReader
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.IOException
protected InputStream getCellCodecInputStream(org.apache.hadoop.fs.FSDataInputStream stream)
AbstractProtobufWALReader
getCellCodecInputStream
in class AbstractProtobufWALReader
protected void skipTo(long position) throws IOException
AbstractProtobufWALReader
skipTo
in class AbstractProtobufWALReader
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.