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

java.lang.Object
  extended by org.apache.hadoop.hdfs.server.namenode.FSEditLog

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class FSEditLog
extends Object

FSEditLog maintains a log of the namespace modifications.


Field Summary
static byte OP_INVALID
           
 
Method Summary
 Iterator<org.apache.hadoop.hdfs.server.namenode.EditLogOutputStream> getOutputStreamIterator(JournalStream.JournalType streamType)
          Get stream iterator for the specified type.
 void logCloseFile(String path, org.apache.hadoop.hdfs.server.namenode.INodeFile newNode)
          Add close lease record to edit log.
 void logMkDir(String path, org.apache.hadoop.hdfs.server.namenode.INode newNode)
          Add create directory record to edit log
 void logOpenFile(String path, org.apache.hadoop.hdfs.server.namenode.INodeFileUnderConstruction newNode)
          Add open lease record to edit log.
 void logSync()
          Sync all modifications done by this thread.
 void setBufferCapacity(int size)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OP_INVALID

public static final byte OP_INVALID
See Also:
Constant Field Values
Method Detail

logSync

public void logSync()
             throws IOException
Sync all modifications done by this thread. The internal concurrency design of this class is as follows: - Log items are written synchronized into an in-memory buffer, and each assigned a transaction ID. - When a thread (client) would like to sync all of its edits, logSync() uses a ThreadLocal transaction ID to determine what edit number must be synced to. - The isSyncRunning volatile boolean tracks whether a sync is currently under progress. The data is double-buffered within each edit log implementation so that in-memory writing can occur in parallel with the on-disk writing. Each sync occurs in three steps: 1. synchronized, it swaps the double buffer and sets the isSyncRunning flag. 2. unsynchronized, it flushes the data to storage 3. synchronized, it resets the flag and notifies anyone waiting on the sync. The lack of synchronization on step 2 allows other threads to continue to write into the memory buffer while the sync is in progress. Because this step is unsynchronized, actions that need to avoid concurrency with sync() should be synchronized and also call waitForSyncToFinish() before assuming they are running alone.

Throws:
IOException

logOpenFile

public void logOpenFile(String path,
                        org.apache.hadoop.hdfs.server.namenode.INodeFileUnderConstruction newNode)
Add open lease record to edit log. Records the block locations of the last block.


logCloseFile

public void logCloseFile(String path,
                         org.apache.hadoop.hdfs.server.namenode.INodeFile newNode)
Add close lease record to edit log.


logMkDir

public void logMkDir(String path,
                     org.apache.hadoop.hdfs.server.namenode.INode newNode)
Add create directory record to edit log


setBufferCapacity

public void setBufferCapacity(int size)

getOutputStreamIterator

public Iterator<org.apache.hadoop.hdfs.server.namenode.EditLogOutputStream> getOutputStreamIterator(JournalStream.JournalType streamType)
Get stream iterator for the specified type.



Copyright © 2009 The Apache Software Foundation