@Override public void cleanupConnection(ConnectionHandle oldHandle, ConnectionHandle newHandle) { this.threadFinalizableRefs.remove(oldHandle); this.threadWatch(newHandle); }
@Override protected SimpleEntry<ConnectionHandle, Boolean> initialValue() { SimpleEntry<ConnectionHandle, Boolean> result = null; ConnectionHandle c = null; // grab a connection from any other configured fallback strategy for (int i=0; i < 4*3; i++){ // there is a slight race with the pool watch creation thread so spin for a bit // no big deal if it keeps failing, we just switch to default connection strategy c = (ConnectionHandle)this.fallbackStrategy.pollConnection(); if (c != null){ break; } // oh-huh? either we are racing while resizing the pool or else no of threads > no of connections. Let's wait a bit // and try again one last time Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); } if (c != null){ result = new SimpleEntry<ConnectionHandle, Boolean>(c, false); this.ccs.threadWatch(c); } return result; }