/** * Returns a free connection. * * @return Connection handle. * @throws SQLException */ public Connection getConnection() throws SQLException { return this.connectionStrategy.getConnection(); }
public void terminateAllConnections() { for (ConnectionHandle conn : this.threadFinalizableRefs.keySet()){ this.pool.destroyConnection(conn); } this.threadFinalizableRefs.clear(); this.fallbackStrategy.terminateAllConnections(); }
@Override protected SimpleEntry<ConnectionHandle, Boolean> initialValue() { SimpleEntry<ConnectionHandle, Boolean> result = null; ConnectionHandle c = null; // grab a connection from any other configured fallback strategy for (int i=0; i < 4*3; i++){ // there is a slight race with the pool watch creation thread so spin for a bit // no big deal if it keeps failing, we just switch to default connection strategy c = (ConnectionHandle)this.fallbackStrategy.pollConnection(); if (c != null){ break; } // oh-huh? either we are racing while resizing the pool or else no of threads > no of connections. Let's wait a bit // and try again one last time Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); } if (c != null){ result = new SimpleEntry<ConnectionHandle, Boolean>(c, false); this.ccs.threadWatch(c); } return result; }
this.pool.connectionStrategy.cleanupConnection(this, handle); this.pool.releaseConnection(handle); } catch(SQLException e) { this.pool.connectionStrategy.cleanupConnection(this, handle); this.pool.releaseConnection(this);
@Override public SimpleEntry<ConnectionHandle, Boolean> get() { SimpleEntry<ConnectionHandle, Boolean> result = super.get(); // have we got one that's cached and unused? Mark it as in use. if (result == null || result.getValue()){ // ... otherwise grab a new connection ConnectionHandle fallbackConnection = (ConnectionHandle)this.fallbackStrategy.pollConnection(); if (fallbackConnection == null){ return null; } result = new SimpleEntry<ConnectionHandle, Boolean>(fallbackConnection, false); } result.setValue(true); result.getKey().logicallyClosed.set(false); return result; } }
this.connectionStrategy.terminateAllConnections(); unregisterDriver(); registerUnregisterJMX(false);
/** * Returns a free connection. * @return Connection handle. * @throws SQLException */ public Connection getConnection() throws SQLException { return this.connectionStrategy.getConnection(); }
this.connectionStrategy.terminateAllConnections(); unregisterDriver(); registerUnregisterJMX(false);
@Override protected Connection getConnectionInternal() throws SQLException { // try to get the connection from thread local storage. SimpleEntry<ConnectionHandle, Boolean> result = this.tlConnections.get(); // we should always be successful. If not, it means we have more threads asking // us for a connection than we've got available. This is not supported so we flip // back our strategy. if (result == null){ this.pool.cachedPoolStrategy = false; this.pool.connectionStrategy = this.fallbackStrategy; stealExistingAllocations(); // get a connection as if under our fallback strategy now. return (ConnectionHandle) this.pool.connectionStrategy.getConnection(); } return result.getKey(); }
this.pool.connectionStrategy.terminateAllConnections(); this.pool.destroyConnection(this); this.logicallyClosed.set(true);