This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 0595ecf2c1 Remove the dependency to Hikari. Instead, users wanting Hikari should provide a `DataSource` as the store input. This approach gives more flexibility by allowing users to configure Hikari as they want, or to use another pool. 0595ecf2c1 is described below commit 0595ecf2c1a5b8c2f73dfec420186eb68dfb75e2 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Aug 12 18:19:39 2024 +0200 Remove the dependency to Hikari. Instead, users wanting Hikari should provide a `DataSource` as the store input. This approach gives more flexibility by allowing users to configure Hikari as they want, or to use another pool. --- incubator/build.gradle.kts | 1 - .../main/module-info.java | 1 - .../sis/storage/geopackage/GpkgProvider.java | 4 -- .../apache/sis/storage/geopackage/GpkgStore.java | 47 +--------------------- netbeans-project/ivy.xml | 1 - 5 files changed, 2 insertions(+), 52 deletions(-) diff --git a/incubator/build.gradle.kts b/incubator/build.gradle.kts index e3f96b3083..a60706f6ae 100644 --- a/incubator/build.gradle.kts +++ b/incubator/build.gradle.kts @@ -59,7 +59,6 @@ dependencies { */ implementation(group = "org.antlr", name = "antlr4-maven-plugin", version = "4.11.1") implementation(group = "org.xerial", name = "sqlite-jdbc", version = "3.45.1.0") - implementation(group = "com.zaxxer", name = "HikariCP", version = "5.1.0") compileOnly (group = "jakarta.servlet", name = "jakarta.servlet-api", version = "6.0.0") compileOnly (group = "org.osgi", name = "osgi.core", version = "8.0.0") antlr (group = "org.antlr", name = "antlr4", version = "4.11.1") diff --git a/incubator/src/org.apache.sis.storage.geopackage/main/module-info.java b/incubator/src/org.apache.sis.storage.geopackage/main/module-info.java index 0fed36b356..26a43e2cd5 100644 --- a/incubator/src/org.apache.sis.storage.geopackage/main/module-info.java +++ b/incubator/src/org.apache.sis.storage.geopackage/main/module-info.java @@ -26,7 +26,6 @@ module org.apache.sis.storage.geopackage { requires transitive org.apache.sis.storage; requires transitive org.apache.sis.storage.sql; requires transitive org.apache.sis.feature; - requires transitive com.zaxxer.hikari; requires org.xerial.sqlitejdbc; exports org.apache.sis.storage.geopackage; diff --git a/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgProvider.java b/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgProvider.java index 1e66a8b5a8..26dc05846f 100644 --- a/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgProvider.java +++ b/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgProvider.java @@ -54,10 +54,6 @@ public final class GpkgProvider extends DataStoreProvider { * Provider identifier. */ public static final String NAME = "gpkg"; - /** - * Custom pragma to enforce use of an Hikari connection pool. - */ - public static final String PRAGMA_HIKARICP = "HIKARICP"; /** * URI to the dafift folder. diff --git a/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgStore.java b/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgStore.java index be0e78db36..6a8b1db6d9 100644 --- a/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgStore.java +++ b/incubator/src/org.apache.sis.storage.geopackage/main/org/apache/sis/storage/geopackage/GpkgStore.java @@ -16,8 +16,6 @@ */ package org.apache.sis.storage.geopackage; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -51,7 +49,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.Properties; -import java.util.UUID; import java.util.concurrent.Executor; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -366,53 +363,13 @@ public class GpkgStore extends DataStore implements WritableAggregate, ResourceO //TODO need to find a list of pragma not causing errors in readonly. for (Entry<String,String> entry : pragmas.entrySet()) { - if (GpkgProvider.PRAGMA_HIKARICP.equalsIgnoreCase(entry.getKey())) continue; config.setPragma(Pragma.valueOf(entry.getKey()), entry.getValue()); } } else { // config.setReadOnly(true); } - - final String useHikariValue = pragmas.remove(GpkgProvider.PRAGMA_HIKARICP); - final boolean useHikari = ("1".equalsIgnoreCase(useHikariValue) || "true".equalsIgnoreCase(useHikariValue)); - - final DataSource dataSource; - if (useHikari) { - System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug"); - /* - We use hikari instead of apache dbcp2 because of spring-boot excluding commons-logging - Also because hikari is still in activity and from benchmarks has better performances. - */ - HikariConfig hkcfg = new HikariConfig(); - hkcfg.setPoolName(UUID.randomUUID().toString()); - hkcfg.setDriverClassName("org.sqlite.JDBC"); - hkcfg.setJdbcUrl(url); - hkcfg.setConnectionTestQuery("SELECT 1"); - hkcfg.setMaxLifetime(60000); // 60 Sec - hkcfg.setIdleTimeout(45000); // 45 Sec - //hkcfg.setConnectionTimeout(60000); // 1 min - hkcfg.setMaximumPoolSize(50); // 50 Connections (including idle connections) - hkcfg.setLeakDetectionThreshold(10000); -// hkcfg.setReadOnly(isReadOnly); - - final Properties sqliteprops = config.toProperties(); - for (Entry<Object,Object> entry : sqliteprops.entrySet()) { - hkcfg.addDataSourceProperty(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); - } - dataSource = new HikariDataSource(hkcfg); - -// //normaly SQlite do not support more then one connection -// //or we may obtain errors such as : [SQLITE_BUSY] The database file is locked (database is locked) -// //to workaround this limitation it is possible to add a busy timeout : -// //https://stackoverflow.com/questions/8559623/sqlite-busy-the-database-file-is-locked-database-is-locked-in-wicket -// //dataSource.setConnectionInitSqls(Arrays.asList( -// //"PRAGMA busy_timeout=60000;")); - } else { - final SQLiteConnectionPoolDataSource sds = new SQLiteConnectionPoolDataSource(config); - sds.setUrl(url); - dataSource = sds; - } - + final var dataSource = new SQLiteConnectionPoolDataSource(config); + dataSource.setUrl(url); if (newDb) { try (Connection cnx = dataSource.getConnection()) { cnx.setAutoCommit(false); diff --git a/netbeans-project/ivy.xml b/netbeans-project/ivy.xml index abdca1baf7..02d580d8dc 100644 --- a/netbeans-project/ivy.xml +++ b/netbeans-project/ivy.xml @@ -37,6 +37,5 @@ <dependency org="gov.nist.math" name="jama" rev="1.0.3"/> <dependency org="net.sf.geographiclib" name="GeographicLib-Java" rev="2.0"/> <dependency org="org.xerial" name="sqlite-jdbc" rev="3.45.1.0"/> - <dependency org="com.zaxxer" name="HikariCP" rev="5.1.0"/> </dependencies> </ivy-module>