Skip to content

Commit 95825ce

Browse files
committed
处理器的最大不活跃时间,取调度平台作业最大时间的2倍
1 parent 231c323 commit 95825ce

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

AntJob/Data/IJob.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public interface IJob
3030
/// <summary>并行度。最大同时执行任务数</summary>
3131
Int32 MaxTask { get; set; }
3232

33+
/// <summary>最大执行时间。超过该时间则认为执行器故障,将会把该任务分配给其它执行器</summary>
34+
Int32 MaxTime { get; set; }
35+
3336
/// <summary>调度模式。定时调度只要达到时间片开头就可以跑,数据调度要求达到时间片末尾才可以跑</summary>
3437
JobModes Mode { get; set; }
3538

AntJob/Data/JobModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public partial class JobModel : ICloneable
4848
[XmlAttribute]
4949
public Int32 MaxTask { get; set; }
5050

51+
/// <summary>最大执行时间。超过该时间则认为执行器故障,将会把该任务分配给其它执行器</summary>
52+
[XmlAttribute]
53+
public Int32 MaxTime { get; set; }
54+
5155
/// <summary>调度模式。定时调度只要达到时间片开头就可以跑,数据调度要求达到时间片末尾才可以跑</summary>
5256
[XmlAttribute]
5357
public JobModes Mode { get; set; }

AntJob/Scheduler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ public async Task<Boolean> Process()
277277
// 更新作业参数,并启动处理器
278278
handler.Job = job;
279279
if (job.Mode == 0) job.Mode = handler.Mode;
280+
if (job.MaxTime > 0) handler.MaxInactiveTime = job.MaxTime * 2;
280281
if (!handler.Active)
281282
{
282283
try

Samples/HisAgent/HelloJob.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43
using System.ComponentModel;
54
using System.Diagnostics;
@@ -17,7 +16,11 @@ namespace HisAgent;
1716
[Description("简单的定时任务")]
1817
internal class HelloJob : Handler
1918
{
20-
public HelloJob() => Job.Cron = "7/30 * * * * ?";
19+
public HelloJob()
20+
{
21+
Job.Cron = "7/30 * * * * ?";
22+
//MaxInactiveTime = 60;
23+
}
2124

2225
public override Int32 Execute(JobContext ctx)
2326
{
@@ -46,8 +49,10 @@ public override async Task<Int32> ExecuteAsync(JobContext ctx)
4649
http.SetUserAgent();
4750
var rs = await http.GetAsync<IDictionary<String, Object>>("/cube/info", new { state });
4851

52+
//await Task.Delay(90_000);
4953
if (rs.TryGetValue("state", out var value) && value is String str)
5054
{
55+
WriteLog("返回状态:{0}", str);
5156
Trace.Assert(state == str, "返回状态不一致");
5257
}
5358

0 commit comments

Comments
 (0)