From 0f1bf70771afdc61ae4964721a18bf4913491e6f Mon Sep 17 00:00:00 2001 From: jeremyhi Date: Fri, 26 Jan 2024 17:54:30 +0800 Subject: [PATCH 1/2] feat: can set rpc-closure-executor's work queue size --- .../com/alipay/sofa/jraft/rpc/RpcUtils.java | 59 ++++++++++++------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java b/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java index 38a421a0f..0fd5dd7c1 100644 --- a/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java +++ b/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java @@ -16,6 +16,7 @@ */ package com.alipay.sofa.jraft.rpc; +import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.concurrent.SynchronousQueue; @@ -38,40 +39,54 @@ */ public final class RpcUtils { - private static final Logger LOG = LoggerFactory.getLogger(RpcUtils.class); + private static final Logger LOG = LoggerFactory + .getLogger(RpcUtils.class); /** * Default jraft closure executor pool minimum size, CPUs by default. */ - public static final int MIN_RPC_CLOSURE_EXECUTOR_POOL_SIZE = SystemPropertyUtil.getInt( - "jraft.rpc.closure.threadpool.size.min", - Utils.cpus()); + public static final int MIN_RPC_CLOSURE_EXECUTOR_POOL_SIZE = SystemPropertyUtil + .getInt( + "jraft.rpc.closure.threadpool.size.min", + Utils.cpus()); /** * Default jraft closure executor pool maximum size. */ - public static final int MAX_RPC_CLOSURE_EXECUTOR_POOL_SIZE = SystemPropertyUtil.getInt( - "jraft.rpc.closure.threadpool.size.max", - Math.max(100, Utils.cpus() * 5)); + public static final int MAX_RPC_CLOSURE_EXECUTOR_POOL_SIZE = SystemPropertyUtil + .getInt( + "jraft.rpc.closure.threadpool.size.max", + Math.max(100, Utils.cpus() * 5)); + + /** + * Default jraft closure executor pool work queue size. + */ + public static final int RPC_CLOSURE_EXECUTOR_QUEUE_SIZE = SystemPropertyUtil + .getInt( + "jraft.rpc.closure.threadpool.queue.size", + 100); /** * Global thread pool to run rpc closure. */ - private static ThreadPoolExecutor RPC_CLOSURE_EXECUTOR = ThreadPoolUtil - .newBuilder() - .poolName("JRAFT_RPC_CLOSURE_EXECUTOR") - .enableMetric(true) - .coreThreads( - MIN_RPC_CLOSURE_EXECUTOR_POOL_SIZE) - .maximumThreads( - MAX_RPC_CLOSURE_EXECUTOR_POOL_SIZE) - .keepAliveSeconds(60L) - .workQueue(new SynchronousQueue<>()) - .threadFactory( - new NamedThreadFactory( - "JRaft-Rpc-Closure-Executor-", - true)) // - .build(); + private static final ThreadPoolExecutor RPC_CLOSURE_EXECUTOR = ThreadPoolUtil + .newBuilder() + .poolName( + "JRAFT_RPC_CLOSURE_EXECUTOR") + .enableMetric(true) + .coreThreads( + MIN_RPC_CLOSURE_EXECUTOR_POOL_SIZE) + .maximumThreads( + MAX_RPC_CLOSURE_EXECUTOR_POOL_SIZE) + .keepAliveSeconds(60L) + .workQueue( + new ArrayBlockingQueue<>( + RPC_CLOSURE_EXECUTOR_QUEUE_SIZE)) + .threadFactory( + new NamedThreadFactory( + "JRaft-Rpc-Closure-Executor-", + true)) // + .build(); /** * Run closure with OK status in thread pool. From f4c362539108b9b24b77dd68c83ed448ddf9aaf0 Mon Sep 17 00:00:00 2001 From: jeremyhi Date: Fri, 26 Jan 2024 17:56:47 +0800 Subject: [PATCH 2/2] feat: release 1.3.14 --- jraft-core/pom.xml | 2 +- .../java/com/alipay/sofa/jraft/rpc/RpcUtils.java | 13 +------------ jraft-example/pom.xml | 2 +- jraft-extension/bdb-log-storage-impl/pom.xml | 2 +- jraft-extension/java-log-storage-impl/pom.xml | 2 +- jraft-extension/pom.xml | 2 +- jraft-extension/rpc-grpc-impl/pom.xml | 2 +- jraft-rheakv/pom.xml | 2 +- jraft-rheakv/rheakv-core/pom.xml | 2 +- jraft-rheakv/rheakv-pd/pom.xml | 2 +- jraft-test/pom.xml | 2 +- pom.xml | 2 +- 12 files changed, 12 insertions(+), 23 deletions(-) diff --git a/jraft-core/pom.xml b/jraft-core/pom.xml index dc869d6e9..4fa739f4b 100644 --- a/jraft-core/pom.xml +++ b/jraft-core/pom.xml @@ -5,7 +5,7 @@ jraft-parent com.alipay.sofa - 1.3.13 + 1.3.14 jraft-core jar diff --git a/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java b/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java index 0fd5dd7c1..ad0f1ebea 100644 --- a/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java +++ b/jraft-core/src/main/java/com/alipay/sofa/jraft/rpc/RpcUtils.java @@ -16,7 +16,6 @@ */ package com.alipay.sofa.jraft.rpc; -import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.concurrent.SynchronousQueue; @@ -58,14 +57,6 @@ public final class RpcUtils { "jraft.rpc.closure.threadpool.size.max", Math.max(100, Utils.cpus() * 5)); - /** - * Default jraft closure executor pool work queue size. - */ - public static final int RPC_CLOSURE_EXECUTOR_QUEUE_SIZE = SystemPropertyUtil - .getInt( - "jraft.rpc.closure.threadpool.queue.size", - 100); - /** * Global thread pool to run rpc closure. */ @@ -79,9 +70,7 @@ public final class RpcUtils { .maximumThreads( MAX_RPC_CLOSURE_EXECUTOR_POOL_SIZE) .keepAliveSeconds(60L) - .workQueue( - new ArrayBlockingQueue<>( - RPC_CLOSURE_EXECUTOR_QUEUE_SIZE)) + .workQueue(new SynchronousQueue<>()) .threadFactory( new NamedThreadFactory( "JRaft-Rpc-Closure-Executor-", diff --git a/jraft-example/pom.xml b/jraft-example/pom.xml index 879f222c8..051bc93d9 100644 --- a/jraft-example/pom.xml +++ b/jraft-example/pom.xml @@ -5,7 +5,7 @@ jraft-parent com.alipay.sofa - 1.3.13 + 1.3.14 jraft-example jar diff --git a/jraft-extension/bdb-log-storage-impl/pom.xml b/jraft-extension/bdb-log-storage-impl/pom.xml index be28e0389..7d6680efc 100644 --- a/jraft-extension/bdb-log-storage-impl/pom.xml +++ b/jraft-extension/bdb-log-storage-impl/pom.xml @@ -4,7 +4,7 @@ jraft-extension com.alipay.sofa - 1.3.13 + 1.3.14 bdb-log-storage-impl bdb-log-storage-impl ${project.version} diff --git a/jraft-extension/java-log-storage-impl/pom.xml b/jraft-extension/java-log-storage-impl/pom.xml index 9ec35f6ae..2ed9b628d 100644 --- a/jraft-extension/java-log-storage-impl/pom.xml +++ b/jraft-extension/java-log-storage-impl/pom.xml @@ -4,7 +4,7 @@ jraft-extension com.alipay.sofa - 1.3.13 + 1.3.14 java-log-storage-impl diff --git a/jraft-extension/pom.xml b/jraft-extension/pom.xml index 69ce2d422..1a016ce0f 100644 --- a/jraft-extension/pom.xml +++ b/jraft-extension/pom.xml @@ -4,7 +4,7 @@ jraft-parent com.alipay.sofa - 1.3.13 + 1.3.14 jraft-extension diff --git a/jraft-extension/rpc-grpc-impl/pom.xml b/jraft-extension/rpc-grpc-impl/pom.xml index 3719331e5..1d3e1e978 100644 --- a/jraft-extension/rpc-grpc-impl/pom.xml +++ b/jraft-extension/rpc-grpc-impl/pom.xml @@ -4,7 +4,7 @@ jraft-extension com.alipay.sofa - 1.3.13 + 1.3.14 rpc-grpc-impl diff --git a/jraft-rheakv/pom.xml b/jraft-rheakv/pom.xml index 9fac8cc96..db55b2730 100644 --- a/jraft-rheakv/pom.xml +++ b/jraft-rheakv/pom.xml @@ -4,7 +4,7 @@ jraft-parent com.alipay.sofa - 1.3.13 + 1.3.14 jraft-rheakv diff --git a/jraft-rheakv/rheakv-core/pom.xml b/jraft-rheakv/rheakv-core/pom.xml index 5b8db59c1..8e3720d38 100644 --- a/jraft-rheakv/rheakv-core/pom.xml +++ b/jraft-rheakv/rheakv-core/pom.xml @@ -4,7 +4,7 @@ jraft-rheakv com.alipay.sofa - 1.3.13 + 1.3.14 jraft-rheakv-core diff --git a/jraft-rheakv/rheakv-pd/pom.xml b/jraft-rheakv/rheakv-pd/pom.xml index 8279d69c6..e9c4b67e9 100644 --- a/jraft-rheakv/rheakv-pd/pom.xml +++ b/jraft-rheakv/rheakv-pd/pom.xml @@ -4,7 +4,7 @@ jraft-rheakv com.alipay.sofa - 1.3.13 + 1.3.14 jraft-rheakv-pd diff --git a/jraft-test/pom.xml b/jraft-test/pom.xml index 4e8ebdcdd..e3d460278 100644 --- a/jraft-test/pom.xml +++ b/jraft-test/pom.xml @@ -5,7 +5,7 @@ jraft-parent com.alipay.sofa - 1.3.13 + 1.3.14 jraft-test jar diff --git a/pom.xml b/pom.xml index 90aa1cd84..8fd58064d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.alipay.sofa jraft-parent - 1.3.13 + 1.3.14 pom ${project.groupId}:${project.artifactId}