Search in sources :

Example 1 with PoolStats

use of com.linkedin.r2.transport.http.client.PoolStats in project rest.li by linkedin.

the class TestAsyncPool method testCreationTimeout.

@Test(dataProvider = "creationTimeoutDataProvider")
public void testCreationTimeout(int poolSize, int concurrency) throws Exception {
    // this object creation life cycle simulate the creation limbo state
    ObjectCreatorThatNeverCreates objectCreatorThatNeverCreates = new ObjectCreatorThatNeverCreates();
    ClockedExecutor clockedExecutor = new ClockedExecutor();
    ExponentialBackOffRateLimiter rateLimiter = new ExponentialBackOffRateLimiter(0, 5000, 10, clockedExecutor, concurrency);
    final AsyncPool<Object> pool = new AsyncPoolImpl<>("object pool", objectCreatorThatNeverCreates, poolSize, Integer.MAX_VALUE, Integer.MAX_VALUE, clockedExecutor, Integer.MAX_VALUE, AsyncPoolImpl.Strategy.MRU, 0, rateLimiter, clockedExecutor, new LongTracking());
    pool.start();
    List<FutureCallback<Object>> checkoutCallbacks = new ArrayList<>();
    // Lets try to checkout more than the max Pool Size times when the object creator is in limbo state
    for (int i = 0; i < poolSize * 2; i++) {
        FutureCallback<Object> cb = new FutureCallback<>();
        checkoutCallbacks.add(cb);
        // Reset the exponential back off due to creation timeout error
        rateLimiter.setPeriod(0);
        pool.get(cb);
        // run for the duration of default creation timeout
        // TODO: parameterize the creation duration when the default creation gets parameterized
        clockedExecutor.runFor(AsyncPoolImpl.DEFAULT_OBJECT_CREATION_TIMEOUT);
    }
    // drain all the pending tasks
    clockedExecutor.runFor(AsyncPoolImpl.DEFAULT_OBJECT_CREATION_TIMEOUT);
    // since the object creator went to limbo state
    for (FutureCallback<Object> cb : checkoutCallbacks) {
        try {
            cb.get(100, TimeUnit.MILLISECONDS);
        } catch (Exception ex) {
            Assert.assertTrue(ex.getCause() instanceof ObjectCreationTimeoutException);
        }
    }
    // Lets make sure the channel pool stats are at expected state
    PoolStats stats = pool.getStats();
    // Lets make sure all the limbo creations are timed out as expected
    Assert.assertEquals(stats.getTotalCreateErrors(), poolSize * 2);
    // No checkout should have happened due to object creator in limbo
    Assert.assertEquals(stats.getCheckedOut(), 0);
    // No Idle objects in the pool
    Assert.assertEquals(stats.getIdleCount(), 0);
    // Lets make sure that all the slots in the pool are reclaimed even if the object creation is in limbo
    Assert.assertEquals(stats.getPoolSize(), 0);
    // Since the max pending creation request reached the max pool size,
    // we should have reached the maPool Size at least once
    Assert.assertEquals(stats.getMaxPoolSize(), poolSize);
    // Since no object is successfully created, expecting idle objects to be zero
    Assert.assertEquals(stats.getIdleCount(), 0);
}
Also used : LongTracking(com.linkedin.common.stats.LongTracking) ArrayList(java.util.ArrayList) ClockedExecutor(com.linkedin.test.util.ClockedExecutor) ObjectCreationTimeoutException(com.linkedin.r2.transport.http.client.ObjectCreationTimeoutException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) PoolStats(com.linkedin.r2.transport.http.client.PoolStats) AsyncPoolImpl(com.linkedin.r2.transport.http.client.AsyncPoolImpl) ExponentialBackOffRateLimiter(com.linkedin.r2.transport.http.client.ExponentialBackOffRateLimiter) FutureCallback(com.linkedin.common.callback.FutureCallback) ObjectCreationTimeoutException(com.linkedin.r2.transport.http.client.ObjectCreationTimeoutException) Test(org.testng.annotations.Test)

Example 2 with PoolStats

use of com.linkedin.r2.transport.http.client.PoolStats in project rest.li by linkedin.

the class TestAsyncPool method testWaiterTimeout.

