use of com.linkedin.r2.transport.http.client.AsyncPoolStats in project rest.li by linkedin.
the class TestAsyncPoolStatsTracker method testIncrements.
@Test
public void testIncrements() {
AsyncPoolStatsTracker tracker = new AsyncPoolStatsTracker(() -> LIFECYCLE_STATS, () -> MAX_SIZE, () -> MIN_SIZE, () -> POOL_SIZE, () -> CHECKED_OUT, () -> IDLE_SIZE, CLOCK, new LongTracking());
IntStream.range(0, DESTROY_ERROR_INCREMENTS).forEach(i -> tracker.incrementDestroyErrors());
IntStream.range(0, DESTROY_INCREMENTS).forEach(i -> tracker.incrementDestroyed());
IntStream.range(0, TIMEOUT_INCREMENTS).forEach(i -> tracker.incrementTimedOut());
IntStream.range(0, CREATE_ERROR_INCREMENTS).forEach(i -> tracker.incrementCreateErrors());
IntStream.range(0, BAD_DESTROY_INCREMENTS).forEach(i -> tracker.incrementBadDestroyed());
IntStream.range(0, CREATED_INCREMENTS).forEach(i -> tracker.incrementCreated());
AsyncPoolStats stats = tracker.getStats();
Assert.assertEquals(stats.getTotalDestroyErrors(), DESTROY_ERROR_INCREMENTS);
Assert.assertEquals(stats.getTotalDestroyed(), DESTROY_INCREMENTS);
Assert.assertEquals(stats.getTotalTimedOut(), TIMEOUT_INCREMENTS);
Assert.assertEquals(stats.getTotalCreateErrors(), CREATE_ERROR_INCREMENTS);
Assert.assertEquals(stats.getTotalBadDestroyed(), BAD_DESTROY_INCREMENTS);
Assert.assertEquals(stats.getTotalCreated(), CREATED_INCREMENTS);
Assert.assertEquals(stats.getCheckedOut(), CHECKED_OUT);
Assert.assertEquals(stats.getPoolSize(), POOL_SIZE);
}
use of com.linkedin.r2.transport.http.client.AsyncPoolStats in project rest.li by linkedin.
the class TestAsyncPoolStatsTracker method testDefaults.
@Test
public void testDefaults() {
AsyncPoolStatsTracker tracker = new AsyncPoolStatsTracker(() -> LIFECYCLE_STATS, () -> MAX_SIZE, () -> MIN_SIZE, () -> POOL_SIZE, () -> CHECKED_OUT, () -> IDLE_SIZE, CLOCK, new LongTracking());
AsyncPoolStats stats = tracker.getStats();
Assert.assertSame(stats.getLifecycleStats(), LIFECYCLE_STATS);
Assert.assertEquals(stats.getMaxPoolSize(), MAX_SIZE);
Assert.assertEquals(stats.getMinPoolSize(), MIN_SIZE);
Assert.assertEquals(stats.getIdleCount(), IDLE_SIZE);
Assert.assertEquals(stats.getCheckedOut(), CHECKED_OUT);
Assert.assertEquals(stats.getPoolSize(), POOL_SIZE);
Assert.assertEquals(stats.getTotalDestroyErrors(), 0);
Assert.assertEquals(stats.getTotalDestroyed(), 0);
Assert.assertEquals(stats.getTotalTimedOut(), 0);
Assert.assertEquals(stats.getTotalCreateErrors(), 0);
Assert.assertEquals(stats.getTotalBadDestroyed(), 0);
Assert.assertEquals(stats.getTotalCreated(), 0);
Assert.assertEquals(stats.getWaitTime50Pct(), 0);
Assert.assertEquals(stats.getWaitTime95Pct(), 0);
Assert.assertEquals(stats.getWaitTime99Pct(), 0);
Assert.assertEquals(stats.getWaitTimeAvg(), 0.0);
}
Aggregations