You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/01/10 06:26:18 UTC
[shardingsphere] branch master updated: Use Vert.x CpuCoreSensor to handle cgroup stuff (#14656)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new a701cc7 Use Vert.x CpuCoreSensor to handle cgroup stuff (#14656)
a701cc7 is described below
commit a701cc73569ed5b23fa2a4b807a88ceba6a7d1a0
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Mon Jan 10 14:25:24 2022 +0800
Use Vert.x CpuCoreSensor to handle cgroup stuff (#14656)
---
.../proxy/backend/communication/vertx/VertxBackendDataSource.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
index 856d97f..77b8143 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/vertx/VertxBackendDataSource.java
@@ -20,9 +20,11 @@ package org.apache.shardingsphere.proxy.backend.communication.vertx;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.zaxxer.hikari.HikariDataSource;
+import io.netty.util.NettyRuntime;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
+import io.vertx.core.impl.cpu.CpuCoreSensor;
import io.vertx.mysqlclient.MySQLConnectOptions;
import io.vertx.mysqlclient.MySQLPool;
import io.vertx.sqlclient.Pool;
@@ -55,7 +57,11 @@ public final class VertxBackendDataSource implements BackendDataSource {
private final Vertx vertx;
private VertxBackendDataSource() {
- vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true).setEventLoopPoolSize(Runtime.getRuntime().availableProcessors()));
+ vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true).setEventLoopPoolSize(determineEventLoopPoolSize()));
+ }
+
+ private int determineEventLoopPoolSize() {
+ return Math.min(CpuCoreSensor.availableProcessors(), NettyRuntime.availableProcessors());
}
/**