Skip to content

Commit 285e6cb

Browse files
author
pgarre
committed
HBASE-24667 - Rename regionserver.hostname defined in HBASE-12954 into hbase.unsafe
1 parent 7d870f8 commit 285e6cb

5 files changed

Lines changed: 40 additions & 22 deletions

File tree

hbase-common/src/main/java/org/apache/hadoop/hbase/util/DNS.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@ public final class DNS {
3535
// the specification of server hostname is optional. The hostname should be resolvable from
3636
// both master and region server
3737
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
38-
public static final String RS_HOSTNAME_KEY = "hbase.regionserver.hostname";
38+
public static final String UNSAFE_RS_HOSTNAME_KEY = "hbase.unsafe.regionserver.hostname";
3939
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
4040
public static final String MASTER_HOSTNAME_KEY = "hbase.master.hostname";
4141

4242
private static boolean HAS_NEW_DNS_GET_DEFAULT_HOST_API;
4343
private static Method GET_DEFAULT_HOST_METHOD;
4444

45+
/**
46+
* @deprecated since 2.4.0 and in 3.0.0, to be removed in 4.0.0.
47+
* Use {@link DNS#UNSAFE_RS_HOSTNAME_KEY} instead.
48+
*/
49+
@Deprecated
50+
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
51+
public static final String RS_HOSTNAME_KEY = "hbase.regionserver.hostname";
52+
4553
static {
4654
try {
4755
GET_DEFAULT_HOST_METHOD = org.apache.hadoop.net.DNS.class
@@ -50,6 +58,7 @@ public final class DNS {
5058
} catch (Exception e) {
5159
HAS_NEW_DNS_GET_DEFAULT_HOST_API = false; // FindBugs: Causes REC_CATCH_EXCEPTION. Suppressed
5260
}
61+
Configuration.addDeprecation(RS_HOSTNAME_KEY, UNSAFE_RS_HOSTNAME_KEY);
5362
}
5463

5564
public enum ServerType {
@@ -106,7 +115,7 @@ public static String getHostname(@NonNull Configuration conf, @NonNull ServerTyp
106115
hostname = conf.get(MASTER_HOSTNAME_KEY);
107116
break;
108117
case REGIONSERVER:
109-
hostname = conf.get(RS_HOSTNAME_KEY);
118+
hostname = conf.get(UNSAFE_RS_HOSTNAME_KEY);
110119
break;
111120
default:
112121
hostname = null;

hbase-common/src/main/resources/hbase-default.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ possible configurations would overwhelm and obscure the important.
11191119
http://docs.oracle.com/javase/1.5.0/docs/api/java/net/Socket.html#getTcpNoDelay()</description>
11201120
</property>
11211121
<property>
1122-
<name>hbase.regionserver.hostname</name>
1122+
<name>hbase.unsafe.regionserver.hostname</name>
11231123
<value></value>
11241124
<description>This config is for experts: don't set its value unless you really know what you are doing.
11251125
When set to a non-empty value, this represents the (external facing) hostname for the underlying server.
@@ -1131,7 +1131,7 @@ possible configurations would overwhelm and obscure the important.
11311131
<description>This config is for experts: don't set its value unless you really know what you are doing.
11321132
When set to true, regionserver will use the current node hostname for the servername and HMaster will
11331133
skip reverse DNS lookup and use the hostname sent by regionserver instead. Note that this config and
1134-
hbase.regionserver.hostname are mutually exclusive. See https://issues.apache.org/jira/browse/HBASE-18226
1134+
hbase.unsafe.regionserver.hostname are mutually exclusive. See https://issues.apache.org/jira/browse/HBASE-18226
11351135
for more details.</description>
11361136
</property>
11371137
<!-- The following properties configure authentication information for

hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestSecureRESTServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public static void setupServer() throws Exception {
168168
HBaseKerberosUtils.setKeytabFileForTesting(serviceKeytab.getAbsolutePath());
169169
// Why doesn't `setKeytabFileForTesting` do this?
170170
conf.set("hbase.master.keytab.file", serviceKeytab.getAbsolutePath());
171-
conf.set("hbase.regionserver.hostname", "localhost");
171+
conf.set("hbase.unsafe.regionserver.hostname", "localhost");
172172
conf.set("hbase.master.hostname", "localhost");
173173
HBaseKerberosUtils.setSecuredConfiguration(conf,
174174
SERVICE_PRINCIPAL+ "@" + KDC.getRealm(), SPNEGO_SERVICE_PRINCIPAL+ "@" + KDC.getRealm());

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_WAL_MAX_SPLITTER;
2222
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
2323
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_MAX_SPLITTER;
24-
import static org.apache.hadoop.hbase.util.DNS.RS_HOSTNAME_KEY;
24+
import static org.apache.hadoop.hbase.util.DNS.UNSAFE_RS_HOSTNAME_KEY;
2525

2626
import java.io.IOException;
2727
import java.lang.management.MemoryType;
@@ -467,16 +467,16 @@ public class HRegionServer extends Thread implements
467467
protected String useThisHostnameInstead;
468468

469469
/**
470-
* @deprecated
470+
* @deprecated since 2.4.0 and in 3.0.0, to be removed in 4.0.0.
471471
* Use {@link HRegionServer#UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY} instead.
472472
*/
473473
@Deprecated
474474
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
475-
final static String DEPRECATED_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY =
475+
final static String RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY =
476476
"hbase.regionserver.hostname.disable.master.reversedns";
477477

478478
/**
479-
* HBASE-18226: This config and hbase.regionserver.hostname are mutually exclusive.
479+
* HBASE-18226: This config and hbase.unasfe.regionserver.hostname are mutually exclusive.
480480
* Exception will be thrown if both are used.
481481
*/
482482
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
@@ -489,7 +489,7 @@ public class HRegionServer extends Thread implements
489489
* compatibility.
490490
*/
491491
static {
492-
Configuration.addDeprecation(DEPRECATED_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY);
492+
Configuration.addDeprecation(RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY);
493493
}
494494

495495
/**
@@ -709,12 +709,12 @@ private void initNamedQueueRecorder(Configuration conf) {
709709

710710
// HMaster should override this method to load the specific config for master
711711
protected String getUseThisHostnameInstead(Configuration conf) throws IOException {
712-
String hostname = conf.get(RS_HOSTNAME_KEY);
712+
String hostname = conf.get(UNSAFE_RS_HOSTNAME_KEY);
713713
if (conf.getBoolean(UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, false)) {
714714
if (!StringUtils.isBlank(hostname)) {
715-
String msg = UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY + " and " + RS_HOSTNAME_KEY +
715+
String msg = UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY + " and " + UNSAFE_RS_HOSTNAME_KEY +
716716
" are mutually exclusive. Do not set " + UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY +
717-
" to true while " + RS_HOSTNAME_KEY + " is used";
717+
" to true while " + UNSAFE_RS_HOSTNAME_KEY + " is used";
718718
throw new IOException(msg);
719719
} else {
720720
return rpcServices.isa.getHostName();

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void teardown() throws Exception {
7777
@Test
7878
public void testInvalidRegionServerHostnameAbortsServer() throws Exception {
7979
String invalidHostname = "hostAddr.invalid";
80-
TEST_UTIL.getConfiguration().set(DNS.RS_HOSTNAME_KEY, invalidHostname);
80+
TEST_UTIL.getConfiguration().set(DNS.UNSAFE_RS_HOSTNAME_KEY, invalidHostname);
8181
HRegionServer hrs = null;
8282
try {
8383
hrs = new HRegionServer(TEST_UTIL.getConfiguration());
@@ -106,7 +106,7 @@ public void testRegionServerHostname() throws Exception {
106106
LOG.info("Found " + hostName + " on " + ni + ", addr=" + addr);
107107

108108
TEST_UTIL.getConfiguration().set(DNS.MASTER_HOSTNAME_KEY, hostName);
109-
TEST_UTIL.getConfiguration().set(DNS.RS_HOSTNAME_KEY, hostName);
109+
TEST_UTIL.getConfiguration().set(DNS.UNSAFE_RS_HOSTNAME_KEY, hostName);
110110
StartMiniClusterOption option = StartMiniClusterOption.builder()
111111
.numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
112112
TEST_UTIL.startMiniCluster(option);
@@ -132,14 +132,23 @@ public void testRegionServerHostname() throws Exception {
132132
public void testDeprecatedConfigs() throws Exception {
133133
Configuration conf = TEST_UTIL.getConfiguration();
134134
new HRegionServer(conf);
135-
conf.setBoolean(HRegionServer.DEPRECATED_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, false);
135+
conf.setBoolean(HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, false);
136136
assertFalse(conf.getBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true));
137-
conf.setBoolean(HRegionServer.DEPRECATED_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
137+
conf.setBoolean(HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
138138
assertTrue(conf.getBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, false));
139139
conf.setBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
140-
assertTrue(conf.getBoolean(HRegionServer.DEPRECATED_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, false));
140+
assertTrue(conf.getBoolean(HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, false));
141141
conf.setBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, false);
142-
assertFalse(conf.getBoolean(HRegionServer.DEPRECATED_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true));
142+
assertFalse(conf.getBoolean(HRegionServer.RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true));
143+
144+
conf.setBoolean(DNS.RS_HOSTNAME_KEY, false);
145+
assertFalse(conf.getBoolean(DNS.UNSAFE_RS_HOSTNAME_KEY, true));
146+
conf.setBoolean(DNS.RS_HOSTNAME_KEY, true);
147+
assertTrue(conf.getBoolean(DNS.UNSAFE_RS_HOSTNAME_KEY, false));
148+
conf.setBoolean(DNS.UNSAFE_RS_HOSTNAME_KEY, true);
149+
assertTrue(conf.getBoolean(DNS.RS_HOSTNAME_KEY, false));
150+
conf.setBoolean(DNS.UNSAFE_RS_HOSTNAME_KEY, false);
151+
assertFalse(conf.getBoolean(DNS.RS_HOSTNAME_KEY, true));
143152
}
144153

145154
@Test
@@ -158,9 +167,9 @@ public void testConflictRegionServerHostnameConfigurationsAbortServer() throws E
158167
LOG.info("Found " + hostName + " on " + ni);
159168

160169
TEST_UTIL.getConfiguration().set(DNS.MASTER_HOSTNAME_KEY, hostName);
161-
// "hbase.regionserver.hostname" and "hbase.unsafe.regionserver.hostname.disable.master.reversedns"
170+
// "hbase.unsafe.regionserver.hostname" and "hbase.unsafe.regionserver.hostname.disable.master.reversedns"
162171
// are mutually exclusive. Exception should be thrown if both are used.
163-
TEST_UTIL.getConfiguration().set(DNS.RS_HOSTNAME_KEY, hostName);
172+
TEST_UTIL.getConfiguration().set(DNS.UNSAFE_RS_HOSTNAME_KEY, hostName);
164173
TEST_UTIL.getConfiguration().setBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
165174
try {
166175
StartMiniClusterOption option = StartMiniClusterOption.builder()
@@ -171,7 +180,7 @@ public void testConflictRegionServerHostnameConfigurationsAbortServer() throws E
171180
Throwable t2 = t1.getCause();
172181
assertTrue(t1.getMessage()+" - "+t2.getMessage(), t2.getMessage().contains(
173182
HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY + " and " +
174-
DNS.RS_HOSTNAME_KEY + " are mutually exclusive"));
183+
DNS.UNSAFE_RS_HOSTNAME_KEY + " are mutually exclusive"));
175184
return;
176185
} finally {
177186
TEST_UTIL.shutdownMiniCluster();

0 commit comments

Comments
 (0)