use of com.dtflys.forest.backend.ForestConnectionManager in project forest by dromara.
the class TestPoolClient method testPool.
@Test
public void testPool() throws InterruptedException {
int count = 100;
for (int i = 0; i < count; i++) {
server.enqueue(new MockResponse().setBody(EXPECTED).setHeadersDelay(1, TimeUnit.SECONDS));
}
HttpBackend backend = configuration.getBackend();
ForestConnectionManager connectionManager = backend.getConnectionManager();
ExecutorService executorService = Executors.newFixedThreadPool(count);
CountDownLatch latch = new CountDownLatch(count);
for (int i = 0; i < count; i++) {
executorService.execute(() -> {
poolClient.send();
if (connectionManager instanceof OkHttp3ConnectionManager) {
ConnectionPool pool = ((OkHttp3ConnectionManager) connectionManager).getOkHttpPool();
System.out.println("connect count = " + pool.connectionCount());
}
latch.countDown();
});
}
latch.await();
}
Aggregations