HBASE-14078 improve error message when HMaster can't bind to port

This commit is contained in:
stack 2015-08-26 09:17:33 -07:00
parent dc79b3c5c9
commit ff86749cae
2 changed files with 20 additions and 14 deletions

View File

@ -2306,16 +2306,14 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
Constructor<? extends HMaster> c =
masterClass.getConstructor(Configuration.class, CoordinatedStateManager.class);
return c.newInstance(conf, cp);
} catch (InvocationTargetException ite) {
Throwable target = ite.getTargetException() != null?
ite.getTargetException(): ite;
if (target.getCause() != null) target = target.getCause();
throw new RuntimeException("Failed construction of Master: " +
masterClass.toString(), target);
} catch (Exception e) {
throw new RuntimeException("Failed construction of Master: " +
masterClass.toString() + ((e.getCause() != null)?
e.getCause().getMessage(): ""), e);
} catch(Exception e) {
Throwable error = e;
if (e instanceof InvocationTargetException &&
((InvocationTargetException)e).getTargetException() != null) {
error = ((InvocationTargetException)e).getTargetException();
}
throw new RuntimeException("Failed construction of Master: " + masterClass.toString() + ". "
, error);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
@ -946,10 +947,17 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
String name = rs.getProcessName() + "/" + initialIsa.toString();
// Set how many times to retry talking to another server over HConnection.
ConnectionUtils.setServerSideHConnectionRetriesConfig(rs.conf, name, LOG);
try {
rpcServer = new RpcServer(rs, name, getServices(),
bindAddress, // use final bindAddress for this server.
rs.conf,
rpcSchedulerFactory.create(rs.conf, this, rs));
} catch(BindException be) {
String configName = (this instanceof MasterRpcServices) ? HConstants.MASTER_PORT :
HConstants.REGIONSERVER_PORT;
throw new IOException(be.getMessage() + ". To switch ports use the '" + configName +
"' configuration property.", be.getCause() != null ? be.getCause() : be);
}
scannerLeaseTimeoutPeriod = rs.conf.getInt(
HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD,