Quellcode durchsuchen

auto commit 2.1.11

lith vor 3 Jahren
Ursprung
Commit
bba72527bf
66 geänderte Dateien mit 1164 neuen und 885 gelöschten Zeilen
  1. 13 5
      Publish/ReleaseFile/StressTest/分布式压测/Demo/appsettings.json
  2. 13 5
      Publish/ReleaseFile/StressTest/分布式压测/Robot/appsettings.json
  3. 13 5
      Publish/ReleaseFile/StressTest/分布式压测/ServiceCenter/appsettings.json
  4. 15 7
      Publish/ReleaseFile/StressTest/单体压测/ServiceCenter/appsettings.json
  5. 1 1
      Publish/ReleaseFile/docker-image/docker导入导出镜像.md
  6. 1 1
      Publish/ReleaseFile/docker-image/制作镜像Sers.md
  7. 1 1
      dotnet/Gateway/App.Gateway/App.Gateway.csproj
  8. 6 2
      dotnet/Gateway/App.Gateway/appsettings.json
  9. 1 1
      dotnet/Library/Sers/Sers.CL/Ipc/Sers.CL.Ipc.NamedPipe/Doc/Sers.CL.Ipc.NamedPipe-额外命名管道/Sers.CL.Ipc.NamedPipe.csproj
  10. 1 1
      dotnet/Library/Sers/Sers.CL/Ipc/Sers.CL.Ipc.NamedPipe/Sers.CL.Ipc.NamedPipe.csproj
  11. 1 1
      dotnet/Library/Sers/Sers.CL/Ipc/Sers.CL.Ipc.SharedMemory/Sers.CL.Ipc.SharedMemory.csproj
  12. 1 1
      dotnet/Library/Sers/Sers.CL/Socket/Sers.CL.Socket.Iocp/Sers.CL.Socket.Iocp.csproj
  13. 1 1
      dotnet/Library/Sers/Sers.CL/Socket/Sers.CL.Socket.ThreadWait/Sers.CL.Socket.ThreadWait.csproj
  14. 7 2
      dotnet/Library/Sers/Sers.CL/Test/CommunicationManage/CmClient/appsettings.json
  15. 6 2
      dotnet/Library/Sers/Sers.CL/Test/CommunicationManage/CmServer/appsettings.json
  16. 1 1
      dotnet/Library/Sers/Sers.CL/WebSocket/Sers.CL.WebSocket/Sers.CL.WebSocket.csproj
  17. 1 1
      dotnet/Library/Sers/Sers.CL/Zmq/FullDuplex/Sers.CL.Zmq.FullDuplex/Sers.CL.Zmq.FullDuplex.csproj
  18. 1 1
      dotnet/Library/Sers/Sers.CL/Zmq/ThreadWait/Sers.CL.ClrZmq.ThreadWait/Sers.CL.ClrZmq.ThreadWait.csproj
  19. 1 1
      dotnet/Library/Sers/Sers.Core/Sers.Core.Temp/Sers.Core.Temp.csproj
  20. 4 1
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Env/EnvUsageInfo.cs
  21. 7 4
      dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Env/UsageReporter.cs
  22. 1 1
      dotnet/Library/Sers/Sers.Core/Sers.Core/Sers.Core.csproj
  23. 2 5
      dotnet/Library/Sers/Sers.Core/Sers.Core/Util/Consumer/ConsumerFactory.cs
  24. 0 63
      dotnet/Library/Sers/Sers.Core/Sers.Core/Util/Consumer/Mode/LongTask.cs
  25. 15 8
      dotnet/Library/Sers/Sers.Core/Sers.Core/Util/Consumer/Mode/ManagedThread.cs
  26. 2 2
      dotnet/Library/Sers/Sers.Core/Test/Sers.Core.Util.Consumer.Test/ProgramQps.cs
  27. 1 1
      dotnet/Library/Sers/Sers.Gateway/Sers.Gateway/Sers.Gateway.csproj
  28. 57 0
      dotnet/Library/Sers/Sers.Hardware/Sers.Hardware/Process/ProcessInfo.cs
  29. 1 1
      dotnet/Library/Sers/Sers.Hardware/Sers.Hardware/Sers.Hardware.csproj
  30. 2 2
      dotnet/Library/Sers/Sers.Hardware/Sers.Hardware/Usage/WindowsUsageReader.cs
  31. 1 1
      dotnet/Library/Sers/Sers.Serslot/Sers.Serslot/Sers.Serslot.csproj
  32. 1 1
      dotnet/Library/Sers/Sers.ServiceStation/Sers.ServiceStation/Sers.ServiceStation.csproj
  33. 0 67
      dotnet/Library/Vit/Vit.Core/Test/Vit.Core.Util.Threading.Worker.MsTest/Worker/LongTask_Test.cs
  34. 12 13
      dotnet/Library/Vit/Vit.Core/Test/Vit.Core.Util.Threading.Worker.MsTest/Worker/ManagedThread_Test.cs
  35. 0 146
      dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/LongTask.cs
  36. 0 333
      dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/LongTask_TimeLimit.cs
  37. 2 1
      dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/LongThread_TimeLimit.cs
  38. 573 0
      dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/ManagedThread.cs
  39. 1 1
      dotnet/Library/Vit/Vit.Core/Vit.Core/Vit.Core.csproj
  40. 1 1
      dotnet/Library/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj
  41. 1 1
      dotnet/Library/Vit/Vit.WebHost/Vit.WebHost.csproj
  42. 1 1
      dotnet/ServiceCenter/App.Gover.Gateway/App.Gover.Gateway.csproj
  43. 6 2
      dotnet/ServiceCenter/App.Gover.Gateway/appsettings.json
  44. 16 5
      dotnet/ServiceCenter/App.Gover.Gateway/wwwroot/_gover_/ServiceStation.html
  45. 218 37
      dotnet/ServiceCenter/App.ServiceCenter.NetFx/App.ServiceCenter.NetFx/appsettings.json
  46. 9 9
      dotnet/ServiceCenter/App.ServiceCenter.NetFx/App.ServiceCenter.NetFx/packages.config
  47. 1 1
      dotnet/ServiceCenter/App.ServiceCenter/App.ServiceCenter.csproj
  48. 13 5
      dotnet/ServiceCenter/App.ServiceCenter/appsettings.json
  49. 1 1
      dotnet/ServiceCenter/Sers.ServiceCenter/Apm/Sers.Gover.Apm.Txt/Sers.Gover.Apm.Txt.csproj
  50. 1 1
      dotnet/ServiceCenter/Sers.ServiceCenter/Apm/Sers.Gover.Apm.Zipkin/Sers.Gover.Apm.Zipkin.csproj
  51. 3 0
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Model/ServiceStationData.cs
  52. 19 9
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/ServiceStationMng.cs
  53. 9 56
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Controllers/ApiControllers/ServiceCenterController.cs
  54. 1 1
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Sers.Gover.csproj
  55. 15 7
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Entity/ServiceStation.cs
  56. 1 1
      dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter.csproj
  57. 1 1
      dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/Controllers/Demo/SampleController.cs
  58. 1 1
      dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/Did.SersLoader.Demo.csproj
  59. 13 5
      dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/appsettings.json
  60. 1 1
      dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.HelloWorld/Did.SersLoader.HelloWorld.csproj
  61. 1 0
      dotnet/ServiceStation/Demo/Serslot/Did.Serslot.Demo/Controllers/ValuesController.cs
  62. 13 5
      dotnet/ServiceStation/Demo/Serslot/Did.Serslot.Demo/appsettings.json
  63. 1 1
      dotnet/ServiceStation/Demo/StressTest/App.Robot.Station/App.Robot.Station.csproj
  64. 13 5
      dotnet/ServiceStation/Demo/StressTest/App.Robot.Station/appsettings.json
  65. 25 25
      java/App.StationDemo.Station/appsettings.json
  66. 12 12
      java/Sers.Test/appsettings.json

+ 13 - 5
Publish/ReleaseFile/StressTest/分布式压测/Demo/appsettings.json

@@ -7,11 +7,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 2,
-          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
@@ -184,11 +188,15 @@
       "PrintTrace": false,
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 20,
-        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 13 - 5
Publish/ReleaseFile/StressTest/分布式压测/Robot/appsettings.json

@@ -6,11 +6,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 2,
-          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
@@ -159,11 +163,15 @@
     "LocalApiService": {
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 20,
-        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 13 - 5
Publish/ReleaseFile/StressTest/分布式压测/ServiceCenter/appsettings.json

@@ -6,11 +6,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 4,
-          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
@@ -196,11 +200,15 @@
       "PrintTrace": false,
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 4,
-        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 15 - 7
Publish/ReleaseFile/StressTest/单体压测/ServiceCenter/appsettings.json

@@ -7,16 +7,20 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 1,
-          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
 
 
         //HeartBeat  
@@ -66,11 +70,15 @@
       "PrintTrace": false,
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 20,
-        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 1 - 1
Publish/ReleaseFile/docker-image/docker导入导出镜像.md

@@ -1,5 +1,5 @@
 #导出镜像
-tag=2.1.10
+tag=2.1.11
 
 docker save -o /root/image/dotnet.2.1.tar serset/dotnet:2.1
 docker save -o /root/image/sers-cgateway-1.2.0.tar serset/sers-cgateway:1.2.0

+ 1 - 1
Publish/ReleaseFile/docker-image/制作镜像Sers.md

@@ -37,7 +37,7 @@ cd /root/image
 
 
 #构建镜像并推送到 Docker Hub 
-export tag=2.1.10
+export tag=2.1.11
 
 cd sers
 docker buildx build . -t serset/sers:${tag} -t serset/sers --platform=linux/amd64,linux/arm64,linux/arm/v7 --push

+ 1 - 1
dotnet/Gateway/App.Gateway/App.Gateway.csproj

@@ -8,7 +8,7 @@
 	<PropertyGroup>
 		<OutputType>Exe</OutputType>
 		<TargetFramework>netcoreapp2.1</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 		<PackageProjectUrl>https://github.com/serset/Sers</PackageProjectUrl>
 	</PropertyGroup>
 

+ 6 - 2
dotnet/Gateway/App.Gateway/appsettings.json

@@ -21,11 +21,15 @@
 
 
           "workThread": {
-            // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+            // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
             "mode": "LongThread",
             /* 后台处理消息的线程个数(单位个,默认2) */
             "threadCount": 2,
-            /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+            /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+            "maxThreadCount": 100,
+            /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+            "pendingQueueLength": 100000,
+            /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
             "timeoutMs": 300000
           },
 

+ 1 - 1
dotnet/Library/Sers/Sers.CL/Ipc/Sers.CL.Ipc.NamedPipe/Doc/Sers.CL.Ipc.NamedPipe-额外命名管道/Sers.CL.Ipc.NamedPipe.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.10</Version>
+    <Version>2.1.11</Version>
     <Description>https://github.com/serset/Sers</Description>
   </PropertyGroup>
 

+ 1 - 1
dotnet/Library/Sers/Sers.CL/Ipc/Sers.CL.Ipc.NamedPipe/Sers.CL.Ipc.NamedPipe.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Sers/Sers.CL/Ipc/Sers.CL.Ipc.SharedMemory/Sers.CL.Ipc.SharedMemory.csproj

@@ -2,7 +2,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Sers/Sers.CL/Socket/Sers.CL.Socket.Iocp/Sers.CL.Socket.Iocp.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Sers/Sers.CL/Socket/Sers.CL.Socket.ThreadWait/Sers.CL.Socket.ThreadWait.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 7 - 2
dotnet/Library/Sers/Sers.CL/Test/CommunicationManage/CmClient/appsettings.json

@@ -5,12 +5,17 @@
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
 
+
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 4,
-          /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 

+ 6 - 2
dotnet/Library/Sers/Sers.CL/Test/CommunicationManage/CmServer/appsettings.json

@@ -6,11 +6,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 4,
-          /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 

+ 1 - 1
dotnet/Library/Sers/Sers.CL/WebSocket/Sers.CL.WebSocket/Sers.CL.WebSocket.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Sers/Sers.CL/Zmq/FullDuplex/Sers.CL.Zmq.FullDuplex/Sers.CL.Zmq.FullDuplex.csproj

@@ -3,7 +3,7 @@
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
 		<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Sers/Sers.CL/Zmq/ThreadWait/Sers.CL.ClrZmq.ThreadWait/Sers.CL.ClrZmq.ThreadWait.csproj

@@ -2,7 +2,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Sers/Sers.Core/Sers.Core.Temp/Sers.Core.Temp.csproj

@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <Version>2.1.10</Version>
+    <Version>2.1.11</Version>
   </PropertyGroup>
   
   <PropertyGroup>

+ 4 - 1
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Env/EnvUsageInfo.cs

@@ -1,4 +1,5 @@
-using Sers.Hardware.Usage;
+using Sers.Hardware.Process;
+using Sers.Hardware.Usage;
 
 namespace Sers.Core.Module.Env
 {
@@ -8,5 +9,7 @@ namespace Sers.Core.Module.Env
         public string serviceStationKey;    
 
         public UsageStatus usageStatus;
+
+        public ProcessInfo Process;
     }
 }

