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
This commit is contained in:
jxiang 2014-03-27 00:34:43 +00:00
parent 25932c793d
commit a87927acdc
3 changed files with 25 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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();