public synchronized void shutdown ( ) throws InterruptedException { try { poolState = POOL_SHUTDOWN ; if ( addConnectionExecutor == null ) { // pool never started return ; } logPoolState ( "Before shutdown " ) ; if ( houseKeeperTask != null ) { houseKeeperTask . cancel ( false ) ; houseKeeperTask = null ; } softEvictConnections ( ) ; addConnectionExecutor . shutdown ( ) ; addConnectionExecutor . awaitTermination ( getLoginTimeout ( ) , SECONDS ) ; destroyHouseKeepingExecutorService ( ) ; connectionBag . close ( ) ; final ExecutorService assassinExecutor = createThreadPoolExecutor ( config . getMaximumPoolSize ( ) , poolName + " connection assassinator" , config . getThreadFactory ( ) , new ThreadPoolExecutor . CallerRunsPolicy ( ) ) ; try { final long start = currentTime ( ) ; do { abortActiveConnections ( assassinExecutor ) ; softEvictConnections ( ) ; } while ( getTotalConnections ( ) > 0 && elapsedMillis ( start ) < SECONDS . toMillis ( 10 ) ) ; } finally { assassinExecutor . shutdown ( ) ; assassinExecutor . awaitTermination ( 10L , SECONDS ) ; } shutdownNetworkTimeoutExecutor ( ) ; closeConnectionExecutor . shutdown ( ) ; closeConnectionExecutor . awaitTermination ( 10L , SECONDS ) ; } finally { logPoolState ( "After shutdown " ) ; handleMBeans ( this , false ) ; metricsTracker . close ( ) ; } }
Shutdown the pool closing all idle connections and aborting or closing active connections .