HBASE-23804: Fix default master addr hostname in master registry (#1137)
Master rpc server end point doesn't bind to localhost's IP address by default. Instead, it looks up the hostname and binds to the endpoint to which it resolves. MasterRegistry should do the same when building the default server end point to talk to. Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> (cherry picked from commit c34dbc3c29438b18c6b84aac05ccb5adc038342a)
This commit is contained in:
parent
09ca6bdcd4
commit
5848b7d835
@ -17,11 +17,12 @@
|
||||
*/
|
||||
package org.apache.hadoop.hbase.client;
|
||||
|
||||
import static org.apache.hadoop.hbase.HConstants.MASTER_ADDRS_DEFAULT;
|
||||
import static org.apache.hadoop.hbase.HConstants.MASTER_ADDRS_KEY;
|
||||
import static org.apache.hadoop.hbase.HConstants.MASTER_REGISTRY_ENABLE_HEDGED_READS_DEFAULT;
|
||||
import static org.apache.hadoop.hbase.HConstants.MASTER_REGISTRY_ENABLE_HEDGED_READS_KEY;
|
||||
import static org.apache.hadoop.hbase.util.DNS.getHostname;
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -41,9 +42,11 @@ import org.apache.hadoop.hbase.ipc.RpcClient;
|
||||
import org.apache.hadoop.hbase.ipc.RpcClientFactory;
|
||||
import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
|
||||
import org.apache.hadoop.hbase.security.User;
|
||||
import org.apache.hadoop.hbase.util.DNS.ServerType;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
|
||||
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
|
||||
import org.apache.hbase.thirdparty.com.google.common.base.Strings;
|
||||
import org.apache.hbase.thirdparty.com.google.common.net.HostAndPort;
|
||||
import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback;
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
|
||||
@ -78,7 +81,7 @@ public class MasterRegistry implements ConnectionRegistry {
|
||||
private final RpcControllerFactory rpcControllerFactory;
|
||||
private final int rpcTimeoutMs;
|
||||
|
||||
MasterRegistry(Configuration conf) {
|
||||
MasterRegistry(Configuration conf) throws UnknownHostException {
|
||||
boolean hedgedReadsEnabled = conf.getBoolean(MASTER_REGISTRY_ENABLE_HEDGED_READS_KEY,
|
||||
MASTER_REGISTRY_ENABLE_HEDGED_READS_DEFAULT);
|
||||
Configuration finalConf;
|
||||
@ -90,7 +93,9 @@ public class MasterRegistry implements ConnectionRegistry {
|
||||
} else {
|
||||
finalConf = conf;
|
||||
}
|
||||
finalConf.set(MASTER_ADDRS_KEY, conf.get(MASTER_ADDRS_KEY, MASTER_ADDRS_DEFAULT));
|
||||
if (conf.get(MASTER_ADDRS_KEY) != null) {
|
||||
finalConf.set(MASTER_ADDRS_KEY, conf.get(MASTER_ADDRS_KEY));
|
||||
}
|
||||
rpcTimeoutMs = (int) Math.min(Integer.MAX_VALUE, conf.getLong(HConstants.HBASE_RPC_TIMEOUT_KEY,
|
||||
HConstants.DEFAULT_HBASE_RPC_TIMEOUT));
|
||||
masterServers = new HashSet<>();
|
||||
@ -99,6 +104,19 @@ public class MasterRegistry implements ConnectionRegistry {
|
||||
rpcControllerFactory = RpcControllerFactory.instantiate(finalConf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the default master address end point if it is not specified in the configuration.
|
||||
*/
|
||||
public static String getMasterAddr(Configuration conf) throws UnknownHostException {
|
||||
String masterAddrFromConf = conf.get(MASTER_ADDRS_KEY);
|
||||
if (!Strings.isNullOrEmpty(masterAddrFromConf)) {
|
||||
return masterAddrFromConf;
|
||||
}
|
||||
String hostname = getHostname(conf, ServerType.MASTER);
|
||||
int port = conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT);
|
||||
return String.format("%s:%d", hostname, port);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Stub needed to make RPC using a hedged channel to the master end points.
|
||||
*/
|
||||
@ -113,8 +131,8 @@ public class MasterRegistry implements ConnectionRegistry {
|
||||
* assumed.
|
||||
* @param conf Configuration to parse from.
|
||||
*/
|
||||
private void parseMasterAddrs(Configuration conf) {
|
||||
String configuredMasters = conf.get(MASTER_ADDRS_KEY, MASTER_ADDRS_DEFAULT);
|
||||
private void parseMasterAddrs(Configuration conf) throws UnknownHostException {
|
||||
String configuredMasters = getMasterAddr(conf);
|
||||
for (String masterAddr: configuredMasters.split(MASTER_ADDRS_CONF_SEPARATOR)) {
|
||||
HostAndPort masterHostPort =
|
||||
HostAndPort.fromString(masterAddr.trim()).withDefaultPort(HConstants.DEFAULT_MASTER_PORT);
|
||||
|
@ -186,8 +186,6 @@ public final class HConstants {
|
||||
/** Configuration key for the list of master host:ports **/
|
||||
public static final String MASTER_ADDRS_KEY = "hbase.masters";
|
||||
|
||||
public static final String MASTER_ADDRS_DEFAULT = "localhost:" + DEFAULT_MASTER_PORT;
|
||||
|
||||
/** Full class name of the Zookeeper based connection registry implementation */
|
||||
public static final String ZK_CONNECTION_REGISTRY_CLASS =
|
||||
"org.apache.hadoop.hbase.client.ZKConnectionRegistry";
|
||||
|
@ -16,9 +16,12 @@
|
||||
*/
|
||||
package org.apache.hadoop.hbase.util;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
||||
/**
|
||||
@ -28,6 +31,14 @@ import org.apache.yetus.audience.InterfaceAudience;
|
||||
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION",
|
||||
justification="If exception, presume HAS_NEW_DNS_GET_DEFAULT_HOST_API false")
|
||||
public final class DNS {
|
||||
// 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
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
|
||||
public static final String RS_HOSTNAME_KEY = "hbase.regionserver.hostname";
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
|
||||
public static final String MASTER_HOSTNAME_KEY = "hbase.master.hostname";
|
||||
|
||||
private static boolean HAS_NEW_DNS_GET_DEFAULT_HOST_API;
|
||||
private static Method GET_DEFAULT_HOST_METHOD;
|
||||
|
||||
@ -41,6 +52,20 @@ public final class DNS {
|
||||
}
|
||||
}
|
||||
|
||||
public enum ServerType {
|
||||
MASTER("master"),
|
||||
REGIONSERVER("regionserver");
|
||||
|
||||
private String name;
|
||||
ServerType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
private DNS() {}
|
||||
|
||||
/**
|
||||
@ -66,4 +91,32 @@ public final class DNS {
|
||||
return org.apache.hadoop.net.DNS.getDefaultHost(strInterface, nameserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configured hostname for a given ServerType. Gets the default hostname if not specified
|
||||
* in the configuration.
|
||||
* @param conf Configuration to look up.
|
||||
* @param serverType ServerType to look up in the configuration for overrides.
|
||||
*/
|
||||
public static String getHostname(@NonNull Configuration conf, @NonNull ServerType serverType)
|
||||
throws UnknownHostException {
|
||||
String hostname;
|
||||
switch (serverType) {
|
||||
case MASTER:
|
||||
hostname = conf.get(MASTER_HOSTNAME_KEY);
|
||||
break;
|
||||
case REGIONSERVER:
|
||||
hostname = conf.get(RS_HOSTNAME_KEY);
|
||||
break;
|
||||
default:
|
||||
hostname = null;
|
||||
}
|
||||
if (hostname == null || hostname.isEmpty()) {
|
||||
return Strings.domainNamePointerToHostName(getDefaultHost(
|
||||
conf.get("hbase." + serverType.getName() + ".dns.interface", "default"),
|
||||
conf.get("hbase." + serverType.getName() + ".dns.nameserver", "default")));
|
||||
} else {
|
||||
return hostname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.master;
|
||||
import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK;
|
||||
import static org.apache.hadoop.hbase.HConstants.HBASE_MASTER_LOGCLEANER_PLUGINS;
|
||||
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
|
||||
import static org.apache.hadoop.hbase.util.DNS.MASTER_HOSTNAME_KEY;
|
||||
import com.google.protobuf.Descriptors;
|
||||
import com.google.protobuf.Service;
|
||||
import java.io.IOException;
|
||||
|
@ -21,7 +21,7 @@ import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_COORDINATED
|
||||
import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_WAL_MAX_SPLITTER;
|
||||
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
|
||||
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_MAX_SPLITTER;
|
||||
|
||||
import static org.apache.hadoop.hbase.util.DNS.RS_HOSTNAME_KEY;
|
||||
import java.io.IOException;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.lang.management.MemoryType;
|
||||
@ -56,7 +56,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.Function;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
@ -188,7 +187,6 @@ import org.apache.zookeeper.KeeperException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sun.misc.Signal;
|
||||
|
||||
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
|
||||
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
|
||||
import org.apache.hbase.thirdparty.com.google.common.base.Throwables;
|
||||
@ -200,7 +198,6 @@ import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
|
||||
import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException;
|
||||
import org.apache.hbase.thirdparty.com.google.protobuf.TextFormat;
|
||||
import org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations;
|
||||
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceCall;
|
||||
@ -454,14 +451,6 @@ public class HRegionServer extends HasThread implements
|
||||
*/
|
||||
protected String useThisHostnameInstead;
|
||||
|
||||
// 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
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
|
||||
final static String RS_HOSTNAME_KEY = "hbase.regionserver.hostname";
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
|
||||
protected final static String MASTER_HOSTNAME_KEY = "hbase.master.hostname";
|
||||
|
||||
/**
|
||||
* HBASE-18226: This config and hbase.regionserver.hostname are mutually exclusive.
|
||||
* Exception will be thrown if both are used.
|
||||
|
@ -24,7 +24,6 @@ import java.io.UncheckedIOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.BindException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -137,7 +136,6 @@ import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||
import org.apache.hadoop.hbase.util.Pair;
|
||||
import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil;
|
||||
import org.apache.hadoop.hbase.util.Strings;
|
||||
import org.apache.hadoop.hbase.wal.WAL;
|
||||
import org.apache.hadoop.hbase.wal.WALEdit;
|
||||
import org.apache.hadoop.hbase.wal.WALKey;
|
||||
@ -1221,13 +1219,13 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||
final InetSocketAddress initialIsa;
|
||||
final InetSocketAddress bindAddress;
|
||||
if(this instanceof MasterRpcServices) {
|
||||
String hostname = getHostname(conf, true);
|
||||
String hostname = DNS.getHostname(conf, DNS.ServerType.MASTER);
|
||||
int port = 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(conf.get("hbase.master.ipc.address", hostname), port);
|
||||
} else {
|
||||
String hostname = getHostname(conf, false);
|
||||
String hostname = DNS.getHostname(conf, DNS.ServerType.REGIONSERVER);
|
||||
int port = conf.getInt(HConstants.REGIONSERVER_PORT,
|
||||
HConstants.DEFAULT_REGIONSERVER_PORT);
|
||||
// Creation of a HSA will force a resolve.
|
||||
@ -1315,22 +1313,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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." + masterOrRS + ".dns.interface", "default"),
|
||||
conf.get("hbase." + masterOrRS + ".dns.nameserver", "default")));
|
||||
} else {
|
||||
LOG.info("hostname is configured to be " + hostname);
|
||||
return hostname;
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public int getScannersCount() {
|
||||
return scanners.size();
|
||||
|
@ -29,9 +29,9 @@ import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
|
||||
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
|
||||
import org.apache.hadoop.hbase.regionserver.HStoreFile;
|
||||
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
|
||||
import org.apache.hadoop.hbase.regionserver.StoreConfigInformation;
|
||||
import org.apache.hadoop.hbase.regionserver.StoreUtils;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||
import org.apache.hadoop.hbase.util.Pair;
|
||||
import org.apache.hadoop.hbase.util.ReflectionUtils;
|
||||
@ -172,7 +172,7 @@ public class DateTieredCompactionPolicy extends SortedCompactionPolicy {
|
||||
}
|
||||
|
||||
float blockLocalityIndex = hdfsBlocksDistribution
|
||||
.getBlockLocalityIndex(RSRpcServices.getHostname(comConf.conf, false));
|
||||
.getBlockLocalityIndex(DNS.getHostname(comConf.conf, DNS.ServerType.REGIONSERVER));
|
||||
if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
|
||||
LOG.debug("Major compaction triggered on store " + this
|
||||
+ "; to make hdfs blocks local, current blockLocalityIndex is "
|
||||
|
@ -28,9 +28,9 @@ import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.regionserver.HStore;
|
||||
import org.apache.hadoop.hbase.regionserver.HStoreFile;
|
||||
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
|
||||
import org.apache.hadoop.hbase.regionserver.StoreConfigInformation;
|
||||
import org.apache.hadoop.hbase.regionserver.StoreUtils;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
import org.slf4j.Logger;
|
||||
@ -85,7 +85,7 @@ public class RatioBasedCompactionPolicy extends SortedCompactionPolicy {
|
||||
if (sf.isMajorCompactionResult() && (cfTTL == Long.MAX_VALUE || oldest < cfTTL)) {
|
||||
float blockLocalityIndex =
|
||||
sf.getHDFSBlockDistribution().getBlockLocalityIndex(
|
||||
RSRpcServices.getHostname(comConf.conf, false));
|
||||
DNS.getHostname(comConf.conf, DNS.ServerType.REGIONSERVER));
|
||||
if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
|
||||
LOG.debug("Major compaction triggered on only store " + regionInfo
|
||||
+ "; to make hdfs blocks local, current blockLocalityIndex is "
|
||||
|
@ -74,6 +74,7 @@ import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.Hbck;
|
||||
import org.apache.hadoop.hbase.client.ImmutableHRegionInfo;
|
||||
import org.apache.hadoop.hbase.client.ImmutableHTableDescriptor;
|
||||
import org.apache.hadoop.hbase.client.MasterRegistry;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
|
||||
@ -1147,8 +1148,7 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
|
||||
option.getNumRegionServers(), option.getRsPorts(), option.getMasterClass(),
|
||||
option.getRsClass());
|
||||
// Populate the master address configuration from mini cluster configuration.
|
||||
conf.set(HConstants.MASTER_ADDRS_KEY,
|
||||
c.get(HConstants.MASTER_ADDRS_KEY, HConstants.MASTER_ADDRS_DEFAULT));
|
||||
conf.set(HConstants.MASTER_ADDRS_KEY, MasterRegistry.getMasterAddr(c));
|
||||
// Don't leave here till we've done a successful scan of the hbase:meta
|
||||
Table t = getConnection().getTable(TableName.META_TABLE_NAME);
|
||||
ResultScanner s = t.getScanner(new Scan());
|
||||
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.client;
|
||||
|
||||
import static org.apache.hadoop.hbase.HConstants.META_REPLICAS_NUM;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -76,7 +77,7 @@ public class TestMasterRegistry {
|
||||
/**
|
||||
* Makes sure the master registry parses the master end points in the configuration correctly.
|
||||
*/
|
||||
@Test public void testMasterAddressParsing() {
|
||||
@Test public void testMasterAddressParsing() throws UnknownHostException {
|
||||
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
|
||||
int numMasters = 10;
|
||||
conf.set(HConstants.MASTER_ADDRS_KEY, generateDummyMastersList(numMasters));
|
||||
|
@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HDFSBlocksDistribution;
|
||||
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
||||
@ -61,8 +62,8 @@ public class MockHStoreFile extends HStoreFile {
|
||||
this.sequenceid = sequenceid;
|
||||
this.isMajor = false;
|
||||
hdfsBlocksDistribution = new HDFSBlocksDistribution();
|
||||
hdfsBlocksDistribution.addHostsAndBlockWeight(
|
||||
new String[] { RSRpcServices.getHostname(testUtil.getConfiguration(), false) }, 1);
|
||||
hdfsBlocksDistribution.addHostsAndBlockWeight(new String[]
|
||||
{ DNS.getHostname(testUtil.getConfiguration(), DNS.ServerType.REGIONSERVER) }, 1);
|
||||
modificationTime = EnvironmentEdgeManager.currentTime();
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.StartMiniClusterOption;
|
||||
import org.apache.hadoop.hbase.master.LoadBalancer;
|
||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
|
||||
import org.junit.After;
|
||||
@ -75,7 +76,7 @@ public class TestRegionServerHostname {
|
||||
@Test
|
||||
public void testInvalidRegionServerHostnameAbortsServer() throws Exception {
|
||||
String invalidHostname = "hostAddr.invalid";
|
||||
TEST_UTIL.getConfiguration().set(HRegionServer.RS_HOSTNAME_KEY, invalidHostname);
|
||||
TEST_UTIL.getConfiguration().set(DNS.RS_HOSTNAME_KEY, invalidHostname);
|
||||
HRegionServer hrs = null;
|
||||
try {
|
||||
hrs = new HRegionServer(TEST_UTIL.getConfiguration());
|
||||
@ -103,8 +104,8 @@ public class TestRegionServerHostname {
|
||||
String hostName = addr.getHostName();
|
||||
LOG.info("Found " + hostName + " on " + ni + ", addr=" + addr);
|
||||
|
||||
TEST_UTIL.getConfiguration().set(HRegionServer.MASTER_HOSTNAME_KEY, hostName);
|
||||
TEST_UTIL.getConfiguration().set(HRegionServer.RS_HOSTNAME_KEY, hostName);
|
||||
TEST_UTIL.getConfiguration().set(DNS.MASTER_HOSTNAME_KEY, hostName);
|
||||
TEST_UTIL.getConfiguration().set(DNS.RS_HOSTNAME_KEY, hostName);
|
||||
StartMiniClusterOption option = StartMiniClusterOption.builder()
|
||||
.numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
|
||||
TEST_UTIL.startMiniCluster(option);
|
||||
@ -141,10 +142,10 @@ public class TestRegionServerHostname {
|
||||
String hostName = addr.getHostName();
|
||||
LOG.info("Found " + hostName + " on " + ni);
|
||||
|
||||
TEST_UTIL.getConfiguration().set(HRegionServer.MASTER_HOSTNAME_KEY, hostName);
|
||||
TEST_UTIL.getConfiguration().set(DNS.MASTER_HOSTNAME_KEY, hostName);
|
||||
// "hbase.regionserver.hostname" and "hbase.regionserver.hostname.disable.master.reversedns"
|
||||
// are mutually exclusive. Exception should be thrown if both are used.
|
||||
TEST_UTIL.getConfiguration().set(HRegionServer.RS_HOSTNAME_KEY, hostName);
|
||||
TEST_UTIL.getConfiguration().set(DNS.RS_HOSTNAME_KEY, hostName);
|
||||
TEST_UTIL.getConfiguration().setBoolean(HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
|
||||
try {
|
||||
StartMiniClusterOption option = StartMiniClusterOption.builder()
|
||||
@ -154,8 +155,8 @@ public class TestRegionServerHostname {
|
||||
Throwable t1 = e.getCause();
|
||||
Throwable t2 = t1.getCause();
|
||||
assertTrue(t1.getMessage()+" - "+t2.getMessage(), t2.getMessage().contains(
|
||||
HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY + " and " + HRegionServer.RS_HOSTNAME_KEY +
|
||||
" are mutually exclusive"));
|
||||
HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY + " and " +
|
||||
DNS.RS_HOSTNAME_KEY + " are mutually exclusive"));
|
||||
return;
|
||||
} finally {
|
||||
TEST_UTIL.shutdownMiniCluster();
|
||||
|
Loading…
x
Reference in New Issue
Block a user