Factored into own method code executed after creation of a new

connection.
This commit is contained in:
Simone Bordet 2015-03-05 16:54:44 +01:00
parent 1a5346ec4f
commit a64368df5d
1 changed files with 13 additions and 8 deletions

View File

@ -109,13 +109,7 @@ public class ConnectionPool implements Closeable, Dumpable
if (LOG.isDebugEnabled())
LOG.debug("Connection {}/{} creation succeeded {}", next, maxConnections, connection);
boolean idle;
try (SpinLock.Lock lock = ConnectionPool.this.lock.lock())
{
// Use "cold" new connections as last.
idle = idleConnections.offerLast(connection);
}
idle(connection, idle);
idleCreated(connection);
requester.succeeded(connection);
}
@ -138,6 +132,17 @@ public class ConnectionPool implements Closeable, Dumpable
}
}
protected void idleCreated(Connection connection)
{
boolean idle;
try (SpinLock.Lock lock = this.lock.lock())
{
// Use "cold" new connections as last.
idle = idleConnections.offerLast(connection);
}
idle(connection, idle);
}
private Connection activateIdle()
{
boolean acquired;
@ -184,7 +189,7 @@ public class ConnectionPool implements Closeable, Dumpable
return idle(connection, idle);
}
private boolean idle(Connection connection, boolean idle)
protected boolean idle(Connection connection, boolean idle)
{
if (idle)
{