in geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java [208:232]
public void setPartitionMaxSize(int newMaxSize) throws InterruptedException {
if (newMaxSize <= 0) {
throw new IllegalArgumentException("Max size must be positive, not " + newMaxSize);
}
if (newMaxSize != getPartitionMaxSize()) {
resizeLock.writeLock().lock();
try {
ResizeInfo resizeInfo = new ResizeInfo(this.minSize, permits.availablePermits(), connectionCount, newMaxSize);
permits = new Semaphore(newMaxSize, true);
//pre-acquire permits for the existing checked out connections that will not be closed when they are returned.
for (int i = 0; i < resizeInfo.getTransferCheckedOut(); i++) {
permits.acquire();
}
//make sure shrinkLater is 0 while discarding excess connections
this.shrinkLater = 0;
//transfer connections we are going to keep
transferConnections(newMaxSize, resizeInfo.getShrinkNow());
this.shrinkLater = resizeInfo.getShrinkLater();
this.minSize = resizeInfo.getNewMinSize();
this.maxSize = newMaxSize;
} finally {
resizeLock.writeLock().unlock();
}
}
}