org.apache.hadoop.contrib.bkjournal
Class BookKeeperJournalManager

java.lang.Object
  extended by org.apache.hadoop.contrib.bkjournal.BookKeeperJournalManager
All Implemented Interfaces:
Closeable, org.apache.hadoop.hdfs.server.common.Storage.FormatConfirmable, org.apache.hadoop.hdfs.server.namenode.JournalManager

public class BookKeeperJournalManager
extends Object
implements org.apache.hadoop.hdfs.server.namenode.JournalManager

BookKeeper Journal Manager To use, add the following to hdfs-site.xml.

 <property>
   <name>dfs.namenode.edits.dir</name>
   <value>bookkeeper://zk1:2181;zk2:2181;zk3:2181/hdfsjournal</value>
 </property>

 <property>
   <name>dfs.namenode.edits.journal-plugin.bookkeeper</name>
   <value>org.apache.hadoop.contrib.bkjournal.BookKeeperJournalManager</value>
 </property>
 
 
The URI format for bookkeeper is bookkeeper://[zkEnsemble]/[rootZnode] [zookkeeper ensemble] is a list of semi-colon separated, zookeeper host:port pairs. In the example above there are 3 servers, in the ensemble, zk1, zk2 & zk3, each one listening on port 2181. [root znode] is the path of the zookeeper znode, under which the editlog information will be stored. Other configuration options are:


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hdfs.server.namenode.JournalManager
org.apache.hadoop.hdfs.server.namenode.JournalManager.CorruptionException
 
Field Summary
static String BKJM_BOOKKEEPER_DIGEST_PW
           
static String BKJM_BOOKKEEPER_DIGEST_PW_DEFAULT
           
static String BKJM_BOOKKEEPER_ENSEMBLE_SIZE
           
static int BKJM_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT
           
static String BKJM_BOOKKEEPER_QUORUM_SIZE
           
static int BKJM_BOOKKEEPER_QUORUM_SIZE_DEFAULT
           
static String BKJM_OUTPUT_BUFFER_SIZE
           
static int BKJM_OUTPUT_BUFFER_SIZE_DEFAULT
           
static String BKJM_ZK_LEDGERS_AVAILABLE_PATH
           
static String BKJM_ZK_LEDGERS_AVAILABLE_PATH_DEFAULT
           
static String BKJM_ZK_SESSION_TIMEOUT
           
static int BKJM_ZK_SESSION_TIMEOUT_DEFAULT
           
 
Constructor Summary
BookKeeperJournalManager(org.apache.hadoop.conf.Configuration conf, URI uri, org.apache.hadoop.hdfs.server.protocol.NamespaceInfo nsInfo)
          Construct a Bookkeeper journal manager.
 
Method Summary
 void close()
           
 void finalizeLogSegment(long firstTxId, long lastTxId)
          Finalize a log segment.
 void format(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo ns)
           
 boolean hasSomeData()
           
 void purgeLogsOlderThan(long minTxIdToKeep)
           
 void recoverUnfinalizedSegments()
           
 void selectInputStreams(Collection<org.apache.hadoop.hdfs.server.namenode.EditLogInputStream> streams, long fromTxId, boolean inProgressOk)
           
 void setOutputBufferCapacity(int size)
          Set the amount of memory that this stream should use to buffer edits.
 org.apache.hadoop.hdfs.server.namenode.EditLogOutputStream startLogSegment(long txId)
          Start a new log segment in a BookKeeper ledger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hdfs.server.common.Storage.FormatConfirmable
toString
 

Field Detail

BKJM_OUTPUT_BUFFER_SIZE

public static final String BKJM_OUTPUT_BUFFER_SIZE
See Also:
Constant Field Values

BKJM_OUTPUT_BUFFER_SIZE_DEFAULT

public static final int BKJM_OUTPUT_BUFFER_SIZE_DEFAULT
See Also:
Constant Field Values

BKJM_BOOKKEEPER_ENSEMBLE_SIZE

public static final String BKJM_BOOKKEEPER_ENSEMBLE_SIZE
See Also:
Constant Field Values

BKJM_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT

public static final int BKJM_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT
See Also:
Constant Field Values

BKJM_BOOKKEEPER_QUORUM_SIZE

public static final String BKJM_BOOKKEEPER_QUORUM_SIZE
See Also:
Constant Field Values

