HBASE-16244 LocalHBaseCluster start timeout should be configurable (Siddharth Wagle)

This commit is contained in:
Enis Soztutar 2016-07-19 14:12:47 -07:00
parent 82ddc931fb
commit d86f8a4943
2 changed files with 9 additions and 2 deletions

View File

@ -217,6 +217,8 @@ public class HMasterCommandLine extends ServerCommandLine {
// Run a subclass that does the zk cluster shutdown on its way out. // Run a subclass that does the zk cluster shutdown on its way out.
int mastersCount = conf.getInt("hbase.masters", 1); int mastersCount = conf.getInt("hbase.masters", 1);
int regionServersCount = conf.getInt("hbase.regionservers", 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 + LOG.info("Starting up instance of localHBaseCluster; master=" + mastersCount +
", regionserversCount=" + regionServersCount); ", regionserversCount=" + regionServersCount);
LocalHBaseCluster cluster = new LocalHBaseCluster(conf, mastersCount, regionServersCount, LocalHBaseCluster cluster = new LocalHBaseCluster(conf, mastersCount, regionServersCount,

View File

@ -172,11 +172,14 @@ public class JVMClusterUtil {
public static String startup(final List<JVMClusterUtil.MasterThread> masters, public static String startup(final List<JVMClusterUtil.MasterThread> masters,
final List<JVMClusterUtil.RegionServerThread> regionservers) throws IOException { final List<JVMClusterUtil.RegionServerThread> regionservers) throws IOException {
Configuration configuration = null;
if (masters == null || masters.isEmpty()) { if (masters == null || masters.isEmpty()) {
return null; return null;
} }
for (JVMClusterUtil.MasterThread t : masters) { for (JVMClusterUtil.MasterThread t : masters) {
configuration = t.getMaster().getConfiguration();
t.start(); t.start();
} }
@ -190,8 +193,10 @@ public class JVMClusterUtil {
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw (InterruptedIOException)new InterruptedIOException().initCause(e); throw (InterruptedIOException)new InterruptedIOException().initCause(e);
} }
if (System.currentTimeMillis() > startTime + 30000) { int startTimeout = configuration != null ? Integer.parseInt(
throw new RuntimeException("Master not active after 30 seconds"); 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));
} }
} }