org.apache.hadoop.hbase.io
Class FSDataInputStreamWrapper

java.lang.Object
  extended by org.apache.hadoop.hbase.io.FSDataInputStreamWrapper

public class FSDataInputStreamWrapper
extends Object

Wrapper for input stream(s) that takes care of the interaction of FS and HBase checksums, as well as closing streams. Initialization is not thread-safe, but normal operation is; see method comments.


Constructor Summary
FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs, FileLink link)
           
FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path)
           
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.
 
Method Summary
 void checksumOk()
          Report that checksum was ok, so we may ponder going back to HBase checksum.
 void close()
          Close 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()
           
 org.apache.hadoop.fs.FSDataInputStream getStream(boolean useHBaseChecksum)
          Get the stream to use.
 void prepareForBlockReader(boolean forceNoHBaseChecksum)
          Prepares the streams for block reader.
 boolean shouldUseHBaseChecksum()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FSDataInputStreamWrapper

public FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs,
                                org.apache.hadoop.fs.Path path)
                         throws IOException
Throws:
IOException

FSDataInputStreamWrapper

public FSDataInputStreamWrapper(org.apache.hadoop.fs.FileSystem fs,
                                FileLink link)
                         throws IOException
Throws:
IOException

FSDataInputStreamWrapper

public FSDataInputStreamWrapper(org.apache.hadoop.fs.FSDataInputStream fsdis)
For use in tests.


FSDataInputStreamWrapper

public FSDataInputStreamWrapper(org.apache.hadoop.fs.FSDataInputStream fsdis,
                                org.apache.hadoop.fs.FSDataInputStream noChecksum)
For use in tests.

Method Detail

prepareForBlockReader

public void prepareForBlockReader(boolean forceNoHBaseChecksum)
                           throws IOException
Prepares the streams for block reader. NOT THREAD SAFE. Must be called once, after any reads finish and before any other reads start (what happens in reality is we read the tail, then call this based on what's in the tail, then read blocks).

Parameters:
forceNoHBaseChecksum - Force not using HBase checksum.
Throws:
IOException

shouldUseHBaseChecksum

public boolean shouldUseHBaseChecksum()
Returns:
Whether we are presently using HBase checksum.

getStream

public org.apache.hadoop.fs.FSDataInputStream getStream(boolean useHBaseChecksum)
Get the stream to use. Thread-safe.

Parameters:
useHBaseChecksum - must be the value that shouldUseHBaseChecksum has returned at some point in the past, otherwise the result is undefined.

fallbackToFsChecksum

public org.apache.hadoop.fs.FSDataInputStream fallbackToFsChecksum(int offCount)
                                                            throws IOException
Read from non-checksum stream failed, fall back to FS checksum. Thread-safe.

Parameters:
offCount - For how many checksumOk calls to turn off the HBase checksum.
Throws:
IOException

checksumOk

public void checksumOk()
Report that checksum was ok, so we may ponder going back to HBase checksum.


close

public void close()
           throws IOException
Close stream(s) if necessary.

Throws:
IOException

getHfs

public HFileSystem getHfs()


Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.