Search in sources :

Example 1 with NamedInternalThreadFactory

use of org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory in project dubbo by alibaba.

the class CachedThreadPool method getExecutor.

@Override
public Executor getExecutor(URL url) {
    String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
    int cores = url.getParameter(CORE_THREADS_KEY, DEFAULT_CORE_THREADS);
    int threads = url.getParameter(THREADS_KEY, Integer.MAX_VALUE);
    int queues = url.getParameter(QUEUES_KEY, DEFAULT_QUEUES);
    int alive = url.getParameter(ALIVE_KEY, DEFAULT_ALIVE);
    return new ThreadPoolExecutor(cores, threads, alive, TimeUnit.MILLISECONDS, queues == 0 ? new SynchronousQueue<Runnable>() : (queues < 0 ? new LinkedBlockingQueue<Runnable>() : new LinkedBlockingQueue<Runnable>(queues)), new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url));
}
Also used : NamedInternalThreadFactory(org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory) SynchronousQueue(java.util.concurrent.SynchronousQueue) AbortPolicyWithReport(org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Example 2 with NamedInternalThreadFactory

use of org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory in project dubbo by alibaba.

the class LimitedThreadPool method getExecutor.

@Override
public Executor getExecutor(URL url) {
    String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
    int cores = url.getParameter(CORE_THREADS_KEY, DEFAULT_CORE_THREADS);
    int threads = url.getParameter(THREADS_KEY, DEFAULT_THREADS);
    int queues = url.getParameter(QUEUES_KEY, DEFAULT_QUEUES);
    return new ThreadPoolExecutor(cores, threads, Long.MAX_VALUE, TimeUnit.MILLISECONDS, queues == 0 ? new SynchronousQueue<Runnable>() : (queues < 0 ? new LinkedBlockingQueue<Runnable>() : new LinkedBlockingQueue<Runnable>(queues)), new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url));
}
Also used : NamedInternalThreadFactory(org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory) SynchronousQueue(java.util.concurrent.SynchronousQueue) AbortPolicyWithReport(org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Example 3 with NamedInternalThreadFactory

use of org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory in project dubbo by alibaba.

the class FixedThreadPool method getExecutor.

@Override
public Executor getExecutor(URL url) {
    String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
    int threads = url.getParameter(THREADS_KEY, DEFAULT_THREADS);
    int queues = url.getParameter(QUEUES_KEY, DEFAULT_QUEUES);
    return new ThreadPoolExecutor(threads, threads, 0, TimeUnit.MILLISECONDS, queues == 0 ? new SynchronousQueue<Runnable>() : (queues < 0 ? new LinkedBlockingQueue<Runnable>() : new LinkedBlockingQueue<Runnable>(queues)), new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url));
}
Also used : NamedInternalThreadFactory(org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory) SynchronousQueue(java.util.concurrent.SynchronousQueue) AbortPolicyWithReport(org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Example 4 with NamedInternalThreadFactory

use of org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory in project dubbo by alibaba.

the class EagerThreadPool method getExecutor.

@Override
public Executor getExecutor(URL url) {
    String name = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
    int cores = url.getParameter(CORE_THREADS_KEY, DEFAULT_CORE_THREADS);
    int threads = url.getParameter(THREADS_KEY, Integer.MAX_VALUE);
    int queues = url.getParameter(QUEUES_KEY, DEFAULT_QUEUES);
    int alive = url.getParameter(ALIVE_KEY, DEFAULT_ALIVE);
    // init queue and executor
    TaskQueue<Runnable> taskQueue = new TaskQueue<Runnable>(queues <= 0 ? 1 : queues);
    EagerThreadPoolExecutor executor = new EagerThreadPoolExecutor(cores, threads, alive, TimeUnit.MILLISECONDS, taskQueue, new NamedInternalThreadFactory(name, true), new AbortPolicyWithReport(name, url));
    taskQueue.setExecutor(executor);
    return executor;
}
Also used : NamedInternalThreadFactory(org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory) AbortPolicyWithReport(org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport)

Aggregations

NamedInternalThreadFactory (org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory)4 AbortPolicyWithReport (org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport)4 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)3 SynchronousQueue (java.util.concurrent.SynchronousQueue)3 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)3