World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#9363] improvement(jdbc-common): Make maxWaitDuration configurable in JDBC catalog (#9364)
qbhan71ca8fe2a07e
diff --git a/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/config/JdbcConfig.java b/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/config/JdbcConfig.javaindex 28c6aa9fb4..18f1023b20 100644--- a/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/config/JdbcConfig.java+++ b/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/config/JdbcConfig.java@@ -92,6 +92,14 @@ public class JdbcConfig extends Config {.booleanConf().createWithDefault(true);+ public static final ConfigEntry<Long> POOL_MAX_WAIT_MS =+ new ConfigBuilder("jdbc.pool.max-wait-ms")+ .doc("The maximum Duration that the pool will wait for a connection to be returned")+ .version(ConfigConstants.VERSION_1_1_0)+ .longConf()+ .checkValue(value -> value > 0, ConfigConstants.POSITIVE_NUMBER_ERROR_MSG)+ .createWithDefault(30000L);+public String getJdbcUrl() {return get(JDBC_URL);}@@ -124,6 +132,10 @@ public class JdbcConfig extends Config {return get(TEST_ON_BORROW);}+ public long getMaxWaitMs() {+ return get(POOL_MAX_WAIT_MS);+ }+public JdbcConfig(Map<String, String> properties) {super(false);loadFromMap(properties, k -> true);diff --git a/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/utils/DataSourceUtils.java b/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/utils/DataSourceUtils.javaindex 9af11395b5..59da59b770 100644--- a/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/utils/DataSourceUtils.java+++ b/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/utils/DataSourceUtils.java@@ -19,6 +19,7 @@package org.apache.gravitino.catalog.jdbc.utils;import java.sql.SQLException;+import java.time.Duration;import java.util.Map;import java.util.Properties;import javax.sql.DataSource;@@ -70,6 +71,7 @@ public class DataSourceUtils {// executed to confirm whether the connection is valid.basicDataSource.setTestOnBorrow(jdbcConfig.getTestOnBorrow());basicDataSource.setValidationQuery(POOL_TEST_QUERY);+ basicDataSource.setMaxWait(Duration.ofMillis(jdbcConfig.getMaxWaitMs()));return basicDataSource;}diff --git a/catalogs/catalog-jdbc-common/src/test/java/org/apache/gravitino/catalog/jdbc/utils/TestJdbcConfig.java b/catalogs/catalog-jdbc-common/src/test/java/org/apache/gravitino/catalog/jdbc/utils/TestJdbcConfig.javaindex a77777764e..9eebf08ff7 100644--- a/catalogs/catalog-jdbc-common/src/test/java/org/apache/gravitino/catalog/jdbc/utils/TestJdbcConfig.java+++ b/catalogs/catalog-jdbc-common/src/test/java/org/apache/gravitino/catalog/jdbc/utils/TestJdbcConfig.java@@ -36,4 +36,14 @@ public class TestJdbcConfig {jdbcConfig = new JdbcConfig(immutableMap);Assertions.assertFalse(jdbcConfig.getTestOnBorrow());}++ @Test+ void testMaxWaitMs() {+ JdbcConfig jdbcConfig = new JdbcConfig(Maps.newHashMap());+ Assertions.assertEquals(30000L, jdbcConfig.getMaxWaitMs());++ ImmutableMap immutableMap = ImmutableMap.of("jdbc.pool.max-wait-ms", "60000");+ jdbcConfig = new JdbcConfig(immutableMap);+ Assertions.assertEquals(60000L, jdbcConfig.getMaxWaitMs());+ }}diff --git a/docs/jdbc-doris-catalog.md b/docs/jdbc-doris-catalog.mdindex 6cf55de4bb..900b351e9a 100644--- a/docs/jdbc-doris-catalog.md+++ b/docs/jdbc-doris-catalog.md@@ -41,16 +41,16 @@ more details.Besides the [common catalog properties](./gravitino-server-config.md#apache-gravitino-catalog-properties-configuration), the Doris catalog has the following properties:-| Configuration item | Description | Default value | Required | Since Version |-|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|------------------|-| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:9030` | (none) | Yes | 0.5.0 |-| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver`. | (none) | Yes | 0.5.0 |-| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.5.0 |-| `jdbc-password` | The JDBC password. | (none) | Yes | 0.5.0 |-| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.5.0 |-| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.5.0 |-| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.5.0 |-| `replication_num` | The number of replications for the table. If not specified and the number of backend servers less than 3, then the default value is 1; If not specified and the number of backend servers greater or equals to 3, the default value (3) in Doris server will be used. For more, please see the [doc](https://doris.apache.org/docs/1.2/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE/) | `1` or `3` | No | 0.6.0-incubating |+| Configuration item | Description | Default value | Required | Since Version |+|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|------------------|+| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:9030` | (none) | Yes | 0.5.0 |+| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver`. | (none) | Yes | 0.5.0 |+| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.5.0 |+| `jdbc-password` | The JDBC password. | (none) | Yes | 0.5.0 |+| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.5.0 |+| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.5.0 |+| `replication_num` | The number of replications for the table. If not specified and the number of backend servers less than 3, then the default value is 1; If not specified and the number of backend servers greater or equals to 3, the default value (3) in Doris server will be used. For more, please see the [doc](https://doris.apache.org/docs/1.2/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-TABLE/) | `1` or `3` | No | 0.6.0-incubating |+| `jdbc.pool.max-wait-ms` | The maximum Duration that the pool will wait for a connection to be returned. `30000` by default. | `30000` | No | 1.1.0 |Before using the Doris Catalog, you must download the corresponding JDBC driver to the `catalogs/jdbc-doris/libs` directory.Gravitino doesn't package the JDBC driver for Doris due to licensing issues.diff --git a/docs/jdbc-mysql-catalog.md b/docs/jdbc-mysql-catalog.mdindex 5406daea55..8571a63fd9 100644--- a/docs/jdbc-mysql-catalog.md+++ b/docs/jdbc-mysql-catalog.md@@ -41,14 +41,15 @@ When you use the Gravitino with Trino. You can pass the Trino MySQL connector coIf you use a JDBC catalog, you must provide `jdbc-url`, `jdbc-driver`, `jdbc-user` and `jdbc-password` to catalog properties.Besides the [common catalog properties](./gravitino-server-config.md#apache-gravitino-catalog-properties-configuration), the MySQL catalog has the following properties:-| Configuration item | Description | Default value | Required | Since Version |-|----------------------|--------------------------------------------------------------------------------------------------------|---------------|----------|---------------|-| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:3306` | (none) | Yes | 0.3.0 |-| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver` or `com.mysql.cj.jdbc.Driver`. | (none) | Yes | 0.3.0 |-| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.3.0 |-| `jdbc-password` | The JDBC password. | (none) | Yes | 0.3.0 |-| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.3.0 |-| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.3.0 |+| Configuration item | Description | Default value | Required | Since Version |+|-------------------------|--------------------------------------------------------------------------------------------------------|---------------|----------|---------------|+| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:3306` | (none) | Yes | 0.3.0 |+| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver` or `com.mysql.cj.jdbc.Driver`. | (none) | Yes | 0.3.0 |+| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.3.0 |+| `jdbc-password` | The JDBC password. | (none) | Yes | 0.3.0 |+| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.3.0 |+| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.3.0 |+| `jdbc.pool.max-wait-ms` | The maximum Duration that the pool will wait for a connection to be returned. `30000` by default. | `30000` | No | 1.1.0 |:::cautionYou must download the corresponding JDBC driver to the `catalogs/jdbc-mysql/libs` directory.diff --git a/docs/jdbc-oceanbase-catalog.md b/docs/jdbc-oceanbase-catalog.mdindex 6acada8da9..2a1f37475f 100644--- a/docs/jdbc-oceanbase-catalog.md+++ b/docs/jdbc-oceanbase-catalog.md@@ -38,14 +38,15 @@ Check the relevant data source configuration in [data source properties](https:/If you use a JDBC catalog, you must provide `jdbc-url`, `jdbc-driver`, `jdbc-user` and `jdbc-password` to catalog properties.Besides the [common catalog properties](./gravitino-server-config.md#apache-gravitino-catalog-properties-configuration), the OceanBase catalog has the following properties:-| Configuration item | Description | Default value | Required | Since Version |-|----------------------|---------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|------------------|-| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:2881` or `jdbc:oceanbase://localhost:2881` | (none) | Yes | 0.7.0-incubating |-| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver` or `com.mysql.cj.jdbc.Driver` or `com.oceanbase.jdbc.Driver`. | (none) | Yes | 0.7.0-incubating |-| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.7.0-incubating |-| `jdbc-password` | The JDBC password. | (none) | Yes | 0.7.0-incubating |-| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.7.0-incubating |-| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.7.0-incubating |+| Configuration item | Description | Default value | Required | Since Version |+|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|------------------|+| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:2881` or `jdbc:oceanbase://localhost:2881` | (none) | Yes | 0.7.0-incubating |+| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver` or `com.mysql.cj.jdbc.Driver` or `com.oceanbase.jdbc.Driver`. | (none) | Yes | 0.7.0-incubating |+| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.7.0-incubating |+| `jdbc-password` | The JDBC password. | (none) | Yes | 0.7.0-incubating |+| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.7.0-incubating |+| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.7.0-incubating |+| `jdbc.pool.max-wait-ms` | The maximum Duration that the pool will wait for a connection to be returned. `30000` by default. | `30000` | No | 1.1.0 |:::cautionBefore using the OceanBase Catalog, you must download the corresponding JDBC driver to the `catalogs/jdbc-oceanbase/libs` directory.diff --git a/docs/jdbc-postgresql-catalog.md b/docs/jdbc-postgresql-catalog.mdindex c3285ab5c2..973a3a0373 100644--- a/docs/jdbc-postgresql-catalog.md+++ b/docs/jdbc-postgresql-catalog.md@@ -39,15 +39,16 @@ When you use the Gravitino with Trino. You can pass the Trino PostgreSQL connectIf you use JDBC catalog, you must provide `jdbc-url`, `jdbc-driver`, `jdbc-database`, `jdbc-user` and `jdbc-password` to catalog properties.Besides the [common catalog properties](./gravitino-server-config.md#apache-gravitino-catalog-properties-configuration), the PostgreSQL catalog has the following properties:-| Configuration item | Description | Default value | Required | Since Version |-|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|---------------|-| `jdbc-url` | JDBC URL for connecting to the database. You need to specify the database in the URL. For example `jdbc:postgresql://localhost:3306/pg_database?sslmode=require`. | (none) | Yes | 0.3.0 |-| `jdbc-driver` | The driver of the JDBC connection. For example `org.postgresql.Driver`. | (none) | Yes | 0.3.0 |-| `jdbc-database` | The database of the JDBC connection. Configure it with the same value as the database in the `jdbc-url`. For example `pg_database`. | (none) | Yes | 0.3.0 |-| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.3.0 |-| `jdbc-password` | The JDBC password. | (none) | Yes | 0.3.0 |-| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.3.0 |-| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.3.0 |+| Configuration item | Description | Default value | Required | Since Version |+|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|---------------|+| `jdbc-url` | JDBC URL for connecting to the database. You need to specify the database in the URL. For example `jdbc:postgresql://localhost:3306/pg_database?sslmode=require`. | (none) | Yes | 0.3.0 |+| `jdbc-driver` | The driver of the JDBC connection. For example `org.postgresql.Driver`. | (none) | Yes | 0.3.0 |+| `jdbc-database` | The database of the JDBC connection. Configure it with the same value as the database in the `jdbc-url`. For example `pg_database`. | (none) | Yes | 0.3.0 |+| `jdbc-user` | The JDBC user name. | (none) | Yes | 0.3.0 |+| `jdbc-password` | The JDBC password. | (none) | Yes | 0.3.0 |+| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 0.3.0 |+| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 0.3.0 |+| `jdbc.pool.max-wait-ms` | The maximum Duration that the pool will wait for a connection to be returned. `30000` by default. | `30000` | No | 1.1.0 |:::cautionYou must download the corresponding JDBC driver to the `catalogs/jdbc-postgresql/libs` directory.diff --git a/docs/jdbc-starrocks-catalog.md b/docs/jdbc-starrocks-catalog.mdindex eecfc7aa6e..7864052939 100644--- a/docs/jdbc-starrocks-catalog.md+++ b/docs/jdbc-starrocks-catalog.md@@ -40,16 +40,15 @@ more details.Besides the [common catalog properties](./gravitino-server-config.md#apache-gravitino-catalog-properties-configuration), the StarRocks catalog has the following properties:-| Configuration item | Description | Default value | Required | Since Version |-|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|------------------|-| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:9030` | (none) | Yes | 1.0.0 |-| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver`. | (none) | Yes | 1.0.0 |-| `jdbc-user` | The JDBC user name. | (none) | Yes | 1.0.0 |-| `jdbc-password` | The JDBC password. | (none) | Yes | 1.0.0 |-| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 1.0.0 |-| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 1.0.0 |-| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 1.0.0 |-+| Configuration item | Description | Default value | Required | Since Version |+|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|-----------------|+| `jdbc-url` | JDBC URL for connecting to the database. For example, `jdbc:mysql://localhost:9030` | (none) | Yes | 1.0.0 |+| `jdbc-driver` | The driver of the JDBC connection. For example, `com.mysql.jdbc.Driver`. | (none) | Yes | 1.0.0 |+| `jdbc-user` | The JDBC user name. | (none) | Yes | 1.0.0 |+| `jdbc-password` | The JDBC password. | (none) | Yes | 1.0.0 |+| `jdbc.pool.min-size` | The minimum number of connections in the pool. `2` by default. | `2` | No | 1.0.0 |+| `jdbc.pool.max-size` | The maximum number of connections in the pool. `10` by default. | `10` | No | 1.0.0 |+| `jdbc.pool.max-wait-ms` | The maximum Duration that the pool will wait for a connection to be returned. `30000` by default. | `30000` | No | 1.1.0 |Before using the StarRocks Catalog, you must download the corresponding JDBC driver to the `catalogs/jdbc-starrocks/libs` directory.Gravitino doesn't package the JDBC driver for StarRocks due to licensing issues.