org.apache.hadoop.hbase.regionserver.wal
Class ProtobufLogReader

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.wal.ReaderBase
      extended by org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader
All Implemented Interfaces:
HLog.Reader
Direct Known Subclasses:
SecureProtobufLogReader

@InterfaceAudience.LimitedPrivate(value={"Coprocesssor","Phoenix","Configuration"})
public class ProtobufLogReader
extends ReaderBase

A Protobuf based WAL has the following structure:

<PB_WAL_MAGIC><WALHeader><WALEdits>...<WALEdits><Trailer> <TrailerSize> <PB_WAL_COMPLETE_MAGIC>

The Reader reads meta information (WAL Compression state, WALTrailer, etc) in initReader(FSDataInputStream). A WALTrailer is an extensible structure which is appended at the end of the WAL. This is empty for now; it can contain some meta information such as Region level stats, etc in future.


Field Summary
protected  WALCellCodec.ByteStringUncompressor byteStringUncompressor
           
protected  Codec.Decoder cellDecoder
           
protected  boolean hasCompression
           
protected  boolean hasTagCompression
           
protected  org.apache.hadoop.fs.FSDataInputStream inputStream
           
 
Fields inherited from class org.apache.hadoop.hbase.regionserver.wal.ReaderBase
compressionContext, conf, edit, emptyCompressionContext, fileLength, fs, path, trailer, trailerWarnSize
 
Constructor Summary
ProtobufLogReader()
           
 
Method Summary
 void close()
           
protected  WALCellCodec getCodec(org.apache.hadoop.conf.Configuration conf, String cellCodecClsName, org.apache.hadoop.hbase.regionserver.wal.CompressionContext compressionContext)
           
 long getPosition()
           
 WALProtos.WALTrailer getWALTrailer()
           
protected  List<String> getWriterClsNames()
           
protected  boolean hasCompression()
           
protected  boolean hasTagCompression()
           
protected  void initAfterCompression()
          Initializes the compression after the shared stuff has been initialized.
protected  void initAfterCompression(String cellCodecClsName)
          Initializes the compression after the shared stuff has been initialized.
protected  String initReader(org.apache.hadoop.fs.FSDataInputStream stream)
          Initializes the log reader with a particular stream (may be null).
protected  org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader.WALHdrContext readHeader(WALProtos.WALHeader.Builder builder, org.apache.hadoop.fs.FSDataInputStream stream)
           
protected  boolean readNext(HLog.Entry entry)
          Read next entry.
 void reset()
           
protected  void seekOnFs(long pos)
          Performs a filesystem-level seek to a certain position in an underlying file.
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.wal.ReaderBase
init, next, next, seek
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputStream

protected org.apache.hadoop.fs.FSDataInputStream inputStream

cellDecoder

protected Codec.Decoder cellDecoder

byteStringUncompressor

protected WALCellCodec.ByteStringUncompressor byteStringUncompressor

hasCompression

protected boolean hasCompression

hasTagCompression

protected boolean hasTagCompression
Constructor Detail

ProtobufLogReader

public ProtobufLogReader()
Method Detail

close

public void close()
           throws IOException
Throws:
IOException

getPosition

public long getPosition()
                 throws IOException
Throws:
IOException

reset

public void reset()
           throws IOException
Throws:
IOException

initReader

protected String initReader(org.apache.hadoop.fs.FSDataInputStream stream)
                     throws IOException
Description copied from class: ReaderBase
Initializes the log reader with a particular stream (may be null). Reader assumes ownership of the stream if not null and may use it. Called once.

Specified by:
initReader in class ReaderBase
Returns:
the class name of cell Codec, null if such information is not available
Throws:
IOException

getWriterClsNames

protected List<String> getWriterClsNames()

readHeader

protected org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader.WALHdrContext readHeader(WALProtos.WALHeader.Builder builder,
                                                                                              org.apache.hadoop.fs.FSDataInputStream stream)
                                                                                       throws IOException
Throws:
IOException

getCodec

protected WALCellCodec getCodec(org.apache.hadoop.conf.Configuration conf,
                                String cellCodecClsName,
                                org.apache.hadoop.hbase.regionserver.wal.CompressionContext compressionContext)
                         throws IOException
Throws:
IOException

initAfterCompression

protected void initAfterCompression()
                             throws IOException
Description copied from class: ReaderBase
Initializes the compression after the shared stuff has been initialized. Called once.

Specified by:
initAfterCompression in class ReaderBase
Throws:
IOException

initAfterCompression

protected void initAfterCompression(String cellCodecClsName)
                             throws IOException
Description copied from class: ReaderBase
Initializes the compression after the shared stuff has been initialized. Called once.

Specified by:
initAfterCompression in class ReaderBase
Parameters:
cellCodecClsName - class name of cell Codec
Throws:
IOException

hasCompression

protected boolean hasCompression()
Specified by:
hasCompression in class ReaderBase
Returns:
Whether compression is enabled for this log.

hasTagCompression

protected boolean hasTagCompression()
Specified by:
hasTagCompression in class ReaderBase
Returns:
Whether tag compression is enabled for this log.

readNext

protected boolean readNext(HLog.Entry entry)
                    throws IOException
Description copied from class: ReaderBase
Read next entry.

Specified by:
readNext in class ReaderBase
Parameters:
entry - The entry to read into.
Returns:
Whether there was anything to read.
Throws:
IOException

getWALTrailer

public WALProtos.WALTrailer getWALTrailer()
Specified by:
getWALTrailer in interface HLog.Reader
Overrides:
getWALTrailer in class ReaderBase
Returns:
the WALTrailer of the current HLog. It may be null in case of legacy or corrupt WAL files.

seekOnFs

protected void seekOnFs(long pos)
                 throws IOException
Description copied from class: ReaderBase
Performs a filesystem-level seek to a certain position in an underlying file.

Specified by:
seekOnFs in class ReaderBase
Throws:
IOException


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