remove method calls from hot path and sleep in smaller steps

pull/453/head
Nitin 9 years ago
parent 316629b72f
commit 3218166f7d

@ -302,7 +302,7 @@ public class HikariPool extends PoolBase implements HikariPoolMXBean, IBagStateL
while (poolState == POOL_NORMAL && totalConnections.get() < maxPoolSize && getIdleConnections() <= minimumIdle && !addConnection()) {
// If we got into the loop, addConnection() failed, so we sleep and retry
quietlySleep(sleepBackoff);
sleepBackoff = Math.min(connectionTimeout / 2, (long) (sleepBackoff * 1.5));
sleepBackoff = Math.min(connectionTimeout / 2, (long) (sleepBackoff * 1.3));
}
}
}, true);

@ -168,17 +168,7 @@ abstract class PoolBase
PoolEntry newPoolEntry() throws Exception
{
return new PoolEntry(newConnection(), this);
}
boolean getReadOnly()
{
return isReadOnly;
}
boolean getAutoCommit()
{
return isAutoCommit;
return new PoolEntry(newConnection(), this, isReadOnly, isAutoCommit);
}
void resetConnectionState(final Connection connection, final ProxyConnection proxyConnection, final int dirtyBits) throws SQLException

@ -44,11 +44,14 @@ final class PoolEntry implements IConcurrentBagEntry
long lastBorrowed;
private volatile boolean evict;
private volatile ScheduledFuture<?> endOfLife;
private final FastList<Statement> openStatements;
private final HikariPool hikariPool;
private final AtomicInteger state;
private volatile ScheduledFuture<?> endOfLife;
private final boolean isReadOnly;
private final boolean isAutoCommit;
static
{
@ -60,13 +63,15 @@ final class PoolEntry implements IConcurrentBagEntry
};
}
PoolEntry(final Connection connection, final PoolBase pool)
PoolEntry(final Connection connection, final PoolBase pool, final boolean isReadOnly, final boolean isAutoCommit)
{
this.connection = connection;
this.hikariPool = (HikariPool) pool;
this.state = new AtomicInteger(STATE_NOT_IN_USE);
this.lastAccessed = ClockSource.INSTANCE.currentTime();
this.openStatements = new FastList<>(Statement.class, 16);
this.isReadOnly = isReadOnly;
this.isAutoCommit = isAutoCommit;
}
/**
@ -90,7 +95,7 @@ final class PoolEntry implements IConcurrentBagEntry
Connection createProxyConnection(final ProxyLeakTask leakTask, final long now)
{
return ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, now, hikariPool.getReadOnly(), hikariPool.getAutoCommit());
return ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, now, isReadOnly, isAutoCommit);
}
void resetConnectionState(final ProxyConnection proxyConnection, final int dirtyBits) throws SQLException

Loading…
Cancel
Save