This is an automated email from the ASF dual-hosted git repository.
lokiore 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 095617f387 PHOENIX-7464 :- Performance Regression in Connection
Initialization due to Configuration Handling in ConnInfo (#2027)
095617f387 is described below
commit 095617f387600df459bbf5a41cece57875bf5d07
Author: Lokesh Khurana <[email protected]>
AuthorDate: Sun Dec 1 12:24:02 2024 -0800
PHOENIX-7464 :- Performance Regression in Connection Initialization due to
Configuration Handling in ConnInfo (#2027)
Co-authored-by: lokesh-khurana <[email protected]>
---
.../org/apache/phoenix/jdbc/ConnectionInfo.java | 54 +++++++++++++++++-----
1 file changed, 42 insertions(+), 12 deletions(-)
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
index 945060c153..3acfef801a 100644
---
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
+++
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
@@ -59,6 +59,19 @@ public abstract class ConnectionInfo {
protected static final boolean HAS_MASTER_REGISTRY;
protected static final boolean HAS_RPC_REGISTRY;
+ private static volatile Configuration configuration;
+
+ public static Configuration getCachedConfiguration() {
+ if (configuration == null) {
+ synchronized (ConnectionInfo.class) {
+ if (configuration == null) {
+ configuration =
HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ }
+ }
+ }
+ return configuration;
+ }
+
static {
String version = VersionInfo.getVersion();
if (VersionInfo.getMajorVersion(version) >= 3) {
@@ -107,14 +120,12 @@ public abstract class ConnectionInfo {
public static ConnectionInfo createNoLogin(String url, ReadOnlyProps
props, Properties info)
throws SQLException {
- Configuration conf =
HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
- return create(url, conf, props, info, true);
+ return create(url, getCachedConfiguration(), props, info, true);
}
public static ConnectionInfo create(String url, ReadOnlyProps props,
Properties info)
throws SQLException {
- Configuration conf =
HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
- return create(url, conf, props, info);
+ return create(url, getCachedConfiguration(), props, info);
}
public static ConnectionInfo createNoLogin(String url, Configuration
configuration,
@@ -482,15 +493,10 @@ public abstract class ConnectionInfo {
LOGGER.info("Trying to connect to a secure
cluster as {} "
+ "with keytab {}",
principal, keytab);
+ final Configuration newConfig =
getConfiguration(principal, keytab);
// We are intentionally changing the passed in
Configuration object
- if (null != principal) {
-
config.set(QueryServices.HBASE_CLIENT_PRINCIPAL, principal);
- }
- if (null != keytab) {
-
config.set(QueryServices.HBASE_CLIENT_KEYTAB, keytab);
- }
- UserGroupInformation.setConfiguration(config);
- User.login(config,
QueryServices.HBASE_CLIENT_KEYTAB,
+
UserGroupInformation.setConfiguration(newConfig);
+ User.login(newConfig,
QueryServices.HBASE_CLIENT_KEYTAB,
QueryServices.HBASE_CLIENT_PRINCIPAL,
null);
user = User.getCurrent();
LOGGER.info("Successful login to secure
cluster");
@@ -510,6 +516,30 @@ public abstract class ConnectionInfo {
}
}
+ private Configuration getConfiguration( String principal, String
keytab) {
+ final Configuration config =
HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
+ // Add QueryServices properties
+ if (props != null) {
+ for (Entry<String,String> entry : props) {
+ config.set(entry.getKey(), entry.getValue());
+ }
+ }
+ // Add any user-provided properties (via DriverManager)
+ if (info != null) {
+ for (Object key : info.keySet()) {
+ config.set((String) key, info.getProperty((String) key));
+ }
+ }
+ // Set the principal and keytab if provided from the URL
(overriding those provided in Properties)
+ if (null != principal) {
+ config.set(QueryServices.HBASE_CLIENT_PRINCIPAL, principal);
+ }
+ if (null != keytab) {
+ config.set(QueryServices.HBASE_CLIENT_KEYTAB, keytab);
+ }
+ return config;
+ }
+
protected String normalizeHostsList(String quorum, Integer defaultPort)
throws SQLException {
// The input host:port separator char is "=" (after unescaping)