This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new d64c724021 PHOENIX-7505 HBase 3 compatibility changes: Update
zookeeper handling (#2056)
d64c724021 is described below
commit d64c72402109e0682603783ce8d4258486848a34
Author: szucsvillo <[email protected]>
AuthorDate: Wed Feb 26 08:06:54 2025 +0100
PHOENIX-7505 HBase 3 compatibility changes: Update zookeeper handling
(#2056)
Co-authored-by: Istvan Toth <[email protected]>
---
.../org/apache/phoenix/jdbc/HighAvailabilityGroup.java | 10 +++++++++-
.../java/org/apache/phoenix/jdbc/PhoenixHAAdminTool.java | 2 +-
.../src/main/java/org/apache/phoenix/util/JDBCUtil.java | 7 ++++++-
.../it/java/org/apache/phoenix/end2end/ConnectionIT.java | 2 ++
.../org/apache/phoenix/end2end/ContextClassloaderIT.java | 4 ++--
.../end2end/MigrateSystemTablesToSystemNamespaceIT.java | 2 +-
.../end2end/PartialResultServerConfigurationIT.java | 2 +-
.../java/org/apache/phoenix/end2end/PhoenixDriverIT.java | 15 +++++++++------
.../phoenix/end2end/RebuildIndexConnectionPropsIT.java | 2 +-
.../end2end/UpdateCacheAcrossDifferentClientsIT.java | 9 +++++++++
.../apache/phoenix/end2end/UserDefinedFunctionsIT.java | 4 ++--
.../org/apache/phoenix/iterate/ScannerLeaseRenewalIT.java | 2 +-
.../apache/phoenix/jdbc/FailoverPhoenixConnectionIT.java | 2 +-
.../org/apache/phoenix/jdbc/HighAvailabilityGroupIT.java | 3 ++-
.../phoenix/jdbc/LoggingSingleConnectionLimiterIT.java | 8 ++++++--
.../org/apache/phoenix/jdbc/SecureUserConnectionsIT.java | 2 ++
.../org/apache/phoenix/monitoring/PhoenixMetricsIT.java | 12 ++++++------
.../phoenix/monitoring/PhoenixTableLevelMetricsIT.java | 2 +-
.../apache/phoenix/query/MaxConcurrentConnectionsIT.java | 2 +-
.../apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java | 5 ++++-
.../org/apache/phoenix/jdbc/PhoenixHAAdminToolTest.java | 4 ++--
21 files changed, 69 insertions(+), 32 deletions(-)
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java
index c5a1c67be9..9f27a0998d 100644
---
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java
+++
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java
@@ -383,7 +383,8 @@ public class HighAvailabilityGroup {
*
* @param url The HA connection url optionally; empty optional if
properties disables fallback
* @param properties The client connection properties
- * @return The connection url of the single cluster to fall back
+ * @return The connection url of the single cluster to fall back on,
+ * with a fully qualified JDBC protocol
* @throws SQLException if fails to get HA information and/or invalid
properties are seen
*/
static Optional<String> getFallbackCluster(String url, Properties
properties) throws SQLException {
@@ -400,6 +401,13 @@ public class HighAvailabilityGroup {
if (StringUtils.isEmpty(fallbackCluster)) {
fallbackCluster = haGroupInfo.getUrl1();
}
+
+ // Ensure the fallback cluster URL includes the JDBC protocol prefix
+ if (!fallbackCluster.startsWith(PhoenixRuntime.JDBC_PROTOCOL_ZK)) {
+ fallbackCluster = PhoenixRuntime.JDBC_PROTOCOL_ZK
+ + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + fallbackCluster;
+ }
+
LOG.info("Falling back to single cluster '{}' for the HA group {} to
serve HA connection "
+ "request against url '{}'.",
fallbackCluster, haGroupInfo.getName(), url);
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixHAAdminTool.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixHAAdminTool.java
index e7a9cd7a22..5da3ea1593 100644
---
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixHAAdminTool.java
+++
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixHAAdminTool.java
@@ -280,7 +280,7 @@ public class PhoenixHAAdminTool extends Configured
implements Tool {
}
String portStr = conf.get(HConstants.ZOOKEEPER_CLIENT_PORT);
- int port = HConstants.DEFAULT_ZOOKEPER_CLIENT_PORT;
+ int port = HConstants.DEFAULT_ZOOKEEPER_CLIENT_PORT;
if (portStr != null) {
try {
port = Integer.parseInt(portStr);
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/util/JDBCUtil.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/util/JDBCUtil.java
index 6e72fc1940..c4f64c47a2 100644
--- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/JDBCUtil.java
+++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/JDBCUtil.java
@@ -26,6 +26,7 @@ import java.util.Properties;
import javax.annotation.Nullable;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Consistency;
import org.apache.phoenix.jdbc.ConnectionInfo;
import org.apache.phoenix.jdbc.ZKConnectionInfo;
@@ -219,7 +220,11 @@ public class JDBCUtil {
public static String formatZookeeperUrl(String jdbcUrl) {
ConnectionInfo connInfo;
try {
- connInfo = ConnectionInfo.create(jdbcUrl, null, null);
+ Properties info = new Properties();
+ // Make sure we use ZK on HBase 3.x
+ info.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
+ ZKConnectionInfo.ZK_REGISTRY_NAME);
+ connInfo = ConnectionInfo.create(jdbcUrl, null, info);
// TODO in theory we could support non-ZK registries for HA.
// However, as HA already relies on ZK, this wouldn't be
particularly useful,
// and would require significant changes.
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java
index 0eba0b8f51..8aab8feb1d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java
@@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.util.VersionInfo;
import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.jdbc.PhoenixDriver;
import org.apache.phoenix.jdbc.PhoenixTestDriver;
+import org.apache.phoenix.jdbc.ZKConnectionInfo;
import org.apache.phoenix.mapreduce.util.ConnectionUtil;
import org.apache.phoenix.query.ConfigurationFactory;
import org.apache.phoenix.util.InstanceResolver;
@@ -58,6 +59,7 @@ public class ConnectionIT {
conf = hbaseTestUtil.getConfiguration();
setUpConfigForMiniCluster(conf);
conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test");
+ conf.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
hbaseTestUtil.startMiniCluster();
Class.forName(PhoenixDriver.class.getName());
DriverManager.registerDriver(new PhoenixTestDriver());
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
index ed0bd6cbb1..9592e47498 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java
@@ -17,7 +17,7 @@
*/
package org.apache.phoenix.end2end;
-import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_ZK;
import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
import static
org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
@@ -60,7 +60,7 @@ public class ContextClassloaderIT extends BaseTest {
hbaseTestUtil = new HBaseTestingUtility(conf);
hbaseTestUtil.startMiniCluster();
String clientPort =
hbaseTestUtil.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
- String url = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + LOCALHOST +
JDBC_PROTOCOL_SEPARATOR + clientPort
+ String url = JDBC_PROTOCOL_ZK + JDBC_PROTOCOL_SEPARATOR + LOCALHOST +
JDBC_PROTOCOL_SEPARATOR + clientPort
+ JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM;
driver = initAndRegisterTestDriver(url, ReadOnlyProps.EMPTY_PROPS);
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
index f9ceccfe65..6aaba958ff 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
@@ -421,7 +421,7 @@ public class MigrateSystemTablesToSystemNamespaceIT extends
BaseTest {
}
private String getJdbcUrl() {
- return "jdbc:phoenix:localhost:" +
testUtil.getZkCluster().getClientPort() + ":/hbase";
+ return "jdbc:phoenix+zk:localhost:" +
testUtil.getZkCluster().getClientPort() + ":/hbase";
}
}
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java
index 2cc4629cd7..b77231520e 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java
@@ -75,7 +75,7 @@ public class PartialResultServerConfigurationIT {
hbaseTestUtil.startMiniCluster();
zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort();
- url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
+ url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
DriverManager.registerDriver(PhoenixDriver.INSTANCE);
DriverManager.registerDriver(new PhoenixTestDriver());
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java
index d85df7e68b..5a6f94c960 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java
@@ -40,6 +40,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
+import org.apache.phoenix.jdbc.ConnectionInfo;
import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.jdbc.PhoenixDriver;
import org.apache.phoenix.jdbc.PhoenixStatement;
@@ -75,7 +76,7 @@ public class PhoenixDriverIT extends BaseTest {
hbaseTestUtil.startMiniCluster();
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort();
- url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
+ url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
DriverManager.registerDriver(PhoenixDriver.INSTANCE);
}
@@ -85,12 +86,14 @@ public class PhoenixDriverIT extends BaseTest {
// force the use of ConnectionQueryServicesImpl instead of
ConnectionQueryServicesTestImpl
props.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
- if (tenantId!=null)
+ if (tenantId!=null) {
props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
- StringBuilder sb = new StringBuilder(url);
- if (isDifferentClient)
- sb.append(PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + "Client2");
- return DriverManager.getConnection(sb.toString(), props);
+ }
+ if (isDifferentClient) {
+ ConnectionInfo info = ConnectionInfo.createNoLogin(url, null,
props);
+ return
DriverManager.getConnection(info.withPrincipal(tenantId).toUrl(), props);
+ }
+ return DriverManager.getConnection(url, props);
}
@Test
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java
index 7fd66da08b..a0b5ff1145 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java
@@ -70,7 +70,7 @@ public class RebuildIndexConnectionPropsIT extends BaseTest {
hbaseTestUtil.startMiniCluster();
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort();
- url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
+ url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
Properties driverProps = PropertiesUtil.deepCopy(TEST_PROPERTIES);
DriverManager.registerDriver(PhoenixDriver.INSTANCE);
try (PhoenixConnection phxConn =
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
index 76f5a701eb..a9d0f69cda 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java
@@ -10,6 +10,7 @@
*/
package org.apache.phoenix.end2end;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.phoenix.thirdparty.com.google.common.base.Throwables;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
@@ -19,6 +20,7 @@ import org.apache.phoenix.exception.PhoenixIOException;
import org.apache.phoenix.jdbc.PhoenixConnection;
import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
import org.apache.phoenix.jdbc.PhoenixDriver;
+import org.apache.phoenix.jdbc.ZKConnectionInfo;
import org.apache.phoenix.query.BaseTest;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
@@ -71,6 +73,8 @@ public class UpdateCacheAcrossDifferentClientsIT extends
BaseTest {
longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
longRunningProps.put(QueryServices.DROP_METADATA_ATTRIB,
Boolean.TRUE.toString());
+
longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
+
Connection conn1 = DriverManager.getConnection(url, longRunningProps);
String url2 = url + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR +
"LongRunningQueries";
Connection conn2 = DriverManager.getConnection(url2, longRunningProps);
@@ -136,6 +140,7 @@ public class UpdateCacheAcrossDifferentClientsIT extends
BaseTest {
longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
longRunningProps.put(QueryServices.DROP_METADATA_ATTRIB,
Boolean.TRUE.toString());
+
longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
Connection conn1 = DriverManager.getConnection(url, longRunningProps);
String url2 = url + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR +
"LongRunningQueries";
Connection conn2 = DriverManager.getConnection(url2, longRunningProps);
@@ -171,6 +176,7 @@ public class UpdateCacheAcrossDifferentClientsIT extends
BaseTest {
public void testUpdateCacheFrequencyWithAddColumn() throws Exception {
// Create connections 1 and 2
Properties longRunningProps = new Properties(); // Must update config
before starting server
+
longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
Connection conn1 = DriverManager.getConnection(url, longRunningProps);
Connection conn2 = DriverManager.getConnection(url, longRunningProps);
conn1.setAutoCommit(true);
@@ -218,6 +224,7 @@ public class UpdateCacheAcrossDifferentClientsIT extends
BaseTest {
Properties longRunningProps = new Properties();
longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
+
longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
Connection conn1 = DriverManager.getConnection(url, longRunningProps);
String url2 = url + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR +
"LongRunningQueries";
Connection conn2 = DriverManager.getConnection(url2, longRunningProps);
@@ -269,6 +276,7 @@ public class UpdateCacheAcrossDifferentClientsIT extends
BaseTest {
Properties longRunningProps = new Properties();
longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
+
longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
Connection conn1 = DriverManager.getConnection(url, longRunningProps);
String url2 = url + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR +
"LongRunningQueries";
Connection conn2 = DriverManager.getConnection(url2, longRunningProps);
@@ -316,6 +324,7 @@ public class UpdateCacheAcrossDifferentClientsIT extends
BaseTest {
Properties longRunningProps = new Properties();
longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
+
longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
Connection conn1 = DriverManager.getConnection(url, longRunningProps);
String url2 = url + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR +
"LongRunningQueries";
Connection conn2 = DriverManager.getConnection(url2, longRunningProps);
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
index fa8c8ffe57..624fda60e6 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UserDefinedFunctionsIT.java
@@ -20,7 +20,7 @@ package org.apache.phoenix.end2end;
import static
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA;
import static
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_FUNCTION_TABLE;
import static org.apache.phoenix.query.QueryServices.DYNAMIC_JARS_DIR_KEY;
-import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_ZK;
import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
import static
org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
@@ -289,7 +289,7 @@ public class UserDefinedFunctionsIT extends
BaseOwnClusterIT {
String clientPort =
util.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
url =
- JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + LOCALHOST +
JDBC_PROTOCOL_SEPARATOR
+ JDBC_PROTOCOL_ZK + JDBC_PROTOCOL_SEPARATOR + LOCALHOST +
JDBC_PROTOCOL_SEPARATOR
+ clientPort + JDBC_PROTOCOL_TERMINATOR +
PHOENIX_TEST_DRIVER_URL_PARAM;
Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
props.put(QueryServices.ALLOW_USER_DEFINED_FUNCTIONS_ATTRIB, "true");
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/iterate/ScannerLeaseRenewalIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/iterate/ScannerLeaseRenewalIT.java
index 42876eae60..b332b070ac 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/iterate/ScannerLeaseRenewalIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/iterate/ScannerLeaseRenewalIT.java
@@ -71,7 +71,7 @@ public class ScannerLeaseRenewalIT {
hbaseTestUtil.startMiniCluster();
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort();
- url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
+ url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
Properties driverProps = PropertiesUtil.deepCopy(TEST_PROPERTIES);
driverProps.put(RENEW_LEASE_THREAD_POOL_SIZE, Long.toString(4));
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/FailoverPhoenixConnectionIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/FailoverPhoenixConnectionIT.java
index 29c5f2f1b0..de2486fb51 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/FailoverPhoenixConnectionIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/FailoverPhoenixConnectionIT.java
@@ -245,7 +245,7 @@ public class FailoverPhoenixConnectionIT {
*/
@Test(timeout = 300000)
public void testNonHAConnectionNotClosedAfterFailover() throws Exception {
- String firstUrl = String.format("jdbc:phoenix:%s", CLUSTERS.getUrl1());
+ String firstUrl = String.format("jdbc:phoenix+zk:%s",
CLUSTERS.getUrl1());
// This is a vanilla Phoenix connection without using high
availability (HA) feature.
Connection phoenixConn = DriverManager.getConnection(firstUrl, new
Properties());
Connection failoverConn = createFailoverConnection();
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityGroupIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityGroupIT.java
index 5f1b86fdaa..9acad37044 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityGroupIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityGroupIT.java
@@ -49,6 +49,7 @@ import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.jdbc.ClusterRoleRecord.ClusterRole;
import
org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.HBaseTestingUtilityPair;
+import org.apache.phoenix.util.PhoenixRuntime;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -796,7 +797,7 @@ public class HighAvailabilityGroupIT {
if (CLUSTERS.getUrl1().compareTo(CLUSTERS.getUrl2()) > 0) {
firstClusterUrl = CLUSTERS.getUrl2();
}
- assertEquals(firstClusterUrl, ((PhoenixConnection) conn).getURL());
+ assertEquals(PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + firstClusterUrl, ((PhoenixConnection)
conn).getURL());
doTestBasicOperationsWithConnection(conn, tableName, haGroupName2);
}
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/LoggingSingleConnectionLimiterIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/LoggingSingleConnectionLimiterIT.java
index f5b1330def..b35e348b50 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/LoggingSingleConnectionLimiterIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/LoggingSingleConnectionLimiterIT.java
@@ -20,6 +20,7 @@ package org.apache.phoenix.jdbc;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
import org.apache.phoenix.log.ConnectionLimiter;
import org.apache.phoenix.query.ConfigurationFactory;
@@ -64,6 +65,7 @@ public class LoggingSingleConnectionLimiterIT extends
LoggingConnectionLimiterIT
conf.set(QueryServices.INTERNAL_CONNECTION_MAX_ALLOWED_CONNECTIONS,
String.valueOf(20));
conf.set(PhoenixHAExecutorServiceProvider.HA_MAX_POOL_SIZE,
String.valueOf(5));
conf.set(PhoenixHAExecutorServiceProvider.HA_MAX_QUEUE_SIZE,
String.valueOf(30));
+ conf.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
return conf;
}
@@ -74,6 +76,7 @@ public class LoggingSingleConnectionLimiterIT extends
LoggingConnectionLimiterIT
conf.set(QueryServices.INTERNAL_CONNECTION_MAX_ALLOWED_CONNECTIONS,
String.valueOf(20));
conf.set(PhoenixHAExecutorServiceProvider.HA_MAX_POOL_SIZE,
String.valueOf(5));
conf.set(PhoenixHAExecutorServiceProvider.HA_MAX_QUEUE_SIZE,
String.valueOf(30));
+ conf.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
Configuration copy = new Configuration(conf);
copy.addResource(confToClone);
return copy;
@@ -90,9 +93,10 @@ public class LoggingSingleConnectionLimiterIT extends
LoggingConnectionLimiterIT
DriverManager.registerDriver(PhoenixDriver.INSTANCE);
DriverManager.registerDriver(new PhoenixTestDriver());
String profileName = "setup";
- final String urlWithPrinc = url +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + profileName
- + PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
Properties props = new Properties();
+ final String urlWithPrinc =
+ ConnectionInfo.createNoLogin(url, null,
props).withPrincipal("nocache")
+ .toUrl();
try (Connection connection = DriverManager.getConnection(urlWithPrinc,
props)) {
try (Statement statement = connection.createStatement()) {
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/SecureUserConnectionsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/SecureUserConnectionsIT.java
index 47d7c0424b..d17a73f085 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/SecureUserConnectionsIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/SecureUserConnectionsIT.java
@@ -33,6 +33,7 @@ import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
@@ -99,6 +100,7 @@ public class SecureUserConnectionsIT {
conf.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION,
"kerberos");
conf.set(User.HBASE_SECURITY_CONF_KEY, "kerberos");
conf.setBoolean(User.HBASE_SECURITY_AUTHORIZATION_CONF_KEY, true);
+ conf.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
ZKConnectionInfo.ZK_REGISTRY_NAME);
UserGroupInformation.setConfiguration(conf);
// Clear the cached singletons so we can inject our own.
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
index f3495fef91..ed0d319dea 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
@@ -1059,7 +1059,7 @@ public class PhoenixMetricsIT extends
BasePhoenixMetricsIT {
public void testGetConnectionsForSameUrlConcurrently() throws Exception {
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
String zkQuorum = "localhost:" +
getUtility().getZkCluster().getClientPort();
- String url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
+ String url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
ExecutorService exec = Executors.newFixedThreadPool(10);
try {
GLOBAL_HCONNECTIONS_COUNTER.getMetric().reset();
@@ -1093,7 +1093,7 @@ public class PhoenixMetricsIT extends
BasePhoenixMetricsIT {
int maxConnections = attemptedPhoenixConnections -1;
List<Connection> connections = Lists.newArrayList();
String zkQuorum = "localhost:" +
getUtility().getZkCluster().getClientPort();
- String url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum +
+ String url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum +
':' + CUSTOM_URL_STRING + '=' + "throttletest";
Properties props = new Properties();
@@ -1147,7 +1147,7 @@ public class PhoenixMetricsIT extends
BasePhoenixMetricsIT {
int maxConnections = attemptedPhoenixConnections - 4;
List<Connection> connections = Lists.newArrayList();
String zkQuorum = "localhost:" +
getUtility().getZkCluster().getClientPort();
- String url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum +
+ String url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum +
':' + CUSTOM_URL_STRING + '=' + "FailedCounterTest";
Properties props = new Properties();
props.setProperty(QueryServices.CLIENT_CONNECTION_MAX_ALLOWED_CONNECTIONS,
Integer.toString(maxConnections));
@@ -1199,7 +1199,7 @@ public class PhoenixMetricsIT extends
BasePhoenixMetricsIT {
props1.setProperty(HBASE_CLIENT_RETRIES_NUMBER, Integer.toString(2));
props1.setProperty("zookeeper.recovery.retry", Integer.toString(2));
try {
- DriverManager.getConnection(PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + "jdbcthisIsBadZk", props1);
+ DriverManager.getConnection(PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + "jdbcthisIsBadZk", props1);
} catch (Exception e) {
assertEquals(4,
GLOBAL_FAILED_PHOENIX_CONNECTIONS.getMetric().getValue());
assertEquals(attemptedPhoenixConnections + 1,
GLOBAL_PHOENIX_CONNECTIONS_ATTEMPTED_COUNTER.getMetric().getValue());
@@ -1212,7 +1212,7 @@ public class PhoenixMetricsIT extends
BasePhoenixMetricsIT {
public void testGetConnectionsForDifferentTenantsConcurrently() throws
Exception {
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
String zkQuorum = "localhost:" +
getUtility().getZkCluster().getClientPort();
- String url = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
+ String url = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
ExecutorService exec = Executors.newFixedThreadPool(10);
try {
GLOBAL_HCONNECTIONS_COUNTER.getMetric().reset();
@@ -1247,7 +1247,7 @@ public class PhoenixMetricsIT extends
BasePhoenixMetricsIT {
ExecutorService exec = Executors.newFixedThreadPool(4);
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
String zkQuorum = "localhost:" +
getUtility().getZkCluster().getClientPort();
- String baseUrl = PhoenixRuntime.JDBC_PROTOCOL +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
+ String baseUrl = PhoenixRuntime.JDBC_PROTOCOL_ZK +
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
int numConnections = 20;
List<Callable<Connection>> callables = new ArrayList<>(numConnections);
List<Future<Connection>> futures = new ArrayList<>(numConnections);
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java
index 1a1280e12a..f46723cf2d 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixTableLevelMetricsIT.java
@@ -184,7 +184,7 @@ public class PhoenixTableLevelMetricsIT extends BaseTest {
hbaseTestUtil.startMiniCluster(1, 1, null, null,
DelayedOrFailingRegionServer.class);
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
String zkQuorum = "localhost:" +
hbaseTestUtil.getZkCluster().getClientPort();
- url = PhoenixRuntime.JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR +
zkQuorum;
+ url = PhoenixRuntime.JDBC_PROTOCOL_ZK + JDBC_PROTOCOL_SEPARATOR +
zkQuorum;
// Add our own driver
Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/query/MaxConcurrentConnectionsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/query/MaxConcurrentConnectionsIT.java
index dacd07ee19..43065582ff 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/query/MaxConcurrentConnectionsIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/query/MaxConcurrentConnectionsIT.java
@@ -67,7 +67,7 @@ public class MaxConcurrentConnectionsIT extends BaseTest {
hbaseTestUtil.startMiniCluster(1,1,null,null,DelayedRegionServer.class);
// establish url and quorum. Need to use PhoenixDriver and not
PhoenixTestDriver
String zkQuorum = "localhost:" +
hbaseTestUtil.getZkCluster().getClientPort();
- url = PhoenixRuntime.JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR +
zkQuorum +
+ url = PhoenixRuntime.JDBC_PROTOCOL_ZK + JDBC_PROTOCOL_SEPARATOR +
zkQuorum +
JDBC_PROTOCOL_SEPARATOR + "uniqueConn=A";
DriverManager.registerDriver(PhoenixDriver.INSTANCE);
DriverManager.registerDriver(new PhoenixTestDriver());
diff --git
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
index fe439d7462..c4d6f83a48 100644
---
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
+++
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
@@ -41,6 +41,9 @@ public class PhoenixEmbeddedDriverTest {
@Test
public void testGetZKConnectionInfo() throws SQLException {
Configuration config =
HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ // Need to set explicitly for HBase 3.x
+ config.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
+ "org.apache.hadoop.hbase.client.ZKConnectionRegistry");
String defaultQuorum = config.get(HConstants.ZOOKEEPER_QUORUM);
for (String protocol : new String[] { "phoenix", "phoenix+zk" }) {
@@ -130,7 +133,7 @@ public class PhoenixEmbeddedDriverTest {
int pos = 0;
try {
ZKConnectionInfo info =
- (ZKConnectionInfo) ConnectionInfo.create(urls[i],
null, null);
+ (ZKConnectionInfo) ConnectionInfo.create(urls[i],
config, null, null);
String[] parts = partsList[i];
if (parts.length > pos) {
assertEquals(parts[pos], info.getZkHosts());
diff --git
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixHAAdminToolTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixHAAdminToolTest.java
index 9b46355171..eeafec80ba 100644
---
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixHAAdminToolTest.java
+++
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixHAAdminToolTest.java
@@ -276,14 +276,14 @@ public class PhoenixHAAdminToolTest {
Configuration conf = HBaseConfiguration.create();
// default local ZK is 127.0.0.1:2181:/hbase
final String localZk = String.format("127.0.0.1:%d:%s",
- HConstants.DEFAULT_ZOOKEPER_CLIENT_PORT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
+ HConstants.DEFAULT_ZOOKEEPER_CLIENT_PORT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
assertEquals(localZk, getLocalZkUrl(conf));
// set host name only; use default port and znode parent
final String host = "foobar";
conf.set(HConstants.ZOOKEEPER_QUORUM, "foobar");
final String expectedLocalZk = String.format("%s:%d:%s", host,
- HConstants.DEFAULT_ZOOKEPER_CLIENT_PORT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
+ HConstants.DEFAULT_ZOOKEEPER_CLIENT_PORT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
assertEquals(expectedLocalZk, getLocalZkUrl(conf));
// set host name and port; use default znode parent