synchronized int removeOldConnections ( ) { long now = System . currentTimeMillis ( ) ; long expirationTime = now - idleTransportTimeout . millis ( ) ; List < PooledTransport > removeFromIdle = new ArrayList < PooledTransport > ( ) ; for ( Map . Entry < PooledTransport , Long > idleEntry : idle . entrySet ( ) ) { long lastUsed = idleEntry . getValue ( ) ; if ( lastUsed < expirationTime ) { PooledTransport removed = idleEntry . getKey ( ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Expiring idle transport for job [" + jobPoolingKey + "], transport: [" + removed . toString ( ) + "]. Last used [" + new TimeValue ( now - lastUsed ) + "] ago. Expired [" + idleTransportTimeout + "] ago." ) ; } release ( removed ) ; removeFromIdle . add ( removed ) ; } } for ( PooledTransport toRemove : removeFromIdle ) { idle . remove ( toRemove ) ; } return idle . size ( ) + leased . size ( ) ; }
Cleans the pool by removing any resources that have been idle for longer than the configured transport pool idle time .