/**
 * This test case verifies that the correct number of waiters are timed out while waiting for object from the pool
 *
 *     Assumption: the channel pool max size is always bigger than the requested checkout size
 *
 *|----------A------------|---------------B---------------|---------------C--------------|-------------D--------------
 *   A = In Phase A , N number of object checkout request to the pool when there are no tasks pending in the rate
 *       limiter. A's Expected result = channel pool will create N number of new objects and check them out
 *   B = In Phase B, O number of object checkout request again sent to the channel pool when the pool has already
 *       checkout N number of objects, In this phase, the object creation inside the pool is blocked
 *       and the rate limiter will Queue the creation requests once it reached its maximum concurrency configured.
 *   C = Ih Phase C, P number of objects are returned to the pool which are created in Phase A, this will make
 *       the number of waiter queue size to be O-P
 *   D = In Phase D, A delay will be introduced to timeout the waiters and all the O-P waiters should be timed out.
 *       After the delay the object creation will be unblocked and it should create aleast the concurrency number of
 *       objects even though the waiters are timedout.
 *
 * @param numberOfCheckoutsInPhaseA the N number of checkout operations that will be performed in phase A
 * @param numberOfCheckoutsInPhaseB the O number of checkout operations that will be performed in Phase B
 * @param numbOfObjectsToBeReturnedInPhaseC the numeber of objects returned in Phase C
 * @param poolSize size of the pool,
 * @param concurrency concurrency of the rate limiter
 */
@Test(dataProvider = "waiterTimeoutDataProvider")
public void testWaiterTimeout(int numberOfCheckoutsInPhaseA, int numberOfCheckoutsInPhaseB, int numbOfObjectsToBeReturnedInPhaseC, int poolSize, int concurrency, int waiterTimeout) throws Exception {
    CreationBlockableSynchronousLifecycle blockableObjectCreator = new CreationBlockableSynchronousLifecycle(numberOfCheckoutsInPhaseB, concurrency);
    ScheduledExecutorService executor = Executors.newScheduledThreadPool(500);
    ExponentialBackOffRateLimiter rateLimiter = new ExponentialBackOffRateLimiter(0, 5000, 10, executor, concurrency);
    ClockedExecutor clockedExecutor = new ClockedExecutor();
    final AsyncPool<Object> pool = new AsyncPoolImpl<>("object pool", blockableObjectCreator, poolSize, Integer.MAX_VALUE, waiterTimeout, clockedExecutor, Integer.MAX_VALUE, AsyncPoolImpl.Strategy.MRU, 0, rateLimiter, clockedExecutor, new LongTracking());
    pool.start();
    // Phase A : Checking out object 'numberOfCheckoutsInPhaseA' times !
    List<Object> checkedOutObjects = performCheckout(numberOfCheckoutsInPhaseA, pool);
    // Phase B : Blocking object creation and performing the checkout 'numberOfCheckoutsInPhaseB' times again
    blockableObjectCreator.blockCreation();
    Future<None> future = performUnblockingCheckout(numberOfCheckoutsInPhaseB, 0, pool);
    blockableObjectCreator.waitUntilAllBlocked();
    // Phase C : Returning the checkedOut objects from Phase A back to the object pool
    for (int i = 0; i < numbOfObjectsToBeReturnedInPhaseC; i++) {
        pool.put(checkedOutObjects.remove(0));
    }
    clockedExecutor.runFor(waiterTimeout);
    // Phase D : All the object creation in phase B gets unblocked now
    blockableObjectCreator.unblockCreation();
    try {
        future.get(5, TimeUnit.SECONDS);
    } catch (Exception e) {
        Assert.fail("Did not complete unblocked object creations on time, Unexpected interruption", e);
    }
    // Making sure the rate limiter pending tasks are submitted to the executor
    AssertionMethods.assertWithTimeout(5000, () -> Assert.assertEquals(rateLimiter.numberOfPendingTasks(), 0, "Number of tasks has to drop to 0"));
    executor.shutdown();
    try {
        if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
            Assert.fail("Executor took too long to shutdown");
        }
    } catch (Exception ex) {
        Assert.fail("Unexpected interruption while shutting down executor", ex);
    }
    PoolStats stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreationIgnored(), numberOfCheckoutsInPhaseB - concurrency);
    Assert.assertEquals(stats.getCheckedOut(), numberOfCheckoutsInPhaseA);
    Assert.assertEquals(stats.getIdleCount(), concurrency);
    Assert.assertEquals(stats.getTotalCreated(), numberOfCheckoutsInPhaseA + concurrency);
    Assert.assertEquals(stats.getPoolSize(), numberOfCheckoutsInPhaseA + concurrency);
    Assert.assertEquals(stats.getTotalWaiterTimedOut(), numberOfCheckoutsInPhaseB - numbOfObjectsToBeReturnedInPhaseC);
}
Also used : LongTracking(com.linkedin.common.stats.LongTracking) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ClockedExecutor(com.linkedin.test.util.ClockedExecutor) ObjectCreationTimeoutException(com.linkedin.r2.transport.http.client.ObjectCreationTimeoutException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) PoolStats(com.linkedin.r2.transport.http.client.PoolStats) AsyncPoolImpl(com.linkedin.r2.transport.http.client.AsyncPoolImpl) ExponentialBackOffRateLimiter(com.linkedin.r2.transport.http.client.ExponentialBackOffRateLimiter) None(com.linkedin.common.util.None) Test(org.testng.annotations.Test)

