PooledClientProvider extends AbstractClientProvider { @Override public String toString() { return "Elastic pool of size " + this.maxClients + ", with timeout (in milliseconds): " + this.obtainClientTimeoutMs; } PooledClientProvider(Configuration conf, DiscoveryServiceClient discoveryServiceClient); @Override CloseableThriftClient getCloseableClient(); @Override void returnClient(TransactionServiceThriftClient client); @Override String toString();  }
@Test public void testClientConnectionPoolMaximumNumberOfClients() throws Exception { InMemoryZKServer zkServer = InMemoryZKServer.builder().setDataDir(tmpFolder.newFolder()).build(); zkServer.startAndWait(); try { Configuration conf = new Configuration(); conf.set(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM, zkServer.getConnectionStr()); conf.set(TxConstants.Manager.CFG_TX_SNAPSHOT_DIR, tmpFolder.newFolder().getAbsolutePath()); conf.set("data.tx.client.count", Integer.toString(MAX_CLIENT_COUNT)); conf.set("data.tx.client.obtain.timeout", Long.toString(CLIENT_OBTAIN_TIMEOUT)); final TransactionServiceMain main = new TransactionServiceMain(conf); final CountDownLatch latch = new CountDownLatch(1); Thread t = new Thread() { @Override public void run() { try { main.start(); latch.countDown(); } catch (Exception e) { throw Throwables.propagate(e); } } }; try { t.start(); latch.await(); startClientAndTestPool(conf); } finally { main.stop(); t.join(); } } finally { zkServer.stopAndWait(); } }