HBASE-13481 Master should respect master (old) DNS/bind related configurations
This commit is contained in:
parent
abe3796a99
commit
66e55ff388
|
@ -408,7 +408,9 @@ public class HRegionServer extends HasThread implements
|
||||||
// key to the config parameter of server hostname
|
// key to the config parameter of server hostname
|
||||||
// the specification of server hostname is optional. The hostname should be resolvable from
|
// the specification of server hostname is optional. The hostname should be resolvable from
|
||||||
// both master and region server
|
// both master and region server
|
||||||
final static String HOSTNAME_KEY = "hbase.regionserver.hostname";
|
final static String RS_HOSTNAME_KEY = "hbase.regionserver.hostname";
|
||||||
|
|
||||||
|
final static String MASTER_HOSTNAME_KEY = "hbase.master.hostname";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This servers startcode.
|
* This servers startcode.
|
||||||
|
@ -528,7 +530,11 @@ public class HRegionServer extends HasThread implements
|
||||||
|
|
||||||
rpcServices = createRpcServices();
|
rpcServices = createRpcServices();
|
||||||
this.startcode = System.currentTimeMillis();
|
this.startcode = System.currentTimeMillis();
|
||||||
useThisHostnameInstead = conf.get(HOSTNAME_KEY);
|
if (this instanceof HMaster) {
|
||||||
|
useThisHostnameInstead = conf.get(MASTER_HOSTNAME_KEY);
|
||||||
|
} else {
|
||||||
|
useThisHostnameInstead = conf.get(RS_HOSTNAME_KEY);
|
||||||
|
}
|
||||||
String hostName = shouldUseThisHostnameInstead() ? useThisHostnameInstead :
|
String hostName = shouldUseThisHostnameInstead() ? useThisHostnameInstead :
|
||||||
rpcServices.isa.getHostName();
|
rpcServices.isa.getHostName();
|
||||||
serverName = ServerName.valueOf(hostName, rpcServices.isa.getPort(), startcode);
|
serverName = ServerName.valueOf(hostName, rpcServices.isa.getPort(), startcode);
|
||||||
|
@ -1734,13 +1740,16 @@ public class HRegionServer extends HasThread implements
|
||||||
private int putUpWebUI() throws IOException {
|
private int putUpWebUI() throws IOException {
|
||||||
int port = this.conf.getInt(HConstants.REGIONSERVER_INFO_PORT,
|
int port = this.conf.getInt(HConstants.REGIONSERVER_INFO_PORT,
|
||||||
HConstants.DEFAULT_REGIONSERVER_INFOPORT);
|
HConstants.DEFAULT_REGIONSERVER_INFOPORT);
|
||||||
|
String addr = this.conf.get("hbase.regionserver.info.bindAddress", "0.0.0.0");
|
||||||
|
|
||||||
if(this instanceof HMaster) {
|
if(this instanceof HMaster) {
|
||||||
port = conf.getInt(HConstants.MASTER_INFO_PORT,
|
port = conf.getInt(HConstants.MASTER_INFO_PORT,
|
||||||
HConstants.DEFAULT_MASTER_INFOPORT);
|
HConstants.DEFAULT_MASTER_INFOPORT);
|
||||||
|
addr = this.conf.get("hbase.master.info.bindAddress", "0.0.0.0");
|
||||||
}
|
}
|
||||||
// -1 is for disabling info server
|
// -1 is for disabling info server
|
||||||
if (port < 0) return port;
|
if (port < 0) return port;
|
||||||
String addr = this.conf.get("hbase.regionserver.info.bindAddress", "0.0.0.0");
|
|
||||||
if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
|
if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
|
||||||
String msg =
|
String msg =
|
||||||
"Failed to start http info server. Address " + addr
|
"Failed to start http info server. Address " + addr
|
||||||
|
|
|
@ -822,17 +822,23 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
// Server to handle client requests.
|
// Server to handle client requests.
|
||||||
String hostname = getHostname(rs.conf);
|
InetSocketAddress initialIsa;
|
||||||
int port = rs.conf.getInt(HConstants.REGIONSERVER_PORT,
|
InetSocketAddress bindAddress;
|
||||||
HConstants.DEFAULT_REGIONSERVER_PORT);
|
|
||||||
if(this instanceof MasterRpcServices) {
|
if(this instanceof MasterRpcServices) {
|
||||||
port = rs.conf.getInt(HConstants.MASTER_PORT,
|
String hostname = getHostname(rs.conf, true);
|
||||||
HConstants.DEFAULT_MASTER_PORT);
|
int port = rs.conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT);
|
||||||
|
// Creation of a HSA will force a resolve.
|
||||||
|
initialIsa = new InetSocketAddress(hostname, port);
|
||||||
|
bindAddress = new InetSocketAddress(rs.conf.get("hbase.master.ipc.address", hostname), port);
|
||||||
|
} else {
|
||||||
|
String hostname = getHostname(rs.conf, false);
|
||||||
|
int port = rs.conf.getInt(HConstants.REGIONSERVER_PORT,
|
||||||
|
HConstants.DEFAULT_REGIONSERVER_PORT);
|
||||||
|
// Creation of a HSA will force a resolve.
|
||||||
|
initialIsa = new InetSocketAddress(hostname, port);
|
||||||
|
bindAddress = new InetSocketAddress(
|
||||||
|
rs.conf.get("hbase.regionserver.ipc.address", hostname), port);
|
||||||
}
|
}
|
||||||
// Creation of a HSA will force a resolve.
|
|
||||||
InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
|
|
||||||
InetSocketAddress bindAddress = new InetSocketAddress(
|
|
||||||
rs.conf.get("hbase.regionserver.ipc.address", hostname), port);
|
|
||||||
if (initialIsa.getAddress() == null) {
|
if (initialIsa.getAddress() == null) {
|
||||||
throw new IllegalArgumentException("Failed resolve of " + initialIsa);
|
throw new IllegalArgumentException("Failed resolve of " + initialIsa);
|
||||||
}
|
}
|
||||||
|
@ -864,12 +870,15 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||||
rs.setName(name);
|
rs.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHostname(Configuration conf) throws UnknownHostException {
|
public static String getHostname(Configuration conf, boolean isMaster)
|
||||||
String hostname = conf.get(HRegionServer.HOSTNAME_KEY);
|
throws UnknownHostException {
|
||||||
|
String hostname = conf.get(isMaster? HRegionServer.MASTER_HOSTNAME_KEY :
|
||||||
|
HRegionServer.RS_HOSTNAME_KEY);
|
||||||
if (hostname == null || hostname.isEmpty()) {
|
if (hostname == null || hostname.isEmpty()) {
|
||||||
|
String masterOrRS = isMaster ? "master" : "regionserver";
|
||||||
return Strings.domainNamePointerToHostName(DNS.getDefaultHost(
|
return Strings.domainNamePointerToHostName(DNS.getDefaultHost(
|
||||||
conf.get("hbase.regionserver.dns.interface", "default"),
|
conf.get("hbase." + masterOrRS + ".dns.interface", "default"),
|
||||||
conf.get("hbase.regionserver.dns.nameserver", "default")));
|
conf.get("hbase." + masterOrRS + ".dns.nameserver", "default")));
|
||||||
} else {
|
} else {
|
||||||
LOG.info("hostname is configured to be " + hostname);
|
LOG.info("hostname is configured to be " + hostname);
|
||||||
return hostname;
|
return hostname;
|
||||||
|
@ -1493,6 +1502,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @throws ServiceException
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public WarmupRegionResponse warmupRegion(final RpcController controller,
|
public WarmupRegionResponse warmupRegion(final RpcController controller,
|
||||||
final WarmupRegionRequest request) throws ServiceException {
|
final WarmupRegionRequest request) throws ServiceException {
|
||||||
|
|
||||||
|
|
|
@ -277,6 +277,7 @@ public class RatioBasedCompactionPolicy extends CompactionPolicy {
|
||||||
* @param filesToCompact Files to compact. Can be null.
|
* @param filesToCompact Files to compact. Can be null.
|
||||||
* @return True if we should run a major compaction.
|
* @return True if we should run a major compaction.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isMajorCompaction(final Collection<StoreFile> filesToCompact)
|
public boolean isMajorCompaction(final Collection<StoreFile> filesToCompact)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
@ -300,7 +301,7 @@ public class RatioBasedCompactionPolicy extends CompactionPolicy {
|
||||||
if (sf.isMajorCompaction() &&
|
if (sf.isMajorCompaction() &&
|
||||||
(cfTtl == HConstants.FOREVER || oldest < cfTtl)) {
|
(cfTtl == HConstants.FOREVER || oldest < cfTtl)) {
|
||||||
float blockLocalityIndex = sf.getHDFSBlockDistribution().getBlockLocalityIndex(
|
float blockLocalityIndex = sf.getHDFSBlockDistribution().getBlockLocalityIndex(
|
||||||
RSRpcServices.getHostname(comConf.conf)
|
RSRpcServices.getHostname(comConf.conf, false)
|
||||||
);
|
);
|
||||||
if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
|
if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
|
@ -375,6 +376,7 @@ public class RatioBasedCompactionPolicy extends CompactionPolicy {
|
||||||
* @param compactionSize Total size of some compaction
|
* @param compactionSize Total size of some compaction
|
||||||
* @return whether this should be a large or small compaction
|
* @return whether this should be a large or small compaction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean throttleCompaction(long compactionSize) {
|
public boolean throttleCompaction(long compactionSize) {
|
||||||
return compactionSize > comConf.getThrottlePoint();
|
return compactionSize > comConf.getThrottlePoint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TestRegionServerHostname {
|
||||||
final int NUM_MASTERS = 1;
|
final int NUM_MASTERS = 1;
|
||||||
final int NUM_RS = 1;
|
final int NUM_RS = 1;
|
||||||
String invalidHostname = "hostAddr.invalid";
|
String invalidHostname = "hostAddr.invalid";
|
||||||
TEST_UTIL.getConfiguration().set(HRegionServer.HOSTNAME_KEY, invalidHostname);
|
TEST_UTIL.getConfiguration().set(HRegionServer.RS_HOSTNAME_KEY, invalidHostname);
|
||||||
try {
|
try {
|
||||||
TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
|
TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
@ -88,7 +88,7 @@ public class TestRegionServerHostname {
|
||||||
String hostName = addr.getHostName();
|
String hostName = addr.getHostName();
|
||||||
LOG.info("Found " + hostName + " on " + ni);
|
LOG.info("Found " + hostName + " on " + ni);
|
||||||
|
|
||||||
TEST_UTIL.getConfiguration().set(HRegionServer.HOSTNAME_KEY, hostName);
|
TEST_UTIL.getConfiguration().set(HRegionServer.RS_HOSTNAME_KEY, hostName);
|
||||||
TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
|
TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
|
||||||
try {
|
try {
|
||||||
ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
|
ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
|
||||||
|
|
Loading…
Reference in New Issue