Example 3 with PoolStats

use of com.linkedin.r2.transport.http.client.PoolStats in project rest.li by linkedin.

the class TestAsyncPool method testGetStats.

@Test(retryAnalyzer = SingleRetry.class)
public void testGetStats() throws Exception {
    final int POOL_SIZE = 25;
    final int MIN_SIZE = 0;
    final int MAX_WAITER_SIZE = Integer.MAX_VALUE;
    final SettableClock clock = new SettableClock();
    final LongTracking waitTimeTracker = new LongTracking();
    final int GET = 20;
    final int PUT_GOOD = 2;
    final int PUT_BAD = 3;
    final int DISPOSE = 4;
    final int TIMEOUT = 100;
    final int WAITER_TIMEOUT = 200;
    final int DELAY = 1200;
    final UnreliableLifecycle lifecycle = new UnreliableLifecycle();
    final AsyncPool<AtomicBoolean> pool = new AsyncPoolImpl<>("object pool", lifecycle, POOL_SIZE, TIMEOUT, WAITER_TIMEOUT, _executor, MAX_WAITER_SIZE, AsyncPoolImpl.Strategy.MRU, MIN_SIZE, new NoopRateLimiter(), clock, waitTimeTracker);
    PoolStats stats;
    final List<AtomicBoolean> objects = new ArrayList<>();
    pool.start();
    // test values at initialization
    stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreated(), 0);
    Assert.assertEquals(stats.getTotalDestroyed(), 0);
    Assert.assertEquals(stats.getTotalCreateErrors(), 0);
    Assert.assertEquals(stats.getTotalDestroyErrors(), 0);
    Assert.assertEquals(stats.getCheckedOut(), 0);
    Assert.assertEquals(stats.getTotalTimedOut(), 0);
    Assert.assertEquals(stats.getTotalWaiterTimedOut(), 0);
    Assert.assertEquals(stats.getTotalBadDestroyed(), 0);
    Assert.assertEquals(stats.getMaxPoolSize(), POOL_SIZE);
    Assert.assertEquals(stats.getMinPoolSize(), 0);
    Assert.assertEquals(stats.getPoolSize(), 0);
    Assert.assertEquals(stats.getSampleMaxCheckedOut(), 0);
    Assert.assertEquals(stats.getSampleMaxPoolSize(), 0);
    // do a few gets
    for (int i = 0; i < GET; i++) {
        FutureCallback<AtomicBoolean> cb = new FutureCallback<>();
        pool.get(cb);
        AtomicBoolean obj = cb.get();
        objects.add(obj);
    }
    clock.addDuration(SAMPLING_DURATION_INCREMENT);
    stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreated(), GET);
    Assert.assertEquals(stats.getTotalDestroyed(), 0);
    Assert.assertEquals(stats.getTotalCreateErrors(), 0);
    Assert.assertEquals(stats.getTotalDestroyErrors(), 0);
    Assert.assertEquals(stats.getCheckedOut(), GET);
    Assert.assertEquals(stats.getTotalTimedOut(), 0);
    Assert.assertEquals(stats.getTotalBadDestroyed(), 0);
    Assert.assertEquals(stats.getMaxPoolSize(), POOL_SIZE);
    Assert.assertEquals(stats.getMinPoolSize(), 0);
    Assert.assertEquals(stats.getPoolSize(), GET);
    Assert.assertEquals(stats.getSampleMaxCheckedOut(), GET);
    Assert.assertEquals(stats.getSampleMaxPoolSize(), GET);
    // do some puts with good objects
    for (int i = 0; i < PUT_GOOD; i++) {
        AtomicBoolean obj = objects.remove(objects.size() - 1);
        pool.put(obj);
    }
    clock.addDuration(SAMPLING_DURATION_INCREMENT);
    stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreated(), GET);
    Assert.assertEquals(stats.getTotalDestroyed(), 0);
    Assert.assertEquals(stats.getTotalCreateErrors(), 0);
    Assert.assertEquals(stats.getTotalDestroyErrors(), 0);
    Assert.assertEquals(stats.getCheckedOut(), GET - PUT_GOOD);
    Assert.assertEquals(stats.getTotalTimedOut(), 0);
    Assert.assertEquals(stats.getTotalBadDestroyed(), 0);
    Assert.assertEquals(stats.getMaxPoolSize(), POOL_SIZE);
    Assert.assertEquals(stats.getMinPoolSize(), 0);
    Assert.assertEquals(stats.getPoolSize(), GET);
    Assert.assertEquals(stats.getSampleMaxCheckedOut(), GET);
    Assert.assertEquals(stats.getSampleMaxPoolSize(), GET);
    // do some puts with bad objects
    for (int i = 0; i < PUT_BAD; i++) {
        AtomicBoolean obj = objects.remove(objects.size() - 1);
        // invalidate the object
        obj.set(false);
        pool.put(obj);
    }
    clock.addDuration(SAMPLING_DURATION_INCREMENT);
    stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreated(), GET);
    Assert.assertEquals(stats.getTotalDestroyed(), PUT_BAD);
    Assert.assertEquals(stats.getTotalCreateErrors(), 0);
    Assert.assertEquals(stats.getTotalDestroyErrors(), 0);
    Assert.assertEquals(stats.getCheckedOut(), GET - PUT_GOOD - PUT_BAD);
    Assert.assertEquals(stats.getTotalTimedOut(), 0);
    Assert.assertEquals(stats.getTotalBadDestroyed(), PUT_BAD);
    Assert.assertEquals(stats.getMaxPoolSize(), POOL_SIZE);
    Assert.assertEquals(stats.getMinPoolSize(), 0);
    Assert.assertEquals(stats.getPoolSize(), GET - PUT_BAD);
    Assert.assertEquals(stats.getSampleMaxCheckedOut(), GET - PUT_GOOD);
    Assert.assertEquals(stats.getSampleMaxPoolSize(), GET);
    // do some disposes
    for (int i = 0; i < DISPOSE; i++) {
        AtomicBoolean obj = objects.remove(objects.size() - 1);
        pool.dispose(obj);
    }
    clock.addDuration(SAMPLING_DURATION_INCREMENT);
    stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreated(), GET);
    Assert.assertEquals(stats.getTotalDestroyed(), PUT_BAD + DISPOSE);
    Assert.assertEquals(stats.getTotalCreateErrors(), 0);
    Assert.assertEquals(stats.getTotalDestroyErrors(), 0);
    Assert.assertEquals(stats.getCheckedOut(), GET - PUT_GOOD - PUT_BAD - DISPOSE);
    Assert.assertEquals(stats.getTotalTimedOut(), 0);
    Assert.assertEquals(stats.getTotalBadDestroyed(), PUT_BAD + DISPOSE);
    Assert.assertEquals(stats.getMaxPoolSize(), POOL_SIZE);
    Assert.assertEquals(stats.getMinPoolSize(), 0);
    Assert.assertEquals(stats.getPoolSize(), GET - PUT_BAD - DISPOSE);
    Assert.assertEquals(stats.getSampleMaxCheckedOut(), GET - PUT_GOOD - PUT_BAD);
    Assert.assertEquals(stats.getSampleMaxPoolSize(), GET - PUT_BAD);
    // wait for a reap -- should destroy the PUT_GOOD objects
    Thread.sleep(DELAY);
    clock.addDuration(SAMPLING_DURATION_INCREMENT);
    stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreated(), GET);
    Assert.assertEquals(stats.getTotalDestroyed(), PUT_GOOD + PUT_BAD + DISPOSE);
    Assert.assertEquals(stats.getTotalCreateErrors(), 0);
    Assert.assertEquals(stats.getTotalDestroyErrors(), 0);
    Assert.assertEquals(stats.getCheckedOut(), GET - PUT_GOOD - PUT_BAD - DISPOSE);
    Assert.assertEquals(stats.getTotalTimedOut(), PUT_GOOD);
    Assert.assertEquals(stats.getTotalBadDestroyed(), PUT_BAD + DISPOSE);
    Assert.assertEquals(stats.getMaxPoolSize(), POOL_SIZE);
    Assert.assertEquals(stats.getMinPoolSize(), 0);
    Assert.assertEquals(stats.getPoolSize(), GET - PUT_GOOD - PUT_BAD - DISPOSE);
    Assert.assertEquals(stats.getSampleMaxCheckedOut(), GET - PUT_GOOD - PUT_BAD - DISPOSE);
    Assert.assertEquals(stats.getSampleMaxPoolSize(), GET - PUT_BAD - DISPOSE);
}
Also used : LongTracking(com.linkedin.common.stats.LongTracking) ArrayList(java.util.ArrayList) PoolStats(com.linkedin.r2.transport.http.client.PoolStats) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NoopRateLimiter(com.linkedin.r2.transport.http.client.NoopRateLimiter) AsyncPoolImpl(com.linkedin.r2.transport.http.client.AsyncPoolImpl) SettableClock(com.linkedin.util.clock.SettableClock) FutureCallback(com.linkedin.common.callback.FutureCallback) Test(org.testng.annotations.Test)

