Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CoprocessorConfigurationUtil;
import org.apache.hadoop.hbase.util.DNS;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSTableDescriptors;
import org.apache.hadoop.hbase.util.HBaseFsck;
Expand Down Expand Up @@ -571,6 +572,11 @@ protected String getUseThisHostnameInstead(Configuration conf) {
return conf.get(MASTER_HOSTNAME_KEY);
}

@Override
protected DNS.ServerType getDNSServerType() {
return DNS.ServerType.MASTER;
}

private void registerConfigurationObservers() {
configurationManager.registerObserver(this.rpcServices);
configurationManager.registerObserver(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.CompressionTest;
import org.apache.hadoop.hbase.util.CoprocessorConfigurationUtil;
import org.apache.hadoop.hbase.util.DNS;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.FSTableDescriptors;
import org.apache.hadoop.hbase.util.FSUtils;
Expand Down Expand Up @@ -667,28 +668,23 @@ public HRegionServer(final Configuration conf) throws IOException {
this.stopped = false;

this.namedQueueRecorder = NamedQueueRecorder.getInstance(this.conf);
rpcServices = createRpcServices();
useThisHostnameInstead = getUseThisHostnameInstead(conf);

// if use-ip is enabled, we will use ip to expose Master/RS service for client,
// see HBASE-27304 for details.
boolean useIp = conf.getBoolean(HConstants.HBASE_SERVER_USEIP_ENABLED_KEY,
HConstants.HBASE_SERVER_USEIP_ENABLED_DEFAULT);
String isaHostName =
useIp ? rpcServices.isa.getAddress().getHostAddress() : rpcServices.isa.getHostName();
String hostName =
StringUtils.isBlank(useThisHostnameInstead) ? isaHostName : useThisHostnameInstead;
serverName = ServerName.valueOf(hostName, this.rpcServices.isa.getPort(), this.startcode);

rpcControllerFactory = RpcControllerFactory.instantiate(this.conf);
rpcRetryingCallerFactory = RpcRetryingCallerFactory.instantiate(this.conf,
clusterConnection == null ? null : clusterConnection.getConnectionMetrics());

// Resolve the hostname up-front and log in before creating the RpcServer. The RpcServer
// constructor reads UserGroupInformation.getCurrentUser() (HBASE-28321); if the server
// has not logged in yet, UGI bootstraps from the ticket cache and spawns a TGT renewer
// for whichever principal happens to be there.
String hostName = resolveHostName(conf, useThisHostnameInstead);
// login the zookeeper client principal (if using security)
ZKAuthentication.loginClient(this.conf, HConstants.ZK_CLIENT_KEYTAB_FILE,
HConstants.ZK_CLIENT_KERBEROS_PRINCIPAL, hostName);
// login the server principal (if using secure Hadoop)
login(userProvider, hostName);
rpcServices = createRpcServices();
serverName = ServerName.valueOf(hostName, this.rpcServices.isa.getPort(), this.startcode);

rpcControllerFactory = RpcControllerFactory.instantiate(this.conf);
rpcRetryingCallerFactory = RpcRetryingCallerFactory.instantiate(this.conf,
clusterConnection == null ? null : clusterConnection.getConnectionMetrics());
// init superusers and add the server principal (if using security)
// or process owner as default super user.
Superusers.initialize(conf);
Expand Down Expand Up @@ -772,7 +768,7 @@ protected String getUseThisHostnameInstead(Configuration conf) throws IOExceptio
+ UNSAFE_RS_HOSTNAME_KEY + " is used";
throw new IOException(msg);
} else {
return rpcServices.isa.getHostName();
return DNS.getHostname(conf, DNS.ServerType.REGIONSERVER);
}
} else {
return hostname;
Expand Down Expand Up @@ -827,6 +823,23 @@ private void initializeFileSystem() throws IOException {
!canUpdateTableDescriptor(), cacheTableDescriptor());
}

protected DNS.ServerType getDNSServerType() {
return DNS.ServerType.REGIONSERVER;
}

private String resolveHostName(Configuration conf, String useThisHostnameInstead)
throws IOException {
if (!StringUtils.isBlank(useThisHostnameInstead)) {
return useThisHostnameInstead;
}
// if use-ip is enabled, we will use ip to expose Master/RS service for client,
// see HBASE-27304 for details.
boolean useIp = conf.getBoolean(HConstants.HBASE_SERVER_USEIP_ENABLED_KEY,
HConstants.HBASE_SERVER_USEIP_ENABLED_DEFAULT);
InetAddress addr = InetAddress.getByName(DNS.getHostname(conf, getDNSServerType()));
return useIp ? addr.getHostAddress() : addr.getHostName();
}

protected void login(UserProvider user, String host) throws IOException {
user.login(SecurityConstants.REGIONSERVER_KRB_KEYTAB_FILE,
SecurityConstants.REGIONSERVER_KRB_PRINCIPAL, host);
Expand Down
Loading