Skip to content

Commit

Permalink
ADH-5331
Browse files Browse the repository at this point in the history
- fixed comments
  • Loading branch information
VitekArkhipov committed Dec 5, 2024
1 parent ba328e5 commit 8032a30
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Optional<Connection> tryOpenConnection()
}

@Override
public boolean tryCloseConnection()
public boolean tryCloseDataSource()
{
lock.lock();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class AdbJdbcDataSourcePool
{
private static final long CLEANUP_INITIAL_DELAY_SECONDS = 10L;
private static final long CLEANUP_PERIOD_SECONDS = 10L;
private final Queue<CachedDataSourceEntry> removedConnections = new ConcurrentLinkedQueue<>();
private final Queue<CachedDataSourceEntry> removedEntries = new ConcurrentLinkedQueue<>();
private final AdbJdbcConnectionPoolConfig poolConfig;
private final ConnectionFactory delegate;
private final CatalogName catalogName;
Expand All @@ -59,12 +59,12 @@ public AdbJdbcDataSourcePool(AdbJdbcConnectionPoolConfig config,
CacheBuilder.newBuilder()
.maximumSize(poolConfig.getMaxUsers())
.expireAfterAccess(poolConfig.getUserTtl().toMillis(), TimeUnit.MILLISECONDS)
.removalListener(entry -> removedConnections.add(entry.getValue())));
.removalListener(entry -> removedEntries.add(entry.getValue())));
cleanupExecutor = Executors.newSingleThreadScheduledExecutor(
Threads.daemonThreadsNamed(String.format("adb-jdbc-connection-pool-cleanup-%s", catalogName)));
cleanupExecutor.scheduleAtFixedRate(() -> {
cache.cleanUp();
removedConnections.removeIf(CachedDataSourceEntry::tryCloseConnection);
removedEntries.removeIf(CachedDataSourceEntry::tryCloseDataSource);
}, CLEANUP_INITIAL_DELAY_SECONDS, CLEANUP_PERIOD_SECONDS, TimeUnit.SECONDS);
}

Expand All @@ -77,7 +77,7 @@ public CachedDataSourceEntry get(ConnectorSession session)
HikariConfig config = new HikariConfig();
config.setDataSource(new AdbDataSource(delegate, session));
config.setRegisterMbeans(true);
config.setPoolName(catalogName.toString());
config.setPoolName(catalogName.toString() + "_" + key.hashCode());
config.setMaximumPoolSize(poolConfig.getMaxUserConnections());
config.setMaxLifetime(poolConfig.getConnectionTtl().toMillis());
return new AdbCachedDataSourceEntry(new HikariDataSource(config));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public interface CachedDataSourceEntry
Optional<Connection> tryOpenConnection()
throws SQLException;

boolean tryCloseConnection();
boolean tryCloseDataSource();
}

0 comments on commit 8032a30

Please sign in to comment.