Example 4 with PoolStats

use of com.linkedin.r2.transport.http.client.PoolStats in project rest.li by linkedin.

the class TestAsyncPool method testWaitTimeStats.

/**
 * Wait time percentile, average, and maximum tracking is deprecated in {@link AsyncPool} implementations.
 */
@Test
public void testWaitTimeStats() throws Exception {
    final int POOL_SIZE = 25;
    final int CHECKOUT = POOL_SIZE;
    final long DELAY = 100;
    final double DELTA = 0.1;
    DelayedLifecycle lifecycle = new DelayedLifecycle(DELAY);
    final AsyncPool<Object> pool = new AsyncPoolImpl<>("object pool", lifecycle, POOL_SIZE, 100, _executor);
    pool.start();
    PoolStats stats;
    List<Object> objects = new ArrayList<>(CHECKOUT);
    for (int i = 0; i < CHECKOUT; i++) {
        FutureCallback<Object> cb = new FutureCallback<>();
        pool.get(cb);
        Object o = cb.get();
        objects.add(o);
    }
    stats = pool.getStats();
    Assert.assertEquals(stats.getWaitTimeAvg(), DELAY, DELTA * DELAY);
}
Also used : AsyncPoolImpl(com.linkedin.r2.transport.http.client.AsyncPoolImpl) ArrayList(java.util.ArrayList) FutureCallback(com.linkedin.common.callback.FutureCallback) PoolStats(com.linkedin.r2.transport.http.client.PoolStats) Test(org.testng.annotations.Test)

