HDFS-3468. Make BKJM-ZK session timeout configurable. Contributed by Uma Maheswara Rao G.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1344423 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uma Maheswara Rao G 2012-05-30 19:17:35 +00:00
parent 83cf475050
commit ed7b0622fe

View File

@ -91,6 +91,10 @@
* Default is 2.</li> * Default is 2.</li>
* <li><b>dfs.namenode.bookkeeperjournal.digestPw</b> * <li><b>dfs.namenode.bookkeeperjournal.digestPw</b>
* Password to use when creating ledgers. </li> * Password to use when creating ledgers. </li>
* <li><b>dfs.namenode.bookkeeperjournal.zk.session.timeout</b>
* Session timeout for Zookeeper client from BookKeeper Journal Manager.
* Hadoop recommends that, this value should be less than the ZKFC
* session timeout value. Default value is 3000.</li>
* </ul> * </ul>
*/ */
public class BookKeeperJournalManager implements JournalManager { public class BookKeeperJournalManager implements JournalManager {
@ -114,6 +118,10 @@ public class BookKeeperJournalManager implements JournalManager {
private static final int BKJM_LAYOUT_VERSION = -1; private static final int BKJM_LAYOUT_VERSION = -1;
public static final String BKJM_ZK_SESSION_TIMEOUT
= "dfs.namenode.bookkeeperjournal.zk.session.timeout";
public static final int BKJM_ZK_SESSION_TIMEOUT_DEFAULT = 3000;
private final ZooKeeper zkc; private final ZooKeeper zkc;
private final Configuration conf; private final Configuration conf;
private final BookKeeper bkc; private final BookKeeper bkc;
@ -162,7 +170,8 @@ public BookKeeperJournalManager(Configuration conf, URI uri)
try { try {
zkConnectLatch = new CountDownLatch(1); zkConnectLatch = new CountDownLatch(1);
zkc = new ZooKeeper(zkConnect, 3000, new ZkConnectionWatcher()); zkc = new ZooKeeper(zkConnect, conf.getInt(BKJM_ZK_SESSION_TIMEOUT,
BKJM_ZK_SESSION_TIMEOUT_DEFAULT), new ZkConnectionWatcher());
if (!zkConnectLatch.await(6000, TimeUnit.MILLISECONDS)) { if (!zkConnectLatch.await(6000, TimeUnit.MILLISECONDS)) {
throw new IOException("Error connecting to zookeeper"); throw new IOException("Error connecting to zookeeper");
} }