From a87927acdcc022297fa2ac110f5b29fe8bcad2ea Mon Sep 17 00:00:00 2001 From: jxiang Date: Thu, 27 Mar 2014 00:34:43 +0000 Subject: [PATCH] HBASE-10839 NullPointerException in construction of RegionServer in Security Cluster git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1582140 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/hadoop/hbase/master/HMaster.java | 13 +++++++++++++ .../hadoop/hbase/regionserver/HRegionServer.java | 11 ++++++++--- .../hadoop/hbase/regionserver/RSRpcServices.java | 5 ++++- 3 files changed, 25 insertions(+), 4 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 c7be93aa867..46d4223cbcf 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 @@ -97,6 +97,7 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.RSRpcServices; import org.apache.hadoop.hbase.regionserver.RegionSplitPolicy; import org.apache.hadoop.hbase.replication.regionserver.Replication; +import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.CompressionTest; import org.apache.hadoop.hbase.util.FSUtils; @@ -272,6 +273,18 @@ public class HMaster extends HRegionServer implements MasterServices, Server { startActiveMasterManager(); } + /** + * For compatibility, if failed with regionserver credentials, try the master one + */ + protected void login(UserProvider user, String host) throws IOException { + try { + super.login(user, host); + } catch (IOException ie) { + user.login("hbase.master.keytab.file", + "hbase.master.kerberos.principal", host); + } + } + @VisibleForTesting public MasterRpcServices getMasterRpcServices() { return (MasterRpcServices)rpcServices; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index b7d7c5dd995..329d50b73d8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -437,10 +437,9 @@ public class HRegionServer extends HasThread implements // login the zookeeper client principal (if using security) ZKUtil.loginClient(this.conf, "hbase.zookeeper.client.keytab.file", "hbase.zookeeper.client.kerberos.principal", hostName); - // login the server principal (if using secure Hadoop) - userProvider.login("hbase.regionserver.keytab.file", - "hbase.regionserver.kerberos.principal", hostName); + login(userProvider, hostName); + regionServerAccounting = new RegionServerAccounting(); cacheConfig = new CacheConfig(conf); uncaughtExceptionHandler = new UncaughtExceptionHandler() { @@ -484,9 +483,15 @@ public class HRegionServer extends HasThread implements catalogTracker.start(); } + rpcServices.start(); putUpWebUI(); } + protected void login(UserProvider user, String host) throws IOException { + user.login("hbase.regionserver.keytab.file", + "hbase.regionserver.kerberos.principal", host); + } + protected String getProcessName() { return REGIONSERVER; } 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 54563d54283..faf9561248a 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 @@ -703,7 +703,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler, initialIsa, // BindAddress is IP we got for this server. rs.conf, rpcSchedulerFactory.create(rs.conf, this)); - rpcServer.start(); scannerLeaseTimeoutPeriod = rs.conf.getInt( HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, @@ -759,6 +758,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler, return priority; } + void start() { + rpcServer.start(); + } + void stop() { closeAllScanners(); rpcServer.stop();