任务耗时采用毫秒传输,保存到数据库采用秒数;结果状态在错误和延迟以外,都是完成。
This commit is contained in:
parent
4bda9eea17
commit
1b869ae13f
|
@ -169,7 +169,7 @@
|
|||
<Column Name="AppID" DataType="Int32" Map="App@ID@$" Description="应用" />
|
||||
<Column Name="JobID" DataType="Int32" Map="Job@ID@$" Description="作业" />
|
||||
<Column Name="Client" DataType="String" Description="客户端。IP加进程" />
|
||||
<Column Name="DataTime" DataType="DateTime" Master="True" Description="数据时间。大于等于,定时调度到达该时间点后触发(可能有偏移量),消息调度不适用" />
|
||||
<Column Name="DataTime" DataType="DateTime" DataScale="time" Master="True" Description="数据时间。大于等于,定时调度到达该时间点后触发(可能有偏移量),消息调度不适用" />
|
||||
<Column Name="End" DataType="DateTime" Description="结束。小于不等于,数据调度到达该时间点后触发(可能有偏移量),消息调度不适用" />
|
||||
<Column Name="BatchSize" DataType="Int32" Description="批大小。数据调度每次抽取数据的分页大小,或消息调度每次处理的消息数,定时调度不适用" />
|
||||
<Column Name="Total" DataType="Int32" Description="总数。任务处理的总数据,例如数据调度抽取得到的总行数,定时调度默认1" />
|
||||
|
@ -177,8 +177,8 @@
|
|||
<Column Name="Error" DataType="Int32" Description="错误" />
|
||||
<Column Name="Times" DataType="Int32" Description="次数" />
|
||||
<Column Name="Speed" DataType="Int32" Description="速度。每秒处理数,执行端计算" />
|
||||
<Column Name="Cost" DataType="Int32" Description="耗时。秒,执行端计算的执行时间" />
|
||||
<Column Name="FullCost" DataType="Int32" Description="全部耗时。秒,从任务发放到执行完成的时间" />
|
||||
<Column Name="Cost" DataType="Int32" ItemType="TimeSpan" Description="耗时。秒,执行端计算的执行时间" />
|
||||
<Column Name="FullCost" DataType="Int32" ItemType="TimeSpan" Description="全部耗时。秒,从任务发放到执行完成的时间" />
|
||||
<Column Name="Status" DataType="Int32" Description="状态" Type="JobStatus" />
|
||||
<Column Name="MsgCount" DataType="Int32" Description="消息。消费消息数" />
|
||||
<Column Name="Server" DataType="String" Description="服务器" />
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<Content Include="favicon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Redis" Version="5.7.2024.701" />
|
||||
<PackageReference Include="NewLife.Redis" Version="5.7.2024.709" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AntJob.Data\AntJob.Data.csproj" />
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AntJob.Data;
|
||||
using AntJob.Data;
|
||||
using AntJob.Data.Entity;
|
||||
using AntJob.Models;
|
||||
using NewLife;
|
||||
|
@ -417,30 +415,11 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
|
|||
task.Speed = result.Speed;
|
||||
task.Total = result.Total;
|
||||
task.Success = result.Success;
|
||||
task.Cost = result.Cost;
|
||||
task.Cost = (Int32)Math.Round(result.Cost / 1000d);
|
||||
task.Key = result.Key;
|
||||
task.Message = result.Message;
|
||||
|
||||
//var traceId = result.TraceId ?? DefaultSpan.Current + "";
|
||||
//if (!traceId.IsNullOrEmpty()) task.TraceId = traceId;
|
||||
//task.TraceId += $",{result.TraceId},{DefaultSpan.Current}";
|
||||
var tis = task.TraceId.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
var traceId = result.TraceId;
|
||||
if (!traceId.IsNullOrEmpty())
|
||||
{
|
||||
var ss = traceId.Split('-');
|
||||
if (ss.Length > 3 && ss[0].Length == 2) traceId = ss[1];
|
||||
if (!tis.Contains(traceId)) tis.Add(traceId);
|
||||
}
|
||||
traceId = DefaultSpan.Current?.TraceId;
|
||||
if (!traceId.IsNullOrEmpty() && !tis.Contains(traceId)) tis.Add(traceId);
|
||||
task.TraceId = tis.Join(",");
|
||||
while (true)
|
||||
{
|
||||
if (task.TraceId.Length <= JobTask._.TraceId.Length) break;
|
||||
tis.RemoveAt(0);
|
||||
task.TraceId = tis.Join(",");
|
||||
}
|
||||
var traceId = result.TraceId ?? DefaultSpan.Current + "";
|
||||
// 已终结的任务,汇总统计
|
||||
if (result.Status is JobStatus.完成 or JobStatus.错误)
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<Content Include="favicon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.625-beta1720" />
|
||||
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.710" />
|
||||
<PackageReference Include="NewLife.Stardust.Extensions" Version="3.0.2024.708" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface IJob
|
|||
/// <summary>结束。小于该时间,数据作业使用</summary>
|
||||
DateTime End { get; set; }
|
||||
|
||||
/// <summary>时间偏移。距离实时时间的秒数,部分业务不能跑到实时</summary>
|
||||
/// <summary>时间偏移。距离实时时间的秒数,考虑到服务器之间的时间差,部分业务不能跑到实时</summary>
|
||||
Int32 Offset { get; set; }
|
||||
|
||||
/// <summary>步进。最大区间大小,秒</summary>
|
||||
|
|
|
@ -32,7 +32,7 @@ public partial class JobModel : ICloneable
|
|||
[XmlAttribute]
|
||||
public DateTime End { get; set; }
|
||||
|
||||
/// <summary>时间偏移。距离实时时间的秒数,部分业务不能跑到实时</summary>
|
||||
/// <summary>时间偏移。距离实时时间的秒数,考虑到服务器之间的时间差,部分业务不能跑到实时</summary>
|
||||
[XmlAttribute]
|
||||
public Int32 Offset { get; set; }
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public partial class TaskResult : ITaskResult
|
|||
/// <summary>成功</summary>
|
||||
public Int32 Success { get; set; }
|
||||
|
||||
/// <summary>耗时,秒</summary>
|
||||
/// <summary>耗时,毫秒</summary>
|
||||
public Int32 Cost { get; set; }
|
||||
|
||||
/// <summary>错误</summary>
|
||||
|
@ -22,7 +22,7 @@ public partial class TaskResult : ITaskResult
|
|||
/// <summary>次数</summary>
|
||||
public Int32 Times { get; set; }
|
||||
|
||||
/// <summary>速度</summary>
|
||||
/// <summary>速度。每秒处理数据量</summary>
|
||||
public Int32 Speed { get; set; }
|
||||
|
||||
/// <summary>状态</summary>
|
||||
|
|
|
@ -148,7 +148,7 @@ public abstract class Handler : IExtend, ITracerFeature, ILogFeature
|
|||
|
||||
// APM埋点
|
||||
var span = Schedule.Tracer?.NewSpan($"job:{Name}", task.Data ?? $"({task.DataTime.ToFullString()}, {task.End.ToFullString()})");
|
||||
result.TraceId = span?.ToString();
|
||||
result.TraceId = span?.TraceId;
|
||||
|
||||
// 较慢的作业,及时报告进度
|
||||
if (_speed < 10) Report(ctx, JobStatus.处理中);
|
||||
|
|
|
@ -5,7 +5,6 @@ using AntJob.Data;
|
|||
using AntJob.Models;
|
||||
using NewLife;
|
||||
using NewLife.Model;
|
||||
using NewLife.Net;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Remoting.Clients;
|
||||
using NewLife.Remoting.Models;
|
||||
|
|
|
@ -265,19 +265,21 @@ public class NetworkJobProvider(AntSetting setting) : JobProvider
|
|||
if (ex != null)
|
||||
{
|
||||
var msg = ctx.Error.GetMessage();
|
||||
if (msg.Contains("Exception:")) msg = msg.Substring("Exception:").Trim();
|
||||
var p = msg.IndexOf("Exception:");
|
||||
if (p >= 0) msg = msg.Substring(p + "Exception:".Length).Trim();
|
||||
task.Message = msg;
|
||||
}
|
||||
}
|
||||
else if (ctx.Status <= JobStatus.处理中)
|
||||
else if (ctx.Status == JobStatus.延迟)
|
||||
{
|
||||
task.Status = JobStatus.完成;
|
||||
task.Status = JobStatus.延迟;
|
||||
}
|
||||
else
|
||||
{
|
||||
task.Status = ctx.Status;
|
||||
task.Status = JobStatus.完成;
|
||||
}
|
||||
task.Cost = (Int32)Math.Round(ctx.Cost / 1000);
|
||||
|
||||
task.Cost = (Int32)Math.Round(ctx.Cost);
|
||||
if (task.Message.IsNullOrEmpty()) task.Message = ctx.Remark;
|
||||
|
||||
task.Key = ctx.Key;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.625-beta1720" />
|
||||
<PackageReference Include="NewLife.Cube.Core" Version="6.1.2024.710" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in New Issue