+ 7 - 4
dotnet/Library/Sers/Sers.Core/Sers.Core/Module/Env/UsageReporter.cs

@@ -4,6 +4,7 @@ using Sers.Core.Module.PubSub;
 using Vit.Core.Util.ConfigurationManager;
 using Sers.Hardware.Usage;
 using Vit.Core.Util.Threading.Timer;
+using Sers.Hardware.Process;
 
 namespace Sers.Core.Module.Env
 {
@@ -15,11 +16,13 @@ namespace Sers.Core.Module.Env
 
         [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
         public static void Publish()
-        { 
+        {
             try
-            {              
+            {
                 var info = new EnvUsageInfo();
                 info.usageStatus = UsageHelp.GetUsageInfo();
+                info.Process = ProcessInfo.GetCurrentProcessInfo();
+
                 info.deviceKey = Sers.Core.Module.Env.SersEnvironment.deviceKey;
                 info.serviceStationKey = Sers.Core.Module.Env.SersEnvironment.serviceStationKey;
 
@@ -28,10 +31,10 @@ namespace Sers.Core.Module.Env
             catch (System.Exception ex)
             {
                 Logger.Error(ex);
-            }                   
+            }
         }
 
-        static SersTimer timer = null;   
+        static SersTimer timer = null;
         /// <summary>
         /// 开启自动上报Usage任务
         /// </summary>

+ 1 - 1
dotnet/Library/Sers/Sers.Core/Sers.Core/Sers.Core.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 2 - 5
dotnet/Library/Sers/Sers.Core/Sers.Core/Util/Consumer/ConsumerFactory.cs

@@ -21,11 +21,8 @@ namespace Sers.Core.Util.Consumer
                 case "ConsumerCascade":
                     consumer = new ConsumerCascade<T, LongThread<T>>();
                     break;
-                case "LongTask":
-                    consumer = new LongTask<T>();
-                    break;
-                case "LongTask_TimeLimit":
-                    consumer = new LongTask_TimeLimit<T>();
+                case "ManagedThread":
+                    consumer = new ManagedThread<T>();
                     break;
                 default:
                     consumer = new LongThread<T>();

+ 0 - 63
dotnet/Library/Sers/Sers.Core/Sers.Core/Util/Consumer/Mode/LongTask.cs

@@ -1,63 +0,0 @@
-using Newtonsoft.Json.Linq;
-
-using System;
-using System.Runtime.CompilerServices;
-using Vit.Core.Util.Threading.Worker;
-using Vit.Extensions;
-
-
-
-namespace Sers.Core.Util.Consumer
-{
-
-    public class LongTask<T> : IConsumer<T>
-    {
-
-        public Action<T> Processor { get => task.Processor; set => task.Processor = value; }
-        public Action<ETaskFinishStatus, T> OnFinish { get => task.OnFinish; set => task.OnFinish = value; }
-
-
-
-        Vit.Core.Util.Threading.Worker.LongTask<T> task = new Vit.Core.Util.Threading.Worker.LongTask<T>();
-
-        public string threadName { get; set; }
-
-        public int threadCount { get => task.threadCount; set => task.threadCount = value; }
-
-        /// <summary>
-        /// 等待队列的最大长度(默认:100000)
-        /// </summary>
-        public int pendingQueueLength { get => task.pendingQueueLength; set => task.pendingQueueLength = value; }
-
-
-        public bool isRunning { get => task.IsRunning; }  
-
-
-        public void Init(JObject config)
-        {
-            threadCount = config["threadCount"]?.Deserialize<int?>() ?? 16;
-            pendingQueueLength = config["pendingQueueLength"]?.Deserialize<int?>() ?? 100000;
-        }
-
-
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public void Publish(T t)
-        {
-            task.Publish(t);
-        }
-
-
-        public void Start()
-        {
-            task.Stop();
-            task.Start();
-        }
-
-        public void Stop()
-        {
-            task.Stop();
-        }
-
-         
-    }
-}

+ 15 - 8
dotnet/Library/Sers/Sers.Core/Sers.Core/Util/Consumer/Mode/LongTask_TimeLimit.cs → dotnet/Library/Sers/Sers.Core/Sers.Core/Util/Consumer/Mode/ManagedThread.cs

@@ -10,20 +10,26 @@ using Vit.Extensions;
 namespace Sers.Core.Util.Consumer
 {
 
-    public class LongTask_TimeLimit<T> : IConsumer<T> 
+    public class ManagedThread<T> : IConsumer<T> 
     {
 
+        Vit.Core.Util.Threading.Worker.ManagedThread<T> task = new Vit.Core.Util.Threading.Worker.ManagedThread<T>();
+
         public Action<T> Processor { get => task.Processor; set => task.Processor = value; }
         public Action<ETaskFinishStatus, T> OnFinish { get => task.OnFinish; set => task.OnFinish = value; }
 
+        public string threadName { get => task.threadName; set => task.threadName = value; }
 
-
-        Vit.Core.Util.Threading.Worker.LongTask_TimeLimit<T> task = new Vit.Core.Util.Threading.Worker.LongTask_TimeLimit<T>();
-
-        public string threadName { get; set; }
-
+        /// <summary>
+        /// 常驻线程数,默认16。可为0
+        /// </summary>
         public int threadCount { get => task.threadCount; set => task.threadCount = value; }
 
+        /// <summary>
+        /// 最大线程数(包含常驻线程和临时线程),默认100。
+        /// </summary>
+        public int maxThreadCount { get => task.maxThreadCount; set => task.maxThreadCount = value; }
+
         /// <summary>
         /// 等待队列的最大长度(默认:100000)
         /// </summary>
@@ -34,12 +40,13 @@ namespace Sers.Core.Util.Consumer
         /// </summary>
         public int timeoutMs { get => task.timeoutMs; set => task.timeoutMs = value; }
 
-        public bool isRunning { get => task.IsRunning; }  
+        public bool isRunning { get => task.IsRunning; }
 
 
         public void Init(JObject config)
         {
-            threadCount = config["threadCount"]?.Deserialize<int?>() ?? 100;
+            threadCount = config["threadCount"]?.Deserialize<int?>() ?? 16;
+            maxThreadCount = config["maxThreadCount"]?.Deserialize<int?>() ?? 100;
             pendingQueueLength = config["pendingQueueLength"]?.Deserialize<int?>() ?? 100000;
             timeoutMs = config["timeoutMs"]?.Deserialize<int?>() ?? 300000;
         }

+ 2 - 2
dotnet/Library/Sers/Sers.Core/Test/Sers.Core.Util.Consumer.Test/ProgramQps.cs

@@ -78,8 +78,8 @@ namespace CLClient
                 case "LongThread":
                     consumer = new LongThread<Product>();  //16 16 1600千            //ori:16 16 440万          2  2  800万
                     break;
-                case "LongTask":
-                    consumer = new LongTask<Product>();  //16 16 1600千   
+                case "ManagedThread":
+                    consumer = new ManagedThread<Product>();
                     break;
 
                 case "ConsumerCache_LongThread":

+ 1 - 1
dotnet/Library/Sers/Sers.Gateway/Sers.Gateway/Sers.Gateway.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 57 - 0
dotnet/Library/Sers/Sers.Hardware/Sers.Hardware/Process/ProcessInfo.cs

@@ -0,0 +1,57 @@
+using System;
+using System.Diagnostics;
+
+using Vit.Core.Module.Log;
+
+namespace Sers.Hardware.Process
+{
+    public class ProcessInfo
+    {
+        /// <summary>
+        /// 总线程数
+        /// </summary>
+        public int ThreadCount;
+
+        /// <summary>
+        /// 活动的线程数
+        /// </summary>
+        public int RunningThreadCount;
+
+
+        /// <summary>
+        /// 占用总内存(单位:MB)
+        /// </summary>
+        public float WorkingSet;
+
+
+
+        public static ProcessInfo GetCurrentProcessInfo() 
+        {
+            var processInfo=new ProcessInfo();
+            try
+            {
+                var process = System.Diagnostics.Process.GetCurrentProcess();
+
+                //(x.x.1) ThreadCount
+                processInfo.ThreadCount = process.Threads.Count;
+
+                //(x.x.2) RunningThreadCount
+                int n = 0;
+                foreach (ProcessThread th in process.Threads)
+                {
+                    if (th.ThreadState == ThreadState.Running)
+                        n++;
+                }
+                processInfo.RunningThreadCount = n;
+
+                //(x.x.3) WorkingSet
+                processInfo.WorkingSet = process.WorkingSet64 / 1024.0f / 1024;
+            }
+            catch (Exception ex)
+            {
+                Logger.Error(ex);
+            }
+            return processInfo;
+        }
+    }
+}

+ 1 - 1
dotnet/Library/Sers/Sers.Hardware/Sers.Hardware/Sers.Hardware.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 2 - 2
dotnet/Library/Sers/Sers.Hardware/Sers.Hardware/Usage/WindowsUsageReader.cs

@@ -5,7 +5,7 @@ namespace Sers.Hardware.Usage
 {
     public class WindowsUsageReader : IUsageReader
     {
-        Process process;
+        System.Diagnostics.Process process;
 
         public void Start()
         {
@@ -13,7 +13,7 @@ namespace Sers.Hardware.Usage
             try
             {
                 Dispose();
-                process = new Process
+                process = new System.Diagnostics.Process
                 {
                     StartInfo = new ProcessStartInfo("Sers.Hardware.Net46.Exe.exe")
                     {

+ 1 - 1
dotnet/Library/Sers/Sers.Serslot/Sers.Serslot/Sers.Serslot.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Sers/Sers.ServiceStation/Sers.ServiceStation/Sers.ServiceStation.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 0 - 67
dotnet/Library/Vit/Vit.Core/Test/Vit.Core.Util.Threading.Worker.MsTest/Worker/LongTask_Test.cs

@@ -1,67 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Timers;
-
-using Vit.Core.Util.Threading.Worker;
-
-namespace Vit.Core.Util.Threading.MsTest.Worker
-{
-    [TestClass]
-    public class LongTask_Test
-    {
-        [TestMethod]
-        public void TestMethod()
-        {
-            int count = 0;
-            string errorMessage = "";
-
-            var task = new LongTask<object>
-            {                 
-                Processor = (worker) =>
-                {
-                    var _count = Interlocked.Increment(ref count);
-                    Thread.Sleep(100);
-                },
-                OnFinish = (status,_count) =>
-                {
-                    if (!
-                    (status == ETaskFinishStatus.success
-                    || (status == ETaskFinishStatus.overload && (int)_count > 100)
-                    ))
-                        errorMessage += Environment.NewLine + $"[{_count}]status : "+ status;
-                }
-            };
-
-            task.threadCount = 10;
-            task.pendingQueueLength = 100;      
-
-            task.Start();
-
-
-            for (var t = 0; t < 200; t++)
-                task.Publish(t);
-
-            Thread.Sleep(1050);
-            task.OnFinish = null;
-            task.Stop();
-
-            var curCount = count;
-            Assert.IsTrue(curCount <= 100);
-            Thread.Sleep(10);
-
-            Assert.IsTrue(!task.IsRunning);
-            var curCount2 = count;
-            Thread.Sleep(200);
-            Assert.AreEqual(count, curCount2);
-
-            if (!string.IsNullOrEmpty(errorMessage))
-                Assert.Fail(errorMessage);
-
-
-
-        }
-    }
-}

+ 12 - 13
dotnet/Library/Vit/Vit.Core/Test/Vit.Core.Util.Threading.Worker.MsTest/Worker/LongTask_TimeLimit_Test.cs → dotnet/Library/Vit/Vit.Core/Test/Vit.Core.Util.Threading.Worker.MsTest/Worker/ManagedThread_Test.cs

@@ -1,16 +1,12 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
-
 using System;
 using System.Threading;
-using System.Threading.Tasks;
-using System.Timers;
-
 using Vit.Core.Util.Threading.Worker;
 
 namespace Vit.Core.Util.Threading.MsTest.Worker
 {
     [TestClass]
-    public class LongTask_TimeLimit_Test
+    public class ManagedThread_Test
     {
         [TestMethod]
         public void TestMethod()
@@ -18,7 +14,7 @@ namespace Vit.Core.Util.Threading.MsTest.Worker
             int count = 0;
             string errorMessage = "";
 
-            var task = new LongTask_TimeLimit<object>
+            var task = new ManagedThread<object>
             {                 
                 Processor = (worker) =>
                 {
@@ -27,15 +23,18 @@ namespace Vit.Core.Util.Threading.MsTest.Worker
                 },
                 OnFinish = (status,_count) =>
                 {
-                    if (!
-                    (status == ETaskFinishStatus.timeout
-                    || (status == ETaskFinishStatus.overload && (int)_count > 100)
-                    ))
+                    if( status == ETaskFinishStatus.timeout
+                       || (status == ETaskFinishStatus.overload && (int)_count > 100)
+                    ) 
+                        return;
+
                         errorMessage += Environment.NewLine + $"[{_count}]status : "+ status;
                 }
             };
 
-            task.threadCount = 10;
+            task.threadName = "TestThread";
+            task.threadCount = 4;
+            task.maxThreadCount = 10;
             task.pendingQueueLength = 100;
             task.timeoutMs = 100;
 
@@ -44,14 +43,14 @@ namespace Vit.Core.Util.Threading.MsTest.Worker
 
             for (var t = 0; t < 200; t++)
                 task.Publish(t);
-
+     
             Thread.Sleep(1050);
             task.OnFinish = null;
             task.Stop();
 
             var curCount = count;
             Assert.IsTrue(curCount <= 100);
-            Thread.Sleep(10);
+            Thread.Sleep(100);
 
             Assert.IsTrue(!task.IsRunning);
             var curCount2 = count;

+ 0 - 146
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/LongTask.cs

@@ -1,146 +0,0 @@
-using System;
-using System.Threading;
-using Vit.Core.Module.Log;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Collections.Concurrent;
-
-namespace Vit.Core.Util.Threading.Worker
-{
-    /// <summary>
-    /// 注意!!!慎用!!!
-    /// 线程数量限制不一定准确。
-    /// 请勿处理ThreadInterruptedException异常,否则导致线程无法正常结束
-    /// 若超时则强制关闭任务。
-    /// 通过Task.Run创建新线程。推任务的模式。
-    /// </summary>
-    public class LongTask<T> : IDisposable
-    {
-
-        /// <summary>
-        /// 不可抛异常
-        /// </summary>
-        public Action<T> Processor;
-
-        /// <summary>
-        /// 不可抛异常
-        /// status: success/error/overload
-        /// </summary>
-        public Action<ETaskFinishStatus, T> OnFinish;
-
-        /// <summary>
-        /// 线程数,默认16
-        /// </summary>
-        public int threadCount = 16;
-
-        /// <summary>
-        /// 等待队列的最大长度(默认:100000)
-        /// </summary>
-        public int pendingQueueLength = 100000;
-
-        int runningThreadCount = 0;
-
-        public int RunningThreadCount => runningThreadCount;
-
-
-        ConcurrentQueue<T> pendingQueue = new ConcurrentQueue<T>();
-
-        public bool IsRunning => NeedRunning;
-
-        bool NeedRunning { get; set; } = false;
-
-        ~LongTask()
-        {
-            Dispose();
-        }
-
-        public virtual void Dispose()
-        {
-            Stop();
-        }
-
-
-        public void Start()
-        {
-            NeedRunning = true;
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <returns></returns>
-        public void Stop()
-        {
-            NeedRunning = false;
-            pendingQueue = new ConcurrentQueue<T>();
-        }
-
-
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public void Publish(T arg)
-        {
-            if (!IsRunning)
-            {
-                //(x.1)返回服务过载回应
-                OnFinish?.Invoke(ETaskFinishStatus.overload, arg);
-            }
-
-            //(x.2)启动新线程
-            if (runningThreadCount < threadCount)
-            {
-                StartNewTask(arg);
-                return;
-            }
-
-            //(x.3)推入等待队列
-            if (pendingQueue.Count < pendingQueueLength)
-            {
-                pendingQueue.Enqueue(arg);
-                return;
-            }
-        }
-
-
-
-
-
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        void StartNewTask(T arg_)
-        {
-            Task.Run(() =>
-            {
-                Interlocked.Increment(ref runningThreadCount);
-                T arg = arg_;
-                try
-                {
-                    while (NeedRunning)
-                    {
-                        #region (x.1) do work
-
-                        ETaskFinishStatus status = ETaskFinishStatus.success;
-                        try
-                        {
-                            Processor(arg);
-                        }
-                        catch (Exception ex)
-                        {
-                            status = ETaskFinishStatus.error;
-                            Logger.Error(ex);
-                        }
-                        finally
-                        {
-                            OnFinish?.Invoke(status, arg);
-                        }
-                        #endregion
-
-                        if (!pendingQueue.TryDequeue(out arg)) return;
-                    }
-                }
-                finally
-                {
-                    Interlocked.Decrement(ref runningThreadCount);
-                }
-            });
-        }
-    }
-}

+ 0 - 333
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/LongTask_TimeLimit.cs

@@ -1,333 +0,0 @@
-using System;
-using System.Threading;
-using Vit.Extensions;
-using Vit.Core.Module.Log;
-using Vit.Core.Util.Threading.Timer;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Collections.Concurrent;
-
-namespace Vit.Core.Util.Threading.Worker
-{
-    /// <summary>
-    /// 注意!!!慎用!!!
-    /// 线程数量限制不一定准确。
-    /// 请勿处理ThreadInterruptedException异常,否则导致线程无法正常结束
-    /// 若超时则强制关闭任务。
-    /// 通过Task.Run创建新线程。推任务的模式。
-    /// </summary>
-    public class LongTask_TimeLimit<T> : IDisposable
-    {
-
-        /// <summary>
-        /// 不可抛异常
-        /// </summary>
-        public Action<T> Processor;
-
-        /// <summary>
-        /// 不可抛异常
-        /// status: success/error/timeout/overload
-        /// </summary>
-        public Action<ETaskFinishStatus, T> OnFinish;
-
-        /// <summary>
-        /// 线程名称
-        /// </summary>
-        public string threadName;
-
-        /// <summary>
-        /// 线程数,默认100
-        /// </summary>
-        public int threadCount = 100;
-
-        /// <summary>
-        /// 等待队列的最大长度(默认:100000)
-        /// </summary>
-        public int pendingQueueLength = 100000;
-
-      
-        public int RunningThreadCount => runInfo.runningThreadCount;
-
-
-        #region RunInfo
-     
-        class RunInfo 
-        {
-          
-            /// <summary>
-            /// 运行中或准备启动的线程个数
-            /// </summary>
-            public int curThreadCount = 0;
-
-            /// <summary>
-            /// 在运行中的线程个数
-            /// </summary>
-            public int runningThreadCount = 0;
-
-            public readonly ConcurrentQueue<T> pendingQueue = new ConcurrentQueue<T>();
-
-            public readonly ConcurrentDictionary<int, WorkInfo> workInfoCache = new ConcurrentDictionary<int, WorkInfo>();
-
-        }
-        RunInfo runInfo = new RunInfo();
-
-        #endregion
-
-
-        public bool IsRunning => NeedRunning;
-
-        bool NeedRunning { get; set; } = false; 
-
-        /// <summary>
-        /// 超时时间。脉冲间隔。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。(默认300000)
-        /// </summary>
-        public int timeoutMs { get => pulseMaker.intervalMs; set => pulseMaker.intervalMs = value; }
-
-
-        public LongTask_TimeLimit()
-        {
-            pulseMaker = new SersTimer { intervalMs = 300000, timerCallback = PulseMake };
-        }
-
-
-        ~LongTask_TimeLimit()
-        {
-            Dispose();
-        }
-
-        public virtual void Dispose()
-        {
-            Stop();
-        }
-
-
-        #region 电子脉冲
-        /// <summary>
-        /// 脉冲生产器
-        /// </summary>
-        readonly SersTimer pulseMaker;
-
-        /// <summary>
-        /// 电子脉冲,在固定的时间间隔发送脉冲
-        /// </summary>
-        [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
-        public void PulseMake(object obj)
-        {
-            if (!IsRunning) return;
-
-            foreach (var workInfo in runInfo.workInfoCache.Values)
-            {
-                workInfo.Pulse();
-            }
-        }
-        #endregion
-
-
-        public void Start()
-        {
-            lock (this)
-            {
-                if (IsRunning)
-                {
-                    throw WorkerHelp.Error_CannotStartWhileRunning.ToException();
-                }
-                NeedRunning = true;              
-
-                //(x.2)开启脉冲生产器
-                pulseMaker.Start();
-            }
-        }
-
-        public void Stop()
-        {
-            lock (this)
-            {
-                if (!IsRunning) return;
-                NeedRunning = false;
-
-                try
-                {
-                    pulseMaker.Stop();
-                }
-                catch (Exception ex)
-                {
-                    Logger.Error(ex);
-                }
-
-                var info = runInfo;
-                runInfo = new RunInfo();
-                Task.Run(() =>
-                { 
-                    foreach (var workInfo in info.workInfoCache.Values)
-                    {
-                        workInfo.TryStop();
-                    }
-
-                    if (OnFinish != null) 
-                    {
-                        T arg;
-                        while (info.pendingQueue.TryDequeue(out arg))
-                        {
-                            OnFinish?.Invoke(ETaskFinishStatus.overload, arg);
-                        }
-                    }
-                });
-            }
-        }
-
-
-
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public void Publish(T arg)
-        {
-            if (IsRunning)
-            {
-                //(x.1)启动新线程
-                if (runInfo.runningThreadCount < threadCount)
-                {
-                    if(WorkInfo.StartNewTask(this, arg))
-                        return;
-                }
-
-                //(x.2)推入等待队列
-                if (runInfo.pendingQueue.Count < pendingQueueLength)
-                {
-                    runInfo.pendingQueue.Enqueue(arg);
-                    return;
-                }
-            }
-
-            //(x.3)返回服务过载回应
-            OnFinish?.Invoke(ETaskFinishStatus.overload, arg);
-        }
-
-       
-
-        class WorkInfo
-        {
-            int pulseCount = 0;
-
-            public T arg;
-            LongTask_TimeLimit<T> task;
-            public Thread thread;
-
-            [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            public bool TryStop()
-            {
-                try
-                {
-                    if (thread.IsAlive)
-                        thread.Interrupt();
-                }
-                catch { }
-                return thread.IsAlive;
-            }
-
-            [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            public void Pulse()
-            {
-                if (!thread.IsAlive)
-                    return;
-                try
-                {
-                    Interlocked.Increment(ref pulseCount);
-                    if (pulseCount >= 2)
-                        TryStop();
-                }
-                catch { }
-            }
-
-            [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            public static bool StartNewTask(LongTask_TimeLimit<T> task, T arg)
-            {
-                var info = task.runInfo;
-                var curThreadCount = Interlocked.Increment(ref info.curThreadCount);
-
-                try
-                {
-                    if (curThreadCount <= task.threadCount)
-                    {
-                        var workInfo = new WorkInfo { arg = arg, task = task };
-                        var thread = new Thread(workInfo.Run);
-                        workInfo.thread = thread;
-                        thread.IsBackground = true;
-                        thread.Name = task.threadName + "-" + thread.ManagedThreadId;
-                        thread.Start();
-                        return true;
-                    }                    
-                }
-                catch
-                {
-                    Interlocked.Decrement(ref info.curThreadCount);
-                    throw;
-                }
-
-                Interlocked.Decrement(ref info.curThreadCount);
-                return false;
-            }
-
-            [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            void Run()
-            {
-                var info = task.runInfo;
-                Interlocked.Increment(ref info.runningThreadCount);
-                try
-                {
-                    info.workInfoCache.TryAdd(this.GetHashCode(), this);
-
-                    T arg_;
-                    while (task.NeedRunning)
-                    {
-                        try
-                        {
-                            pulseCount = 0;
-                            if (arg == null)
-                            {
-                                if (!info.pendingQueue.TryDequeue(out arg_))
-                                    return;
-                            }
-                            else
-                            {
-                                arg_ = arg;
-                                arg = default;
-                            }
-
-                            #region do work
-                            ETaskFinishStatus status = ETaskFinishStatus.success;
-                            try
-                            {
-                                task.Processor(arg_);
-                            }
-                            catch (Exception ex) when (ex.GetBaseException() is ThreadInterruptedException)
-                            {
-                                status = ETaskFinishStatus.timeout;
-                            }
-                            catch (Exception ex)
-                            {
-                                status = ETaskFinishStatus.error;
-                                Logger.Error(ex);
-                            }
-                            finally
-                            {
-                                task.OnFinish?.Invoke(status, arg_);
-                            }
-                            #endregion
-                        }
-                        catch (Exception ex)
-                        {
-                            Logger.Error(ex);
-                        }
-                    }
-                }
-                finally
-                {
-                    Interlocked.Decrement(ref info.runningThreadCount);
-                    Interlocked.Decrement(ref info.curThreadCount);
-                    info.workInfoCache.TryRemove(this.GetHashCode(), out _);
-                }
-
-            }
-        }
-
-    }
-}

+ 2 - 1
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/LongThread_TimeLimit.cs

@@ -254,7 +254,7 @@ namespace Vit.Core.Util.Threading.Worker
                     {
                         try
                         {
-                            ETaskFinishStatus status = ETaskFinishStatus.success;
+                            ETaskFinishStatus status = ETaskFinishStatus.error;
                             try
                             {
                                 IsDealing = false;
@@ -268,6 +268,7 @@ namespace Vit.Core.Util.Threading.Worker
 
                                 //(x.x.3)
                                 Processor(workArg);
+                                status = ETaskFinishStatus.success;
                                 IsDealing = false;
                             }
                             catch (Exception ex) when (ex.GetBaseException() is ThreadInterruptedException)

+ 573 - 0
dotnet/Library/Vit/Vit.Core/Vit.Core/Util/Threading/Worker/ManagedThread.cs

@@ -0,0 +1,573 @@
+using System;
+using System.Threading;
+using Vit.Extensions;
+using Vit.Core.Module.Log;
+using Vit.Core.Util.Threading.Timer;
+using System.Runtime.CompilerServices;
+using System.Collections.Concurrent;
+
+namespace Vit.Core.Util.Threading.Worker
+{
+    /// <summary>
+    /// 注意!!!慎用!!!
+    /// 线程数量限制不一定准确。
+    /// 请勿处理ThreadInterruptedException异常,否则导致线程无法正常结束
+    /// 若超时则强制关闭任务。
+    /// 托管线程。推任务的模式。
+    /// </summary>
+    public class ManagedThread<T> : IDisposable
+    {
+
+        /// <summary>
+        /// 不可抛异常
+        /// </summary>
+        public Action<T> Processor;
+
+        /// <summary>
+        /// 不可抛异常
+        /// status: success/error/timeout/overload
+        /// </summary>
+        public Action<ETaskFinishStatus, T> OnFinish;
+
+        /// <summary>
+        /// 线程名称
+        /// </summary>
+        public string threadName;
+
+        /// <summary>
+        /// 常驻线程数,默认16。可为0
+        /// </summary>
+        public int threadCount = 16;
+
+        /// <summary>
+        /// 最大线程数(包含常驻线程和临时线程),默认100。
+        /// </summary>
+        public int maxThreadCount = 100;
+
+        /// <summary>
+        /// 等待队列的最大长度(默认:100000)
+        /// </summary>
+        public int pendingQueueLength = 100000;
+
+
+        public bool IsRunning => runInfo != null;
+
+
+        /// <summary>
+        /// 超时时间。脉冲间隔。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。(默认300000)
+        /// </summary>
+        public int timeoutMs { get => pulseMaker.intervalMs; set => pulseMaker.intervalMs = value; }
+
+
+        public ManagedThread()
+        {
+            pulseMaker = new SersTimer { intervalMs = 300000, timerCallback = Pulse };
+        }
+
+
+        ~ManagedThread()
+        {
+            Dispose();
+        }
+
+        public virtual void Dispose()
+        {
+            Stop();
+        }
+
+
+        #region 电子脉冲
+        /// <summary>
+        /// 脉冲生产器
+        /// </summary>
+        readonly SersTimer pulseMaker;
+
+        /// <summary>
+        /// 电子脉冲,在固定的时间间隔发送脉冲
+        /// </summary>
+        [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+        public void Pulse(object obj)
+        {
+            runInfo?.Pulse();
+        }
+        #endregion
+
+
+        public void Start()
+        {
+            lock (this)
+            {
+                if (IsRunning)
+                {
+                    throw WorkerHelp.Error_CannotStartWhileRunning.ToException();
+                }
+
+                //(x.1)
+                runInfo = new RunInfo(this);
+                runInfo.Start();
+
+                //(x.2)开启脉冲生产器
+                pulseMaker.Start();
+            }
+        }
+
+        public void Stop()
+        {
+            lock (this)
+            {
+                if (!IsRunning) return;
+
+                runInfo.needRunning = false;
+
+                var info = runInfo;
+                runInfo = null;
+
+                //关闭脉冲生产器
+                try
+                {
+                    pulseMaker.Stop();
+                }
+                catch (Exception ex)
+                {
+                    Logger.Error(ex);
+                }
+
+                //Task.Run(() =>
+                {
+                    //(x.1)终止常驻线程
+                    foreach (var thread in info.longThreadManager.threads)
+                    {
+                        try
+                        {
+                            thread.Pulse();
+                            thread.Pulse();
+                        }
+                        catch (Exception)
+                        {
+                        }
+                    }
+
+                    //(x.2)终止临时线程
+                    foreach (var thread in info.casualThreadManager.threadMap.Values)
+                    {
+                        try
+                        {
+                            thread.Pulse();
+                            thread.Pulse();
+                        }
+                        catch (Exception)
+                        {
+                        }
+                    }
+
+                    //(x.3)清空等待队列
+                    if (OnFinish != null)
+                    {
+                        T arg;
+                        while (info.pendingQueue.TryTake(out arg))
+                        {
+                            OnFinish?.Invoke(ETaskFinishStatus.overload, arg);
+                        }
+                    }
+                }
+                //);
+            }
+        }
+
+
+
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public void Publish(T arg)
+        {
+            if (IsRunning)
+            {
+                //(x.1)启动临时线程
+                if (runInfo.longThreadManager.waitingThreadCount == 0
+                    && runInfo.casualThreadManager.TryStartNewThread(arg))
+                {
+                    return;
+                }
+
+                //(x.2)推入等待队列
+                if (runInfo.pendingQueue.TryAdd(arg))
+                {
+                    return;
+                }
+            }
+
+            //(x.3)返回服务过载回应
+            OnFinish?.Invoke(ETaskFinishStatus.overload, arg);
+        }
+
+
+        #region RunInfo
+
+        class RunInfo
+        {
+            /// <summary>
+            /// 不可抛异常
+            /// </summary>
+            public Action<T> Processor;
+
+            /// <summary>
+            /// 不可抛异常
+            /// status: success/error/timeout/overload
+            /// </summary>
+            public Action<ETaskFinishStatus, T> OnFinish;
+
+
+            public bool needRunning = true;
+
+            public readonly BlockingCollection<T> pendingQueue;
+
+            public LongThreadManager longThreadManager;
+
+            public CasualThreadManager casualThreadManager;
+
+ 
+            public RunInfo(ManagedThread<T> task)
+            {   
+
+                this.Processor = task.Processor;
+                this.OnFinish = task.OnFinish;
+
+
+                pendingQueue = new BlockingCollection<T>(task.pendingQueueLength);
+
+
+                longThreadManager = new LongThreadManager(task);
+
+                casualThreadManager = new CasualThreadManager(task);
+            }
+
+
+            public void Start() 
+            {
+                longThreadManager.Start();
+            }
+
+
+            /// <summary>
+            /// 电子脉冲,在固定的时间间隔发送脉冲
+            /// </summary>
+            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+            public void Pulse()
+            {
+                longThreadManager.Pulse();
+                casualThreadManager.Pulse();
+            }
+
+        }
+        #endregion
+
+
+        RunInfo runInfo;
+
+
+
+
+
+        #region Manager 
+        class LongThreadManager
+        {
+            /// <summary>
+            /// 等待中的线程个数
+            /// </summary>
+            public int waitingThreadCount = 0;
+
+            public LongThread[] threads;
+            ManagedThread<T> task;
+            public LongThreadManager(ManagedThread<T> task)
+            {
+                this.task = task;
+            }
+
+            public void Start()
+            {
+                threads = new LongThread[task.threadCount];
+                for (int i = 0; i < threads.Length; i++)
+                {
+                    threads[i] = new LongThread(task,i);
+                }
+            }
+
+            /// <summary>
+            /// 电子脉冲,在固定的时间间隔发送脉冲
+            /// </summary>
+            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+            public void Pulse()
+            {
+                foreach (var thread in threads)
+                {
+                    thread?.Pulse();
+                }
+            }
+        }
+        class CasualThreadManager
+        {
+            public readonly ConcurrentDictionary<int, CasualThread> threadMap = new ConcurrentDictionary<int, CasualThread>();
+
+            ManagedThread<T> task;
+
+            public int runningThreadCount = 0;
+
+            public int curThreadCount = 0;
+
+            int maxThreadCount;
+            public CasualThreadManager(ManagedThread<T> task)
+            {
+                this.task = task;
+                maxThreadCount = task.maxThreadCount - task.threadCount;
+            }
+
+
+            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+            public bool TryStartNewThread(T arg)
+            {
+                var curThreadCount = Interlocked.Increment(ref this.curThreadCount);
+                try
+                {
+                    if (curThreadCount <= maxThreadCount)
+                    {
+                        new CasualThread(task, arg);
+                        return true;
+                    }
+                }
+                catch
+                {
+                    Interlocked.Decrement(ref this.curThreadCount);
+                    throw;
+                }
+
+                Interlocked.Decrement(ref this.curThreadCount);
+                return false; 
+            }
+
+
+            /// <summary>
+            /// 电子脉冲,在固定的时间间隔发送脉冲
+            /// </summary>
+            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+            public void Pulse()
+            {
+                foreach (var thread in threadMap.Values)
+                {
+                    thread?.Pulse();
+                }
+            }
+        }
+
+        #endregion
+
+        #region Thread
+
+
+
+
+        class LongThread
+        {
+            RunInfo runInfo;
+
+            LongThreadManager manager;
+
+            bool isProcessing = false;
+
+            int pulseCount = 0;
+
+            Thread thread;
+
+
+            public LongThread(ManagedThread<T> task,int index)
+            {
+                this.runInfo = task.runInfo;
+                this.manager = runInfo.longThreadManager;
+
+                thread = new Thread(Run);
+                thread.IsBackground = true;
+                thread.Name = task.threadName + "-LongThread-" + index + "-" + thread.ManagedThreadId;
+
+                thread.Start();
+            }
+
+
+
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            public void Pulse()
+            {
+                if (thread == null || !thread.IsAlive || !isProcessing)
+                    return;
+                try
+                {
+                    Interlocked.Increment(ref pulseCount);
+                    if (pulseCount >= 2)
+                        thread.Interrupt();
+                }
+                catch { }
+            }
+
+
+
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            void Run()
+            {
+                try
+                {
+                    T arg_;
+                    while (runInfo.needRunning)
+                    {
+                        try
+                        {
+                            isProcessing = false;
+                            Interlocked.Increment(ref manager.waitingThreadCount);
+                            arg_ = runInfo.pendingQueue.Take();
+                            Interlocked.Decrement(ref manager.waitingThreadCount);
+                            pulseCount = 0;
+                            isProcessing = true;
+
+                            #region processing 
+                            ETaskFinishStatus status = ETaskFinishStatus.error;
+                            try
+                            {
+                                runInfo.Processor(arg_);
+                                status = ETaskFinishStatus.success;
+                            }
+                            catch (Exception ex) when (ex.GetBaseException() is ThreadInterruptedException)
+                            {
+                                status = ETaskFinishStatus.timeout;
+                            }
+                            catch (Exception ex)
+                            {
+                                status = ETaskFinishStatus.error;
+                                Logger.Error(ex);
+                            }
+                            finally
+                            {
+                                runInfo.OnFinish?.Invoke(status, arg_);
+                            }
+                            #endregion
+                        }
+                        catch (Exception ex)
+                        {
+                            Logger.Error(ex);
+                        }
+                    }
+                }
+                finally
+                {
+                    thread = null;
+                }
+            }
+        }
+
+        class CasualThread
+        {
+            RunInfo runInfo;
+
+            int pulseCount = 0;
+
+            T arg;
+            Thread thread;
+
+            CasualThreadManager manager;
+
+
+            [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
+            public CasualThread(ManagedThread<T> task, T arg)
+            {
+                this.runInfo = task.runInfo;
+                this.manager = runInfo.casualThreadManager;
+                this.arg = arg;
+
+                thread = new Thread(Run);
+                thread.IsBackground = true;
+                thread.Name = task.threadName + "-Casual-" + thread.ManagedThreadId;
+                thread.Start();
+            }
+
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            public void Pulse()
+            {
+                if (!thread.IsAlive)
+                {
+                    manager.threadMap.TryRemove(this.GetHashCode(), out _);
+                    return;
+                }
+
+                try
+                {
+                    Interlocked.Increment(ref pulseCount);
+                    if (pulseCount >= 2)
+                        thread.Interrupt();
+                }
+                catch { }
+            }
+
+
+
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            void Run()
+            {
+                Interlocked.Increment(ref manager.runningThreadCount);
+                try
+                {
+                    manager.threadMap.TryAdd(this.GetHashCode(), this);
+
+                    T arg_;
+                    while (runInfo.needRunning)
+                    {
+                        try
+                        {
+                            pulseCount = 0;
+                            if (arg == null)
+                            {
+                                if (!runInfo.pendingQueue.TryTake(out arg_))
+                                    return;
+                            }
+                            else
+                            {
+                                arg_ = arg;
+                                arg = default;
+                            }
+
+                            #region processing
+                            ETaskFinishStatus status = ETaskFinishStatus.error;
+                            try
+                            {
+                                runInfo.Processor(arg_);
+                                status = ETaskFinishStatus.success;
+                            }
+                            catch (Exception ex) when (ex.GetBaseException() is ThreadInterruptedException)
+                            {
+                                status = ETaskFinishStatus.timeout;
+                            }
+                            catch (Exception ex)
+                            {
+                                status = ETaskFinishStatus.error;
+                                Logger.Error(ex);
+                            }
+                            finally
+                            {
+                                runInfo.OnFinish?.Invoke(status, arg_);
+                            }
+                            #endregion
+                        }
+                        catch (Exception ex)
+                        {
+                            Logger.Error(ex);
+                        }
+                    }
+                }
+                finally
+                {
+                    Interlocked.Decrement(ref manager.runningThreadCount);
+                    Interlocked.Decrement(ref manager.curThreadCount);
+                    manager.threadMap.TryRemove(this.GetHashCode(), out _);
+                }
+
+            }
+        }
+
+
+        #endregion
+    }
+}

+ 1 - 1
dotnet/Library/Vit/Vit.Core/Vit.Core/Vit.Core.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.9</Version>
+		<Version>2.1.10</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Vit/Vit.Net.Http.FormFile/Vit.Net.Http.FormFile.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.9</Version>
+		<Version>2.1.10</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/Library/Vit/Vit.WebHost/Vit.WebHost.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.9</Version>
+		<Version>2.1.10</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/ServiceCenter/App.Gover.Gateway/App.Gover.Gateway.csproj

@@ -8,7 +8,7 @@
 	<PropertyGroup>
 		<OutputType>Exe</OutputType>
 		<TargetFramework>netcoreapp2.1</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 		<PackageProjectUrl>https://github.com/serset/Sers</PackageProjectUrl>
 	</PropertyGroup>
 

+ 6 - 2
dotnet/ServiceCenter/App.Gover.Gateway/appsettings.json

@@ -21,11 +21,15 @@
 
 
           "workThread": {
-            // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+            // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
             "mode": "LongThread",
             /* 后台处理消息的线程个数(单位个,默认2) */
             "threadCount": 2,
-            /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+            /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+            "maxThreadCount": 100,
+            /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+            "pendingQueueLength": 100000,
+            /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
             "timeoutMs": 300000
           },
 

+ 16 - 5
dotnet/ServiceCenter/App.Gover.Gateway/wwwroot/_gover_/ServiceStation.html

@@ -128,16 +128,16 @@
                     <script src="Scripts/Sers/sers.apiClient.js"></script>
                     <div id="stations">
 
-                        <div v-for="station in stations" style="width:300px;height:500px;line-height:1.5;float:left;margin:2px;padding:4px;word-wrap:break-word;" class="line">
+                        <div v-for="station in stations" style="width:300px;height:520px;line-height:1.5;float:left;margin:2px;padding:4px;word-wrap:break-word;" class="line">
                             <font style="font-weight:bold;color:#e84855;">{{ (station.serviceStationInfo||{}).serviceStationName }} </font><br />
-                            {{station.apiStationNames}} <br />                            
-                            操作 : <a @click="start(station)">打开</a>   <a @click="pause(station)">暂停</a>  <a @click="stop(station)">强制关闭</a> 
+                            {{station.apiStationNames}} <br />
+                            操作 : <a @click="start(station)">打开</a>   <a @click="pause(station)">暂停</a>  <a @click="stop(station)">强制关闭</a>
                             <br />
                             <table>
                                 <tr>
                                     <td> 状态(正常|暂停) </td>
                                     <td> : {{station.status}}  </td>
-                                </tr>     
+                                </tr>
                                 <tr>
                                     <td> stationVersion </td>
                                     <td> : {{ (station.serviceStationInfo||{}).stationVersion }} </td>
@@ -145,7 +145,7 @@
                                 <tr>
                                     <td> startTime </td>
                                     <td> : {{station.startTime}} </td>
-                                </tr>                          
+                                </tr>
                             </table>
                             -----------------------<br />
                             <table>
@@ -182,6 +182,17 @@
                                 </tr>
                             </table>
                             -----------------------<br />
+                            <table>
+                                <tr>
+                                    <td> Thread(running/all) </td>
+                                    <td> : {{ getStringByPath(station,'Process.RunningThreadCount') }}/{{ getStringByPath(station,'Process.ThreadCount')}} </td>
+                                </tr>
+                                <tr>
+                                    <td> WorkingSet(MB) </td>
+                                    <td> : {{ getFloatByPath(station,'Process.WorkingSet') }} </td>
+                                </tr>
+                            </table>
+                            -----------------------<br />
                             <table>
                                 <tr>
                                     <td> deviceKey </td>

+ 218 - 37
dotnet/ServiceCenter/App.ServiceCenter.NetFx/App.ServiceCenter.NetFx/appsettings.json

@@ -1,16 +1,25 @@
 {
-
   "Sers": {
     /* 通讯层配置 */
     "CL": {
       /* 共用配置,子项共用,覆写子项未指定的配置 */
       "Config": {
 
-        /* 请求超时时间(单位ms,默认60000) */
-        "requestTimeoutMs": 60000,
+        "workThread": {
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
+          "mode": "LongThread",
+          /* 后台处理消息的线程个数(单位个,默认2) */
+          "threadCount": 2,
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
+          "timeoutMs": 300000
+        },
 
-        /* 后台处理消息的线程个数(单位个,默认2) */
-        "workThreadCount": 8,
+        /* 请求超时时间(单位ms,默认300000) */
+        "requestTimeoutMs": 300000,
 
         //HeartBeat
         /* 心跳检测时间间隔(单位ms,默认10000,若指定为0则不进行心跳检测) */
@@ -19,7 +28,7 @@
         "heartBeatTimeoutMs": 30000,
         /* 心跳检测失败重试次数(单位次,默认10) */
         "heartBeatRetryCount": 10,
-     
+
 
         /* 数据传输 加密协议,可多个,可不指定 */
         "//security": [
@@ -51,9 +60,9 @@
         {
           //Ipc.NamedPipe
           /* (x.1) type */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Ipc.NamedPipe.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Ipc.NamedPipe.OrganizeServerBuilder",
 
 
@@ -64,12 +73,25 @@
         {
           // Socket.Iocp
           /* (x.1) type - Iocp */
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           "className": "Sers.CL.Socket.Iocp.OrganizeServerBuilder",
 
+          /* 通信模式(默认值:Simple)。可为 Simple、Timer、ThreadWait  */
+          //"mode": "ThreadWait",
+
+          /* 接收缓存区大小(单位:byte,默认:8192)  */
+          //"receiveBufferSize": 8192,
+
+          /* 发送缓冲区刷新间隔(单位:毫秒,默认:1)(仅当mode为Timer和ThreadWait时有效)  */
+          //"sendFlushInterval": 1,
+          /* 发送缓冲区数据块的最小大小(单位:byte,默认 1000000)(仅当mode为Timer和ThreadWait时有效)  */
+          //"sendBufferSize": 1000000,
+          /* 发送缓冲区个数(默认1024)(仅当mode为Timer和ThreadWait时有效)    */
+          //"sendBufferCount": 1024,
+
 
           /* (x.2) config */
-          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.com"。*/
+          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
           //"host": "127.0.0.1",
           /* 服务端 监听端口号。例如: 4501 */
           "port": 4501
@@ -77,12 +99,12 @@
         {
           // Socket.ThreadWait
           /* (x.1) type - Socket */
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Socket.ThreadWait.OrganizeServerBuilder",
 
 
           /* (x.2) config */
-          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.com"。*/
+          /* 服务端 监听地址。若不指定则监听所有网卡。例如: "127.0.0.1"、"sers.cloud"。*/
           //"host": "127.0.0.1",
           /* 服务端 监听端口号。例如: 4501 */
           "port": 4501
@@ -91,9 +113,9 @@
         {
           // Zmq.ThreadWait
           /* (x.1) type */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.ClrZmq.ThreadWait.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.ClrZmq.ThreadWait.OrganizeServerBuilder",
 
 
@@ -118,9 +140,9 @@
         {
           // Zmq.FullDuplex
           /* (x.1) type */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Zmq.FullDuplex.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Zmq.FullDuplex.OrganizeServerBuilder",
 
           /* (x.2) config */
@@ -132,9 +154,9 @@
         {
           //Ipc.SharedMemory
           /* (x.1) type - Ipc.SharedMemory */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
 
 
@@ -148,9 +170,9 @@
         },
         {
           /* (x.1) type - Ipc.SharedMemory */
-          /* 在此Assembly中查找Builder */
+          /* 在此Assembly中查找builder */
           "assemblyFile": "Sers.CL.Ipc.SharedMemory.dll",
-          /* the class of Builder in assemblyFile  */
+          /* the class of builder in assemblyFile  */
           //"className": "Sers.CL.Ipc.SharedMemory.OrganizeServerBuilder",
 
           /* (x.2) config */
@@ -164,19 +186,32 @@
       ]
     },
 
-    /* LocalApiService 配置,可不指定 */
-    "LocalApiService": {
+    // RpcData序列化模式。可不指定。默认为Text。
+    // 可为 Newtonsoft、Text、BytePointor。
+    // 效率依次递增。BytePointor 序列化为二进制数据而不是json字符串。
+    "RpcDataSerializeMode": "Text",
 
-      /* 后台服务的线程个数(单位个,默认0,代表不开启服务)*/
-      "workThreadCount": 1,
 
-      /* 超时时间,若不指定则后台任务永不超时。(主动关闭超过此时间的任务,实际任务强制关闭的时间会在1倍超时时间到2倍超时时间内)。单位:ms。*/
-      //"timeout_ms": 10000,
 
+    /* LocalApiService 配置,可不指定 */
+    "LocalApiService": {
 
       /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
       "PrintTrace": false,
 
+      "workThread": {
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
+        "mode": "LongThread",
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
+        "threadCount": 4,
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
+        "timeoutMs": 300000
+      },
+
 
       /* 静态文件映射器。映射站点静态文件,可多个,可不指定 */
       "//staticFiles": [
@@ -244,7 +279,7 @@
         {
           /* 在此Assembly中加载类 */
           "assemblyFile": "Sers.ApiTrace.dll",
-          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScope */
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.ApiScope.IApiScopeEvent */
           "className": "Sers.ApiTrace.ApiScope"
         }
       ],
@@ -253,7 +288,7 @@
       "//BeforeCallApi": [
         {
           /* 在此Assembly中加载类 */
-          //"assemblyFile": "Sers.Core.dll",
+          "assemblyFile": "Sers.Core.dll",
           /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
           "className": "Bearer",
           //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
@@ -321,10 +356,10 @@
 
 
       //调用api前的事件,可不指定
-      "BeforeCallApi": [
+      "//BeforeCallApi": [
         {
           /* 在此Assembly中加载类 */
-          //"assemblyFile": "Sers.Core.dll",
+          "assemblyFile": "Sers.Core.dll",
           /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
           "className": "Bearer",
           //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
@@ -356,7 +391,8 @@
 
     /* 动态加载的App事件 */
     "AppEvent": [
-      {
+      { //记录请求Trace到Zipkin
+
         /* 在此Assembly中加载类 */
         "assemblyFile": "Sers.Gover.Apm.Zipkin.dll",
         /* 动态加载的类名,必须继承接口 Sers.Core.Module.App.AppEvent.IAppEvent */
@@ -366,21 +402,165 @@
 
         /* 配置 */
         "SamplingRate": "1.0",
-        "zipkinCollectorUrl": "http://do.sers.com:9411",
+        "zipkinCollectorUrl": "http://sers.cloud:9411",
 
         /* 若不指定则默认为ServiceCenter */
         "rpcName": "ServiceCenter",
         "tags": {
+          // 可为 requestRpc requestData responseRpc responseData
+          "traceName": "demoTrace",
+
           "route": "{{requestRpc.route}}",
           "{{requestRpc.route}}": "route",
           "url": "{{requestRpc.http.url}}",
           "method": "{{requestRpc.http.method}}",
           "requestRpc": "{{requestRpc}}",
-          "requestData": "{{requestData}}",
-          "traceName": "demoTrace"
+          //"requestData": "{{requestData}}",
+
+
+          "responseRpc": "{{responseRpc}}",
+          "responseState": "{{responseRpc.http.headers.responseState}}",
+          "responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
+
+          //"responseData": "{{responseData}}",
+          //"responseData.error": "{{responseData.error}}"
+
+        }
+      },
+      { //记录请求Trace到 Log/{yyyy-MM}/[{yyyy-MM-dd}]ApiTrace.txt文件
+
+        /* 在此Assembly中加载类 */
+        "assemblyFile": "Sers.Gover.Apm.Txt.dll",
+        /* 动态加载的类名,必须继承接口 Sers.Core.Module.App.AppEvent.IAppEvent */
+        //"className": "Sers.Gover.Apm.Txt.AppEvent",
+
+
+        "tags": {
+          // 可为 requestRpc requestData responseRpc responseData
+          "From": "Sers.Gover.Apm.Txt",
+
+          "route": "{{requestRpc.route}}",
+          //"{{requestRpc.route}}": "route",
+
+          "url": "{{requestRpc.http.url}}",
+          "method": "{{requestRpc.http.method}}",
+          "requestRpc": "{{requestRpc}}",
+          //"requestData": "{{requestData}}",
+
+
+          "responseRpc": "{{responseRpc}}",
+          "responseState": "{{responseRpc.http.headers.responseState}}"
+          //"responseError_Base64": "{{responseRpc.http.headers.responseError_Base64}}"
+
+          //"responseData": "{{responseData}}",
+          //"responseData.error": "{{responseData.error}}"
+
         }
       }
-    ]
+    ],
+
+
+    /* 网关配置。若不指定,则不开启网关服务 */
+    "Gateway": {
+
+      /* Rpc配置,可不指定 */
+      "Rpc": {
+        /* 网关转发的请求中的rpc 信息中的 CallerSource。(暗指调用来源,默认"OutSide")  */
+        //"CallerSource": "OutSide"
+      },
+
+      "WebHost": {
+
+        /* url,可多个 */
+        "urls": [ "http://*:4580" ],
+
+        /* 是否允许跨域访问,默认true */
+        "allowAnyOrigin": true,
+
+        /* 把请求的ip地址、端口号复制到请求头中的前缀。若不指定则不复制。 */
+        "prefixOfCopyIpToHeader": "Sers-Gateway-",
+
+        /* http回应中的默认Content-Type。若不指定则默认为 "application/json; charset="+Serialization.Instance.charset  */
+        "//ResponseDefaultContentType": "application/json; charset=UTF-8",
+
+
+        /* 映射静态文件。若不指定则不映射静态文件 */
+        "staticFiles": {
+
+          /* 请求路径(可不指定)。demo:"/file/static"。The relative request path that maps to static resources */
+          //"requestPath": "/file",
+
+          /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则为默认路径(wwwroot)。demo:"wwwroot/demo" */
+          //"rootPath": "wwwroot",
+
+          /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering  may affect performance */
+          "defaultFileNames": [ "index.html" ],
+
+          /* 是否可浏览目录(default false)。Enables directory browsing */
+          //"useDirectoryBrowser": false,
+
+          /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
+          "contentTypeMapFile": "contentTypeMap.json",
+
+          /* 回应静态文件时额外添加的http回应头。可不指定。 */
+          "responseHeaders": {
+
+            //设置浏览器静态文件缓存3600秒
+            "Cache-Control": "public,max-age=3600"
+          }
+        }
+
+      },
+
+
+      //调用api前的事件,可不指定
+      "BeforeCallApi": [
+        {
+          /* 在此Assembly中加载类 */
+          "assemblyFile": "Sers.Core.dll",
+          /* 动态加载的类名,必须继承接口 Sers.Core.Module.Api.ApiEvent.BeforeCallApi.IBeforeCallApi */
+          //"className": "Bearer",
+          //Bearer: 在调用接口前,会获取 rpcData.http.headers.Authorization(格式为 "Bearer xxxxxx"),并作为参数调用接口api_verifyAt,把返回数据放到 rpcData.user.userInfo
+
+          /* 验证at接口的地址 */
+          "api_verifyAt": "/AuthCenter/account/verifyAt",
+          /* 验证at接口的httpMethod。(如 GET POST 可不指定) */
+          "api_httpMethod": "POST"
+        },
+
+        {
+          //AccountInCookie 在调用接口前,会获取 rpcData.http.headers.Cookie(格式为 "user=xxx;c=7")中的user,在账号列表中比对userToken,回写 CallerSource(rpcData.caller.source) 和 userInfo(rpcData.user.userInfo)
+          "className": "AccountInCookie",
+          "account": [
+            {
+              "userToken": "admin_123456",
+              "CallerSource": "Internal",
+              "userInfo": {
+                "name": "Gover管理员",
+                "入口": "Gover网关"
+              }
+            }
+          ]
+        }
+      ],
+
+
+      /* 服务限流配置,可不指定 */
+      "rateLimit": [
+        {
+          /* 服务限流key,标识一个限流服务,必须唯一 */
+          "rateLimitKey": "rate",
+
+          /* 固定时间窗口限流。在单位时间(msInterval)内限制最大请求数量为reqLimit。超出数量的请求将被拒绝 */
+          "rateLimitType": "FixedWindow",
+          /* 单位时间内最大请求数量(个)*/
+          "reqLimit": 100000,
+          /* 单位时间长度(单位:ms)*/
+          "msInterval": 1000
+        }
+      ]
+
+    }
 
 
 
@@ -395,11 +575,12 @@
 
     /* 日志配置,可不指定 */
     "Logger": {
-      /* print the log to console. default:false  */
+      /* print the log to Log/*.txt default:true  */
+      "PrintToTxt": true,
+      /* print the log to console. default:true  */
       "PrintToConsole": true
     },
 
-
     /* 序列化配置,可不指定 */
     "Serialization": {
       /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */

+ 9 - 9
dotnet/ServiceCenter/App.ServiceCenter.NetFx/App.ServiceCenter.NetFx/packages.config

@@ -4,14 +4,14 @@
   <package id="Microsoft.DotNet.PlatformAbstractions" version="2.0.0" targetFramework="net461" />
   <package id="Microsoft.Extensions.DependencyModel" version="2.0.0" targetFramework="net461" />
   <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
-  <package id="Sers.CL.Ipc.NamedPipe" version="2.1.10" targetFramework="net461" />
-  <package id="Sers.CL.Socket.Iocp" version="2.1.10" targetFramework="net461" />
-  <package id="Sers.CL.Socket.ThreadWait" version="2.1.10" targetFramework="net461" />
-  <package id="Sers.CL.WebSocket" version="2.1.10" targetFramework="net461" />
-  <package id="Sers.Core" version="2.1.10" targetFramework="net461" />
-  <package id="Sers.Gover" version="2.1.10" targetFramework="net461" />
-  <package id="Sers.Hardware" version="2.1.10" targetFramework="net461" />
-  <package id="Sers.ServiceCenter" version="2.1.10" targetFramework="net461" />
+  <package id="Sers.CL.Ipc.NamedPipe" version="2.1.11" targetFramework="net461" />
+  <package id="Sers.CL.Socket.Iocp" version="2.1.11" targetFramework="net461" />
+  <package id="Sers.CL.Socket.ThreadWait" version="2.1.11" targetFramework="net461" />
+  <package id="Sers.CL.WebSocket" version="2.1.11" targetFramework="net461" />
+  <package id="Sers.Core" version="2.1.11" targetFramework="net461" />
+  <package id="Sers.Gover" version="2.1.11" targetFramework="net461" />
+  <package id="Sers.Hardware" version="2.1.11" targetFramework="net461" />
+  <package id="Sers.ServiceCenter" version="2.1.11" targetFramework="net461" />
   <package id="System.Buffers" version="4.5.1" targetFramework="net461" />
-  <package id="Vit.Core" version="2.1.9" targetFramework="net461" />
+  <package id="Vit.Core" version="2.1.10" targetFramework="net461" />
 </packages>

+ 1 - 1
dotnet/ServiceCenter/App.ServiceCenter/App.ServiceCenter.csproj

@@ -8,7 +8,7 @@
 	<PropertyGroup>
 		<OutputType>Exe</OutputType>
 		<TargetFramework>netcoreapp2.1</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 		<PackageProjectUrl>https://github.com/serset/Sers</PackageProjectUrl>
 	</PropertyGroup>
 

+ 13 - 5
dotnet/ServiceCenter/App.ServiceCenter/appsettings.json

@@ -6,11 +6,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 2,
-          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
@@ -196,11 +200,15 @@
       "PrintTrace": false,
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 4,
-        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 1 - 1
dotnet/ServiceCenter/Sers.ServiceCenter/Apm/Sers.Gover.Apm.Txt/Sers.Gover.Apm.Txt.csproj

@@ -2,7 +2,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/ServiceCenter/Sers.ServiceCenter/Apm/Sers.Gover.Apm.Zipkin/Sers.Gover.Apm.Zipkin.csproj

@@ -2,7 +2,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 3 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Model/ServiceStationData.cs

@@ -4,6 +4,7 @@ using Newtonsoft.Json;
 using Sers.Core.Module.Counter;
 using Sers.Core.Module.Env;
 using Sers.Hardware.Env;
+using Sers.Hardware.Process;
 using Sers.Hardware.Usage;
 
 namespace Sers.Gover.Base.Model
@@ -25,6 +26,8 @@ namespace Sers.Gover.Base.Model
 
         public DeviceInfo deviceInfo;
 
+        public ProcessInfo Process;
+
         public ServiceStationInfo serviceStationInfo;
 
         public UsageStatus usageStatus;

+ 19 - 9
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/ServiceStationMng.cs

@@ -33,14 +33,21 @@ namespace Sers.Gover.Base
         ///  serviceStationKey 和 服务站点 的映射
         /// </summary>
         /// 
-        readonly Reference<string, UsageStatus> serviceStationKey_UsageStatus_Map = new Reference<string, UsageStatus>();
+        readonly Reference<string, ServiceStation> serviceStationKey_Map = new Reference<string, ServiceStation>();
 
 
         public void SaveUsageInfo(EnvUsageInfo item)
         {
             lock (this)
             {
-                serviceStationKey_UsageStatus_Map.Get(item.serviceStationKey)?.CopyFrom(item.usageStatus);
+                var station = serviceStationKey_Map.Get(item.serviceStationKey);
+                if (station == null) return; 
+
+                if (item.usageStatus != null)
+                    station.usageStatus = item.usageStatus;
+
+                if (item.Process != null)
+                    station.Process = item.Process;
             }
         }
 
@@ -57,6 +64,7 @@ namespace Sers.Gover.Base
                         serviceStationInfo = m.serviceStationInfo,
                         status = "" + m.Status_Get(),
                         usageStatus = m.usageStatus,
+                        Process = m.Process,
                         counter = m.counter,
                         qps = m.qps,
                         apiNodeCount = m.apiNodes.Count,
@@ -88,8 +96,7 @@ namespace Sers.Gover.Base
                 if (string.IsNullOrEmpty(serviceStation.serviceStationInfo.serviceStationKey))
                     serviceStation.serviceStationInfo.serviceStationKey = "tmp" + serviceStation.GetHashCode();
 
-
-                serviceStation.usageStatus = serviceStationKey_UsageStatus_Map.Add(serviceStation.serviceStationKey, serviceStation.usageStatus ?? new UsageStatus());      
+                serviceStationKey_Map.Add(serviceStation.serviceStationKey, serviceStation);
 
                 serviceStation.Status_Set(EServiceStationStatus.正常);
                 goverManage.apiStationMng.ServiceStation_Add(serviceStation);
@@ -109,12 +116,12 @@ namespace Sers.Gover.Base
         {
             lock (this)
             {
-                if (!serviceStation_ConnKey_Map.TryGetValue(newServiceStation.connection.GetHashCode(),out var serviceStation))
+                if (!serviceStation_ConnKey_Map.TryGetValue(newServiceStation.connection.GetHashCode(), out var serviceStation))
                 {
                     return false;
                 }
 
-                serviceStationKey_UsageStatus_Map.Remove(serviceStation.serviceStationKey);
+                serviceStationKey_Map.Remove(serviceStation.serviceStationKey);
 
 
                 if (newServiceStation.serviceStationInfo != null)
@@ -127,8 +134,11 @@ namespace Sers.Gover.Base
 
                 if (newServiceStation.deviceInfo != null)
                     serviceStation.deviceInfo = newServiceStation.deviceInfo;
-           
-                serviceStation.usageStatus = serviceStationKey_UsageStatus_Map.Add(serviceStation.serviceStationKey, serviceStation.usageStatus ?? new UsageStatus());
+
+                if (newServiceStation.Process != null)
+                    serviceStation.Process = newServiceStation.Process;
+
+                serviceStationKey_Map.Add(serviceStation.serviceStationKey, serviceStation);
 
                 return true;
             }
@@ -145,7 +155,7 @@ namespace Sers.Gover.Base
                     return null;
                 }
 
-                serviceStationKey_UsageStatus_Map.Remove(serviceStation.serviceStationKey);
+                serviceStationKey_Map.Remove(serviceStation.serviceStationKey);
 
                 goverManage.apiStationMng.ServiceStation_Remove(serviceStation);
 

+ 9 - 56
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Controllers/ApiControllers/ServiceCenterController.cs

@@ -1,17 +1,17 @@
 using System;
-using System.Diagnostics;
 using System.Linq;
-using Newtonsoft.Json.Linq;
+
 using Sers.Core.Module.Rpc;
 using Sers.Gover.Base;
+using Sers.Hardware.Process;
 using Sers.Hardware.Usage;
 using Sers.SersLoader;
 using Sers.SersLoader.ApiDesc.Attribute.Valid;
+
 using Vit.Core.Module.Log;
 using Vit.Core.Util.ComponentModel.Api;
 using Vit.Core.Util.ComponentModel.Data;
 using Vit.Core.Util.ComponentModel.Model;
-using Vit.Extensions;
 
 namespace Sers.Gover.Controllers.ApiControllers
 {
@@ -20,7 +20,7 @@ namespace Sers.Gover.Controllers.ApiControllers
     {
         #region HealthInfo
 
-     
+
 
         [SsRoute("serviceCenter/healthInfo")]
         [SsCallerSource(ECallerSource.Internal)]
@@ -34,61 +34,17 @@ namespace Sers.Gover.Controllers.ApiControllers
             info.usageStatus = UsageHelp.GetUsageInfo();
 
             //(x.2) Process信息
-            try
-            {
-                var process = Process.GetCurrentProcess();
-
+            info.Process = ProcessInfo.GetCurrentProcessInfo();
 
-                //(x.x.1) ThreadCount
-                info.Process.ThreadCount = process.Threads.Count;
-
-                //(x.x.2) RunningThreadCount
-                int n = 0;        
-                foreach (ProcessThread th in process.Threads)
-                {             
-                    if (th.ThreadState == ThreadState.Running)
-                        n++;
-                }
-                info.Process.RunningThreadCount = n;
-
-                //(x.x.3) WorkingSet
-                info.Process.WorkingSet = process.WorkingSet64 / 1024.0f / 1024;
-
-            }
-            catch (Exception ex)
-            {
-                Logger.Error(ex);
-            } 
             return info;
         }
 
 
-        public class HealthInfoData 
+        public class HealthInfoData
         {
             public UsageStatus usageStatus;
 
-            public ProcessInfo Process = new ProcessInfo();
-
-
-            public class ProcessInfo 
-            {
-                /// <summary>
-                /// 总线程数
-                /// </summary>
-                public int ThreadCount;
-
-                /// <summary>
-                /// 活动的线程数
-                /// </summary>
-                public int RunningThreadCount;
-
-
-                /// <summary>
-                /// 占用总内存(单位:MB)
-                /// </summary>
-                public float WorkingSet;
-            }
-
+            public ProcessInfo Process;
         }
 
         #endregion
@@ -96,9 +52,6 @@ namespace Sers.Gover.Controllers.ApiControllers
 
 
 
-
-
-
         #region Statistics
 
         [SsRoute("serviceCenter/statistics")]
@@ -114,7 +67,7 @@ namespace Sers.Gover.Controllers.ApiControllers
             try
             {
                 var qps = GoverApiCenterService.Instance.ApiStation_GetAll().Sum(m => m.qps);
-                info.qps= qps;
+                info.qps = qps;
             }
             catch (Exception ex)
             {
@@ -124,7 +77,7 @@ namespace Sers.Gover.Controllers.ApiControllers
             return info;
         }
 
-        public class StatisticsInfo 
+        public class StatisticsInfo
         {
             /// <summary>
             /// 总qps

+ 1 - 1
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Sers.Gover.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 15 - 7
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Entity/ServiceStation.cs

@@ -2,13 +2,17 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Runtime.CompilerServices;
+
 using Newtonsoft.Json;
+
 using Sers.Core.CL.MessageOrganize;
 using Sers.Core.Module.Counter;
 using Sers.Core.Module.Env;
 using Sers.Core.Module.Message;
 using Sers.Hardware.Env;
+using Sers.Hardware.Process;
 using Sers.Hardware.Usage;
+
 using Vit.Core.Util.Extensible;
 using Vit.Extensions;
 
@@ -18,7 +22,7 @@ namespace Sers.ServiceCenter.Entity
     /// 对应一个部署的服务站点
     /// </summary>
     [JsonObject(MemberSerialization.OptIn)]
-    public class ServiceStation: Extensible
+    public class ServiceStation : Extensible
     {
         /// <summary>
         /// 服务站点开启时间
@@ -30,7 +34,7 @@ namespace Sers.ServiceCenter.Entity
         /// CL通信层连接对象
         /// </summary>
         [JsonIgnore]
-        public IOrganizeConnection  connection { get; set; }
+        public IOrganizeConnection connection { get; set; }
 
         /// <summary>
         /// 站点软硬件环境信息
@@ -38,13 +42,17 @@ namespace Sers.ServiceCenter.Entity
         [JsonProperty]
         public DeviceInfo deviceInfo;
 
+
+        [JsonProperty]
+        public ProcessInfo Process;
+
         /// <summary>
         /// 站点信息。同一硬件可以部署多个站点,它们软硬件环境是一样的,但站点信息不一样。
         /// </summary>
         [JsonProperty]
         public ServiceStationInfo serviceStationInfo;
-     
- 
+
+
         [JsonProperty]
         public List<ApiNode> apiNodes;
 
@@ -55,7 +63,7 @@ namespace Sers.ServiceCenter.Entity
         public UsageStatus usageStatus;
 
         [JsonIgnore]
-        public string serviceStationKey=> serviceStationInfo?.serviceStationKey;
+        public string serviceStationKey => serviceStationInfo?.serviceStationKey;
 
 
         #region counter    
@@ -97,14 +105,14 @@ namespace Sers.ServiceCenter.Entity
         public string GetApiStationNames()
         {
             var stationNames = apiNodes.Select(m => m.apiDesc.ApiStationNameGet());
-            return String.Join(",", stationNames); 
+            return String.Join(",", stationNames);
         }
 
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public void SendRequestAsync(Object sender, ApiMessage apiReqMessage, Action<object, Vit.Core.Util.Pipelines.ByteData> callback)
         {
-            connection.SendRequestAsync(sender,apiReqMessage.Package(), callback);            
+            connection.SendRequestAsync(sender, apiReqMessage.Package(), callback);
         }
     }
 }

+ 1 - 1
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter.csproj

@@ -6,7 +6,7 @@
 
 	<PropertyGroup>
 		<TargetFramework>netstandard2.0</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 	</PropertyGroup>
 
 	<PropertyGroup>

+ 1 - 1
dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/Controllers/Demo/SampleController.cs

@@ -31,7 +31,7 @@ namespace Did.SersLoader.Demo.Controllers.Demo
         [SsRoute("/a")]
         public void Empty()
         {
-            
+            //SpinWait.SpinUntil(() => false, 1000);
         }
 
         #region (x.1)route

+ 1 - 1
dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/Did.SersLoader.Demo.csproj

@@ -8,7 +8,7 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-    <Version>2.1.10</Version>
+    <Version>2.1.11</Version>
     <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
     <Description>https://github.com/serset/Sers</Description>
   </PropertyGroup>

+ 13 - 5
dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.Demo/appsettings.json

@@ -7,11 +7,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 2,
-          /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
@@ -185,11 +189,15 @@
       "PrintTrace": false,
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 16,
-        /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 1 - 1
dotnet/ServiceStation/Demo/SersLoader/Did.SersLoader.HelloWorld/Did.SersLoader.HelloWorld.csproj

@@ -3,7 +3,7 @@
 	<PropertyGroup>
 		<OutputType>Exe</OutputType>
 		<TargetFramework>netcoreapp2.1</TargetFramework>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 		<Description>https://github.com/serset/Sers</Description>
 	</PropertyGroup>
 

+ 1 - 0
dotnet/ServiceStation/Demo/Serslot/Did.Serslot.Demo/Controllers/ValuesController.cs

@@ -28,6 +28,7 @@ namespace Did.Serslot.Demo.Controllers
         [HttpPost]
         public object Route0([FromQuery]string a)
         {
+            //SpinWait.SpinUntil(()=> false, 1000);
             //var requestFeature = Request.HttpContext.Features.Get<IHttpRequestFeature>();             
             return "GET did_serslot/Values?a=" + a;
         }

+ 13 - 5
dotnet/ServiceStation/Demo/Serslot/Did.Serslot.Demo/appsettings.json

@@ -21,11 +21,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 2,
-          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
@@ -72,11 +76,15 @@
       "PrintTrace": false,
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 16,
-        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 1 - 1
dotnet/ServiceStation/Demo/StressTest/App.Robot.Station/App.Robot.Station.csproj

@@ -9,7 +9,7 @@
 		<OutputType>Exe</OutputType>
 		<TargetFramework>netcoreapp2.1</TargetFramework>
 		<RunPostBuildEvent>Always</RunPostBuildEvent>
-		<Version>2.1.10</Version>
+		<Version>2.1.11</Version>
 		<Description>https://github.com/serset/Sers</Description>
 	</PropertyGroup>
 

+ 13 - 5
dotnet/ServiceStation/Demo/StressTest/App.Robot.Station/appsettings.json

@@ -6,11 +6,15 @@
       "Config": {
 
         "workThread": {
-          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+          // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
           "mode": "LongThread",
           /* 后台处理消息的线程个数(单位个,默认2) */
           "threadCount": 2,
-          /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+          /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+          "maxThreadCount": 100,
+          /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+          "pendingQueueLength": 100000,
+          /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
           "timeoutMs": 300000
         },
 
@@ -158,11 +162,15 @@
       "PrintTrace": false,
 
       "workThread": {
-        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、LongTask、LongTask_TimeLimit、ConsumerCascade
+        // 模式,可为 LongThread(默认)、LongThread_TimeLimit、ManagedThread、ConsumerCascade
         "mode": "LongThread",
-        /* 后台处理消息的线程个数(单位个,默认16)(0代表不开启服务) */
+        /* 后台服务的线程个数(单位个,默认16)(0代表不开启服务) */
         "threadCount": 4,
-        /* 请求超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、LongTask_TimeLimit时有效 */
+        /* 最大线程数(包含常驻线程和临时线程),默认100。仅当mode为ManagedThread时有效 */
+        "maxThreadCount": 100,
+        /* 等待队列的最大长度(默认:100000)。仅当mode为LongThread_TimeLimit和ManagedThread时有效 */
+        "pendingQueueLength": 100000,
+        /* 超时时间(单位ms,默认300000),仅当mode为LongThread_TimeLimit、ManagedThread时有效 */
         "timeoutMs": 300000
       },
 

+ 25 - 25
java/App.StationDemo.Station/appsettings.json

@@ -2,68 +2,68 @@
   "Sers": {
     "Mq": {
       "Socket": {
-        /* ServiceCenter ����� host��ַ */
+        /* ServiceCenter 服务端 host地址 */
         "host": "127.0.0.1",
-        /* ServiceCenter ����� �����˿ں� */
+        /* ServiceCenter 服务端 监听端口号 */
         "port": 4501,
 
 
-        /* �����DZ������� */
+        /* 以下为非必须配置 */
 
         //(x.1)workThread
-        /* ��̨������Ϣ���̸߳�������λ����Ĭ��16�� */
+        /* 后台处理消息的线程个数(单位个,默认16) */
         "workThreadCount": 16,
 
         //(x.2)ping
-        /* �������Գ�ʱʱ�䣨��λms��Ĭ��2000�� */
+        /* 心跳测试超时时间(单位ms,默认2000) */
         "pingTimeout": 20000,
-        /* ��������ʧ�����Դ�������λ�Σ�Ĭ��3�� */
+        /* 心跳测试失败重试次数(单位次,默认3) */
         "pingRetryCount": 3,
-        /* ��������ʱ�������λms��Ĭ��1000�� */
+        /* 心跳测试时间间隔(单位ms,默认1000) */
         "pingInterval": 1000,
 
         //(x.3)request
-        /* ����ʱʱ�䣨��λms��Ĭ��300000�� */
+        /* 请求超时时间(单位ms,默认300000) */
         "requestTimeout": 300000,
 
         //(x.4)secretKey
-        /* ������Կ��������֤���Ӱ�ȫ�ԡ�����˺Ϳͻ��˱���һ�� */
+        /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
         "secretKey": "SersSocketMq"
       }
     },
 
-    /* ���л�����,�ɲ�ָ�� */
+    /* 序列化配置,可不指定 */
     "Serialization": {
-      /* ���л��ַ����롣�ɲ�ָ����Ĭ�� UTF8��ֻ��Ϊ UTF7,UTF8,UTF32,ASCII,Unicode�� */
+      /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
       "Encoding": "UTF8"
     },
 
 
-    /* ApiStation վ������,�ɲ�ָ�� */
+    /* ApiStation 站点配置,可不指定 */
     "ApiStation": {
-      /* �Ƿ� �������Api�ĵ�����Ϣ����ApiTrace��Log�ļ���Ĭ��:false */
+      /* 是否 输出本地Api的调用信息到(ApiTrace)Log文件。默认:false */
       "PrintTrace": false,      
       
-      /* Ĭ��վ�����ƣ��ɶ��,�ɲ�ָ�� */
+      /* 默认站点名称,可多个,可不指定 */
       "apiStationName": [ "JStationDemo" ],
       
-       /* ���������ã�ͨ������Ӵ˰��л�ȡҪע���api���ɶ��,�ɲ�ָ���� */
+       /* 服务发现配置(通过反射从此包中获取要注册的api,可多个,可不指定) */
       "DiscoveryConfig": [
         {
-          /* ǿ��ָ��ApiStation���ơ��ɲ�ָ���������ȼ��Ӹߵ��ͣ�  apiStationName_Force �� �ڴ����ϵ�SsStationNameAttribute����ָ�� �� apiStationName �� appsettings.jsonָ���� */
+          /* 强制指定ApiStation名称。可不指定。(优先级从高到低:  apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
           "apiStationName_Force": "",
 
-          /* ApiStation���ơ��ɲ�ָ���������ȼ��Ӹߵ��ͣ�  apiStationName_Force �� �ڴ����ϵ�SsStationNameAttribute����ָ�� �� apiStationName �� appsettings.jsonָ���� */
+          /* ApiStation名称。可不指定。(优先级从高到低:  apiStationName_Force 、 在代码上的SsStationNameAttribute特性指定 、 apiStationName 、 appsettings.json指定) */
           "apiStationName": "JStationDemo",
 
-          /* �ڴ˰��в��ҷ���(�� StationDemo.Controllers) */
+          /* 在此包中查找服务(如 StationDemo.Controllers) */
           "packageName": "StationDemo.Controllers",
 
 
-          /* ǿ��·��ǰ׺,���磺"demo/v1"���ɲ�ָ���������ȼ��Ӹߵ��ͣ�  routePrefix_Force���ڴ����ϵ�SsRoutePrefixAttribute����ָ�� �� routePrefix�� */
+          /* 强制路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低:  routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix) */
           "routePrefix_Force": "",
 
-          /* ·��ǰ׺,���磺"demo/v1"���ɲ�ָ���������ȼ��Ӹߵ��ͣ�  routePrefix_Force���ڴ����ϵ�SsRoutePrefixAttribute����ָ�� �� routePrefix �� */
+          /* 路由前缀,例如:"demo/v1"。可不指定。(优先级从高到低:  routePrefix_Force、在代码上的SsRoutePrefixAttribute特性指定 、 routePrefix ) */
           "routePrefix": ""
         }
 
@@ -73,19 +73,19 @@
       
     },
 
-    /* ServiceStation����,�ɲ�ָ�� */
+    /* ServiceStation配置,可不指定 */
     "ServiceStation": {
 
-      /* �Ƿ� �Զ��ϱ�cpu Usage��Ĭ��:false */
+      /* 是否 自动上报cpu Usage。默认:false */
       "UsageReporter": false,
 
       /* print the log to console. default:false  */
       "Console_PrintLog": true,
 
-      /* ��������ע�����á������������ע��վ��ǰ �Ƿ��ӡ��Logger.Info�����������Ĭ��:false */
+      /* 服务中心注册配置。在向服务中心注册站点前 是否打印(Logger.Info)请求参数。默认:false */
       "StationRegist_PrintRegistArg": false,
 
-	  /* serviceStationվ����Ϣ */
+	  /* serviceStation站点信息 */
       "serviceStationInfo": {
         "serviceStationName": "JStationDemo",
         "serviceStationKey": "serviceStationKey_java001",
@@ -93,7 +93,7 @@
         "info": null
       }
 
-      /* ����վ�㲿�������豸����Ϣ */
+      /* 服务站点部署所在设备的信息 */
       ,"deviceInfo": {
         "deviceKey": "deviceKey_java001",
         "OSPlatform": "WINDOWS",

+ 12 - 12
java/Sers.Test/appsettings.json

@@ -2,41 +2,41 @@
   "Sers": {
     "Mq": {
       "Socket": {
-        /* ServiceCenter ����� host��ַ */
+        /* ServiceCenter 服务端 host地址 */
         "host": "127.0.0.1",
-        /* ServiceCenter ����� �����˿ں� */
+        /* ServiceCenter 服务端 监听端口号 */
         "port": 4501,
 
 
-        /* �����DZ������� */
+        /* 以下为非必须配置 */
 
         //(x.1)workThread
-        /* ��̨������Ϣ���̸߳�������λ����Ĭ��16�� */
+        /* 后台处理消息的线程个数(单位个,默认16) */
         "workThreadCount": 16,
 
         //(x.2)ping
-        /* �������Գ�ʱʱ�䣨��λms��Ĭ��2000�� */
+        /* 心跳测试超时时间(单位ms,默认2000) */
         "pingTimeout": 20000,
-        /* ��������ʧ�����Դ�������λ�Σ�Ĭ��3�� */
+        /* 心跳测试失败重试次数(单位次,默认3) */
         "pingRetryCount": 3,
-        /* ��������ʱ�������λms��Ĭ��1000�� */
+        /* 心跳测试时间间隔(单位ms,默认1000) */
         "pingInterval": 1000,
 
         //(x.3)request
-        /* ����ʱʱ�䣨��λms��Ĭ��300000�� */
+        /* 请求超时时间(单位ms,默认300000) */
         "requestTimeout": 300000,
 
         //(x.4)secretKey
-        /* ������Կ��������֤���Ӱ�ȫ�ԡ�����˺Ϳͻ��˱���һ�� */
+        /* 连接秘钥,用以验证连接安全性。服务端和客户端必须一致 */
         "secretKey": "SersSocketMq"
       }
     },
 
-    /* ���л�����,�ɲ�ָ�� */
+    /* 序列化配置,可不指定 */
     "Serialization": {
-      /* ���л��ַ����롣�ɲ�ָ����Ĭ�� UTF8��ֻ��Ϊ UTF7,UTF8,UTF32,ASCII,Unicode�� */
+      /* 序列化字符编码。可不指定,默认 UTF8。只可为 UTF7,UTF8,UTF32,ASCII,Unicode。 */
       "Encoding": "UTF8"
-    }  
+    }
  
   }