Skip to content

Commit 4b6b849

Browse files
committed
hbase: patch for 2.6.2 endpoints
1 parent 9b02ec8 commit 4b6b849

File tree

4 files changed

+288
-164
lines changed

4 files changed

+288
-164
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
1-
From c17e6c5bc3a942600eb901798654d767448c1e16 Mon Sep 17 00:00:00 2001
1+
From 00ec82be6136e55d4d901e28791bc3ce36d726c7 Mon Sep 17 00:00:00 2001
22
From: =?UTF-8?q?Natalie=20Klestrup=20R=C3=B6ijezon?= <[email protected]>
3-
Date: Fri, 30 May 2025 15:36:36 +0200
4-
Subject: Use this port instead
3+
Date: Fri, 30 May 2025 14:26:26 +0200
4+
Subject: Allow overriding ipc bind port and use alternative port from listener
55

66
---
7-
.../hadoop/hbase/ipc/RpcClientFactory.java | 1 +
8-
.../apache/hadoop/hbase/master/HMaster.java | 4 ++--
9-
.../hbase/regionserver/HRegionServer.java | 22 +++++++++++++------
10-
3 files changed, 18 insertions(+), 9 deletions(-)
7+
.../apache/hadoop/hbase/master/HMaster.java | 10 +++++--
8+
.../hbase/regionserver/HRegionServer.java | 28 +++++++++++++------
9+
.../hbase/regionserver/RSRpcServices.java | 4 +--
10+
3 files changed, 30 insertions(+), 12 deletions(-)
1111

