diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 34776d5fba7..7834f254140 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -2306,16 +2306,14 @@ public class HMaster extends HRegionServer implements MasterServices, Server { Constructor 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); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index 65cedeeae03..70ac7a68355 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -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); - rpcServer = new RpcServer(rs, name, getServices(), - bindAddress, // use final bindAddress for this server. - rs.conf, - rpcSchedulerFactory.create(rs.conf, this, rs)); + 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,