@Override public int compare(HostConnectionPool<?> p1, HostConnectionPool<?> p2) { return p1.getBusyConnectionCount() + p1.getBlockedThreadCount() - p2.getBusyConnectionCount() - p2.getBlockedThreadCount(); } };
@Override public int compare(HostConnectionPool<?> p1, HostConnectionPool<?> p2) { return p1.getBusyConnectionCount() + p1.getBlockedThreadCount() - p2.getBusyConnectionCount() - p2.getBlockedThreadCount(); } };
Collections.sort(pools, busyComparator); HostConnectionPool<CL> poolFirst = pools.get(0); int firstBusy = poolFirst.getBusyConnectionCount() - poolFirst.getBlockedThreadCount(); for (int i = pools.size() - 1; i >= keep; i--) { HostConnectionPool<CL> pool = pools.get(i); int busy = pool.getBusyConnectionCount() + pool.getBlockedThreadCount(); if ( (busy - firstBusy) > getBlockedThreshold()) {
Collections.sort(pools, busyComparator); HostConnectionPool<CL> poolFirst = pools.get(0); int firstBusy = poolFirst.getBusyConnectionCount() - poolFirst.getBlockedThreadCount(); for (int i = pools.size() - 1; i >= keep; i--) { HostConnectionPool<CL> pool = pools.get(i); int busy = pool.getBusyConnectionCount() + pool.getBlockedThreadCount(); if ( (busy - firstBusy) > getBlockedThreshold()) {