/** Closes off this connection * @param connection to close */ protected void closeConnection(ConnectionHandle connection) { if (connection != null) { try { connection.internalClose(); } catch (Throwable t) { logger.error("Destroy connection exception", t); } finally { this.pool.postDestroyConnection(connection); } } } }
/** * Physically close off the internal connection. * @param conn */ protected void destroyConnection(ConnectionHandle conn) { postDestroyConnection(conn); conn.setInReplayMode(true); // we're dead, stop attempting to replay anything try { conn.internalClose(); } catch (SQLException e) { logger.error("Error in attempting to close connection", e); } }
/** * Physically close off the internal connection. * * @param conn the connection */ protected void destroyConnection(ConnectionHandle conn) { postDestroyConnection(conn); // we're dead, stop attempting to replay anything conn.setInReplayMode(true); try { conn.internalClose(); } catch (SQLException e) { LOGGER.error("Error in attempting to close connection", e); } }
/** Closes off this connection * @param connection to close */ protected void closeConnection(ConnectionHandle connection) { if (connection != null && !connection.isClosed()) { try { connection.internalClose(); } catch (SQLException e) { logger.error("Destroy connection exception", e); } finally { this.pool.postDestroyConnection(connection); connection.getOriginatingPartition().getPoolWatchThreadSignalQueue().offer(new Object()); // item being pushed is not important. } } }
/** Places a connection back in the originating partition. * @param connectionHandle to place back * @throws SQLException on error */ protected void putConnectionBackInPartition(ConnectionHandle connectionHandle) throws SQLException { if (this.cachedPoolStrategy && ((CachedConnectionStrategy)this.connectionStrategy).tlConnections.dumbGet().getValue()){ connectionHandle.logicallyClosed.set(true); ((CachedConnectionStrategy)this.connectionStrategy).tlConnections.set(new AbstractMap.SimpleEntry<ConnectionHandle, Boolean>(connectionHandle, false)); } else { BlockingQueue<ConnectionHandle> queue = connectionHandle.getOriginatingPartition().getFreeConnections(); if (!queue.offer(connectionHandle)){ // this shouldn't fail connectionHandle.internalClose(); } } }
/** * Places a connection back in the originating partition. * * @param connectionHandle to place back * @throws SQLException on error */ protected void putConnectionBackInPartition(ConnectionHandle connectionHandle) throws SQLException { if (this.cachedPoolStrategy && ((CachedConnectionStrategy) this.connectionStrategy).tlConnections.dumbGet().getValue()) { connectionHandle.logicallyClosed.set(true); ((CachedConnectionStrategy) this.connectionStrategy).tlConnections.set(new AbstractMap.SimpleEntry<ConnectionHandle, Boolean>(connectionHandle, false)); } else { BlockingQueue<ConnectionHandle> queue = connectionHandle.getOriginatingPartition().getFreeConnections(); if (!queue.offer(connectionHandle)) { // this shouldn't fail connectionHandle.internalClose(); } } }
/** * Adds a free connection. * * @param connectionHandle * @throws SQLException on error */ protected void addFreeConnection(ConnectionHandle connectionHandle) throws SQLException{ connectionHandle.setOriginatingPartition(this); // assume success to avoid racing where we insert an item in a queue and having that item immediately // taken and closed off thus decrementing the created connection count. updateCreatedConnections(1); if (!this.disableTracking){ trackConnectionFinalizer(connectionHandle); } // the instant the following line is executed, consumers can start making use of this // connection. if (!this.freeConnections.offer(connectionHandle)){ // we failed. rollback. updateCreatedConnections(-1); // compensate our createdConnection count. if (!this.disableTracking){ this.pool.getFinalizableRefs().remove(connectionHandle.getInternalConnection()); } // terminate the internal handle. connectionHandle.internalClose(); } }
connectionHandle.internalClose(); putConnectionBackInPartition(connectionHandle); } else { connectionHandle.internalClose();
connectionHandle.internalClose(); putConnectionBackInPartition(connectionHandle); } else { connectionHandle.internalClose();