Skip to content

HBASE-29378 Make TestingHBaseCluster expose address/port information #7074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

junegunn
Copy link
Member

@junegunn junegunn commented Jun 5, 2025

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@junegunn junegunn marked this pull request as draft June 6, 2025 08:20
Comment on lines 239 to 243
@Override
public Optional<Integer> getActiveZooKeeperClientPort() {
return Optional.ofNullable(util.getZkCluster()).map(MiniZooKeeperCluster::getClientPort)
.filter(port -> port > 0);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I have a second thought here as well.

Since the port is going to be used to build hbase.zookeeper.quorum, we should probably return the ports of all servers, not just the leader's.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just return the zookeeper connect string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're saying one can directly use the return value as hbase.zookeeper.quorum? (e.g. localhost:1111,localhost:2222,localhost:3333). If that's the case, I agree. I don't see much value in returning the ports separately and forcing the user to assemble the configuration string themselves.

@junegunn
Copy link
Member Author

junegunn commented Jun 6, 2025

Please take a look at the updated methods in 86ca728.

  • Null-safety
  • Support for HTTPS addresses

With the updated method signatures, it's going to be easier for users to print the information they need.

println("hbase.zookeeper.quorum: ${cluster.zooKeeperQuorum.orElse("N/A")}")
println("hbase.masters: ${cluster.masterAddresses.joinToString(",")}")
println("Active HBase Master: ${cluster.activeMasterInfoAddress.orElse("N/A")}")
println("Active HDFS NameNode: ${cluster.activeNameNodeInfoAddress.orElse("N/A")}")
hbase.zookeeper.quorum: localhost:2181
hbase.masters: 192.168.35.49:61959,192.168.35.49:61962
Active HBase Master: https://192.168.35.49:61964
Active HDFS NameNode: http://localhost:61940

It's quite different from what I originally proposed. I've updated the Jira description accordingly.

@junegunn junegunn requested review from Apache9 and NihalJain June 6, 2025 14:28
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@junegunn junegunn marked this pull request as ready for review June 6, 2025 15:21
@@ -147,7 +154,7 @@ public void startHBaseCluster() throws Exception {
public void start() throws Exception {
Preconditions.checkState(!miniClusterRunning, "Cluster has already been started");
if (externalZkConnectString == null) {
util.startMiniZKCluster();
util.startMiniZKCluster(option.getNumZkServers());
Copy link
Member Author

@junegunn junegunn Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While testing getZooKeeperQuorum, I noticed that numZkServers was never used. The fix is trivial (5bc0f4c), so I included it here, but if you think it deserves a separate issue, I'll split it.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 29s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚 mvninstall 3m 22s master passed
+1 💚 compile 0m 17s master passed
+1 💚 javadoc 0m 15s master passed
+1 💚 shadedjars 6m 9s branch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 3m 10s the patch passed
+1 💚 compile 0m 17s the patch passed
+1 💚 javac 0m 17s the patch passed
+1 💚 javadoc 0m 12s the patch passed
+1 💚 shadedjars 6m 3s patch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚 unit 2m 4s hbase-testing-util in the patch passed.
23m 19s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7074/3/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR #7074
Optional Tests javac javadoc unit compile shadedjars
uname Linux 373ead978f94 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 5bc0f4c
Default Java Eclipse Adoptium-17.0.11+9
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7074/3/testReport/
Max. process+thread count 2163 (vs. ulimit of 30000)
modules C: hbase-testing-util U: hbase-testing-util
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7074/3/console
versions git=2.34.1 maven=3.9.8
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 27s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
_ master Compile Tests _
+1 💚 mvninstall 3m 19s master passed
+1 💚 compile 0m 26s master passed
+1 💚 checkstyle 0m 10s master passed
+1 💚 spotbugs 0m 29s master passed
+1 💚 spotless 0m 49s branch has no errors when running spotless:check.
_ Patch Compile Tests _
+1 💚 mvninstall 3m 9s the patch passed
+1 💚 compile 0m 23s the patch passed
+1 💚 javac 0m 23s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 9s the patch passed
+1 💚 spotbugs 0m 33s the patch passed
+1 💚 hadoopcheck 12m 11s Patch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚 spotless 0m 45s patch has no errors when running spotless:check.
_ Other Tests _
+1 💚 asflicense 0m 10s The patch does not generate ASF License warnings.
30m 41s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7074/3/artifact/yetus-general-check/output/Dockerfile
GITHUB PR #7074
Optional Tests dupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
uname Linux 664ac6130ec3 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 5bc0f4c
Default Java Eclipse Adoptium-17.0.11+9
Max. process+thread count 83 (vs. ulimit of 30000)
modules C: hbase-testing-util U: hbase-testing-util
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7074/3/console
versions git=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@junegunn junegunn requested a review from Copilot June 21, 2025 09:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extends the TestingHBaseCluster API to expose detailed address and port information for components such as the active master, NameNode, ZooKeeper quorum, and master addresses.

  • Added new configuration and tests in TestTestingHBaseCluster.java to verify address formats.
  • Implemented new methods in TestingHBaseClusterImpl.java to fetch web UI addresses, NameNode addresses, ZooKeeper quorum, and master addresses.
  • Updated the TestingHBaseCluster interface to include the new API definitions.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
hbase-testing-util/src/test/java/org/apache/hadoop/hbase/testing/TestTestingHBaseCluster.java Added tests to verify that the address/port information complies with the expected format.
hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterImpl.java Implemented new methods to expose addresses for the active master, NameNode, ZooKeeper, and masters.
hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/TestingHBaseCluster.java Updated interface definitions for the new methods.
Comments suppressed due to low confidence (1)

hbase-testing-util/src/main/java/org/apache/hadoop/hbase/testing/TestingHBaseClusterImpl.java:261

  • [nitpick] Consider renaming the variable 'ann' to a more descriptive name like 'activeNameNode' to improve code clarity.
      .filter(NameNode::isActiveState).findFirst().orElse(null);

Comment on lines +268 to +272
String protocol = "http";
InetSocketAddress address = ann.getHttpAddress();
if (address == null) {
protocol = "https";
address = ann.getHttpsAddress();
Copy link
Preview

Copilot AI Jun 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider refactoring the logic for retrieving the NameNode address to separately determine the protocol and the address for better readability, rather than reassigning the 'address' variable within the same block.

Suggested change
String protocol = "http";
InetSocketAddress address = ann.getHttpAddress();
if (address == null) {
protocol = "https";
address = ann.getHttpsAddress();
InetSocketAddress address = ann.getHttpAddress();
String protocol;
if (address != null) {
protocol = "http";
} else {
address = ann.getHttpsAddress();
protocol = "https";

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants