Skip to content

Commit ecb539c

Browse files
committed
Merge pull request #43 from qq254963746/develop
Develop
2 parents af4a276 + be20668 commit ecb539c

File tree

39 files changed

+517
-265
lines changed

39 files changed

+517
-265
lines changed

lts-admin/src/main/java/com/lts/web/controller/ui/UIController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ public String addJobUI(Model model) {
3939

4040
@RequestMapping("job-logger/job-logger")
4141
public String jobLoggerUI(Model model, String taskId, String taskTrackerNodeGroup,
42-
Date startTimestamp, Date endTimestamp) {
42+
Date startLogTime, Date endLogTime) {
4343
model.addAttribute("taskId", taskId);
4444
model.addAttribute("taskTrackerNodeGroup", taskTrackerNodeGroup);
45-
if (startTimestamp == null) {
46-
startTimestamp = DateUtils.addDay(new Date(), -3);
45+
if (startLogTime == null) {
46+
startLogTime = DateUtils.addDay(new Date(), -3);
4747
}
48-
model.addAttribute("startTimestamp", DateUtils.formatYMD_HMS(startTimestamp));
49-
if (endTimestamp == null) {
50-
endTimestamp = new Date();
48+
model.addAttribute("startLogTime", DateUtils.formatYMD_HMS(startLogTime));
49+
if (endLogTime == null) {
50+
endLogTime = new Date();
5151
}
52-
model.addAttribute("endTimestamp", DateUtils.formatYMD_HMS(endTimestamp));
52+
model.addAttribute("endLogTime", DateUtils.formatYMD_HMS(endLogTime));
5353
setAttr(model);
5454
return "job-logger";
5555
}

lts-admin/src/main/webapp/main/executable-job-queue.jsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
},
8383
{title: 'cron表达式', dataIndex: 'cronExpression', width: 100},
8484
{title: '优先级', dataIndex: 'priority', width: 60},
85+
{
86+
title: '重试次数', dataIndex: 'retryTimes', width: 60
87+
},
8588
{
8689
title: '反馈客户端', dataIndex: 'needFeedback', width: 80, renderer: function (v) {
8790
return v ? '需要' : '不需要';

lts-admin/src/main/webapp/main/executing-job-queue.jsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
return v ? '需要' : '不需要';
9292
}
9393
},
94+
{
95+
title: '重试次数', dataIndex: 'retryTimes', width: 60
96+
},
9497
{
9598
title: '用户参数', dataIndex: 'extParams', width: 140, sortable: false, renderer: function (v, obj) {
9699
if (v) {

lts-admin/src/main/webapp/main/job-logger.jsp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
<label class="control-label">日志记录时间:</label>
3434

3535
<div class="controls">
36-
<input type="text" class="calendar calendar-time" name="startTimestamp"
37-
value="${startTimestamp}"><span> -
38-
</span><input name="endTimestamp" value="${endTimestamp}" type="text"
36+
<input type="text" class="calendar calendar-time" name="startLogTime"
37+
value="${startLogTime}"><span> -
38+
</span><input name="endLogTime" value="${endLogTime}" type="text"
3939
class="calendar calendar-time">
4040
</div>
4141
</div>
@@ -92,6 +92,9 @@
9292
{
9393
title: '日志级别', dataIndex: 'level', width: 60
9494
},
95+
{
96+
title: '重试次数', dataIndex: 'retryTimes', width: 60
97+
},
9598
{
9699
title: '优先级', dataIndex: 'priority', sortable: false, width: 60
97100
},

lts-admin/src/test/java/com/lts/biz/logger/mysql/MysqlJobLoggerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public void testLog() throws Exception {
3333
List<JobLogPo> jobLogPoList = new ArrayList<JobLogPo>();
3434

3535
JobLogPo jobLogPo = new JobLogPo();
36-
jobLogPo.setTimestamp(DateUtils.currentTimeMillis());
36+
jobLogPo.setGmtCreated(DateUtils.currentTimeMillis());
37+
jobLogPo.setLogTime(DateUtils.currentTimeMillis());
3738
jobLogPo.setLevel(Level.INFO);
3839
jobLogPo.setLogType(LogType.BIZ);
3940
jobLogPoList.add(jobLogPo);

lts-core/src/main/java/com/lts/core/constant/Constants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,9 @@ public interface Constants {
8080
public static final String JOB_TAKE_PARALLEL_SIZE = "job.take.parallel.size";
8181
public static final String JOB_TAKE_ACQUIRE_TIMEOUT = "job.take.acquire.timeout";
8282
public static final int DEFAULT_JOB_TAKE_PARALLEL_SIZE = 20;
83+
84+
// 任务最多重试次数
85+
public static final String JOB_MAX_RETRY_TIMES = "job.max.retry.times";
86+
public static final int DEFAULT_JOB_MAX_RETRY_TIMES = 10;
87+
8388
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.lts.core.domain;
2+
3+
/**
4+
* @author Robert HG (254963746@qq.com) on 6/13/15.
5+
*/
6+
public enum Action {
7+
8+
EXECUTE_SUCCESS, // 执行成功,这种情况 直接反馈客户端
9+
EXECUTE_FAILED, // 执行失败,这种情况,直接反馈给客户端,不重新执行
10+
EXECUTE_LATER, // 稍后重新执行,这种情况, 不反馈客户端,稍后重新执行,不过有最大重试次数
11+
EXECUTE_EXCEPTION // 执行异常, 这中情况也会重试
12+
13+
}

lts-core/src/main/java/com/lts/core/domain/BizLog.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class BizLog implements Serializable {
1717

1818
private Level level;
1919

20-
private Long timestamp;
20+
private Long logTime;
2121

2222
private String taskTrackerIdentity;
2323

@@ -55,12 +55,12 @@ public void setLevel(Level level) {
5555
this.level = level;
5656
}
5757

58-
public Long getTimestamp() {
59-
return timestamp;
58+
public Long getLogTime() {
59+
return logTime;
6060
}
6161

62-
public void setTimestamp(Long timestamp) {
63-
this.timestamp = timestamp;
62+
public void setLogTime(Long logTime) {
63+
this.logTime = logTime;
6464
}
6565

6666
public String getTaskTrackerIdentity() {

lts-core/src/main/java/com/lts/core/domain/Job.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,22 @@
1717
public class Job {
1818

1919
@NotNull
20-
protected String taskId;
20+
private String taskId;
2121
/**
2222
* 优先级 (数值越大 优先级越低)
2323
*/
24-
protected Integer priority = 100;
24+
private Integer priority = 100;
2525
// 提交的节点 (可以手动指定)
26-
protected String submitNodeGroup;
26+
private String submitNodeGroup;
2727
// 执行的节点
2828
@NotNull
29-
protected String taskTrackerNodeGroup;
29+
private String taskTrackerNodeGroup;
3030

31-
protected Map<String, String> extParams;
31+
private Map<String, String> extParams;
3232
// 是否要反馈给客户端
33-
protected boolean needFeedback = true;
34-
33+
private boolean needFeedback = true;
34+
// 重试次数
35+
private int retryTimes;
3536
/**
3637
* 执行表达式 和 quartz 的一样
3738
* 如果这个为空,表示立即执行的
@@ -80,6 +81,14 @@ public boolean isNeedFeedback() {
8081
return needFeedback;
8182
}
8283

84+
public Integer getRetryTimes() {
85+
return retryTimes;
86+
}
87+
88+
public void setRetryTimes(int retryTimes) {
89+
this.retryTimes = retryTimes;
90+
}
91+
8392
public void setNeedFeedback(boolean needFeedback) {
8493
this.needFeedback = needFeedback;
8594
}
@@ -118,8 +127,8 @@ public boolean isSchedule() {
118127
return this.cronExpression != null && !"".equals(this.cronExpression.trim());
119128
}
120129

121-
public void setTriggerTime(Date date){
122-
if(date != null){
130+
public void setTriggerTime(Date date) {
131+
if (date != null) {
123132
this.triggerTime = date.getTime();
124133
}
125134
}

lts-core/src/main/java/com/lts/core/domain/TaskTrackerJobResult.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public class TaskTrackerJobResult {
1010

1111
private JobWrapper jobWrapper;
1212

13-
// 执行成功还是失败
14-
private boolean success;
13+
private Action action;
1514

1615
private String msg;
1716
// 任务完成时间
@@ -25,12 +24,12 @@ public void setJobWrapper(JobWrapper jobWrapper) {
2524
this.jobWrapper = jobWrapper;
2625
}
2726

28-
public boolean isSuccess() {
29-
return success;
27+
public Action getAction() {
28+
return action;
3029
}
3130

32-
public void setSuccess(boolean success) {
33-
this.success = success;
31+
public void setAction(Action action) {
32+
this.action = action;
3433
}
3534

3635
public String getMsg() {

0 commit comments

Comments
 (0)