@InterfaceAudience.Private public class FSDataInputStreamWrapper extends Object implements Closeable
Modifier and Type | Class and Description |
---|---|
private static class |
FSDataInputStreamWrapper.ReadStatistics |
Modifier and Type | Field and Description |
---|---|
private boolean |
doCloseStreams |
private boolean |
dropBehind |
private AtomicInteger |
hbaseChecksumOffCount |
private HFileSystem |
hfs |
private Boolean |
instanceOfCanUnbuffer |
private static boolean |
isLogTraceEnabled |
private FileLink |
link |
private static org.slf4j.Logger |
LOG |
private org.apache.hadoop.fs.Path |
path |
private long |
readahead |
private static FSDataInputStreamWrapper.ReadStatistics |
readStatistics |
private org.apache.hadoop.fs.FSDataInputStream |
stream
Two stream handles, one with and one without FS-level checksum.
|
private org.apache.hadoop.fs.FSDataInputStream |
streamNoFsChecksum |
private Object |
streamNoFsChecksumFirstCreateLock |
private org.apache.hadoop.fs.CanUnbuffer |
unbuffer |
private boolean |
useHBaseChecksum |
private boolean |
useHBaseChecksumConfigured |
Modifier | Constructor and Description |
---|---|
|
FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs,
FileLink link,
boolean dropBehind,
long readahead) |
private |
FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs,
FileLink link,
org.apache.hadoop.fs.Path path,
boolean dropBehind,
long readahead) |
|
FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path) |
|
FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
boolean dropBehind,
long readahead) |
|
FSDataInputStreamWrapper(org.apache.hadoop.fs.FSDataInputStream fsdis)
For use in tests.
|
|
FSDataInputStreamWrapper(org.apache.hadoop.fs.FSDataInputStream fsdis,
org.apache.hadoop.fs.FSDataInputStream noChecksum)
For use in tests.
|
Modifier and Type | Method and Description |
---|---|
void |
checksumOk()
Report that checksum was ok, so we may ponder going back to HBase checksum.
|
void |
close()
CloseClose stream(s) if necessary.
|
org.apache.hadoop.fs.FSDataInputStream |
fallbackToFsChecksum(int offCount)
Read from non-checksum stream failed, fall back to FS checksum.
|
HFileSystem |
getHfs() |
static long |
getLocalBytesRead() |
static long |
getShortCircuitBytesRead() |
org.apache.hadoop.fs.FSDataInputStream |
getStream(boolean useHBaseChecksum)
Get the stream to use.
|
static long |
getTotalBytesRead() |
static long |
getZeroCopyBytesRead() |
void |
prepareForBlockReader(boolean forceNoHBaseChecksum)
Prepares the streams for block reader.
|
private void |
setStreamOptions(org.apache.hadoop.fs.FSDataInputStream in) |
boolean |
shouldUseHBaseChecksum() |
void |
unbuffer()
This will free sockets and file descriptors held by the stream only when the stream implements
org.apache.hadoop.fs.CanUnbuffer.
|
private void |
updateInputStreamStatistics(org.apache.hadoop.fs.FSDataInputStream stream) |
private static final org.slf4j.Logger LOG
private static final boolean isLogTraceEnabled
private final HFileSystem hfs
private final org.apache.hadoop.fs.Path path
private final boolean doCloseStreams
private final boolean dropBehind
private final long readahead
private volatile org.apache.hadoop.fs.FSDataInputStream stream
stream
.
2.1) After that, if HBase checksum is not used, we'd just always use stream
;
2.2) If HBase checksum can be used, we'll open streamNoFsChecksum
,
and close stream
. User MUST call prepareForBlockReader for that to happen;
if they don't, (2.1) will be the default.
3) The users can call shouldUseHBaseChecksum()
, and pass its result to
getStream(boolean)
to get stream (if Java had out/pointer params we could
return both in one call). This stream is guaranteed to be set.
4) The first time HBase checksum fails, one would call fallbackToFsChecksum(int)
.
That will take lock, and open stream
. While this is going on, others will
continue to use the old stream; if they also want to fall back, they'll also call
fallbackToFsChecksum(int)
, and block until stream
is set.
5) After some number of checksumOk() calls, we will go back to using HBase checksum.
We will have 2 handles; however we presume checksums fail so rarely that we don't care.private volatile org.apache.hadoop.fs.FSDataInputStream streamNoFsChecksum
private final Object streamNoFsChecksumFirstCreateLock
private boolean useHBaseChecksumConfigured
private volatile boolean useHBaseChecksum
private AtomicInteger hbaseChecksumOffCount
private static final FSDataInputStreamWrapper.ReadStatistics readStatistics
private Boolean instanceOfCanUnbuffer
private org.apache.hadoop.fs.CanUnbuffer unbuffer
public FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException
IOException
public FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, boolean dropBehind, long readahead) throws IOException
IOException
public FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs, FileLink link, boolean dropBehind, long readahead) throws IOException
IOException
private FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs, FileLink link, org.apache.hadoop.fs.Path path, boolean dropBehind, long readahead) throws IOException
IOException
public FSDataInputStreamWrapper(org.apache.hadoop.fs.FSDataInputStream fsdis)
public FSDataInputStreamWrapper(org.apache.hadoop.fs.FSDataInputStream fsdis, org.apache.hadoop.fs.FSDataInputStream noChecksum)
private void setStreamOptions(org.apache.hadoop.fs.FSDataInputStream in)
public void prepareForBlockReader(boolean forceNoHBaseChecksum) throws IOException
forceNoHBaseChecksum
- Force not using HBase checksum.IOException
public boolean shouldUseHBaseChecksum()
public org.apache.hadoop.fs.FSDataInputStream getStream(boolean useHBaseChecksum)
useHBaseChecksum
- must be the value that shouldUseHBaseChecksum has returned
at some point in the past, otherwise the result is undefined.public org.apache.hadoop.fs.FSDataInputStream fallbackToFsChecksum(int offCount) throws IOException
offCount
- For how many checksumOk calls to turn off the HBase checksum.IOException
public void checksumOk()
private void updateInputStreamStatistics(org.apache.hadoop.fs.FSDataInputStream stream)
public static long getTotalBytesRead()
public static long getLocalBytesRead()
public static long getShortCircuitBytesRead()
public static long getZeroCopyBytesRead()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public HFileSystem getHfs()
public void unbuffer()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.