(hbase) branch branch-2 updated: HBASE-28436 Use connection url to specify the connection registry information (#5770) (#5847)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-2 in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/branch-2 by this push: new 24118e04850 HBASE-28436 Use connection url to specify the connection registry information (#5770) (#5847) 24118e04850 is described below commit 24118e0485002b3472fe0b3f5b2c0eab1f8243f9 Author: Duo Zhang AuthorDate: Wed Apr 24 11:03:59 2024 +0800 HBASE-28436 Use connection url to specify the connection registry information (#5770) (#5847) Signed-off-by: Istvan Toth Signed-off-by: Nick Dimiduk Reviewed-by: Bryan Beaudreault (cherry picked from commit e3761baec1158d617c46bbdf54725206544717e9) --- hbase-client/pom.xml | 5 + .../hadoop/hbase/client/ConnectionFactory.java | 322 + .../hbase/client/ConnectionImplementation.java | 2 +- .../hbase/client/ConnectionRegistryFactory.java| 62 +++- ...tory.java => ConnectionRegistryURIFactory.java} | 27 +- .../hadoop/hbase/client/ConnectionUtils.java | 4 +- ...tory.java => RpcConnectionRegistryCreator.java} | 30 +- ...ctory.java => ZKConnectionRegistryCreator.java} | 33 ++- ...adoop.hbase.client.ConnectionRegistryURIFactory | 17 ++ .../hadoop/hbase/client/TestClientNoCluster.java | 12 +- .../TestConnectionRegistryCreatorUriParsing.java | 157 ++ .../hbase/client/AbstractTestRegionLocator.java| 2 +- .../client/TestAsyncAdminWithRegionReplicas.java | 2 +- .../hbase/client/TestAsyncMetaRegionLocator.java | 3 +- .../client/TestAsyncNonMetaRegionLocator.java | 2 +- ...stAsyncNonMetaRegionLocatorConcurrenyLimit.java | 2 +- .../hbase/client/TestAsyncRegionLocator.java | 2 +- .../TestAsyncSingleRequestRpcRetryingCaller.java | 2 +- .../client/TestAsyncTableUseMetaReplicas.java | 3 +- ...ReadWriteWithDifferentConnectionRegistries.java | 177 +++ ...estCatalogReplicaLoadBalanceSimpleSelector.java | 3 +- .../hbase/client/TestMetaRegionLocationCache.java | 3 +- 22 files changed, 752 insertions(+), 120 deletions(-) diff --git a/hbase-client/pom.xml b/hbase-client/pom.xml index 8f476fd4815..8343037a233 100644 --- a/hbase-client/pom.xml +++ b/hbase-client/pom.xml @@ -182,6 +182,11 @@ mockito-core test + + org.mockito + mockito-inline + test + org.hamcrest hamcrest-library diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java index 0a95d1b195e..de5981b4041 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java @@ -21,6 +21,7 @@ import static org.apache.hadoop.hbase.util.FutureUtils.addListener; import java.io.IOException; import java.lang.reflect.Constructor; +import java.net.URI; import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.Map; @@ -32,6 +33,7 @@ import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.trace.TraceUtil; +import org.apache.hadoop.hbase.util.FutureUtils; import org.apache.hadoop.hbase.util.ReflectionUtils; import org.apache.yetus.audience.InterfaceAudience; @@ -88,41 +90,55 @@ public class ConnectionFactory { * instance. Typical usage: * * - * Connection connection = ConnectionFactory.createConnection(); - * Table table = connection.getTable(TableName.valueOf("mytable")); - * try { + * try (Connection connection = ConnectionFactory.createConnection(conf); + * Table table = connection.getTable(TableName.valueOf("table1"))) { * table.get(...); * ... - * } finally { - * table.close(); - * connection.close(); * } * * * @return Connection object for conf */ public static Connection createConnection() throws IOException { -Configuration conf = HBaseConfiguration.create(); -return createConnection(conf, null, AuthUtil.loginClient(conf), Collections.emptyMap()); +return createConnection(HBaseConfiguration.create()); + } + + /** + * Create a new Connection instance using default HBaseConfiguration. Connection encapsulates all + * housekeeping for a connection to the cluster. All tables and interfaces created from returned + * connection share zookeeper connection, meta cache, and connections to region servers and + * masters. + * The caller is responsible for calling {@link Connection#close()} on the returned connection + * instance. Typical usage: + * + * + * try (Connection connection =
(hbase) branch branch-2 updated: HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-2 in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/branch-2 by this push: new 8b5d059ee84 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) 8b5d059ee84 is described below commit 8b5d059ee84209c77f195da0f3f2ee9468fe6ce6 Author: Duo Zhang AuthorDate: Tue Apr 23 21:57:47 2024 +0800 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) Signed-off-by: Wellington Chevreuil Reviewed-by: Andor Molnár Reviewed-by: BukrosSzabolcs (cherry picked from commit 6c6e776eea6ebd62a3a030a1820c4eef2636553c) --- .../hadoop/hbase/zookeeper/ReadOnlyZKClient.java | 13 ++-- .../apache/hadoop/hbase/zookeeper/ZKConfig.java| 29 - .../hadoop/hbase/zookeeper/TestZKConfig.java | 47 ++ .../hbase/zookeeper/RecoverableZooKeeper.java | 75 ++ .../apache/hadoop/hbase/zookeeper/ZKWatcher.java | 4 +- .../hbase/zookeeper/TestRecoverableZooKeeper.java | 2 +- 6 files changed, 62 insertions(+), 108 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java index 979094fda80..64b151dc19a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java @@ -38,6 +38,7 @@ import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.ZooKeeper; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,6 +76,8 @@ public final class ReadOnlyZKClient implements Closeable { private final int keepAliveTimeMs; + private final ZKClientConfig zkClientConfig; + private static abstract class Task implements Delayed { protected long time = System.nanoTime(); @@ -136,10 +139,12 @@ public final class ReadOnlyZKClient implements Closeable { this.retryIntervalMs = conf.getInt(RECOVERY_RETRY_INTERVAL_MILLIS, DEFAULT_RECOVERY_RETRY_INTERVAL_MILLIS); this.keepAliveTimeMs = conf.getInt(KEEPALIVE_MILLIS, DEFAULT_KEEPALIVE_MILLIS); +this.zkClientConfig = ZKConfig.getZKClientConfig(conf); LOG.debug( - "Connect {} to {} with session timeout={}ms, retries {}, " -+ "retry interval {}ms, keepAlive={}ms", - getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs); + "Connect {} to {} with session timeout={}ms, retries={}, " ++ "retry interval={}ms, keepAlive={}ms, zk client config={}", + getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs, + zkClientConfig); Threads.setDaemonThreadRunning(new Thread(this::run), "ReadOnlyZKClient-" + connectString + "@" + getId()); } @@ -316,7 +321,7 @@ public final class ReadOnlyZKClient implements Closeable { // may be closed when session expired if (zookeeper == null || !zookeeper.getState().isAlive()) { zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> { - }); + }, zkClientConfig); } return zookeeper; } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java index 5c24418214b..0edde8da266 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java @@ -25,19 +25,22 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.util.StringUtils; import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.hbase.thirdparty.com.google.common.base.Splitter; /** * Utility methods for reading, and building the ZooKeeper configuration. The order and priority for - * reading the config are as follows: (1). Property with "hbase.zookeeper.property." prefix from - * HBase XML (2). other zookeeper related properties in HBASE XML + * reading the config are as follows: + * + * Property with "hbase.zookeeper.property." prefix from HBase XML. + * other zookeeper related properties in HBASE XML + * */ @InterfaceAudience.Private public final class ZKConfig { private static final String VARIABLE_START = "${"; - private static final String ZOOKEEPER_JAVA_PROPERTY_PREFIX = "zookeeper."; private ZKConfig() { } @@ -131,7 +134,6 @@ public
(hbase) branch branch-2.6 updated: HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-2.6 in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/branch-2.6 by this push: new cb4e11f5fb8 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) cb4e11f5fb8 is described below commit cb4e11f5fb818fb3058b341b57cd51f6d1689e51 Author: Duo Zhang AuthorDate: Tue Apr 23 21:57:47 2024 +0800 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) Signed-off-by: Wellington Chevreuil Reviewed-by: Andor Molnár Reviewed-by: BukrosSzabolcs (cherry picked from commit 6c6e776eea6ebd62a3a030a1820c4eef2636553c) --- .../hadoop/hbase/zookeeper/ReadOnlyZKClient.java | 13 ++-- .../apache/hadoop/hbase/zookeeper/ZKConfig.java| 29 - .../hadoop/hbase/zookeeper/TestZKConfig.java | 47 ++ .../hbase/zookeeper/RecoverableZooKeeper.java | 75 ++ .../apache/hadoop/hbase/zookeeper/ZKWatcher.java | 4 +- .../hbase/zookeeper/TestRecoverableZooKeeper.java | 2 +- 6 files changed, 62 insertions(+), 108 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java index 979094fda80..64b151dc19a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java @@ -38,6 +38,7 @@ import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.ZooKeeper; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,6 +76,8 @@ public final class ReadOnlyZKClient implements Closeable { private final int keepAliveTimeMs; + private final ZKClientConfig zkClientConfig; + private static abstract class Task implements Delayed { protected long time = System.nanoTime(); @@ -136,10 +139,12 @@ public final class ReadOnlyZKClient implements Closeable { this.retryIntervalMs = conf.getInt(RECOVERY_RETRY_INTERVAL_MILLIS, DEFAULT_RECOVERY_RETRY_INTERVAL_MILLIS); this.keepAliveTimeMs = conf.getInt(KEEPALIVE_MILLIS, DEFAULT_KEEPALIVE_MILLIS); +this.zkClientConfig = ZKConfig.getZKClientConfig(conf); LOG.debug( - "Connect {} to {} with session timeout={}ms, retries {}, " -+ "retry interval {}ms, keepAlive={}ms", - getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs); + "Connect {} to {} with session timeout={}ms, retries={}, " ++ "retry interval={}ms, keepAlive={}ms, zk client config={}", + getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs, + zkClientConfig); Threads.setDaemonThreadRunning(new Thread(this::run), "ReadOnlyZKClient-" + connectString + "@" + getId()); } @@ -316,7 +321,7 @@ public final class ReadOnlyZKClient implements Closeable { // may be closed when session expired if (zookeeper == null || !zookeeper.getState().isAlive()) { zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> { - }); + }, zkClientConfig); } return zookeeper; } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java index 5c24418214b..0edde8da266 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java @@ -25,19 +25,22 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.util.StringUtils; import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.hbase.thirdparty.com.google.common.base.Splitter; /** * Utility methods for reading, and building the ZooKeeper configuration. The order and priority for - * reading the config are as follows: (1). Property with "hbase.zookeeper.property." prefix from - * HBase XML (2). other zookeeper related properties in HBASE XML + * reading the config are as follows: + * + * Property with "hbase.zookeeper.property." prefix from HBase XML. + * other zookeeper related properties in HBASE XML + * */ @InterfaceAudience.Private public final class ZKConfig { private static final String VARIABLE_START = "${"; - private static final String ZOOKEEPER_JAVA_PROPERTY_PREFIX = "zookeeper."; private ZKConfig() { } @@ -131,7 +134,6 @@
(hbase) branch branch-2.5 updated: HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-2.5 in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/branch-2.5 by this push: new 28501d83b70 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) 28501d83b70 is described below commit 28501d83b70a9ce97cba8d21db2523d27a418c16 Author: Duo Zhang AuthorDate: Tue Apr 23 21:57:47 2024 +0800 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) Signed-off-by: Wellington Chevreuil Reviewed-by: Andor Molnár Reviewed-by: BukrosSzabolcs (cherry picked from commit 6c6e776eea6ebd62a3a030a1820c4eef2636553c) --- .../hadoop/hbase/zookeeper/ReadOnlyZKClient.java | 13 ++-- .../apache/hadoop/hbase/zookeeper/ZKConfig.java| 29 - .../hadoop/hbase/zookeeper/TestZKConfig.java | 47 ++ .../hbase/zookeeper/RecoverableZooKeeper.java | 75 ++ .../apache/hadoop/hbase/zookeeper/ZKWatcher.java | 4 +- .../hbase/zookeeper/TestRecoverableZooKeeper.java | 2 +- 6 files changed, 62 insertions(+), 108 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java index 979094fda80..64b151dc19a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java @@ -38,6 +38,7 @@ import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.ZooKeeper; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,6 +76,8 @@ public final class ReadOnlyZKClient implements Closeable { private final int keepAliveTimeMs; + private final ZKClientConfig zkClientConfig; + private static abstract class Task implements Delayed { protected long time = System.nanoTime(); @@ -136,10 +139,12 @@ public final class ReadOnlyZKClient implements Closeable { this.retryIntervalMs = conf.getInt(RECOVERY_RETRY_INTERVAL_MILLIS, DEFAULT_RECOVERY_RETRY_INTERVAL_MILLIS); this.keepAliveTimeMs = conf.getInt(KEEPALIVE_MILLIS, DEFAULT_KEEPALIVE_MILLIS); +this.zkClientConfig = ZKConfig.getZKClientConfig(conf); LOG.debug( - "Connect {} to {} with session timeout={}ms, retries {}, " -+ "retry interval {}ms, keepAlive={}ms", - getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs); + "Connect {} to {} with session timeout={}ms, retries={}, " ++ "retry interval={}ms, keepAlive={}ms, zk client config={}", + getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs, + zkClientConfig); Threads.setDaemonThreadRunning(new Thread(this::run), "ReadOnlyZKClient-" + connectString + "@" + getId()); } @@ -316,7 +321,7 @@ public final class ReadOnlyZKClient implements Closeable { // may be closed when session expired if (zookeeper == null || !zookeeper.getState().isAlive()) { zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> { - }); + }, zkClientConfig); } return zookeeper; } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java index 5c24418214b..0edde8da266 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java @@ -25,19 +25,22 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.util.StringUtils; import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.hbase.thirdparty.com.google.common.base.Splitter; /** * Utility methods for reading, and building the ZooKeeper configuration. The order and priority for - * reading the config are as follows: (1). Property with "hbase.zookeeper.property." prefix from - * HBase XML (2). other zookeeper related properties in HBASE XML + * reading the config are as follows: + * + * Property with "hbase.zookeeper.property." prefix from HBase XML. + * other zookeeper related properties in HBASE XML + * */ @InterfaceAudience.Private public final class ZKConfig { private static final String VARIABLE_START = "${"; - private static final String ZOOKEEPER_JAVA_PROPERTY_PREFIX = "zookeeper."; private ZKConfig() { } @@ -131,7 +134,6 @@
(hbase-site) branch asf-site updated: INFRA-10751 Empty commit
This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/hbase-site.git The following commit(s) were added to refs/heads/asf-site by this push: new 1b5b4ad31ca INFRA-10751 Empty commit 1b5b4ad31ca is described below commit 1b5b4ad31ca23dfbf6b58ce082f010b4ef33b332 Author: jenkins AuthorDate: Tue Apr 23 14:44:00 2024 + INFRA-10751 Empty commit
(hbase) branch branch-3 updated: HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-3 in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/branch-3 by this push: new 5d8619fdf9f HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) 5d8619fdf9f is described below commit 5d8619fdf9fe26a1f461b7bb82274597c2916b1b Author: Duo Zhang AuthorDate: Tue Apr 23 21:57:47 2024 +0800 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) Signed-off-by: Wellington Chevreuil Reviewed-by: Andor Molnár Reviewed-by: BukrosSzabolcs (cherry picked from commit 6c6e776eea6ebd62a3a030a1820c4eef2636553c) --- .../hadoop/hbase/zookeeper/ReadOnlyZKClient.java | 13 ++-- .../apache/hadoop/hbase/zookeeper/ZKConfig.java| 29 - .../hadoop/hbase/zookeeper/TestZKConfig.java | 47 ++ .../hbase/zookeeper/RecoverableZooKeeper.java | 75 ++ .../apache/hadoop/hbase/zookeeper/ZKWatcher.java | 4 +- .../hbase/zookeeper/TestRecoverableZooKeeper.java | 2 +- 6 files changed, 62 insertions(+), 108 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java index 979094fda80..64b151dc19a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java @@ -38,6 +38,7 @@ import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.ZooKeeper; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,6 +76,8 @@ public final class ReadOnlyZKClient implements Closeable { private final int keepAliveTimeMs; + private final ZKClientConfig zkClientConfig; + private static abstract class Task implements Delayed { protected long time = System.nanoTime(); @@ -136,10 +139,12 @@ public final class ReadOnlyZKClient implements Closeable { this.retryIntervalMs = conf.getInt(RECOVERY_RETRY_INTERVAL_MILLIS, DEFAULT_RECOVERY_RETRY_INTERVAL_MILLIS); this.keepAliveTimeMs = conf.getInt(KEEPALIVE_MILLIS, DEFAULT_KEEPALIVE_MILLIS); +this.zkClientConfig = ZKConfig.getZKClientConfig(conf); LOG.debug( - "Connect {} to {} with session timeout={}ms, retries {}, " -+ "retry interval {}ms, keepAlive={}ms", - getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs); + "Connect {} to {} with session timeout={}ms, retries={}, " ++ "retry interval={}ms, keepAlive={}ms, zk client config={}", + getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs, + zkClientConfig); Threads.setDaemonThreadRunning(new Thread(this::run), "ReadOnlyZKClient-" + connectString + "@" + getId()); } @@ -316,7 +321,7 @@ public final class ReadOnlyZKClient implements Closeable { // may be closed when session expired if (zookeeper == null || !zookeeper.getState().isAlive()) { zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> { - }); + }, zkClientConfig); } return zookeeper; } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java index 87885e2b9fd..57009eca660 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java @@ -26,19 +26,22 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.util.StringUtils; import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.hbase.thirdparty.com.google.common.base.Splitter; /** * Utility methods for reading, and building the ZooKeeper configuration. The order and priority for - * reading the config are as follows: (1). Property with "hbase.zookeeper.property." prefix from - * HBase XML (2). other zookeeper related properties in HBASE XML + * reading the config are as follows: + * + * Property with "hbase.zookeeper.property." prefix from HBase XML. + * other zookeeper related properties in HBASE XML + * */ @InterfaceAudience.Private public final class ZKConfig { private static final String VARIABLE_START = "${"; - private static final String ZOOKEEPER_JAVA_PROPERTY_PREFIX = "zookeeper."; private ZKConfig() { } @@ -132,7 +135,6 @@ public
(hbase) branch master updated: HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/master by this push: new 6c6e776eea6 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) 6c6e776eea6 is described below commit 6c6e776eea6ebd62a3a030a1820c4eef2636553c Author: Duo Zhang AuthorDate: Tue Apr 23 21:57:47 2024 +0800 HBASE-28529 Use ZKClientConfig instead of system properties when setting zookeeper configurations (#5835) Signed-off-by: Wellington Chevreuil Reviewed-by: Andor Molnár Reviewed-by: BukrosSzabolcs --- .../hadoop/hbase/zookeeper/ReadOnlyZKClient.java | 13 ++-- .../apache/hadoop/hbase/zookeeper/ZKConfig.java| 29 - .../hadoop/hbase/zookeeper/TestZKConfig.java | 47 ++ .../hbase/zookeeper/RecoverableZooKeeper.java | 75 ++ .../apache/hadoop/hbase/zookeeper/ZKWatcher.java | 4 +- .../hbase/zookeeper/TestRecoverableZooKeeper.java | 2 +- 6 files changed, 62 insertions(+), 108 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java index 979094fda80..64b151dc19a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ReadOnlyZKClient.java @@ -38,6 +38,7 @@ import org.apache.yetus.audience.InterfaceAudience; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.ZooKeeper; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,6 +76,8 @@ public final class ReadOnlyZKClient implements Closeable { private final int keepAliveTimeMs; + private final ZKClientConfig zkClientConfig; + private static abstract class Task implements Delayed { protected long time = System.nanoTime(); @@ -136,10 +139,12 @@ public final class ReadOnlyZKClient implements Closeable { this.retryIntervalMs = conf.getInt(RECOVERY_RETRY_INTERVAL_MILLIS, DEFAULT_RECOVERY_RETRY_INTERVAL_MILLIS); this.keepAliveTimeMs = conf.getInt(KEEPALIVE_MILLIS, DEFAULT_KEEPALIVE_MILLIS); +this.zkClientConfig = ZKConfig.getZKClientConfig(conf); LOG.debug( - "Connect {} to {} with session timeout={}ms, retries {}, " -+ "retry interval {}ms, keepAlive={}ms", - getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs); + "Connect {} to {} with session timeout={}ms, retries={}, " ++ "retry interval={}ms, keepAlive={}ms, zk client config={}", + getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs, + zkClientConfig); Threads.setDaemonThreadRunning(new Thread(this::run), "ReadOnlyZKClient-" + connectString + "@" + getId()); } @@ -316,7 +321,7 @@ public final class ReadOnlyZKClient implements Closeable { // may be closed when session expired if (zookeeper == null || !zookeeper.getState().isAlive()) { zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> { - }); + }, zkClientConfig); } return zookeeper; } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java index 87885e2b9fd..57009eca660 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java @@ -26,19 +26,22 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.util.StringUtils; import org.apache.yetus.audience.InterfaceAudience; +import org.apache.zookeeper.client.ZKClientConfig; import org.apache.hbase.thirdparty.com.google.common.base.Splitter; /** * Utility methods for reading, and building the ZooKeeper configuration. The order and priority for - * reading the config are as follows: (1). Property with "hbase.zookeeper.property." prefix from - * HBase XML (2). other zookeeper related properties in HBASE XML + * reading the config are as follows: + * + * Property with "hbase.zookeeper.property." prefix from HBase XML. + * other zookeeper related properties in HBASE XML + * */ @InterfaceAudience.Private public final class ZKConfig { private static final String VARIABLE_START = "${"; - private static final String ZOOKEEPER_JAVA_PROPERTY_PREFIX = "zookeeper."; private ZKConfig() { } @@ -132,7 +135,6 @@ public final class ZKConfig { * @return Quorum servers */ public static
(hbase) branch branch-3 updated: HBASE-28436 Use connection url to specify the connection registry information (#5770)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-3 in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/branch-3 by this push: new 46377c5d966 HBASE-28436 Use connection url to specify the connection registry information (#5770) 46377c5d966 is described below commit 46377c5d96683a283c969a5d7c5ce5b12cfecedb Author: Duo Zhang AuthorDate: Tue Apr 23 16:05:26 2024 +0800 HBASE-28436 Use connection url to specify the connection registry information (#5770) Signed-off-by: Istvan Toth Signed-off-by: Nick Dimiduk Reviewed-by: Bryan Beaudreault (cherry picked from commit e3761baec1158d617c46bbdf54725206544717e9) --- hbase-client/pom.xml | 5 + .../hadoop/hbase/client/ConnectionFactory.java | 313 + .../hbase/client/ConnectionRegistryFactory.java| 64 - ...tory.java => ConnectionRegistryURIFactory.java} | 27 +- ...tory.java => RpcConnectionRegistryCreator.java} | 30 +- ...ctory.java => ZKConnectionRegistryCreator.java} | 33 ++- ...adoop.hbase.client.ConnectionRegistryURIFactory | 17 ++ .../TestConnectionRegistryCreatorUriParsing.java | 157 +++ .../hbase/client/ClusterConnectionFactory.java | 2 +- .../hbase/client/AbstractTestRegionLocator.java| 2 +- .../client/TestAsyncAdminWithRegionReplicas.java | 2 +- .../hbase/client/TestAsyncMetaRegionLocator.java | 3 +- .../client/TestAsyncNonMetaRegionLocator.java | 2 +- ...stAsyncNonMetaRegionLocatorConcurrenyLimit.java | 2 +- .../hbase/client/TestAsyncRegionLocator.java | 2 +- .../TestAsyncSingleRequestRpcRetryingCaller.java | 2 +- .../client/TestAsyncTableUseMetaReplicas.java | 3 +- ...ReadWriteWithDifferentConnectionRegistries.java | 177 ...estCatalogReplicaLoadBalanceSimpleSelector.java | 3 +- .../hbase/client/TestMetaRegionLocationCache.java | 3 +- 20 files changed, 737 insertions(+), 112 deletions(-) diff --git a/hbase-client/pom.xml b/hbase-client/pom.xml index dba79ff07ee..8da4ab8e837 100644 --- a/hbase-client/pom.xml +++ b/hbase-client/pom.xml @@ -170,6 +170,11 @@ mockito-core test + + org.mockito + mockito-inline + test + org.hamcrest hamcrest-library diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java index 716fb4863fe..f4ef4496dfc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java @@ -21,6 +21,7 @@ import static org.apache.hadoop.hbase.util.FutureUtils.addListener; import java.io.IOException; import java.lang.reflect.Constructor; +import java.net.URI; import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.Map; @@ -89,41 +90,55 @@ public class ConnectionFactory { * instance. Typical usage: * * - * Connection connection = ConnectionFactory.createConnection(); - * Table table = connection.getTable(TableName.valueOf("mytable")); - * try { + * try (Connection connection = ConnectionFactory.createConnection(conf); + * Table table = connection.getTable(TableName.valueOf("table1"))) { * table.get(...); * ... - * } finally { - * table.close(); - * connection.close(); * } * * * @return Connection object for conf */ public static Connection createConnection() throws IOException { -Configuration conf = HBaseConfiguration.create(); -return createConnection(conf, null, AuthUtil.loginClient(conf)); +return createConnection(HBaseConfiguration.create()); + } + + /** + * Create a new Connection instance using default HBaseConfiguration. Connection encapsulates all + * housekeeping for a connection to the cluster. All tables and interfaces created from returned + * connection share zookeeper connection, meta cache, and connections to region servers and + * masters. + * The caller is responsible for calling {@link Connection#close()} on the returned connection + * instance. Typical usage: + * + * + * try (Connection connection = ConnectionFactory.createConnection(conf); + * Table table = connection.getTable(TableName.valueOf("table1"))) { + * table.get(...); + * ... + * } + * + * + * @param connectionUri the connection uri for the hbase cluster + * @return Connection object for conf + */ + public static Connection createConnection(URI connectionUri) throws IOException { +return createConnection(connectionUri, HBaseConfiguration.create()); } /** * Create a new Connection instance using the passed conf instance. Connection * encapsulates all
(hbase) branch master updated (5a404c49504 -> e3761baec11)
This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/hbase.git from 5a404c49504 HBASE-28150 CreateTableProcedure and DeleteTableProcedure should sleep a while before retrying (#5502) add e3761baec11 HBASE-28436 Use connection url to specify the connection registry information (#5770) No new revisions were added by this update. Summary of changes: hbase-client/pom.xml | 5 + .../hadoop/hbase/client/ConnectionFactory.java | 313 + .../hbase/client/ConnectionRegistryFactory.java| 64 - .../hbase/client/ConnectionRegistryURIFactory.java | 26 +- .../client/RpcConnectionRegistryCreator.java} | 40 +-- .../hbase/client/ZKConnectionRegistryCreator.java} | 43 ++- ...adoop.hbase.client.ConnectionRegistryURIFactory | 3 +- .../TestConnectionRegistryCreatorUriParsing.java | 157 +++ .../hbase/client/ClusterConnectionFactory.java | 2 +- .../hbase/client/AbstractTestRegionLocator.java| 2 +- .../client/TestAsyncAdminWithRegionReplicas.java | 2 +- .../hbase/client/TestAsyncMetaRegionLocator.java | 3 +- .../client/TestAsyncNonMetaRegionLocator.java | 2 +- ...stAsyncNonMetaRegionLocatorConcurrenyLimit.java | 2 +- .../hbase/client/TestAsyncRegionLocator.java | 2 +- .../TestAsyncSingleRequestRpcRetryingCaller.java | 2 +- .../client/TestAsyncTableUseMetaReplicas.java | 3 +- ...ReadWriteWithDifferentConnectionRegistries.java | 177 ...estCatalogReplicaLoadBalanceSimpleSelector.java | 3 +- .../hbase/client/TestMetaRegionLocationCache.java | 3 +- 20 files changed, 717 insertions(+), 137 deletions(-) copy hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NoRegionSplitRestriction.java => hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionRegistryURIFactory.java (63%) copy hbase-client/src/{test/java/org/apache/hadoop/hbase/client/DoNothingConnectionRegistry.java => main/java/org/apache/hadoop/hbase/client/RpcConnectionRegistryCreator.java} (55%) copy hbase-client/src/{test/java/org/apache/hadoop/hbase/client/DoNothingConnectionRegistry.java => main/java/org/apache/hadoop/hbase/client/ZKConnectionRegistryCreator.java} (52%) copy hbase-it/src/test/resources/META-INF/services/javax.ws.rs.client.ClientBuilder => hbase-client/src/main/resources/META-INF/services/org.apache.hadoop.hbase.client.ConnectionRegistryURIFactory (86%) create mode 100644 hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionRegistryCreatorUriParsing.java create mode 100644 hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBasicReadWriteWithDifferentConnectionRegistries.java