use of com.linkedin.pinot.transport.common.AsyncResponseFuture in project pinot by linkedin.
the class KeyedPoolImplTest method testDestroyError.
@Test
public void testDestroyError() throws Exception {
ScheduledExecutorService timedExecutor = new ScheduledThreadPoolExecutor(1);
ExecutorService service = MoreExecutors.sameThreadExecutor();
int numKeys = 1;
int numResourcesPerKey = 1;
Map<String, List<String>> resources = buildCreateMap(numKeys, numResourcesPerKey);
TestResourceManager rm = new TestResourceManager(resources, null, resources, null);
KeyedPool<String, String> kPool = new KeyedPoolImpl<String, String>(0, 5, 1000L, 1000 * 60 * 60, rm, timedExecutor, service, null);
AsyncResponseFuture<String, String> f = (AsyncResponseFuture<String, String>) kPool.checkoutObject(getKey(0));
String r = f.getOne();
Assert.assertTrue(f.isDone());
Assert.assertNull(f.getError());
// Create a countdown latch that waits for the attempt to delete the resource
CountDownLatch latch = new CountDownLatch(1);
rm.setCountDownLatch(latch);
kPool.destroyObject(getKey(0), r);
latch.await();
// shutdown
kPool.shutdown().get();
AggregatedPoolStats s = (AggregatedPoolStats) kPool.getStats();
s.refresh();
Assert.assertEquals(s.getTotalDestroyErrors(), 1);
}
use of com.linkedin.pinot.transport.common.AsyncResponseFuture in project pinot by linkedin.
the class KeyedPoolImplTest method testCreateError.
@Test
public void testCreateError() throws Exception {
ScheduledExecutorService timedExecutor = new ScheduledThreadPoolExecutor(1);
ExecutorService service = MoreExecutors.sameThreadExecutor();
int numKeys = 1;
int numResourcesPerKey = 1;
Map<String, List<String>> resources = buildCreateMap(numKeys, numResourcesPerKey);
TestResourceManager rm = new TestResourceManager(resources, resources, null, null);
KeyedPool<String, String> kPool = new KeyedPoolImpl<String, String>(0, 1, 1000L, 1000 * 60 * 60, rm, timedExecutor, service, null);
AsyncResponseFuture<String, String> f = (AsyncResponseFuture<String, String>) kPool.checkoutObject(getKey(0));
Assert.assertTrue(f.isDone());
Assert.assertNull(f.get());
Assert.assertNotNull(f.getError());
kPool.shutdown().get();
AggregatedPoolStats s = (AggregatedPoolStats) kPool.getStats();
s.refresh();
Assert.assertEquals(s.getTotalCreateErrors(), 1);
}
Aggregations