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

@InterfaceAudience.Private
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
 
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()
           
 long getPosition()
           
 WALProtos.WALTrailer getWALTrailer()
           
protected  boolean hasCompression()
           
protected  void initAfterCompression()
          Initializes the compression after the shared stuff has been initialized.
protected  void initReader(org.apache.hadoop.fs.FSDataInputStream stream)
          Initializes the log reader with a particular stream (may be null).
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
 

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 void 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
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

hasCompression

protected boolean hasCompression()
Specified by:
hasCompression in class ReaderBase
Returns:
Whether 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 © 2013 The Apache Software Foundation. All Rights Reserved.