Class WALEntryStream
java.lang.Object
org.apache.hadoop.hbase.replication.regionserver.WALEntryStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Streaming access to WAL entries. This class is given a queue of WAL
Path
, and continually
iterates through all the WAL WAL.Entry
in the queue. When it's done reading from a Path, it
dequeues it and starts reading from the next.-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configuration
private WAL.Entry
private org.apache.hadoop.fs.Path
private long
private long
private boolean
private final org.apache.hadoop.fs.FileSystem
private static final org.slf4j.Logger
private final ReplicationSourceLogQueue
private final MetricsSource
private WALTailingReader
private WALTailingReader.State
private final WALFileLengthProvider
private final String
-
Constructor Summary
ConstructorDescriptionWALEntryStream
(ReplicationSourceLogQueue logQueue, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, long startPosition, WALFileLengthProvider walFileLengthProvider, MetricsSource metrics, String walGroupId) Create an entry stream over the given queue at the given start position -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
void
close()
private void
private long
private void
org.apache.hadoop.fs.Path
Returns thePath
of the current WALprivate org.apache.hadoop.fs.FileStatus
private String
long
Returns the position of the last Entry returned by next()hasNext()
Try advance the stream if there is no entry yet.private WALEntryStream.HasNext
next()
Returns the next WAL entry in this stream and advance the stream.peek()
Returns the next WAL entry in this stream but does not advance.private WALEntryStream.HasNext
private Pair<WALTailingReader.State,
Boolean> Returns whether the file is opened for writing.private void
private void
setCurrentPath
(org.apache.hadoop.fs.Path path) private WALEntryStream.HasNext
-
Field Details
-
LOG
-
reader
-
state
-
currentPath
-
currentEntry
-
currentPositionOfEntry
-
currentPositionOfReader
-
logQueue
-
walGroupId
-
fs
-
conf
-
walFileLengthProvider
-
metrics
-
eofAutoRecovery
-
-
Constructor Details
-
WALEntryStream
public WALEntryStream(ReplicationSourceLogQueue logQueue, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf, long startPosition, WALFileLengthProvider walFileLengthProvider, MetricsSource metrics, String walGroupId) Create an entry stream over the given queue at the given start position- Parameters:
logQueue
- the queue of WAL pathsconf
- theConfiguration
to use to createWALStreamReader
for this streamstartPosition
- the position in the first WAL to start reading atwalFileLengthProvider
- provides the length of the WAL fileserverName
- the server name which all WALs belong tometrics
- the replication metrics
-
-
Method Details
-
hasNext
Try advance the stream if there is no entry yet. See the javadoc forWALEntryStream.HasNext
for more details about the meanings of the return values. You can callpeek()
ornext()
to get the actualWAL.Entry
if this method returnsWALEntryStream.HasNext.YES
. -
peek
Returns the next WAL entry in this stream but does not advance. Must callhasNext()
first before calling this method, and if you have already callednext()
to consume the current entry, you need to callhasNext()
again to advance the stream before calling this method again, otherwise it will always returnnull
The reason here is that, we need to use the return value ofhasNext()
to tell upper layer to retry or not, so we can not wrap thehasNext()
call insidepeek()
ornext()
as they have their own return value. -
next
Returns the next WAL entry in this stream and advance the stream. Will throwIllegalStateException
if you do not callhasNext()
before calling this method. Please see the javadoc ofpeek()
method to see why we need this.- Throws:
IllegalStateException
- Every time you want to call this method, please callhasNext()
first, otherwise aIllegalStateException
will be thrown.- See Also:
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getPosition
Returns the position of the last Entry returned by next() -
getCurrentPath
Returns thePath
of the current WAL -
getCurrentPathStat
-
setCurrentPath
-
resetReader
- Throws:
IOException
-
prepareReader
-
lastAttempt
-
tryAdvanceEntry
-
getCurrentPathFileStatus
- Throws:
IOException
-
checkAllBytesParsed
-
dequeueCurrentLog
-
readNextEntryAndRecordReaderPosition
Returns whether the file is opened for writing. -
closeReader
-
currentTrailerSize
-