- 添加模拟数据生成器; - GC时添加碎片整理; - 优化日志输出,添加更多DEBUG监控项目; - 修复输出时分库配置逻辑的严重错误; - 优化了少许内存性能,减少Lambda闭包分配;
51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using System.Numerics;
|
|
using MesETL.App.HostedServices.Abstractions;
|
|
using MesETL.App.Services;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace MesETL.App.HostedServices;
|
|
|
|
// 空输出服务,测试用
|
|
public class VoidOutputService : IOutputService
|
|
{
|
|
private readonly ILogger _logger;
|
|
private readonly RecordQueuePool _queuePool;
|
|
private readonly ProcessContext _context;
|
|
|
|
private BigInteger _total;
|
|
|
|
public VoidOutputService(
|
|
ProcessContext context, ILogger<VoidOutputService> logger, RecordQueuePool queuePool)
|
|
{
|
|
_context = context;
|
|
_logger = logger;
|
|
_queuePool = queuePool;
|
|
}
|
|
|
|
public Task ExecuteAsync(CancellationToken ct)
|
|
{
|
|
_logger.LogInformation("***** Void Output Service Started *****");
|
|
while (!_context.IsTransformCompleted || _queuePool.Queues.Count > 0)
|
|
{
|
|
foreach (var pair in _queuePool.Queues)
|
|
{
|
|
if (_context.IsTransformCompleted && pair.Value.Count == 0)
|
|
{
|
|
_queuePool.RemoveQueue(pair.Key);
|
|
continue;
|
|
}
|
|
|
|
if (!pair.Value.TryDequeue(out var record))
|
|
continue;
|
|
|
|
_total += record.FieldCharCount;
|
|
_context.AddOutput();
|
|
}
|
|
}
|
|
|
|
_context.CompleteOutput();
|
|
_logger.LogInformation("***** Void Output Service Stopped *****");
|
|
_logger.LogInformation("平均列字符数:{Number}", _total / _context.OutputCount);
|
|
return Task.CompletedTask;
|
|
}
|
|
} |