Search in sources :

Example 1 with CallerRunsPolicyWithReport

use of com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport in project sofa-jraft by sofastack.

the class PlacementDriverServer method createDefaultPdExecutor.

private ThreadPoolExecutor createDefaultPdExecutor() {
    final int corePoolSize = Math.max(Utils.cpus() << 2, 32);
    final String name = "rheakv-pd-executor";
    return // 
    ThreadPoolUtil.newBuilder().poolName(// 
    name).enableMetric(// 
    true).coreThreads(// 
    corePoolSize).maximumThreads(// 
    corePoolSize << 2).keepAliveSeconds(// 
    120L).workQueue(// 
    new ArrayBlockingQueue<>(4096)).threadFactory(// 
    new NamedThreadFactory(name, true)).rejectedHandler(// 
    new CallerRunsPolicyWithReport(name, name)).build();
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) NamedThreadFactory(com.alipay.sofa.jraft.rhea.util.concurrent.NamedThreadFactory) Endpoint(com.alipay.sofa.jraft.util.Endpoint) CallerRunsPolicyWithReport(com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport)

Example 2 with CallerRunsPolicyWithReport

use of com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport in project sofa-jraft by sofastack.

the class DefaultPlacementDriverRpcService method createRpcCallbackExecutor.

private ThreadPoolExecutor createRpcCallbackExecutor(final RpcOptions opts) {
    final int callbackExecutorCorePoolSize = opts.getCallbackExecutorCorePoolSize();
    final int callbackExecutorMaximumPoolSize = opts.getCallbackExecutorMaximumPoolSize();
    if (callbackExecutorCorePoolSize <= 0 || callbackExecutorMaximumPoolSize <= 0) {
        return null;
    }
    final String name = "rheakv-pd-rpc-callback";
    return // 
    ThreadPoolUtil.newBuilder().poolName(// 
    name).enableMetric(// 
    true).coreThreads(// 
    callbackExecutorCorePoolSize).maximumThreads(// 
    callbackExecutorMaximumPoolSize).keepAliveSeconds(// 
    120L).workQueue(// 
    new ArrayBlockingQueue<>(opts.getCallbackExecutorQueueCapacity())).threadFactory(// 
    new NamedThreadFactory(name, true)).rejectedHandler(// 
    new CallerRunsPolicyWithReport(name)).build();
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) NamedThreadFactory(com.alipay.sofa.jraft.rhea.util.concurrent.NamedThreadFactory) Endpoint(com.alipay.sofa.jraft.util.Endpoint) CallerRunsPolicyWithReport(com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport)

Example 3 with CallerRunsPolicyWithReport

use of com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport in project sofa-jraft by sofastack.

the class DefaultPlacementDriverService method createPipelineExecutor.

private ThreadPoolExecutor createPipelineExecutor(final PlacementDriverServerOptions opts) {
    final int corePoolSize = opts.getPipelineCorePoolSize();
    final int maximumPoolSize = opts.getPipelineMaximumPoolSize();
    if (corePoolSize <= 0 || maximumPoolSize <= 0) {
        return null;
    }
    final String name = "rheakv-pipeline-executor";
    return // 
    ThreadPoolUtil.newBuilder().poolName(// 
    name).enableMetric(// 
    false).coreThreads(// 
    corePoolSize).maximumThreads(// 
    maximumPoolSize).keepAliveSeconds(// 
    120L).workQueue(// 
    new ArrayBlockingQueue<>(1024)).threadFactory(// 
    new NamedThreadFactory(name, true)).rejectedHandler(// 
    new CallerRunsPolicyWithReport(name)).build();
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) NamedThreadFactory(com.alipay.sofa.jraft.rhea.util.concurrent.NamedThreadFactory) CallerRunsPolicyWithReport(com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport)

Example 4 with CallerRunsPolicyWithReport

use of com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport in project sofa-jraft by sofastack.

the class DefaultRheaKVRpcService method createRpcCallbackExecutor.

private ThreadPoolExecutor createRpcCallbackExecutor(final RpcOptions opts) {
    final int callbackExecutorCorePoolSize = opts.getCallbackExecutorCorePoolSize();
    final int callbackExecutorMaximumPoolSize = opts.getCallbackExecutorMaximumPoolSize();
    if (callbackExecutorCorePoolSize <= 0 || callbackExecutorMaximumPoolSize <= 0) {
        return null;
    }
    final String name = "rheakv-rpc-callback";
    return // 
    ThreadPoolUtil.newBuilder().poolName(// 
    name).enableMetric(// 
    true).coreThreads(// 
    callbackExecutorCorePoolSize).maximumThreads(// 
    callbackExecutorMaximumPoolSize).keepAliveSeconds(// 
    120L).workQueue(// 
    new ArrayBlockingQueue<>(opts.getCallbackExecutorQueueCapacity())).threadFactory(// 
    new NamedThreadFactory(name, true)).rejectedHandler(// 
    new CallerRunsPolicyWithReport(name)).build();
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) NamedThreadFactory(com.alipay.sofa.jraft.rhea.util.concurrent.NamedThreadFactory) Endpoint(com.alipay.sofa.jraft.util.Endpoint) CallerRunsPolicyWithReport(com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport)

Aggregations

CallerRunsPolicyWithReport (com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport)4 NamedThreadFactory (com.alipay.sofa.jraft.rhea.util.concurrent.NamedThreadFactory)4 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)4 Endpoint (com.alipay.sofa.jraft.util.Endpoint)3