@InterfaceAudience.Private @InterfaceStability.Evolving class WALEntryStream extends Object implements Closeable
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.Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
private WAL.Entry |
currentEntry |
private org.apache.hadoop.fs.Path |
currentPath |
private long |
currentPositionOfEntry |
private long |
currentPositionOfReader |
private org.apache.hadoop.fs.FileSystem |
fs |
private static org.slf4j.Logger |
LOG |
private ReplicationSourceLogQueue |
logQueue |
private MetricsSource |
metrics |
private WAL.Reader |
reader |
private ServerName |
serverName |
private WALFileLengthProvider |
walFileLengthProvider |
private String |
walGroupId |
Constructor and Description |
---|
WALEntryStream(ReplicationSourceLogQueue logQueue,
org.apache.hadoop.conf.Configuration conf,
long startPosition,
WALFileLengthProvider walFileLengthProvider,
ServerName serverName,
MetricsSource metrics,
String walGroupId)
Create an entry stream over the given queue at the given start position
|
Modifier and Type | Method and Description |
---|---|
private boolean |
checkAllBytesParsed() |
private boolean |
checkReader() |
void |
close() |
private void |
closeReader() |
private long |
currentTrailerSize() |
private void |
dequeueCurrentLog() |
org.apache.hadoop.fs.Path |
getCurrentPath()
Returns the
Path of the current WAL |
private String |
getCurrentPathStat() |
long |
getPosition()
Returns the position of the last Entry returned by next()
|
private void |
handleFileNotFound(org.apache.hadoop.fs.Path path,
FileNotFoundException fnfe) |
boolean |
hasNext()
Returns true if there is another WAL
WAL.Entry |
WAL.Entry |
next()
Returns the next WAL entry in this stream and advance the stream.
|
private boolean |
openNextLog() |
private void |
openReader(org.apache.hadoop.fs.Path path) |
WAL.Entry |
peek()
Returns the next WAL entry in this stream but does not advance.
|
private boolean |
readNextEntryAndRecordReaderPosition()
Returns whether the file is opened for writing.
|
private void |
recoverLease(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.Path path) |
void |
reset()
Should be called if the stream is to be reused (i.e.
|
private void |
resetReader() |
private void |
seek() |
private void |
setCurrentPath(org.apache.hadoop.fs.Path path) |
private void |
setPosition(long position) |
private void |
tryAdvanceEntry() |
private static final org.slf4j.Logger LOG
private WAL.Reader reader
private org.apache.hadoop.fs.Path currentPath
private WAL.Entry currentEntry
private long currentPositionOfEntry
private long currentPositionOfReader
private final ReplicationSourceLogQueue logQueue
private final String walGroupId
private final org.apache.hadoop.fs.FileSystem fs
private final org.apache.hadoop.conf.Configuration conf
private final WALFileLengthProvider walFileLengthProvider
private final ServerName serverName
private final MetricsSource metrics
public WALEntryStream(ReplicationSourceLogQueue logQueue, org.apache.hadoop.conf.Configuration conf, long startPosition, WALFileLengthProvider walFileLengthProvider, ServerName serverName, MetricsSource metrics, String walGroupId) throws IOException
logQueue
- the queue of WAL pathsconf
- the Configuration
to use to create WAL.Reader
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 metricsIOException
- throw IO exception from streampublic boolean hasNext() throws IOException
WAL.Entry
IOException
public WAL.Entry peek() throws IOException
IOException
public WAL.Entry next() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public long getPosition()
public org.apache.hadoop.fs.Path getCurrentPath()
Path
of the current WALprivate String getCurrentPathStat()
public void reset() throws IOException
IOException
private void setPosition(long position)
private void setCurrentPath(org.apache.hadoop.fs.Path path)
private void tryAdvanceEntry() throws IOException
IOException
private boolean checkAllBytesParsed() throws IOException
IOException
private void dequeueCurrentLog() throws IOException
IOException
private boolean readNextEntryAndRecordReaderPosition() throws IOException
IOException
private void closeReader() throws IOException
IOException
private boolean checkReader() throws IOException
IOException
private boolean openNextLog() throws IOException
IOException
private void handleFileNotFound(org.apache.hadoop.fs.Path path, FileNotFoundException fnfe) throws IOException
IOException
private void openReader(org.apache.hadoop.fs.Path path) throws IOException
IOException
private void recoverLease(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path path)
private void resetReader() throws IOException
IOException
private void seek() throws IOException
IOException
private long currentTrailerSize()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.