|
|
@ -59,6 +59,7 @@ public final class HikariPool implements HikariPoolMBean
|
|
|
|
private final boolean isAutoCommit;
|
|
|
|
private final boolean isAutoCommit;
|
|
|
|
private final boolean jdbc4ConnectionTest;
|
|
|
|
private final boolean jdbc4ConnectionTest;
|
|
|
|
private int transactionIsolation;
|
|
|
|
private int transactionIsolation;
|
|
|
|
|
|
|
|
private volatile boolean shutdown;
|
|
|
|
private boolean debug;
|
|
|
|
private boolean debug;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -140,6 +141,11 @@ public final class HikariPool implements HikariPoolMBean
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Connection getConnection() throws SQLException
|
|
|
|
Connection getConnection() throws SQLException
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (shutdown)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new SQLException("Pool has been shutdown");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
long timeout = configuration.getConnectionTimeout();
|
|
|
|
long timeout = configuration.getConnectionTimeout();
|
|
|
@ -203,7 +209,7 @@ public final class HikariPool implements HikariPoolMBean
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void releaseConnection(IHikariConnectionProxy connectionProxy)
|
|
|
|
public void releaseConnection(IHikariConnectionProxy connectionProxy)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!connectionProxy.isBrokenConnection())
|
|
|
|
if (!connectionProxy.isBrokenConnection() && !shutdown)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
idleConnectionCount.incrementAndGet();
|
|
|
|
idleConnectionCount.incrementAndGet();
|
|
|
|
idleConnections.put(connectionProxy);
|
|
|
|
idleConnections.put(connectionProxy);
|
|
|
@ -216,7 +222,18 @@ public final class HikariPool implements HikariPoolMBean
|
|
|
|
|
|
|
|
|
|
|
|
void shutdown()
|
|
|
|
void shutdown()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO: implement complete shutdown of the pool
|
|
|
|
shutdown = true;
|
|
|
|
|
|
|
|
houseKeepingTimer.cancel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IHikariConnectionProxy connection = idleConnections.poll();
|
|
|
|
|
|
|
|
if (connection == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
closeConnection(connection);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***********************************************************************
|
|
|
|
// ***********************************************************************
|
|
|
@ -325,7 +342,7 @@ public final class HikariPool implements HikariPoolMBean
|
|
|
|
}
|
|
|
|
}
|
|
|
|
backgroundFillQueued.set(false);
|
|
|
|
backgroundFillQueued.set(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 90/*ms*/);
|
|
|
|
}, 100/*ms*/);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -365,9 +382,12 @@ public final class HikariPool implements HikariPoolMBean
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!shutdown)
|
|
|
|
|
|
|
|
{
|
|
|
|
idleConnectionCount.incrementAndGet();
|
|
|
|
idleConnectionCount.incrementAndGet();
|
|
|
|
totalConnections.incrementAndGet();
|
|
|
|
totalConnections.incrementAndGet();
|
|
|
|
idleConnections.add(proxyConnection);
|
|
|
|
idleConnections.add(proxyConnection);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|