use of org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata in project teiid by teiid.
the class ThreadReuseExecutor method getStats.
public WorkerPoolStatisticsMetadata getStats() {
WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
stats.setName(poolName);
stats.setQueued(queue.size());
stats.setHighestQueued(highestQueueSize);
stats.setActiveThreads(getActiveCount());
stats.setMaxThreads(this.maximumPoolSize);
stats.setTotalSubmitted(getSubmittedCount());
stats.setHighestActiveThreads(getLargestPoolSize());
stats.setTotalCompleted(getCompletedCount());
return stats;
}
use of org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata in project teiid by teiid.
the class TestThreadReuseExecutor method testQueuing.
@Test
public void testQueuing() throws Exception {
final long SINGLE_WAIT = 50;
final int WORK_ITEMS = 10;
final int MAX_THREADS = 5;
// $NON-NLS-1$
pool = new ThreadReuseExecutor("test", MAX_THREADS);
for (int i = 0; i < WORK_ITEMS; i++) {
pool.execute(new FakeWorkItem(SINGLE_WAIT));
}
pool.shutdown();
pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
assertTrue(pool.isTerminated());
WorkerPoolStatisticsMetadata stats = pool.getStats();
assertEquals(10, stats.getTotalCompleted());
// $NON-NLS-1$
assertEquals("Expected threads to be maxed out", MAX_THREADS, stats.getHighestActiveThreads());
}
use of org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata in project teiid by teiid.
the class TestThreadReuseExecutor method testThreadReuse.
@Test
public void testThreadReuse() throws Exception {
final long SINGLE_WAIT = 50;
final long NUM_THREADS = 5;
// $NON-NLS-1$
pool = new ThreadReuseExecutor("test", 5);
for (int i = 0; i < NUM_THREADS; i++) {
pool.execute(new FakeWorkItem(SINGLE_WAIT));
try {
Thread.sleep(SINGLE_WAIT * 3);
} catch (InterruptedException e) {
}
}
pool.shutdown();
WorkerPoolStatisticsMetadata stats = pool.getStats();
// $NON-NLS-1$
assertTrue("Expected approximately 1 thread for serial execution", stats.getHighestActiveThreads() <= 2);
pool.awaitTermination(1000, TimeUnit.MILLISECONDS);
}
Aggregations