Example 5 with PoolStats

use of com.linkedin.r2.transport.http.client.PoolStats in project rest.li by linkedin.

the class TestAsyncPool method testObjectsAreNotCreatedWhenThereAreNoWaiters.

/**
 * This test case verifies that if more request object creation requests are submitted to the rate limiter, it only
 * creates the absolute required maximum (see below example)
 *
 *  Assumption: the channel pool max size is always bigger than the requested checkout size
 *
 *|----------A------------|---------------B---------------|---------------C--------------|-------------D--------------
 *  A = In Phase A , N number of object checkout request to the pool when there are no tasks pending in the
 *      rate limiter. A's Expected result = channel pool will create N number of new objects and check them out
 *  B = In Phase B, N number of object checkout request again sent to the channel pool when the pool has already
 *      checkout N number of objects, In this phase, the object creation inside the pool is blocked and the
 *      rate limiter will Queue the creation requests once it reached its maximum concurrency configured.
 *  C = Ih Phase C, N number of objects are returned to the pool which are created in Phase A, this will make
 *      the number of idle objects in the pool as N.
 *  D = In Phase D, All the object creation blocked in Phase B will get un blocked and create number of new objects
 *      that are equal to the rate limiter concurrency. When rate limiter executes the queued creation requests - it
 *      should ignore the creation requests as there are no object waiters in the pool and thus effectively only
 *      creating the absolute minimum required count (N+Concurrency)
 *
 * @param numberOfCheckouts the N number of checkout operations that will be performed in phase A & B
 * @param poolSize the maximum Object Pool Size
 * @param concurrency the maximum allowed concurrent object creation
 */
