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 638ca24f01
commit 5051ab4e70
2 changed files with 9 additions and 2 deletions

View File

@ -219,6 +219,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,

View File

@ -172,11 +172,14 @@ public class JVMClusterUtil {
public static String startup(final List<JVMClusterUtil.MasterThread> masters,
final List<JVMClusterUtil.RegionServerThread> 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));
}
}