From 5848403b46fe916f939028f7c791ffff102a7019 Mon Sep 17 00:00:00 2001 From: Matt Warhaftig Date: Mon, 20 Jul 2015 22:41:29 -0400 Subject: [PATCH] HBASE-14708 Simplify HMaster exception logic and add port config info. --- .../java/org/apache/hadoop/hbase/master/HMaster.java | 18 ++++++++---------- .../hadoop/hbase/regionserver/RSRpcServices.java | 15 +++++++++++---- 2 files changed, 19 insertions(+), 14 deletions(-) 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 f7d839b..e688682 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 @@ -2287,16 +2287,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 7c29b3c..93c7824 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 @@ -942,10 +942,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(IOException ioe){ + String configName = (this instanceof MasterRpcServices) ? HConstants.MASTER_PORT : + HConstants.REGIONSERVER_PORT; + throw new IOException(ioe.getMessage() + ". To switch ports use the '" + configName + + "' configuration property.", ioe.getCause() != null ? ioe.getCause() : ioe); + } scannerLeaseTimeoutPeriod = rs.conf.getInt( HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, -- 2.3.2 (Apple Git-55)