12-
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClientFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClientFactory.java
13-
index fa65739c16..501b6b7637 100644
14-
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClientFactory.java
15-
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClientFactory.java
16-
@@ -99,6 +99,7 @@ public final class RpcClientFactory {
17-
*/
18-
public static RpcClient createClient(Configuration conf, String clusterId,
19-
SocketAddress localAddr, MetricsConnection metrics, Map<String, byte[]> connectionAttributes) {
20-
+ new Exception("BATMAN creating client localAddr="+localAddr).printStackTrace();
21-
String rpcClientClass = getRpcClientClass(conf);
22-
return ReflectionUtils.instantiateWithCustomCtor(
23-
rpcClientClass, new Class[] { Configuration.class, String.class, SocketAddress.class,
2412
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
25-
index 3fe5abac27..5719f276bf 100644
13+
index 3fe5abac27..be0136193b 100644
2614
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
2715
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
28-
@@ -587,7 +587,7 @@ public class HMaster extends HRegionServer implements MasterServices {
16+
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.master;
17+
import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_COORDINATED_BY_ZK;
18+
import static org.apache.hadoop.hbase.HConstants.HBASE_MASTER_LOGCLEANER_PLUGINS;
19+
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
20+
+import static org.apache.hadoop.hbase.HConstants.MASTER_PORT;
21+
import static org.apache.hadoop.hbase.master.cleaner.HFileCleaner.CUSTOM_POOL_SIZE;
22+
import static org.apache.hadoop.hbase.util.DNS.MASTER_HOSTNAME_KEY;
23+
24+
@@ -559,6 +560,11 @@ public class HMaster extends HRegionServer implements MasterServices {
25+
return conf.get(MASTER_HOSTNAME_KEY);
26+
}
27+
28+
+ @Override
29+
+ protected int getUseThisPortInstead(Configuration conf) {
30+
+ return conf.getInt(MASTER_PORT, this.rpcServices.getSocketAddress().getPort());
31+
+ }
32+
+
33+
private void registerConfigurationObservers() {
34+
configurationManager.registerObserver(this.rpcServices);
35+
configurationManager.registerObserver(this);
36+
@@ -587,7 +593,7 @@ public class HMaster extends HRegionServer implements MasterServices {
2937
Threads.setDaemonThreadRunning(new Thread(() -> TraceUtil.trace(() -> {
3038
try {
3139
int infoPort = putUpJettyServer();
@@ -34,7 +42,7 @@ index 3fe5abac27..5719f276bf 100644
3442
} catch (Throwable t) {
3543
// Make sure we log the exception.
3644
String error = "Failed to become Active Master";
37-
@@ -2991,7 +2991,7 @@ public class HMaster extends HRegionServer implements MasterServices {
45+
@@ -2991,7 +2997,7 @@ public class HMaster extends HRegionServer implements MasterServices {
3846
}
3947
case MASTER_INFO_PORT: {
4048
if (infoServer != null) {
@@ -44,10 +52,18 @@ index 3fe5abac27..5719f276bf 100644
4452
break;
4553
}
4654
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
47-
index 27bcef2f06..d18ad91c3a 100644
55+
index 27bcef2f06..80949070fd 100644
4856
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
4957
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
50-
@@ -505,6 +505,10 @@ public class HRegionServer extends Thread
58+
@@ -24,6 +24,7 @@ import static org.apache.hadoop.hbase.HConstants.DEFAULT_HBASE_SPLIT_WAL_MAX_SPL
59+
import static org.apache.hadoop.hbase.HConstants.DEFAULT_SLOW_LOG_SYS_TABLE_CHORE_DURATION;
60+
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_COORDINATED_BY_ZK;
61+
import static org.apache.hadoop.hbase.HConstants.HBASE_SPLIT_WAL_MAX_SPLITTER;
62+
+import static org.apache.hadoop.hbase.HConstants.REGIONSERVER_PORT;
63+
import static org.apache.hadoop.hbase.master.waleventtracker.WALEventTrackerTableCreator.WAL_EVENT_TRACKER_ENABLED_DEFAULT;
64+
import static org.apache.hadoop.hbase.master.waleventtracker.WALEventTrackerTableCreator.WAL_EVENT_TRACKER_ENABLED_KEY;
65+
import static org.apache.hadoop.hbase.namequeues.NamedQueueServiceChore.NAMED_QUEUE_CHORE_DURATION_DEFAULT;
66+
@@ -505,6 +506,10 @@ public class HRegionServer extends Thread
5167
*/
5268
protected String useThisHostnameInstead;
5369

@@ -58,16 +74,16 @@ index 27bcef2f06..d18ad91c3a 100644
5874
/**
5975
* @deprecated since 2.4.0 and will be removed in 4.0.0. Use
6076
* {@link HRegionServer#UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY} instead.
61-
@@ -669,6 +673,8 @@ public class HRegionServer extends Thread
77+
@@ -669,6 +674,8 @@ public class HRegionServer extends Thread
6278
this.namedQueueRecorder = NamedQueueRecorder.getInstance(this.conf);
6379
rpcServices = createRpcServices();
6480
useThisHostnameInstead = getUseThisHostnameInstead(conf);
65-
+ useThisPortInstead = Integer.parseInt(System.getenv("HBASE_SERVICE_PORT"));
66-
+ useThisInfoPortInstead = Integer.parseInt(System.getenv("HBASE_INFO_PORT"));
81+
+ useThisPortInstead = getUseThisPortInstead(conf);
82+
+ useThisInfoPortInstead = conf.getInt("hbase.info.port" , this.infoServer != null ? this.infoServer.getPort() : -1);
6783

6884
// if use-ip is enabled, we will use ip to expose Master/RS service for client,
6985
// see HBASE-27304 for details.
70-
@@ -678,7 +684,7 @@ public class HRegionServer extends Thread
86+
@@ -678,7 +685,7 @@ public class HRegionServer extends Thread
7187
useIp ? rpcServices.isa.getAddress().getHostAddress() : rpcServices.isa.getHostName();
7288
String hostName =
7389
StringUtils.isBlank(useThisHostnameInstead) ? isaHostName : useThisHostnameInstead;
@@ -76,7 +92,7 @@ index 27bcef2f06..d18ad91c3a 100644
7692

7793
rpcControllerFactory = RpcControllerFactory.instantiate(this.conf);
7894
rpcRetryingCallerFactory = RpcRetryingCallerFactory.instantiate(this.conf,
79-
@@ -715,7 +721,7 @@ public class HRegionServer extends Thread
95+
@@ -715,7 +722,7 @@ public class HRegionServer extends Thread
8096

8197
// Some unit tests don't need a cluster, so no zookeeper at all
8298
// Open connection to zookeeper and set primary watcher
@@ -85,16 +101,27 @@ index 27bcef2f06..d18ad91c3a 100644
85101
canCreateBaseZNode());
86102
// If no master in cluster, skip trying to track one or look for a cluster status.
87103
if (!this.masterless) {
88-
@@ -958,7 +964,7 @@ public class HRegionServer extends Thread
104+
@@ -776,6 +783,10 @@ public class HRegionServer extends Thread
105+
}
106+
}
107+
108+
+ protected int getUseThisPortInstead(Configuration conf) {
109+
+ return conf.getInt(REGIONSERVER_PORT, this.rpcServices.isa.getPort());
110+
+ }
111+
+
112+
private void setupSignalHandlers() {
113+
if (!SystemUtils.IS_OS_WINDOWS) {
114+
HBasePlatformDependent.handle("HUP", (number, name) -> {
115+
@@ -958,7 +969,7 @@ public class HRegionServer extends Thread
89116
}
90117
// Setup RPC client for master communication
91118
this.rpcClient = RpcClientFactory.createClient(conf, clusterId,
92119
- new InetSocketAddress(this.rpcServices.isa.getAddress(), 0),
93-
+ new InetSocketAddress(/*this.rpcServices.isa.getAddress(), */0),
120+
+ new InetSocketAddress(0),
94121
clusterConnection.getConnectionMetrics(), Collections.emptyMap());
95122
span.setStatus(StatusCode.OK);
96123
} catch (Throwable t) {
97-
@@ -1533,6 +1539,8 @@ public class HRegionServer extends Thread
124+
@@ -1533,6 +1544,8 @@ public class HRegionServer extends Thread
98125
} else {
99126
serverLoad.setInfoServerPort(-1);
100127
}
@@ -103,7 +130,7 @@ index 27bcef2f06..d18ad91c3a 100644
103130
MetricsUserAggregateSource userSource =
104131
metricsRegionServer.getMetricsUserAggregate().getSource();
105132
if (userSource != null) {
106-
@@ -1688,7 +1696,7 @@ public class HRegionServer extends Thread
133+
@@ -1688,7 +1701,7 @@ public class HRegionServer extends Thread
107134
if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
108135
String hostnameFromMasterPOV = e.getValue();
109136
this.serverName = ServerName.valueOf(hostnameFromMasterPOV,
@@ -112,7 +139,7 @@ index 27bcef2f06..d18ad91c3a 100644
112139
String expectedHostName = rpcServices.getSocketAddress().getHostName();
113140
// if Master use-ip is enabled, RegionServer use-ip will be enabled by default even if it
114141
// is set to disable. so we will use the ip of the RegionServer to compare with the
115-
@@ -1814,7 +1822,7 @@ public class HRegionServer extends Thread
142+
@@ -1814,7 +1827,7 @@ public class HRegionServer extends Thread
116143

117144
private void createMyEphemeralNode() throws KeeperException {
118145
RegionServerInfo.Builder rsInfo = RegionServerInfo.newBuilder();
@@ -121,7 +148,7 @@ index 27bcef2f06..d18ad91c3a 100644
121148
rsInfo.setVersionInfo(ProtobufUtil.getVersionInfo());
122149
byte[] data = ProtobufUtil.prependPBMagic(rsInfo.build().toByteArray());
123150
ZKUtil.createEphemeralNodeAndWatch(this.zooKeeper, getMyEphemeralNodePath(), data);
124-
@@ -2479,7 +2487,7 @@ public class HRegionServer extends Thread
151+
@@ -2479,7 +2492,7 @@ public class HRegionServer extends Thread
125152
LOG.info("Retry starting http info server with port: " + port);
126153
}
127154
}
@@ -130,7 +157,12 @@ index 27bcef2f06..d18ad91c3a 100644
130157
conf.setInt(HConstants.REGIONSERVER_INFO_PORT, port);
131158
int masterInfoPort =
132159
conf.getInt(HConstants.MASTER_INFO_PORT, HConstants.DEFAULT_MASTER_INFOPORT);
133-
@@ -3078,7 +3086,7 @@ public class HRegionServer extends Thread
160+
@@ -3073,12 +3086,11 @@ public class HRegionServer extends Thread
161+
LOG.info("reportForDuty to master=" + masterServerName + " with isa=" + rpcServices.isa
162+
+ ", startcode=" + this.startcode);
163+
long now = EnvironmentEdgeManager.currentTime();
164+
- int port = rpcServices.isa.getPort();
165+
RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();
134166
if (!StringUtils.isBlank(useThisHostnameInstead)) {
135167
request.setUseThisHostnameInstead(useThisHostnameInstead);
136168
}
@@ -139,3 +171,24 @@ index 27bcef2f06..d18ad91c3a 100644
139171
request.setServerStartCode(this.startcode);
140172
request.setServerCurrentTime(now);
141173
result = rss.regionServerStartup(null, request.build());
174+
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
175+
index b77fcf338a..1f5c9dd21f 100644
176+
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
177+
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
178+
@@ -1270,14 +1270,14 @@ public class RSRpcServices implements HBaseRPCErrorHandler, AdminService.Blockin
179+
int port = conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT);
180+
// Creation of a HSA will force a resolve.
181+
initialIsa = new InetSocketAddress(hostname, port);
182+
- bindAddress = new InetSocketAddress(conf.get("hbase.master.ipc.address", hostname), port);
183+
+ bindAddress = new InetSocketAddress(conf.get("hbase.master.ipc.address", hostname), conf.getInt("hbase.master.ipc.port", port));
184+
} else {
185+
String hostname = DNS.getHostname(conf, DNS.ServerType.REGIONSERVER);
186+
int port = conf.getInt(HConstants.REGIONSERVER_PORT, HConstants.DEFAULT_REGIONSERVER_PORT);
187+
// Creation of a HSA will force a resolve.
188+
initialIsa = new InetSocketAddress(hostname, port);
189+
bindAddress =
190+
- new InetSocketAddress(conf.get("hbase.regionserver.ipc.address", hostname), port);
191+
+ new InetSocketAddress(conf.get("hbase.regionserver.ipc.address", hostname), conf.getInt("hbase.regionserver.ipc.port", port));
192+
}
193+
if (initialIsa.getAddress() == null) {
194+
throw new IllegalArgumentException("Failed resolve of " + initialIsa);

hbase/stackable/patches/2.6.1/0005-Allow-overriding-ipc-bind-port.patch

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)