BKJM_BOOKKEEPER_QUORUM_SIZE_DEFAULT

public static final int BKJM_BOOKKEEPER_QUORUM_SIZE_DEFAULT
See Also:
Constant Field Values

BKJM_BOOKKEEPER_DIGEST_PW

public static final String BKJM_BOOKKEEPER_DIGEST_PW
See Also:
Constant Field Values

BKJM_BOOKKEEPER_DIGEST_PW_DEFAULT

public static final String BKJM_BOOKKEEPER_DIGEST_PW_DEFAULT
See Also:
Constant Field Values

BKJM_ZK_SESSION_TIMEOUT

public static final String BKJM_ZK_SESSION_TIMEOUT
See Also:
Constant Field Values

BKJM_ZK_SESSION_TIMEOUT_DEFAULT

public static final int BKJM_ZK_SESSION_TIMEOUT_DEFAULT
See Also:
Constant Field Values

BKJM_ZK_LEDGERS_AVAILABLE_PATH

public static final String BKJM_ZK_LEDGERS_AVAILABLE_PATH
See Also:
Constant Field Values

BKJM_ZK_LEDGERS_AVAILABLE_PATH_DEFAULT

public static final String BKJM_ZK_LEDGERS_AVAILABLE_PATH_DEFAULT
See Also:
Constant Field Values
Constructor Detail

BookKeeperJournalManager

public BookKeeperJournalManager(org.apache.hadoop.conf.Configuration conf,
                                URI uri,
                                org.apache.hadoop.hdfs.server.protocol.NamespaceInfo nsInfo)
                         throws IOException
Construct a Bookkeeper journal manager.

Throws:
IOException
Method Detail

format

public void format(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo ns)
            throws IOException
Specified by:
format in interface org.apache.hadoop.hdfs.server.namenode.JournalManager
Throws:
IOException

hasSomeData

public boolean hasSomeData()
                    throws IOException
Specified by:
hasSomeData in interface org.apache.hadoop.hdfs.server.common.Storage.FormatConfirmable
Throws:
IOException

startLogSegment

public org.apache.hadoop.hdfs.server.namenode.EditLogOutputStream startLogSegment(long txId)
                                                                           throws IOException
Start a new log segment in a BookKeeper ledger. First ensure that we have the write lock for this journal. Then create a ledger and stream based on that ledger. The ledger id is written to the inprogress znode, so that in the case of a crash, a recovery process can find the ledger we were writing to when we crashed.

Specified by:
startLogSegment in interface org.apache.hadoop.hdfs.server.namenode.JournalManager
Parameters:
txId - First transaction id to be written to the stream
Throws:
IOException

finalizeLogSegment

public void finalizeLogSegment(long firstTxId,
                               long lastTxId)
                        throws IOException
Finalize a log segment. If the journal manager is currently writing to a ledger, ensure that this is the ledger of the log segment being finalized. Otherwise this is the recovery case. In the recovery case, ensure that the firstTxId of the ledger matches firstTxId for the segment we are trying to finalize.

Specified by:
finalizeLogSegment in interface org.apache.hadoop.hdfs.server.namenode.JournalManager
Throws:
IOException

selectInputStreams

public void selectInputStreams(Collection<org.apache.hadoop.hdfs.server.namenode.EditLogInputStream> streams,
                               long fromTxId,
                               boolean inProgressOk)
                        throws IOException
Throws:
IOException

recoverUnfinalizedSegments

public void recoverUnfinalizedSegments()
                                throws IOException
Specified by:
recoverUnfinalizedSegments in interface org.apache.hadoop.hdfs.server.namenode.JournalManager
Throws:
IOException

purgeLogsOlderThan

public void purgeLogsOlderThan(long minTxIdToKeep)
                        throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in interface org.apache.hadoop.hdfs.server.namenode.JournalManager
Throws:
IOException

setOutputBufferCapacity

public void setOutputBufferCapacity(int size)
Set the amount of memory that this stream should use to buffer edits. Setting this will only affect future output stream. Streams which have currently be created won't be affected.

Specified by:
setOutputBufferCapacity in interface org.apache.hadoop.hdfs.server.namenode.JournalManager


Copyright © 2014 Apache Software Foundation. All Rights Reserved.