synchronized int cleanPools() {
        int totalConnectionsRemaining = 0;
        List<String> hostsToRemove = new ArrayList<String>();
        for (Map.Entry<String, TransportPool> hostPool : hostPools.entrySet()) {
            String host = hostPool.getKey();
            TransportPool pool = hostPool.getValue();

            int connectionsRemaining = pool.removeOldConnections();
            if (connectionsRemaining == 0) {
                hostsToRemove.add(host);
            } else {
                totalConnectionsRemaining += connectionsRemaining;
            }
        }

        // Remove old pools that now have no connections.
        for (String hostToRemove : hostsToRemove) {
            hostPools.remove(hostToRemove);
        }

        return totalConnectionsRemaining;
    }
synchronized int cleanPools ( ) { int totalConnectionsRemaining = 0 ; List < String > hostsToRemove = new ArrayList < String > ( ) ; for ( Map . Entry < String , TransportPool > hostPool : hostPools . entrySet ( ) ) { String host = hostPool . getKey ( ) ; TransportPool pool = hostPool . getValue ( ) ; int connectionsRemaining = pool . removeOldConnections ( ) ; if ( connectionsRemaining == 0 ) { hostsToRemove . add ( host ) ; } else { totalConnectionsRemaining += connectionsRemaining ; } } for ( String hostToRemove : hostsToRemove ) { hostPools . remove ( hostToRemove ) ; } return totalConnectionsRemaining ; }
Iterates over the available host pools and asks each one to purge transports older than a certain age.
@return Total number of pooled connections still alive in this factory.