use of com.mongodb.selector.ServerAddressSelector in project mongo-java-driver by mongodb.
the class ServerHelper method waitForLastRelease.
public static void waitForLastRelease(final ServerAddress address, final Cluster cluster) {
DefaultServer server = (DefaultServer) cluster.selectServer(new ServerAddressSelector(address));
DefaultConnectionPool connectionProvider = (DefaultConnectionPool) server.getConnectionPool();
ConcurrentPool<UsageTrackingInternalConnection> pool = connectionProvider.getPool();
long startTime = System.currentTimeMillis();
while (pool.getInUseCount() > 0) {
try {
sleep(10);
if (System.currentTimeMillis() > startTime + ClusterFixture.TIMEOUT * 1000) {
throw new MongoTimeoutException("Timed out waiting for pool in use count to drop to 0. Now at: " + pool.getInUseCount());
}
} catch (InterruptedException e) {
throw new MongoInterruptedException("Interrupted", e);
}
}
}
Aggregations