Search in sources :

Example 1 with DynamicallySizedThreadPoolExecutor

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;
}
Also used : DynamicallySizedThreadPoolExecutor(org.alfresco.util.DynamicallySizedThreadPoolExecutor) TraceableThreadFactory(org.alfresco.util.TraceableThreadFactory) DynamicallySizedThreadPoolExecutor(org.alfresco.util.DynamicallySizedThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 2 with DynamicallySizedThreadPoolExecutor

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();
}
Also used : DynamicallySizedThreadPoolExecutor(org.alfresco.util.DynamicallySizedThreadPoolExecutor) DefaultAsynchronouslyRefreshedCacheRegistry(org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry) TraceableThreadFactory(org.alfresco.util.TraceableThreadFactory) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) DynamicallySizedThreadPoolExecutor(org.alfresco.util.DynamicallySizedThreadPoolExecutor)

Aggregations

ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 DynamicallySizedThreadPoolExecutor (org.alfresco.util.DynamicallySizedThreadPoolExecutor)2 TraceableThreadFactory (org.alfresco.util.TraceableThreadFactory)2 DefaultAsynchronouslyRefreshedCacheRegistry (org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry)1