Search in sources :

Example 1 with ThreadPoolMetricSet

use of com.alipay.sofa.jraft.util.ThreadPoolMetricSet in project sofa-jraft by sofastack.

the class AbstractClientService method initRpcClient.

protected boolean initRpcClient(final int rpcProcessorThreadPoolSize) {
    final RaftRpcFactory factory = RpcFactoryHelper.rpcFactory();
    this.rpcClient = factory.createRpcClient(factory.defaultJRaftClientConfigHelper(this.rpcOptions));
    configRpcClient(this.rpcClient);
    this.rpcClient.init(null);
    this.rpcExecutor = // 
    ThreadPoolUtil.newBuilder().poolName(// 
    "JRaft-RPC-Processor").enableMetric(// 
    true).coreThreads(// 
    rpcProcessorThreadPoolSize / 3).maximumThreads(// 
    rpcProcessorThreadPoolSize).keepAliveSeconds(// 
    60L).workQueue(// 
    new ArrayBlockingQueue<>(10000)).threadFactory(// 
    new NamedThreadFactory("JRaft-RPC-Processor-", true)).build();
    if (this.rpcOptions.getMetricRegistry() != null) {
        this.rpcOptions.getMetricRegistry().register("raft-rpc-client-thread-pool", new ThreadPoolMetricSet(this.rpcExecutor));
        Utils.registerClosureExecutorMetrics(this.rpcOptions.getMetricRegistry());
    }
    return true;
}
Also used : ThreadPoolMetricSet(com.alipay.sofa.jraft.util.ThreadPoolMetricSet) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) RaftRpcFactory(com.alipay.sofa.jraft.rpc.RaftRpcFactory) NamedThreadFactory(com.alipay.sofa.jraft.util.NamedThreadFactory)

Aggregations

RaftRpcFactory (com.alipay.sofa.jraft.rpc.RaftRpcFactory)1 NamedThreadFactory (com.alipay.sofa.jraft.util.NamedThreadFactory)1 ThreadPoolMetricSet (com.alipay.sofa.jraft.util.ThreadPoolMetricSet)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1