use of com.linkedin.r2.transport.http.client.AbstractJmxManager in project rest.li by linkedin.
the class TestHttpNettyClient method testPoolStatsProviderManager.
@Test
public void testPoolStatsProviderManager() throws InterruptedException, ExecutionException, TimeoutException {
final CountDownLatch setLatch = new CountDownLatch(1);
final CountDownLatch removeLatch = new CountDownLatch(1);
AbstractJmxManager manager = new AbstractJmxManager() {
@Override
public void onProviderCreate(PoolStatsProvider provider) {
setLatch.countDown();
}
@Override
public void onProviderShutdown(PoolStatsProvider provider) {
removeLatch.countDown();
}
};
HttpNettyClient client = new HttpClientBuilder(_eventLoop, _scheduler).setJmxManager(manager).buildRestClient();
// test setPoolStatsProvider
try {
setLatch.await(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Assert.fail("PoolStatsAware setPoolStatsProvider didn't get called when creating channel pool.");
}
// test removePoolStatsProvider
FutureCallback<None> shutdownCallback = new FutureCallback<>();
client.shutdown(shutdownCallback);
try {
removeLatch.await(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Assert.fail("PoolStatsAware removePoolStatsProvider didn't get called when shutting down channel pool.");
}
shutdownCallback.get(30, TimeUnit.SECONDS);
}
Aggregations