Browse Source

当工作线程设置为0,取核数

sensordb2 1 year ago
parent
commit
06fb29677e

+ 3 - 0
insert-app/src/main/java/db/netty/NettyServer.java

@@ -90,6 +90,9 @@ public class NettyServer {
 
         if (useMultiThread) {
             // linux系统下使用SO_REUSEPORT特性,使得多个线程绑定同一个端口
+            if(workThreadNum<=0) {
+                workThreadNum = Runtime.getRuntime().availableProcessors();
+            }
             log.info("使用 epoll reuseport,启动线程数:{}", workThreadNum);
             for (int i = 0; i < workThreadNum; i++) {
                 ChannelFuture future = bootstrap.bind(host, port).await();

+ 2 - 2
shell/manage/common.sh

@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
-#HOST=127.0.0.1
-HOST=39.104.63.130
+HOST=127.0.0.1
+#HOST=39.104.63.130
 PORT=8088
 
 echo host:$host port:$PORT

+ 17 - 0
shell/manage/statisticLoop.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+
+ROOT=$(cd `dirname $0`/../../; pwd)
+source $ROOT/shell/manage/common.sh
+
+#sleep second
+sleepTime=1
+i=1
+count=100
+while(($i<$count))
+do
+  echo [$i]
+  curl http://$HOST:$PORT/api/v1/manage/statistic
+  echo "end"
+  i=$(($i+1))
+  sleep $sleepTime
+done