use of org.apache.hadoop.hbase.util.IdReadWriteLock.ReferenceType in project hbase by apache.
the class TestIdReadWriteLock method testMultipleClients.
@Test(timeout = 60000)
public void testMultipleClients() throws Exception {
ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS);
try {
ExecutorCompletionService<Boolean> ecs = new ExecutorCompletionService<>(exec);
for (int i = 0; i < NUM_THREADS; ++i) ecs.submit(new IdLockTestThread("client_" + i));
for (int i = 0; i < NUM_THREADS; ++i) {
Future<Boolean> result = ecs.take();
assertTrue(result.get());
}
int entryPoolSize = idLock.purgeAndGetEntryPoolSize();
LOG.debug("Size of entry pool after gc and purge: " + entryPoolSize);
ReferenceType refType = idLock.getReferenceType();
switch(refType) {
case WEAK:
// make sure the entry pool will be cleared after GC and purge call
assertEquals(0, entryPoolSize);
break;
case SOFT:
// make sure the entry pool won't be cleared when JVM memory is enough
// even after GC and purge call
assertEquals(NUM_IDS, entryPoolSize);
break;
default:
break;
}
} finally {
exec.shutdown();
exec.awaitTermination(5000, TimeUnit.MILLISECONDS);
}
}
Aggregations