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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configurationprivate WAL.Entryprivate org.apache.hadoop.fs.Pathprivate longprivate longprivate booleanprivate final org.apache.hadoop.fs.FileSystemprivate static final org.slf4j.Loggerprivate final ReplicationSourceLogQueueprivate final MetricsSourceprivate WALTailingReaderprivate WALTailingReader.Stateprivate final WALFileLengthProviderprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionWALEntryStream(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 booleanvoidclose()private voidprivate longprivate voidorg.apache.hadoop.fs.PathReturns thePathof the current WALprivate org.apache.hadoop.fs.FileStatusprivate StringlongReturns the position of the last Entry returned by next()hasNext()Try advance the stream if there is no entry yet.private WALEntryStream.HasNextnext()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.HasNextprivate Pair<WALTailingReader.State,Boolean> Returns whether the file is opened for writing.private voidsetCurrentPath(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- theConfigurationto use to createWALStreamReaderfor 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.HasNextfor more details about the meanings of the return values. You can callpeek()ornext()to get the actualWAL.Entryif 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 returnnullThe 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 throwIllegalStateExceptionif 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 aIllegalStateExceptionwill be thrown.- See Also:
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getPosition
Returns the position of the last Entry returned by next() -
getCurrentPath
Returns thePathof the current WAL -
getCurrentPathStat
-
setCurrentPath
-
prepareReader
-
lastAttempt
-
tryAdvanceEntry
-
getCurrentPathFileStatus
- Throws:
IOException
-
checkAllBytesParsed
-
dequeueCurrentLog
-
readNextEntryAndRecordReaderPosition
Returns whether the file is opened for writing. -
closeReader
-
currentTrailerSize
-