Skip to content

Commit ee7ea2e

Browse files
committed
patch 2.6.1 to reverse bound/advertised properties
1 parent 3fa6301 commit ee7ea2e

File tree

1 file changed

+174
-0
lines changed

1 file changed

+174
-0
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
From 635aa32bc6fefaefb90d754dcc4ccd67e4cdfa24 Mon Sep 17 00:00:00 2001
2+
From: Andrew Kenworthy <[email protected]>
3+
Date: Thu, 26 Jun 2025 14:59:01 +0200
4+
Subject: Update property usage for bound ports
5+
6+
---
7+
.../org/apache/hadoop/hbase/HConstants.java | 4 ++--
8+
.../hadoop/hbase/LocalHBaseCluster.java | 12 ++++++------
9+
.../apache/hadoop/hbase/master/HMaster.java | 6 +++---
10+
.../hbase/regionserver/HRegionServer.java | 19 +++++++++++++------
11+
.../util/ProcessBasedLocalHBaseCluster.java | 4 ++--
12+
5 files changed, 26 insertions(+), 19 deletions(-)
13+
14+
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
15+
index ea96ff8fce..054beb10d3 100644
16+
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
17+
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
18+
@@ -212,7 +212,7 @@ public final class HConstants {
19+
/** Configuration key for advertised master web API port */
20+
public static final String MASTER_INFO_PORT = "hbase.master.info.port";
21+
22+
- /** Configuration key for bound master web API port. (Defaults to MASTER_INFO_PORT.) */
23+
+ /** Configuration key for bound master web API port */
24+
public static final String MASTER_BOUND_INFO_PORT = "hbase.master.bound.info.port";
25+
26+
/** Configuration key for the list of master host:ports **/
27+
@@ -340,7 +340,7 @@ public final class HConstants {
28+
/** Configuration key for advertised region server web API port */
29+
public static final String REGIONSERVER_INFO_PORT = "hbase.regionserver.info.port";
30+
31+
- /** Configuration key for bound region server web API port. (Defaults to REGIONSERVER_INFO_PORT.) */
32+
+ /** Configuration key for bound region server web API port */
33+
public static final String REGIONSERVER_BOUND_INFO_PORT = "hbase.regionserver.bound.info.port";
34+
35+
/** A flag that enables automatic selection of regionserver info port */
36+
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
37+
index 816ef997cb..2114725986 100644
38+
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
39+
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
40+
@@ -144,20 +144,20 @@ public class LocalHBaseCluster {
41+
// treat info ports special; expressly don't change '-1' (keep off)
42+
// in case we make that the default behavior.
43+
if (
44+
- conf.getInt(HConstants.REGIONSERVER_INFO_PORT, 0) != -1
45+
- && conf.getInt(HConstants.REGIONSERVER_INFO_PORT,
46+
+ conf.getInt(HConstants.REGIONSERVER_BOUND_INFO_PORT, 0) != -1
47+
+ && conf.getInt(HConstants.REGIONSERVER_BOUND_INFO_PORT,
48+
HConstants.DEFAULT_REGIONSERVER_INFOPORT) == HConstants.DEFAULT_REGIONSERVER_INFOPORT
49+
) {
50+
LOG.debug("Setting RS InfoServer Port to random.");
51+
- conf.set(HConstants.REGIONSERVER_INFO_PORT, "0");
52+
+ conf.set(HConstants.REGIONSERVER_BOUND_INFO_PORT, "0");
53+
}
54+
if (
55+
- conf.getInt(HConstants.MASTER_INFO_PORT, 0) != -1
56+
- && conf.getInt(HConstants.MASTER_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT)
57+
+ conf.getInt(HConstants.MASTER_BOUND_INFO_PORT, 0) != -1
58+
+ && conf.getInt(HConstants.MASTER_BOUND_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT)
59+
== HConstants.DEFAULT_MASTER_INFOPORT
60+
) {
61+
LOG.debug("Setting Master InfoServer Port to random.");
62+
- conf.set(HConstants.MASTER_INFO_PORT, "0");
63+
+ conf.set(HConstants.MASTER_BOUND_INFO_PORT, "0");
64+
}
65+
}
66+
67+
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
68+
index 2f323518da..37cd7b3afd 100644
69+
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
70+
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
71+
@@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.master;
72+
import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK;
73+
import static org.apache.hadoop.hbase.HConstants.HBASE_MASTER_LOGCLEANER_PLUGINS;
74+
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
75+
-import static org.apache.hadoop.hbase.HConstants.MASTER_BOUND_INFO_PORT;
76+
+import static org.apache.hadoop.hbase.HConstants.MASTER_INFO_PORT;
77+
import static org.apache.hadoop.hbase.HConstants.MASTER_PORT;
78+
import static org.apache.hadoop.hbase.master.cleaner.HFileCleaner.CUSTOM_POOL_SIZE;
79+
import static org.apache.hadoop.hbase.util.DNS.MASTER_HOSTNAME_KEY;
80+
@@ -569,7 +569,7 @@ public class HMaster extends HRegionServer implements MasterServices {
81+
82+
@Override
83+
protected int getUseThisInfoPortInstead(Configuration conf) {
84+
- int port = conf.getInt(MASTER_BOUND_INFO_PORT, 0);
85+
+ int port = conf.getInt(MASTER_INFO_PORT, 0);
86+
return port != 0 ? port : this.infoServer != null ? this.infoServer.getPort() : -1;
87+
}
88+
89+
@@ -3143,7 +3143,7 @@ public class HMaster extends HRegionServer implements MasterServices {
90+
public int getRegionServerInfoPort(final ServerName sn) {
91+
int port = this.serverManager.getInfoPort(sn);
92+
return port == 0
93+
- ? conf.getInt(HConstants.REGIONSERVER_INFO_PORT, HConstants.DEFAULT_REGIONSERVER_INFOPORT)
94+
+ ? conf.getInt(HConstants.REGIONSERVER_BOUND_INFO_PORT, HConstants.DEFAULT_REGIONSERVER_INFOPORT)
95+
: port;
96+
}
97+
98+
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
99+
index 11bd1e58b5..abeeab3552 100644
100+
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
101+
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
102+
@@ -25,6 +25,7 @@ import static org.apache.hadoop.hbase.HConstants.DEFAULT_SLOW_LOG_SYS_TABLE_CHOR
103+
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
104+
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_MAX_SPLITTER;
105+
import static org.apache.hadoop.hbase.HConstants.REGIONSERVER_BOUND_INFO_PORT;
106+
+import static org.apache.hadoop.hbase.HConstants.REGIONSERVER_INFO_PORT;
107+
import static org.apache.hadoop.hbase.HConstants.REGIONSERVER_PORT;
108+
import static org.apache.hadoop.hbase.HConstants.RPC_CLIENT_BIND_ADDRESS;
109+
import static org.apache.hadoop.hbase.master.waleventtracker.WALEventTrackerTableCreator.WAL_EVENT_TRACKER_ENABLED_DEFAULT;
110+
@@ -791,7 +792,7 @@ public class HRegionServer extends Thread
111+
}
112+
113+
protected int getUseThisInfoPortInstead(Configuration conf) {
114+
- int port = conf.getInt(REGIONSERVER_BOUND_INFO_PORT, 0);
115+
+ int port = conf.getInt(REGIONSERVER_INFO_PORT, 0);
116+
return port != 0 ? port : this.infoServer != null ? this.infoServer.getPort() : -1;
117+
}
118+
119+
@@ -2463,11 +2464,11 @@ public class HRegionServer extends Thread
120+
*/
121+
private void putUpWebUI() throws IOException {
122+
int port =
123+
- this.conf.getInt(HConstants.REGIONSERVER_INFO_PORT, HConstants.DEFAULT_REGIONSERVER_INFOPORT);
124+
+ this.conf.getInt(REGIONSERVER_BOUND_INFO_PORT, HConstants.DEFAULT_REGIONSERVER_INFOPORT);
125+
String addr = this.conf.get("hbase.regionserver.info.bindAddress", "0.0.0.0");
126+
127+
if (this instanceof HMaster) {
128+
- port = conf.getInt(HConstants.MASTER_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT);
129+
+ port = conf.getInt(HConstants.MASTER_BOUND_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT);
130+
addr = this.conf.get("hbase.master.info.bindAddress", "0.0.0.0");
131+
}
132+
// -1 is for disabling info server
133+
@@ -2503,12 +2504,18 @@ public class HRegionServer extends Thread
134+
LOG.info("Retry starting http info server with port: " + port);
135+
}
136+
}
137+
- port = useThisInfoPortInstead;
138+
- conf.setInt(HConstants.REGIONSERVER_INFO_PORT, port);
139+
+
140+
+ // update bound ports
141+
+ port = this.infoServer.getPort();
142+
+ conf.setInt(REGIONSERVER_BOUND_INFO_PORT, port);
143+
+ conf.setInt(HConstants.MASTER_BOUND_INFO_PORT, port);
144+
+
145+
+ // set advertised ports
146+
+ conf.setInt(REGIONSERVER_INFO_PORT, useThisInfoPortInstead);
147+
int masterInfoPort =
148+
conf.getInt(HConstants.MASTER_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT);
149+
conf.setInt("hbase.master.info.port.orig", masterInfoPort);
150+
- conf.setInt(HConstants.MASTER_INFO_PORT, port);
151+
+ conf.setInt(HConstants.MASTER_INFO_PORT, useThisInfoPortInstead);
152+
}
153+
154+
/*
155+
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/ProcessBasedLocalHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/ProcessBasedLocalHBaseCluster.java
156+
index 21c49e61ba..2dd85ab764 100644
157+
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/ProcessBasedLocalHBaseCluster.java
158+
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/ProcessBasedLocalHBaseCluster.java
159+
@@ -370,13 +370,13 @@ public class ProcessBasedLocalHBaseCluster {
160+
161+
int masterInfoPort = HBaseTestingUtility.randomFreePort();
162+
reportWebUIPort("master", masterInfoPort);
163+
- confMap.put(HConstants.MASTER_INFO_PORT, masterInfoPort);
164+
+ confMap.put(HConstants.MASTER_BOUND_INFO_PORT, masterInfoPort);
165+
} else if (serverType == ServerType.RS) {
166+
confMap.put(HConstants.REGIONSERVER_PORT, rpcPort);
167+
168+
int rsInfoPort = HBaseTestingUtility.randomFreePort();
169+
reportWebUIPort("region server", rsInfoPort);
170+
- confMap.put(HConstants.REGIONSERVER_INFO_PORT, rsInfoPort);
171+
+ confMap.put(HConstants.REGIONSERVER_BOUND_INFO_PORT, rsInfoPort);
172+
} else {
173+
confMap.put(HConstants.ZOOKEEPER_DATA_DIR, daemonDir);
174+
}

0 commit comments

Comments
 (0)