Junegunn Choi created HBASE-29378:
-------------------------------------

             Summary: Make TestingHBaseCluster expose address/port information 
for end users
                 Key: HBASE-29378
                 URL: https://issues.apache.org/jira/browse/HBASE-29378
             Project: HBase
          Issue Type: Improvement
            Reporter: Junegunn Choi


h2. Summary

HBASE-13126 introduced TestingHBaseCluster which allows external projects to 
easily start a standalone HBase cluster with configurable number of 
RegionServers and DataNodes for testing purposes.

It is not only useful for writing integration tests, but also for manual 
testing and debugging. To enhance its usability, especially for manual testing, 
I suggest that it exposes some most commonly used address and port information.

h2. Proposal

Extend {{TestingHBaseCluster}} with the following methods to expose key address 
and port information:

* {{Optional<Integer> getActiveZooKeeperClientPort()}}
** ZooKeeper port for clients using {{ZKConnectionRegistry}})
* {{List<String> getMasterAddresses()}}
** Master addresses for clients using {{RpcConnectionRegistry}}. Can be used to 
construct {{hbase.masters}} configuration.
* {{Optional<Integer> getActiveMasterInfoPort()}}
** Info port for the active HBase Master
* {{Optional<Integer> getActiveNameNodeInfoPort()}}
** Info port for the active NameNode

h2. Example usage

The following Kotlin code demonstrates how you can start a standalone HBase 
cluster with different numbers of components and print the address/port 
information for manual testing:

{code}
import org.apache.hadoop.hbase.testing.TestingHBaseCluster
import org.apache.hadoop.hbase.testing.TestingHBaseClusterOption

fun main() {
    val cluster = TestingHBaseCluster.create(
        TestingHBaseClusterOption.builder()
            .numDataNodes(3)
            .numRegionServers(3)
            .numMasters(2)
            .build()
    )
    cluster.start()

    // For clients using ZKConnectionRegistry
    println("ZooKeeper Quorum: 
localhost:${cluster.activeZooKeeperClientPort.get()}")

    // For clients using RpcConnectionRegistry
    println("hbase.masters: ${cluster.masterAddresses.joinToString(",")}")

    // Info ports for web UIs
    println("Active HBase Master: 
http://localhost:${cluster.activeMasterInfoPort.get()}")
    println("Active HDFS NameNode: 
http://localhost:${cluster.activeNameNodeInfoPort.get()}")

    Thread.sleep(Long.MAX_VALUE)
}
{code}

{noformat}
ZooKeeper Quorum: localhost:57924
hbase.masters: 192.168.35.49:61755,192.168.35.49:61758
Active HBase Master: http://localhost:61757
Active HDFS NameNode: http://localhost:61736
{noformat}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to