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