From 9024a1a18f5b6bb6820a5f49b51014bf9d981161 Mon Sep 17 00:00:00 2001 From: Viraj Jasani Date: Fri, 31 Jan 2025 19:02:08 -0800 Subject: [PATCH] HBase Connection Registry usage with Phoenix JDBC url --- docs/src/main/sphinx/connector/phoenix.md | 26 ++++++++++++++++++- .../plugin/phoenix5/TestingPhoenixServer.java | 4 +-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/src/main/sphinx/connector/phoenix.md b/docs/src/main/sphinx/connector/phoenix.md index 38c8e2c5c9ab..c346a3677083 100644 --- a/docs/src/main/sphinx/connector/phoenix.md +++ b/docs/src/main/sphinx/connector/phoenix.md @@ -47,11 +47,35 @@ The following Phoenix-specific configuration properties are available: | Property name | Required | Description | |------------------------------------| -------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `phoenix.connection-url` | Yes | `jdbc:phoenix[:zk_quorum][:zk_port][:zk_hbase_path]`. The `zk_quorum` is a comma separated list of ZooKeeper servers. The `zk_port` is the ZooKeeper port. The `zk_hbase_path` is the HBase root znode path, that is configurable using `hbase-site.xml`. By default the location is `/hbase` | +| `phoenix.connection-url` | Yes | See [](phoenix-connection-url). | | `phoenix.config.resources` | No | Comma-separated list of configuration files (e.g. `hbase-site.xml`) to use for connection properties. These files must exist on the machines running Trino. | | `phoenix.max-scans-per-split` | No | Maximum number of HBase scans that will be performed in a single split. Default is 20. Lower values will lead to more splits in Trino. Can also be set via session propery `max_scans_per_split`. For details see: [https://phoenix.apache.org/update_statistics.html](https://phoenix.apache.org/update_statistics.html). (This setting has no effect when guideposts are disabled in Phoenix.) | | `phoenix.server-scan-page-timeout` | No | The time limit on the amount of work single RPC request can do before it times out. Type: [](prop-type-duration). | +(phoenix-connection-url)= +### Connection URL: + +The connection URL for Phoenix set with `phoenix.connection-url` supports multiple formats: +* `jdbc:phoenix[:zk_quorum][:zk_port][:zk_hbase_path][:principal][:keytab][;options]`: + Connection uses HBase Zookeeper Registry. The `zk_quorum` is a comma separated + list of ZooKeeper servers. The `zk_port` is the ZooKeeper port. The + `zk_hbase_path` is the HBase root znode path, that is configurable using + `hbase-site.xml`. By default the location is `/hbase`. Principal, Keytab and + Options are optional. +* `jdbc:phoenix+zk[:host1\:port1][,:host2\:port2]...[,:hostN\:portN][:zk_hbase_path][:principal][:keytab][;options]`: + Uses same Connection as above, however host:port pairs are separated by comma. +* `jdbc:phoenix+rpc[:host1\:port1][,:host2\:port2]...[,:hostN\:portN][::principal][:keytab][;options]`: + Connection uses HBase RPC Registry. This is recommended for HBase 3+ + versions (HBASE-26174). host:port pairs are separated by comma. + Host names refers to HMaster server names, port refers to HMaster port. + Principal, Keytab and Options are optional. +* `jdbc:phoenix+master[:host1\:port1][,:host2\:port2]...[,:hostN\:portN][::principal][:keytab][;options]`: + Connection uses HBase Master Registry. host:port pairs are separated by comma. + Host names refers to HMaster server names, port refers to HMaster port. + Principal, Keytab and Options are optional. + +PHOENIX-6523 introduced support for various Connection Registries. + ```{include} jdbc-common-configurations.fragment ``` diff --git a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestingPhoenixServer.java b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestingPhoenixServer.java index 0fb1dd163b91..d26fc7743007 100644 --- a/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestingPhoenixServer.java +++ b/plugin/trino-phoenix5/src/test/java/io/trino/plugin/phoenix5/TestingPhoenixServer.java @@ -79,7 +79,6 @@ private TestingPhoenixServer() try { MiniZooKeeperCluster zkCluster = this.hbaseTestingUtility.startMiniZKCluster(); port = zkCluster.getClientPort(); - StartMiniClusterOption option = StartMiniClusterOption.builder().numMasters(1).numRegionServers(4).build(); MiniHBaseCluster hbaseCluster = hbaseTestingUtility.startMiniHBaseCluster(option); hbaseCluster.waitForActiveAndReadyMaster(); @@ -116,6 +115,7 @@ public void close() public String getJdbcUrl() { - return format("jdbc:phoenix:localhost:%d:/hbase;phoenix.schema.isNamespaceMappingEnabled=true", port); + // Alternative: "jdbc:phoenix+rpc:localhost\\:%d;phoenix.schema.isNamespaceMappingEnabled=true" where %d = master's port + return format("jdbc:phoenix+zk:localhost\\:%d:/hbase;phoenix.schema.isNamespaceMappingEnabled=true", port); } }