Skip to content

Commit

Permalink
[Java] Close connection during shutdown (#557)
Browse files Browse the repository at this point in the history
Signed-off-by: chenxu <[email protected]>
Co-authored-by: chenxu <[email protected]>
  • Loading branch information
xuchen-plus and dmetasoul01 authored Nov 5, 2024
1 parent 334c76a commit d25ac74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public static synchronized void closeAllConnections() {
}
}

static {
Runtime.getRuntime().addShutdownHook(new Thread(DBConnector::closeAllConnections));
}

public static void closeConn(Connection conn) {
if (conn != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ public static LinkedHashMap<String, String> parsePartitionDesc(String partitionD

public static void fillDataSourceConfig(HikariConfig config) {
config.setConnectionTimeout(10000);
config.setIdleTimeout(60000);
config.setMaximumPoolSize(8);
config.setKeepaliveTime(30000);
config.setIdleTimeout(30000);
config.setMaximumPoolSize(2);
config.setKeepaliveTime(10000);
config.setMinimumIdle(1);
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.dmetasoul.lakesoul.meta.jnr;

import com.alibaba.fastjson.JSON;
import com.dmetasoul.lakesoul.meta.DBConnector;
import com.dmetasoul.lakesoul.meta.DBUtil;
import com.dmetasoul.lakesoul.meta.DataBaseProperty;
import com.dmetasoul.lakesoul.meta.entity.JniWrapper;
Expand Down Expand Up @@ -541,6 +542,9 @@ public static void closeAll() {
}
}

static {
java.lang.Runtime.getRuntime().addShutdownHook(new Thread(NativeMetadataJavaClient::closeAll));
}

/**
* if ffi function failed with -100
Expand Down

0 comments on commit d25ac74

Please sign in to comment.