Search in sources :

Example 6 with AsyncResponseFuture

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);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) AsyncResponseFuture(com.linkedin.pinot.transport.common.AsyncResponseFuture) CountDownLatch(java.util.concurrent.CountDownLatch) AggregatedPoolStats(com.linkedin.pinot.transport.metrics.AggregatedPoolStats) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.testng.annotations.Test)

Example 7 with AsyncResponseFuture

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);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) AsyncResponseFuture(com.linkedin.pinot.transport.common.AsyncResponseFuture) AggregatedPoolStats(com.linkedin.pinot.transport.metrics.AggregatedPoolStats) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.testng.annotations.Test)

Aggregations

AsyncResponseFuture (com.linkedin.pinot.transport.common.AsyncResponseFuture)7 ExecutorService (java.util.concurrent.ExecutorService)6 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)6 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)6 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)3 Cancellable (com.linkedin.pinot.transport.common.Cancellable)2 AggregatedPoolStats (com.linkedin.pinot.transport.metrics.AggregatedPoolStats)2 TimeoutException (java.util.concurrent.TimeoutException)2 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)1 NoneType (com.linkedin.pinot.transport.common.NoneType)1 NettyClientMetrics (com.linkedin.pinot.transport.metrics.NettyClientMetrics)1 PoolStats (com.linkedin.pinot.transport.metrics.PoolStats)1 AsyncPool (com.linkedin.pinot.transport.pool.AsyncPool)1 AsyncPoolImpl (com.linkedin.pinot.transport.pool.AsyncPoolImpl)1 AsyncPoolResourceManagerAdapter (com.linkedin.pinot.transport.pool.AsyncPoolResourceManagerAdapter)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1