rohityadavcloud commented on code in PR #9518:
URL: https://github.com/apache/cloudstack/pull/9518#discussion_r1726434570


##########
framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java:
##########
@@ -1226,45 +1220,84 @@ private static DataSource createDataSource(String uri, 
String username, String p
                                                Integer maxActive, Integer 
maxIdle, Long maxWait,
                                                Long timeBtwnEvictionRuns, Long 
minEvictableIdleTime,
                                                Boolean testWhileIdle, Boolean 
testOnBorrow,
-                                               String validationQuery, Integer 
isolationLevel) {
-        ConnectionFactory connectionFactory = new 
DriverManagerConnectionFactory(uri, username, password);
-        PoolableConnectionFactory poolableConnectionFactory = new 
PoolableConnectionFactory(connectionFactory, null);
-        GenericObjectPoolConfig config = createPoolConfig(maxActive, maxIdle, 
maxWait, timeBtwnEvictionRuns, minEvictableIdleTime, testWhileIdle, 
testOnBorrow);
-        ObjectPool<PoolableConnection> connectionPool = new 
GenericObjectPool<>(poolableConnectionFactory, config);
-        poolableConnectionFactory.setPool(connectionPool);
-        if (validationQuery != null) {
-            poolableConnectionFactory.setValidationQuery(validationQuery);
+                                               String validationQuery, Integer 
isolationLevel,
+                                               String dsName) {
+        HikariConfig config = new HikariConfig();
+        config.setJdbcUrl(uri);
+        config.setUsername(username);
+        config.setPassword(password);
+
+        config.setPoolName(dsName);
+        if (maxActive != null) {
+            config.setMaximumPoolSize(maxActive);
+        } else {
+            config.setMaximumPoolSize(250); // 250 connections
         }
-        if (isolationLevel != null) {
-            
poolableConnectionFactory.setDefaultTransactionIsolation(isolationLevel);
+        if (maxIdle != null) {
+            config.setIdleTimeout(maxIdle * 1000);
+        } else {
+            config.setIdleTimeout(30000); // 30 seconds
         }
-        return new PoolingDataSource<>(connectionPool);
-    }
-
-    /**
-     * Return a GenericObjectPoolConfig configuration usable on connection 
pool creation
-     */
-    private static GenericObjectPoolConfig createPoolConfig(Integer maxActive, 
Integer maxIdle, Long maxWait,
-                                                            Long 
timeBtwnEvictionRuns, Long minEvictableIdleTime,
-                                                            Boolean 
testWhileIdle, Boolean testOnBorrow) {
-        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
-        config.setMaxTotal(maxActive);
-        config.setMaxIdle(maxIdle);
-        config.setMaxWaitMillis(maxWait);
+        if (maxWait != null) {
+            config.setMaxLifetime(maxWait);
+        } else {
+            config.setMaxLifetime(600000); // 10 minutes
+        }
+
+        // Connection pool properties
+        config.setMinimumIdle(5);           // Minimum number of idle 
connections in the pool
+        config.setConnectionTimeout(30000); // 30 seconds in milliseconds
+        config.setKeepaliveTime(600000);    // Keepalive time in milliseconds 
(10 minutes)
+        config.setIdleTimeout(300000); // 5 minutes
+        //config.setMinimumIdle(maxIdle);

Review Comment:
   @shwstppr worth checking & removing dead/commented code; remove old 
variables in db.properties and or refactor/remove them to introduce for use 
with these configs ^^ which are hard-coded at the moment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to