From d86f8a4943ae3ddca606bd6b3838c8b5f508bda4 Mon Sep 17 00:00:00 2001 From: Enis Soztutar Date: Tue, 19 Jul 2016 14:12:47 -0700 Subject: [PATCH] HBASE-16244 LocalHBaseCluster start timeout should be configurable (Siddharth Wagle) --- .../apache/hadoop/hbase/master/HMasterCommandLine.java | 2 ++ .../org/apache/hadoop/hbase/util/JVMClusterUtil.java | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java index d2957c7d2d1..cc5ca0b052f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMasterCommandLine.java @@ -217,6 +217,8 @@ public class HMasterCommandLine extends ServerCommandLine { // Run a subclass that does the zk cluster shutdown on its way out. int mastersCount = conf.getInt("hbase.masters", 1); int regionServersCount = conf.getInt("hbase.regionservers", 1); + // Set start timeout to 5 minutes for cmd line start operations + conf.setIfUnset("hbase.master.start.timeout.localHBaseCluster", "300000"); LOG.info("Starting up instance of localHBaseCluster; master=" + mastersCount + ", regionserversCount=" + regionServersCount); LocalHBaseCluster cluster = new LocalHBaseCluster(conf, mastersCount, regionServersCount, diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java index 4db20f21b72..25ed63cc195 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java @@ -172,11 +172,14 @@ public class JVMClusterUtil { public static String startup(final List masters, final List regionservers) throws IOException { + Configuration configuration = null; + if (masters == null || masters.isEmpty()) { return null; } for (JVMClusterUtil.MasterThread t : masters) { + configuration = t.getMaster().getConfiguration(); t.start(); } @@ -190,8 +193,10 @@ public class JVMClusterUtil { } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException().initCause(e); } - if (System.currentTimeMillis() > startTime + 30000) { - throw new RuntimeException("Master not active after 30 seconds"); + int startTimeout = configuration != null ? Integer.parseInt( + configuration.get("hbase.master.start.timeout.localHBaseCluster", "30000")) : 30000; + if (System.currentTimeMillis() > startTime + startTimeout) { + throw new RuntimeException(String.format("Master not active after %s seconds", startTimeout)); } }