@Test(dataProvider = "channelStateRandomDataProvider")
public void testObjectsAreNotCreatedWhenThereAreNoWaiters(int numberOfCheckouts, int poolSize, int concurrency) throws Exception {
    CreationBlockableSynchronousLifecycle blockableObjectCreator = new CreationBlockableSynchronousLifecycle(numberOfCheckouts, concurrency);
    ScheduledExecutorService executor = Executors.newScheduledThreadPool(500);
    ExponentialBackOffRateLimiter rateLimiter = new ExponentialBackOffRateLimiter(0, 5000, 10, executor, concurrency);
    final AsyncPool<Object> pool = new AsyncPoolImpl<>("object pool", blockableObjectCreator, poolSize, Integer.MAX_VALUE, _executor, Integer.MAX_VALUE, AsyncPoolImpl.Strategy.MRU, 0, rateLimiter);
    pool.start();
    // Phase A:Checking out object 'numberOfCheckout' times!
    List<Object> checkedOutObjects = performCheckout(numberOfCheckouts, pool);
    // Phase B:Blocking object creation and performing the checkout 'numberOfCheckout' times again
    blockableObjectCreator.blockCreation();
    Future<None> future = performUnblockingCheckout(numberOfCheckouts, numberOfCheckouts, pool);
    blockableObjectCreator.waitUntilAllBlocked();
    // Phase C:Returning the checkedOut objects from Phase A back to the object pool
    for (Object checkedOutObject : checkedOutObjects) {
        pool.put(checkedOutObject);
    }
    // Phase D:All the object creation in phase B gets unblocked now
    blockableObjectCreator.unblockCreation();
    try {
        // Wait for all object creation to be unblocked
        future.get(5, TimeUnit.SECONDS);
    } catch (Exception e) {
        Assert.fail("Did not complete unblocked object creations on time, Unexpected interruption", e);
    }
    // Making sure the rate limiter pending tasks are submitted to the executor
    AssertionMethods.assertWithTimeout(5000, () -> Assert.assertEquals(rateLimiter.numberOfPendingTasks(), 0, "Number of tasks has to drop to 0"));
    // Wait for all the tasks in the rate limiter executor to finish
    executor.shutdown();
    try {
        if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
            Assert.fail("Executor took too long to shutdown");
        }
    } catch (Exception ex) {
        Assert.fail("Unexpected interruption while shutting down executor", ex);
    }
    // Verify all the expectations
    PoolStats stats = pool.getStats();
    Assert.assertEquals(stats.getTotalCreationIgnored(), numberOfCheckouts - concurrency);
    Assert.assertEquals(stats.getCheckedOut(), numberOfCheckouts);
    Assert.assertEquals(stats.getIdleCount(), concurrency);
    Assert.assertEquals(stats.getTotalCreated(), numberOfCheckouts + concurrency);
    Assert.assertEquals(stats.getPoolSize(), numberOfCheckouts + concurrency);
    Assert.assertEquals(stats.getTotalDestroyed(), 0);
    Assert.assertEquals(stats.getTotalBadDestroyed(), 0);
    Assert.assertEquals(stats.getTotalTimedOut(), 0);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AsyncPoolImpl(com.linkedin.r2.transport.http.client.AsyncPoolImpl) ExponentialBackOffRateLimiter(com.linkedin.r2.transport.http.client.ExponentialBackOffRateLimiter) None(com.linkedin.common.util.None) ObjectCreationTimeoutException(com.linkedin.r2.transport.http.client.ObjectCreationTimeoutException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) PoolStats(com.linkedin.r2.transport.http.client.PoolStats) Test(org.testng.annotations.Test)

Aggregations

PoolStats (com.linkedin.r2.transport.http.client.PoolStats)8 Test (org.testng.annotations.Test)8 AsyncPoolImpl (com.linkedin.r2.transport.http.client.AsyncPoolImpl)6 FutureCallback (com.linkedin.common.callback.FutureCallback)5 ExecutionException (java.util.concurrent.ExecutionException)5 ObjectCreationTimeoutException (com.linkedin.r2.transport.http.client.ObjectCreationTimeoutException)4 ArrayList (java.util.ArrayList)4 TimeoutException (java.util.concurrent.TimeoutException)4 LongTracking (com.linkedin.common.stats.LongTracking)3 None (com.linkedin.common.util.None)3 ExponentialBackOffRateLimiter (com.linkedin.r2.transport.http.client.ExponentialBackOffRateLimiter)3 AsyncSharedPoolImpl (com.linkedin.r2.transport.http.client.AsyncSharedPoolImpl)2 ClockedExecutor (com.linkedin.test.util.ClockedExecutor)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 NoopRateLimiter (com.linkedin.r2.transport.http.client.NoopRateLimiter)1 SettableClock (com.linkedin.util.clock.SettableClock)1 CountDownLatch (java.util.concurrent.CountDownLatch)1