use of org.alfresco.util.DynamicallySizedThreadPoolExecutor in project SearchServices by Alfresco.
the class DefaultTrackerPoolFactory method create.
@Override
public ThreadPoolExecutor create() {
// We need a thread factory
TraceableThreadFactory threadFactory = new TraceableThreadFactory();
threadFactory.setThreadDaemon(threadDaemon);
threadFactory.setThreadPriority(threadPriority);
if (poolName.length() > 0) {
threadFactory.setNamePrefix(poolName);
}
BlockingQueue<Runnable> workQueue;
if (workQueueSize < 0) {
// We can have an unlimited queue, as we have a sensible thread pool!
workQueue = new LinkedBlockingQueue<Runnable>();
} else {
// Use an array one for consistent performance on a small queue size
workQueue = new ArrayBlockingQueue<Runnable>(workQueueSize);
}
ThreadPoolExecutor threadPoolExecutor = new DynamicallySizedThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.SECONDS, workQueue, threadFactory, rejectedExecutionHandler);
return threadPoolExecutor;
}
use of org.alfresco.util.DynamicallySizedThreadPoolExecutor in project alfresco-repository by Alfresco.
the class DictionaryLoadDAOTest method initDictionaryCaches.
private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception {
CompiledModelsCache compiledModelsCache = new CompiledModelsCache();
compiledModelsCache.setDictionaryDAO(dictionaryDAO);
compiledModelsCache.setTenantService(tenantService);
compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry());
TraceableThreadFactory threadFactory = new TraceableThreadFactory();
threadFactory.setThreadDaemon(true);
threadFactory.setThreadPriority(Thread.NORM_PRIORITY);
ThreadPoolExecutor threadPoolExecutor = new DynamicallySizedThreadPoolExecutor(20, 20, 90, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
compiledModelsCache.setThreadPoolExecutor(threadPoolExecutor);
dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache);
dictionaryDAO.init();
}
Aggregations