Skip to content

Commit 7a4340e

Browse files
committed
property re-working for 2.6.2
1 parent ee7ea2e commit 7a4340e

File tree

1 file changed

+175
-0
lines changed

1 file changed

+175
-0
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
From af07f7d502fcd6a5566b7cb327dd7a154054a9fc Mon Sep 17 00:00:00 2001
2+
From: Andrew Kenworthy <[email protected]>
3+
Date: Thu, 26 Jun 2025 16:58:47 +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 4d892755d2..3f852e7acc 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 313124d1d0..00e01c116e 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+
@@ -17,7 +17,7 @@
72+
*/
73+
package org.apache.hadoop.hbase.master;
74+
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.HConstants.DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK;
79+
import static org.apache.hadoop.hbase.HConstants.HBASE_MASTER_LOGCLEANER_PLUGINS;
80+
@@ -580,7 +580,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+
@@ -3158,7 +3158,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 68f56ab796..3d1d2d3a5c 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+
@@ -2459,12 +2460,12 @@ 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+
boolean isMaster = false;
128+
if (this instanceof HMaster) {
129+
- port = conf.getInt(HConstants.MASTER_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT);
130+
+ port = conf.getInt(HConstants.MASTER_BOUND_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT);
131+
addr = this.conf.get("hbase.master.info.bindAddress", "0.0.0.0");
132+
isMaster = true;
133+
}
134+
@@ -2501,12 +2502,18 @@ public class HRegionServer extends Thread
135+
LOG.info("Retry starting http info server with port: " + port);
136+
}
137+
}
138+
- port = useThisInfoPortInstead;
139+
- conf.setInt(HConstants.REGIONSERVER_INFO_PORT, port);
140+
+
141+
+ // update bound ports
142+
+ port = this.infoServer.getPort();
143+
+ conf.setInt(REGIONSERVER_BOUND_INFO_PORT, port);
144+
+ conf.setInt(HConstants.MASTER_BOUND_INFO_PORT, port);
145+
+
146+
+ // set advertised ports
147+
+ conf.setInt(REGIONSERVER_INFO_PORT, useThisInfoPortInstead);
148+
int masterInfoPort =
149+
conf.getInt(HConstants.MASTER_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT);
150+
conf.setInt("hbase.master.info.port.orig", masterInfoPort);
151+
- conf.setInt(HConstants.MASTER_INFO_PORT, port);
152+
+ conf.setInt(HConstants.MASTER_INFO_PORT, useThisInfoPortInstead);
153+
}
154+
155+
/*
156+
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
157+
index 21c49e61ba..2dd85ab764 100644
158+
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/ProcessBasedLocalHBaseCluster.java
159+
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/ProcessBasedLocalHBaseCluster.java
160+
@@ -370,13 +370,13 @@ public class ProcessBasedLocalHBaseCluster {
161+
162+
int masterInfoPort = HBaseTestingUtility.randomFreePort();
163+
reportWebUIPort("master", masterInfoPort);
164+
- confMap.put(HConstants.MASTER_INFO_PORT, masterInfoPort);
165+
+ confMap.put(HConstants.MASTER_BOUND_INFO_PORT, masterInfoPort);
166+
} else if (serverType == ServerType.RS) {
167+
confMap.put(HConstants.REGIONSERVER_PORT, rpcPort);
168+
169+
int rsInfoPort = HBaseTestingUtility.randomFreePort();
170+
reportWebUIPort("region server", rsInfoPort);
171+
- confMap.put(HConstants.REGIONSERVER_INFO_PORT, rsInfoPort);
172+
+ confMap.put(HConstants.REGIONSERVER_BOUND_INFO_PORT, rsInfoPort);
173+
} else {
174+
confMap.put(HConstants.ZOOKEEPER_DATA_DIR, daemonDir);
175+
}

0 commit comments

Comments
 (0)