Search in sources :

Example 6 with NamedThreadFactory

use of com.alipay.sofa.jraft.rhea.util.concurrent.NamedThreadFactory 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

NamedThreadFactory (com.alipay.sofa.jraft.rhea.util.concurrent.NamedThreadFactory)6 CallerRunsPolicyWithReport (com.alipay.sofa.jraft.rhea.util.concurrent.CallerRunsPolicyWithReport)4 Endpoint (com.alipay.sofa.jraft.util.Endpoint)4 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)4 StoreEngine (com.alipay.sofa.jraft.rhea.StoreEngine)1 FakePlacementDriverClient (com.alipay.sofa.jraft.rhea.client.pd.FakePlacementDriverClient)1 RemotePlacementDriverClient (com.alipay.sofa.jraft.rhea.client.pd.RemotePlacementDriverClient)1 PlacementDriverOptions (com.alipay.sofa.jraft.rhea.options.PlacementDriverOptions)1 RpcOptions (com.alipay.sofa.jraft.rhea.options.RpcOptions)1 StoreEngineOptions (com.alipay.sofa.jraft.rhea.options.StoreEngineOptions)1 AffinityNamedThreadFactory (com.alipay.sofa.jraft.rhea.util.concurrent.AffinityNamedThreadFactory)1 DiscardOldPolicyWithReport (com.alipay.sofa.jraft.rhea.util.concurrent.DiscardOldPolicyWithReport)1 TaskDispatcher (com.alipay.sofa.jraft.rhea.util.concurrent.disruptor.TaskDispatcher)1 HashedWheelTimer (com.alipay.sofa.jraft.util.timer.HashedWheelTimer)1 ThreadFactory (java.util.concurrent.ThreadFactory)1