org.apache.hadoop.hdfs.server.namenode
Class EditLogFileInputStream

java.lang.Object
  extended by org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
      extended by org.apache.hadoop.hdfs.server.namenode.EditLogFileInputStream
All Implemented Interfaces:
Closeable

public class EditLogFileInputStream
extends org.apache.hadoop.hdfs.server.namenode.EditLogInputStream

An implementation of the abstract class EditLogInputStream, which reads edits from a local file.


Constructor Summary
EditLogFileInputStream(File name, long firstTxId, long lastTxId, boolean isInProgress)
          Open an EditLogInputStream for the given file.
 
Method Summary
 void close()
          Close the stream.
 long getFirstTxId()
           
 long getLastTxId()
           
 String getName()
           
 long getPosition()
          Get the "position" of in the stream.
 int getVersion()
          Get the layout version of the data in the stream.
 boolean isInProgress()
          Return true if this stream is in progress, false if it is finalized.
 long length()
          Return the size of the current edits log.
protected  org.apache.hadoop.hdfs.server.namenode.FSEditLogOp nextOp()
          Get the next operation from the stream storage.
protected  org.apache.hadoop.hdfs.server.namenode.FSEditLogOp nextValidOp()
          Get the next valid operation from the stream storage.
 String toString()
           
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
readOp, resync, skipUntil
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EditLogFileInputStream

public EditLogFileInputStream(File name,
                              long firstTxId,
                              long lastTxId,
                              boolean isInProgress)
                       throws org.apache.hadoop.hdfs.server.namenode.EditLogFileInputStream.LogHeaderCorruptException,
                              IOException
Open an EditLogInputStream for the given file.

Parameters:
name - filename to open
firstTxId - first transaction found in file
lastTxId - last transaction id found in file
Throws:
LogHeaderCorruptException - if the header is either missing or appears to be corrupt/truncated
IOException - if an actual IO error occurs while reading the header
org.apache.hadoop.hdfs.server.namenode.EditLogFileInputStream.LogHeaderCorruptException
Method Detail

getFirstTxId

public long getFirstTxId()
                  throws IOException
Specified by:
getFirstTxId in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Returns:
the first transaction which will be found in this stream
Throws:
IOException

getLastTxId

public long getLastTxId()
                 throws IOException
Specified by:
getLastTxId in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Returns:
the last transaction which will be found in this stream
Throws:
IOException

getName

public String getName()
Specified by:
getName in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Returns:
the name of the EditLogInputStream

nextOp

protected org.apache.hadoop.hdfs.server.namenode.FSEditLogOp nextOp()
                                                             throws IOException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Get the next operation from the stream storage.

Specified by:
nextOp in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Returns:
an operation from the stream or null if at end of stream
Throws:
IOException - if there is an error reading from the stream

nextValidOp

protected org.apache.hadoop.hdfs.server.namenode.FSEditLogOp nextValidOp()
Description copied from class: org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Get the next valid operation from the stream storage. This is exactly like nextOp, except that we attempt to skip over damaged parts of the edit log

Overrides:
nextValidOp in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Returns:
an operation from the stream or null if at end of stream

getVersion

public int getVersion()
               throws IOException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Get the layout version of the data in the stream.

Specified by:
getVersion in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Returns:
the layout version of the ops in the stream.
Throws:
IOException - if there is an error reading the version

getPosition

public long getPosition()
Description copied from class: org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Get the "position" of in the stream. This is useful for debugging and operational purposes. Different stream types can have a different meaning for what the position is. For file streams it means the byte offset from the start of the file.

Specified by:
getPosition in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Returns:
the position in the stream

close

public void close()
           throws IOException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Close the stream.

Specified by:
close in interface Closeable
Specified by:
close in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Throws:
IOException - if an error occurred while closing

length

public long length()
            throws IOException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Return the size of the current edits log.

Specified by:
length in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Throws:
IOException

isInProgress

public boolean isInProgress()
Description copied from class: org.apache.hadoop.hdfs.server.namenode.EditLogInputStream
Return true if this stream is in progress, false if it is finalized.

Specified by:
isInProgress in class org.apache.hadoop.hdfs.server.namenode.EditLogInputStream

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012 Apache Software Foundation. All Rights Reserved.