/** Closes off all connections in all partitions. */ public void terminateAllConnections(){ this.terminationLock.lock(); try{ // close off all connections. for (int i=0; i < this.pool.partitionCount; i++) { this.pool.partitions[i].setUnableToCreateMoreTransactions(false); // we can create new ones now, this is an optimization List<ConnectionHandle> clist = new LinkedList<ConnectionHandle>(); this.pool.partitions[i].getFreeConnections().drainTo(clist); for (ConnectionHandle c: clist){ this.pool.destroyConnection(c); } } } finally { this.terminationLock.unlock(); } }
/** Update counters and call hooks. * @param handle connection handle. */ protected void postDestroyConnection(ConnectionHandle handle){ ConnectionPartition partition = handle.getOriginatingPartition(); if (this.finalizableRefQueue != null && handle.getInternalConnection() != null){ //safety this.finalizableRefs.remove(handle.getInternalConnection()); // assert o != null : "Did not manage to remove connection from finalizable ref queue"; } partition.updateCreatedConnections(-1); partition.setUnableToCreateMoreTransactions(false); // we can create new ones now, this is an optimization // "Destroying" for us means: don't put it back in the pool. if (handle.getConnectionHook() != null){ handle.getConnectionHook().onDestroy(handle); } }
/** * Update counters and call hooks. * * @param handle connection handle. */ protected void postDestroyConnection(ConnectionHandle handle) { ConnectionPartition partition = handle.getOriginatingPartition(); if (this.finalizableRefQueue != null && handle.getInternalConnection() != null) { //safety check this.finalizableRefs.remove(handle.getInternalConnection()); // o != null : "Did not manage to remove connection from finalizable ref queue"; } partition.updateCreatedConnections(-1); // we can create new ones now, this is an optimization partition.setUnableToCreateMoreTransactions(false); // "Destroying" for us means: don't put it back in the pool. if (handle.getConnectionHook() != null) { handle.getConnectionHook().onDestroy(handle); } }
this.partition.setUnableToCreateMoreTransactions(true);