diff --git a/README.md b/README.md index 3ad659a..0a90429 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网关集成的方式。 | 使用方式 | 特性 |备注| -|:---|:---|:---|:---| +|:------|:------|:------| |使用队列|网关不需要重启,相当于透传数据,设备上来的数据直接入队列,通过服务去处理消息。|设备多的可以这样搞,这样关注点在业务上面。| |使用网关集成|网关需要根据消息业务的变化去处理,也就意味着更改业务,需要重启网关,但是上手简单。|设备少的,开发能力弱的,允许设备丢点数据的。| diff --git a/doc/README.md b/doc/README.md index 211af29..06cde12 100644 --- a/doc/README.md +++ b/doc/README.md @@ -181,7 +181,7 @@ pm2 start "dotnet JT808.Gateway.CleintBenchmark.dll ASPNETCORE_ENVIRONMENT=Produ "TcpPort": 808, "UdpPort": 808, "MiniNumBufferSize": 102400, - "SoBacklog": 102400 + "SoBacklog": 204800 } ``` @@ -232,7 +232,7 @@ pm2 start "dotnet JT808.Gateway.CleintBenchmark.dll ASPNETCORE_ENVIRONMENT=Produ "TcpPort": 808, "UdpPort": 808, "MiniNumBufferSize": 102400, - "SoBacklog": 102400 + "SoBacklog": 204800 } ``` @@ -242,82 +242,6 @@ pm2 start "dotnet JT808.Gateway.CleintBenchmark.dll ASPNETCORE_ENVIRONMENT=Produ ![client_60k](https://github.com/SmallChi/JT808Gateway/blob/master/doc/pipeline/client_60k.png) -### 80K - -| 操作系统 | 配置 | 使用 | -|:-------:|:-------:|:-------:| -| centos7 | 16c24g | JT808服务端 | -| centos7 | 8c16g | JT808客户端 | -| centos7 | 8c16g | JT808客户端 | -| centos7 | 8c16g | JT808客户端 | -| centos7 | 8c16g | JT808客户端 | - -> 计算网络增强型 sn1ne ecs.sn1ne.3xlarge 12 vCPU 24 GiB Intel Xeon E5-2682v4 / Intel Xeon(Skylake) Platinum 8163 2.5 GHz 2.5 Gbps 130 万 PPS -> 计算网络增强型 sn1ne ecs.sn1ne.2xlarge 8 vCPU 16 GiB Intel Xeon E5-2682v4 / Intel Xeon(Skylake) Platinum 8163 2.5 GHz 2 Gbps 100 万 PPS - -客户端1的参数配置appsettings.json - -``` 1 - "ClientBenchmarkOptions": { - "IP": "", - "Port": 808, - "DeviceCount": 20000, - "Interval": 1000, - "DeviceTemplate": 100000 //需要多台机器同时访问,那么可以根据这个避开重复终端号 100000-200000-300000 - } -``` - -客户端2的参数配置appsettings.json - -``` 2 - "ClientBenchmarkOptions": { - "IP": "", - "Port": 808, - "DeviceCount": 20000, - "Interval": 1000, - "DeviceTemplate": 200000 //需要多台机器同时访问,那么可以根据这个避开重复终端号 100000-200000-300000 - } -``` - -客户端3的参数配置appsettings.json - -``` 3 - "ClientBenchmarkOptions": { - "IP": "", - "Port": 808, - "DeviceCount": 20000, - "Interval": 1000, - "DeviceTemplate": 300000 //需要多台机器同时访问,那么可以根据这个避开重复终端号 100000-200000-300000 - } -``` - -客户端3的参数配置appsettings.json - -``` 4 - "ClientBenchmarkOptions": { - "IP": "", - "Port": 808, - "DeviceCount": 20000, - "Interval": 1000, - "DeviceTemplate": 400000 //需要多台机器同时访问,那么可以根据这个避开重复终端号 100000-200000-300000 - } -``` - -服务器参数配置appsettings.json - -``` 1 - "JT808Configuration": { - "TcpPort": 808, - "UdpPort": 808, - "MiniNumBufferSize": 204800, - "SoBacklog": 204800 - } -``` - -![server_proccess_80k](https://github.com/SmallChi/JT808Gateway/blob/master/doc/pipeline/server_proccess_80k.png) - -![server_network_80k](https://github.com/SmallChi/JT808Gateway/blob/master/doc/pipeline/server_network_80k.png) - ### 100K | 操作系统 | 配置 | 使用 | @@ -385,7 +309,7 @@ pm2 start "dotnet JT808.Gateway.CleintBenchmark.dll ASPNETCORE_ENVIRONMENT=Produ "JT808Configuration": { "TcpPort": 808, "UdpPort": 808, - "MiniNumBufferSize": 204800, + "MiniNumBufferSize": 102400, "SoBacklog": 204800 } ``` diff --git a/doc/pipeline/server_network_100k.png b/doc/pipeline/server_network_100k.png index 85e1ce0..3967bf4 100644 Binary files a/doc/pipeline/server_network_100k.png and b/doc/pipeline/server_network_100k.png differ diff --git a/doc/pipeline/server_network_80k.png b/doc/pipeline/server_network_80k.png deleted file mode 100644 index 4836250..0000000 Binary files a/doc/pipeline/server_network_80k.png and /dev/null differ diff --git a/doc/pipeline/server_proccess_100k.png b/doc/pipeline/server_proccess_100k.png index 7419e22..b757c76 100644 Binary files a/doc/pipeline/server_proccess_100k.png and b/doc/pipeline/server_proccess_100k.png differ diff --git a/doc/pipeline/server_proccess_80k.png b/doc/pipeline/server_proccess_80k.png deleted file mode 100644 index e8a8ba4..0000000 Binary files a/doc/pipeline/server_proccess_80k.png and /dev/null differ diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808NormalReplyMessageHandlerImpl.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808NormalReplyMessageHandlerImpl.cs index 3dd9216..f24bd21 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808NormalReplyMessageHandlerImpl.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808NormalReplyMessageHandlerImpl.cs @@ -38,19 +38,26 @@ namespace JT808.Gateway.NormalHosting.Impl /// public override byte[] Processor(JT808HeaderPackage request, IJT808Session session) { - //AOP 可以自定义添加一些东西:上下行日志、数据转发 - logger.LogDebug("可以自定义添加一些东西:上下行日志、数据转发"); - //流量 - jT808Traffic.Increment(request.Header.TerminalPhoneNo, DateTime.Now.ToString("yyyyMMdd"), request.OriginalData.Length); - var parameter = (request.Header.TerminalPhoneNo, request.OriginalData.ToArray()); - //转发数据(可同步也可以使用队列进行异步) - jT808TransmitService.Send(parameter); - //上行日志(可同步也可以使用队列进行异步) - jT808MsgLogging.Processor(parameter, JT808MsgLoggingType.up); //处理上行消息 - var down= base.Processor(request, session); - //下行日志(可同步也可以使用队列进行异步) - jT808MsgLogging.Processor((request.Header.TerminalPhoneNo, down), JT808MsgLoggingType.down); + var down = base.Processor(request, session); + try + { + //AOP 可以自定义添加一些东西:上下行日志、 + logger.LogDebug("可以自定义添加一些东西:上下行日志、数据转发"); + //流量 + jT808Traffic.Increment(request.Header.TerminalPhoneNo, DateTime.Now.ToString("yyyyMMdd"), request.OriginalData.Length); + var parameter = (request.Header.TerminalPhoneNo, request.OriginalData.ToArray()); + //上行日志(可同步也可以使用队列进行异步) + jT808MsgLogging.Processor(parameter, JT808MsgLoggingType.up); + //下行日志(可同步也可以使用队列进行异步) + jT808MsgLogging.Processor((request.Header.TerminalPhoneNo, down), JT808MsgLoggingType.down); + //转发数据(可同步也可以使用队列进行异步) + jT808TransmitService.Send(parameter); + } + catch (Exception) + { + + } return down; } diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallGrpcClientJob.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallGrpcClientJob.cs index 7a4810c..b2127ef 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallGrpcClientJob.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/CallGrpcClientJob.cs @@ -9,6 +9,8 @@ using JT808.Gateway.GrpcService; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using System.Text.Json; +using JT808.Protocol.Extensions; +using Microsoft.Extensions.Options; namespace JT808.Gateway.NormalHosting.Jobs { @@ -19,13 +21,13 @@ namespace JT808.Gateway.NormalHosting.Jobs private Grpc.Core.Metadata AuthMetadata; public CallGrpcClientJob( ILoggerFactory loggerFactory, - JT808Configuration configuration) + IOptions configurationAccessor) { Logger = loggerFactory.CreateLogger("CallGrpcClientJob"); - channel = new Channel($"{configuration.WebApiHost}:{configuration.WebApiPort}", + channel = new Channel($"{configurationAccessor.Value.WebApiHost}:{configurationAccessor.Value.WebApiPort}", ChannelCredentials.Insecure); AuthMetadata = new Grpc.Core.Metadata(); - AuthMetadata.Add("token", configuration.WebApiToken); + AuthMetadata.Add("token", configurationAccessor.Value.WebApiToken); } public Task StartAsync(CancellationToken cancellationToken) @@ -39,6 +41,11 @@ namespace JT808.Gateway.NormalHosting.Jobs { var result1 = jT808GatewayClient.GetTcpAtomicCounter(new Empty(), AuthMetadata); var result2 = jT808GatewayClient.GetTcpSessionAll(new Empty(), AuthMetadata); + var result3 = jT808GatewayClient.UnificationSend(new UnificationSendRequest + { + TerminalPhoneNo= "123456789012", + Data=Google.Protobuf.ByteString.CopyFrom("7E02000026123456789012007D02000000010000000200BA7F0E07E4F11C0028003C00001810151010100104000000640202007D01137E".ToHexBytes()) + }, AuthMetadata); Logger.LogInformation($"[GetTcpAtomicCounter]:{JsonSerializer.Serialize(result1)}"); Logger.LogInformation($"[GetTcpSessionAll]:{JsonSerializer.Serialize(result2)}"); } diff --git a/src/Version.props b/src/Version.props index ca515ef..65fdf98 100644 --- a/src/Version.props +++ b/src/Version.props @@ -1,6 +1,6 @@  2.3.1 - 1.0.0-preview6 + 1.0.0-preview7 \ No newline at end of file