From d87c99d82609200d403f2054c3dc308fd51a9ff5 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 13 Oct 2023 15:34:01 +0200 Subject: [PATCH 1/6] feature/add the 6 hikari configurations --- .../resources/props/sample.props.template | 9 ++++++ .../bootstrap/liftweb/CustomDBVendor.scala | 29 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/obp-api/src/main/resources/props/sample.props.template b/obp-api/src/main/resources/props/sample.props.template index 492f3d9932..2224650769 100644 --- a/obp-api/src/main/resources/props/sample.props.template +++ b/obp-api/src/main/resources/props/sample.props.template @@ -23,6 +23,15 @@ connector=star #connector=proxy #connector=... +#OBP uses Hikari as the default database connection pool. OBP supports the following 6 configurations at the moment. +#https://github.com/brettwooldridge/HikariCP#frequently-used +#hikari.connectionTimeout= +#hikari.maximumPoolSize= +#hikari.idleTimeout= +#hikari.keepaliveTime= +#hikari.maxLifetime= +#hikari.metricRegistry= + ## if connector = star, then need to set which connectors will be used. For now, obp support rest, akka, kafka. If you set kafka, then you need to start the kafka server. starConnector_supported_types=mapped,internal diff --git a/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala b/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala index 957f37e3e2..fe70253436 100644 --- a/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala +++ b/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala @@ -1,9 +1,10 @@ package bootstrap.liftweb +import code.api.util.APIUtil import com.zaxxer.hikari.pool.ProxyConnection import com.zaxxer.hikari.{HikariConfig, HikariDataSource} -import java.sql.{Connection} +import java.sql.Connection import net.liftweb.common.{Box, Full, Logger} import net.liftweb.db.ConnectionManager import net.liftweb.util.ConnectionIdentifier @@ -26,6 +27,32 @@ class CustomDBVendor(driverName: String, object HikariDatasource { val config = new HikariConfig() + + val connectionTimeout = APIUtil.getPropsAsLongValue("hikari.connectionTimeout") + val maximumPoolSize = APIUtil.getPropsAsLongValue("hikari.maximumPoolSize") + val idleTimeout = APIUtil.getPropsAsLongValue("hikari.idleTimeout") + val keepaliveTime = APIUtil.getPropsAsLongValue("hikari.keepaliveTime") + val maxLifetime = APIUtil.getPropsAsLongValue("hikari.maxLifetime") + val metricRegistry = APIUtil.getPropsAsLongValue("hikari.metricRegistry") + + if(connectionTimeout.isDefined){ + config.setConnectionTimeout(connectionTimeout.head) + } + if(maximumPoolSize.isDefined){ + config.setConnectionTimeout(maximumPoolSize.head) + } + if(idleTimeout.isDefined){ + config.setConnectionTimeout(idleTimeout.head) + } + if(keepaliveTime.isDefined){ + config.setConnectionTimeout(keepaliveTime.head) + } + if(maxLifetime.isDefined){ + config.setConnectionTimeout(maxLifetime.head) + } + if(metricRegistry.isDefined){ + config.setConnectionTimeout(connectionTimeout.head) + } (dbUser, dbPassword) match { case (Full(user), Full(pwd)) => From b65d9e5fe0b6793aed2e944b98e8810f7c28c74f Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 13 Oct 2023 15:36:38 +0200 Subject: [PATCH 2/6] docfix/added the hikari props to release_notes.md --- release_notes.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/release_notes.md b/release_notes.md index efcd1f5f1e..c2e5a209bf 100644 --- a/release_notes.md +++ b/release_notes.md @@ -3,6 +3,12 @@ ### Most recent changes at top of file ``` Date Commit Action +13/10/2023 d87c99d8 Added props hikari.connectionTimeout, default is from hakari. + Added props hikari.maximumPoolSize, default is from hakari. + Added props hikari.idleTimeout, default is from hakari. + Added props hikari.keepaliveTime, default is from hakari. + Added props hikari.maxLifetime, default is from hakari. + Added props hikari.metricRegistry, default is from hakari. 22/09/2023 752ff04b Added props db.maxPoolSize, default is 10. 24/08/2023 bcb8fcfd Added props expectedOpenFuturesPerService, default is 100. 16/08/2023 4d8dfa66 Added props short_endpoint_timeout, default is 1. From c85433df200a024329debc3c271c19de26c8d877 Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 13 Oct 2023 15:37:18 +0200 Subject: [PATCH 3/6] docfix/remove db.maxPoolSize props --- release_notes.md | 1 - 1 file changed, 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index c2e5a209bf..4fe3b1ccfe 100644 --- a/release_notes.md +++ b/release_notes.md @@ -9,7 +9,6 @@ Date Commit Action Added props hikari.keepaliveTime, default is from hakari. Added props hikari.maxLifetime, default is from hakari. Added props hikari.metricRegistry, default is from hakari. -22/09/2023 752ff04b Added props db.maxPoolSize, default is 10. 24/08/2023 bcb8fcfd Added props expectedOpenFuturesPerService, default is 100. 16/08/2023 4d8dfa66 Added props short_endpoint_timeout, default is 1. Added props medium_endpoint_timeout, default is 7. From f825ed1ef785fba68c2b37fa5f21e2d96ccc83aa Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 13 Oct 2023 15:44:01 +0200 Subject: [PATCH 4/6] docfix/remove hikari.metricRegistry props and tweak the docs --- .../src/main/resources/props/sample.props.template | 3 +-- .../scala/bootstrap/liftweb/CustomDBVendor.scala | 14 +++++--------- release_notes.md | 1 - 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/obp-api/src/main/resources/props/sample.props.template b/obp-api/src/main/resources/props/sample.props.template index 2224650769..f37b8326d3 100644 --- a/obp-api/src/main/resources/props/sample.props.template +++ b/obp-api/src/main/resources/props/sample.props.template @@ -23,14 +23,13 @@ connector=star #connector=proxy #connector=... -#OBP uses Hikari as the default database connection pool. OBP supports the following 6 configurations at the moment. +#OBP uses Hikari as the default database connection pool. OBP supports the following 5 configurations at the moment. #https://github.com/brettwooldridge/HikariCP#frequently-used #hikari.connectionTimeout= #hikari.maximumPoolSize= #hikari.idleTimeout= #hikari.keepaliveTime= #hikari.maxLifetime= -#hikari.metricRegistry= ## if connector = star, then need to set which connectors will be used. For now, obp support rest, akka, kafka. If you set kafka, then you need to start the kafka server. starConnector_supported_types=mapped,internal diff --git a/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala b/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala index fe70253436..47db525326 100644 --- a/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala +++ b/obp-api/src/main/scala/bootstrap/liftweb/CustomDBVendor.scala @@ -29,29 +29,25 @@ class CustomDBVendor(driverName: String, val config = new HikariConfig() val connectionTimeout = APIUtil.getPropsAsLongValue("hikari.connectionTimeout") - val maximumPoolSize = APIUtil.getPropsAsLongValue("hikari.maximumPoolSize") + val maximumPoolSize = APIUtil.getPropsAsIntValue("hikari.maximumPoolSize") val idleTimeout = APIUtil.getPropsAsLongValue("hikari.idleTimeout") val keepaliveTime = APIUtil.getPropsAsLongValue("hikari.keepaliveTime") val maxLifetime = APIUtil.getPropsAsLongValue("hikari.maxLifetime") - val metricRegistry = APIUtil.getPropsAsLongValue("hikari.metricRegistry") if(connectionTimeout.isDefined){ config.setConnectionTimeout(connectionTimeout.head) } if(maximumPoolSize.isDefined){ - config.setConnectionTimeout(maximumPoolSize.head) + config.setMaximumPoolSize(maximumPoolSize.head) } if(idleTimeout.isDefined){ - config.setConnectionTimeout(idleTimeout.head) + config.setIdleTimeout(idleTimeout.head) } if(keepaliveTime.isDefined){ - config.setConnectionTimeout(keepaliveTime.head) + config.setKeepaliveTime(keepaliveTime.head) } if(maxLifetime.isDefined){ - config.setConnectionTimeout(maxLifetime.head) - } - if(metricRegistry.isDefined){ - config.setConnectionTimeout(connectionTimeout.head) + config.setMaxLifetime(maxLifetime.head) } (dbUser, dbPassword) match { diff --git a/release_notes.md b/release_notes.md index 4fe3b1ccfe..a14351198e 100644 --- a/release_notes.md +++ b/release_notes.md @@ -8,7 +8,6 @@ Date Commit Action Added props hikari.idleTimeout, default is from hakari. Added props hikari.keepaliveTime, default is from hakari. Added props hikari.maxLifetime, default is from hakari. - Added props hikari.metricRegistry, default is from hakari. 24/08/2023 bcb8fcfd Added props expectedOpenFuturesPerService, default is 100. 16/08/2023 4d8dfa66 Added props short_endpoint_timeout, default is 1. Added props medium_endpoint_timeout, default is 7. From 86372a2559d31d52380ef5e8768745244b4be361 Mon Sep 17 00:00:00 2001 From: hongwei Date: Mon, 16 Oct 2023 10:42:52 +0200 Subject: [PATCH 5/6] refactor/revert the github workflows api_instance_id settting --- .github/workflows/build_package.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml index b07cca0b3e..207002beb5 100644 --- a/.github/workflows/build_package.yml +++ b/.github/workflows/build_package.yml @@ -52,7 +52,6 @@ jobs: echo kafka.akka.timeout = 9 >> obp-api/src/main/resources/props/test.default.props echo remotedata.timeout = 10 >> obp-api/src/main/resources/props/test.default.props - echo api_instance_id = 1 >> obp-api/src/main/resources/props/test.default.props echo allow_oauth2_login=true >> obp-api/src/main/resources/props/test.default.props echo oauth2.jwk_set.url=https://www.googleapis.com/oauth2/v3/certs >> obp-api/src/main/resources/props/test.default.props From ff2449c97f4dd9e13dd49a17fe9e4182b17fa19b Mon Sep 17 00:00:00 2001 From: hongwei Date: Mon, 16 Oct 2023 11:46:47 +0200 Subject: [PATCH 6/6] docfix/typo --- release_notes.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release_notes.md b/release_notes.md index a14351198e..c5e21fc07f 100644 --- a/release_notes.md +++ b/release_notes.md @@ -3,11 +3,11 @@ ### Most recent changes at top of file ``` Date Commit Action -13/10/2023 d87c99d8 Added props hikari.connectionTimeout, default is from hakari. - Added props hikari.maximumPoolSize, default is from hakari. - Added props hikari.idleTimeout, default is from hakari. - Added props hikari.keepaliveTime, default is from hakari. - Added props hikari.maxLifetime, default is from hakari. +13/10/2023 d87c99d8 Added props hikari.connectionTimeout, default is from hikari. + Added props hikari.maximumPoolSize, default is from hikari. + Added props hikari.idleTimeout, default is from hikari. + Added props hikari.keepaliveTime, default is from hikari. + Added props hikari.maxLifetime, default is from hikari. 24/08/2023 bcb8fcfd Added props expectedOpenFuturesPerService, default is 100. 16/08/2023 4d8dfa66 Added props short_endpoint_timeout, default is 1. Added props medium_endpoint_timeout, default is 7.