Skip to content

Commit

Permalink
提供Job级别的重试次数,用户可以针对每个job设置最大重试次数, 用户需要升级数据表结构
Browse files Browse the repository at this point in the history
  • Loading branch information
qq254963746 committed Mar 13, 2016
1 parent c5cf74f commit 8c73213
Show file tree
Hide file tree
Showing 28 changed files with 151 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ private KVPair<Boolean, String> addJob(JobQueueReq request) {
job.setTriggerTime(request.getTriggerTime().getTime());
}
job.setPriority(request.getPriority());
job.setMaxRetryTimes(request.getMaxRetryTimes() == null ? 0 : request.getMaxRetryTimes());

return addJob(job);
}
Expand Down
17 changes: 17 additions & 0 deletions lts-admin/src/main/webapp/WEB-INF/views/templates/cronJobQueue.vm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@
placeholder="必须为数字,数值越小,优先级越大【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label w_120">最大重试次数</label>

<div class="col-sm-3 w_250">
<input type="text" class="form-control" name="maxRetryTimes" value="0"
placeholder="最大重试次数, 必须为非负数【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label w_120">提交节点组</label>

Expand Down Expand Up @@ -184,6 +192,7 @@
<th>执行节点组</th>
<th>Cron表达式</th>
<th data-hide="all">优先级</th>
<th data-hide="all">最大重试次数</th>
<th>反馈客户端</th>
<th data-hide="all">用户参数</th>
<th data-hide="phone,tablet">创建时间</th>
Expand All @@ -199,6 +208,7 @@
<td>{{row.taskTrackerNodeGroup}}</td>
<td>{{row.cronExpression}}</td>
<td>{{row.priority}}</td>
<td>{{row.maxRetryTimes}}</td>
<td>{{row.needFeedback | format:'needFeedbackLabel',row}}</td>
<td>{{row.extParams | format:'stringifyJSON'}}</td>
<td>{{row.gmtCreated | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
Expand Down Expand Up @@ -285,6 +295,9 @@
value = value + '';
}
if($(this)[0].tagName.toUpperCase() == 'SELECT'){
if(!value){
value = "";
}
$(this).selectpicker('val', value);
}else{
$(this).val(value);
Expand Down Expand Up @@ -323,6 +336,10 @@
sweetAlert("请选择执行节点组", "如果列表中没有,请在节点组管理中添加,并启动改节点。", "error");
return;
}
if(!params['maxRetryTimes'] || !/^\d+$/.test(params['maxRetryTimes'])){
sweetAlert("最大重试次数必须为非负整数", "最大重试次数必须为非负整数", "error");
return;
}
var extParams = params['extParams'];
if (extParams) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@
placeholder="必须为数字,数值越小,优先级越大【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label w_120">最大重试次数</label>

<div class="col-sm-3 w_250">
<input type="text" class="form-control" name="maxRetryTimes" value="0"
placeholder="最大重试次数, 必须为非负数【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label w_120">提交节点组</label>

Expand Down Expand Up @@ -177,7 +185,8 @@
<th>执行时间</th>
<th>Cron表达式</th>
<th data-hide="all">优先级</th>
<th data-hide="all">重试次数</th>
<th data-hide="all">当前重试次数</th>
<th data-hide="all">最大重试次数</th>
<th>反馈客户端</th>
<th data-hide="all">用户参数</th>
<th data-hide="phone,tablet">创建时间</th>
Expand All @@ -195,6 +204,7 @@
<td>{{row.cronExpression}}</td>
<td>{{row.priority}}</td>
<td>{{row.retryTimes}}</td>
<td>{{row.maxRetryTimes}}</td>
<td>{{row.needFeedback | format:'needFeedbackLabel',row}}</td>
<td>{{row.extParams | format:'stringifyJSON'}}</td>
<td>{{row.gmtCreated | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
Expand Down Expand Up @@ -325,6 +335,10 @@
sweetAlert("请选择提交节点组", "需要反馈客户端必须选择提交节点组,如果列表中没有,请在节点组管理中添加,并启动改节点。", "error");
return;
}
if(!params['maxRetryTimes'] || !/^\d+$/.test(params['maxRetryTimes'])){
sweetAlert("最大重试次数必须为非负整数", "最大重试次数必须为非负整数", "error");
return;
}
var extParams = params['extParams'];
if (extParams) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
<th>Cron表达式</th>
<th data-hide="all">优先级</th>
<th>反馈客户端</th>
<th>重试次数</th>
<th>当前重试次数</th>
<th>最大重试次数</th>
<th data-hide="all">用户参数</th>
<th data-hide="phone,tablet">创建时间</th>
<th data-hide="all">修改时间</th>
Expand All @@ -111,6 +112,7 @@
<td>{{row.priority}}</td>
<td>{{row.needFeedback | format:'needFeedbackLabel',row}}</td>
<td>{{row.retryTimes}}</td>
<td>{{row.maxRetryTimes}}</td>
<td>{{row.extParams | format:'stringifyJSON'}}</td>
<td>{{row.gmtCreated | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
<td>{{row.gmtModified | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
Expand Down
12 changes: 12 additions & 0 deletions lts-admin/src/main/webapp/WEB-INF/views/templates/jobAdd.vm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
placeholder="必须为数字,数值越小,优先级越大【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">最大重试次数</label>

<div class="col-sm-3">
<input type="text" class="form-control" name="maxRetryTimes" value="0"
placeholder="最大重试次数, 必须为非负数【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">提交节点组</label>

Expand Down Expand Up @@ -194,6 +202,10 @@
sweetAlert("请选择执行节点组", "如果列表中没有,请在节点组管理中添加,并启动改节点。", "error");
return;
}
if(!params['maxRetryTimes'] || !/^\d+$/.test(params['maxRetryTimes'])){
sweetAlert("最大重试次数必须为非负整数", "最大重试次数必须为非负整数", "error");
return;
}

var extParams = params['extParams'];
if (extParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
<th>日志类型</th>
<th>执行结果</th>
<th data-hide="all">日志级别</th>
<th data-hide="all">重试次数</th>
<th data-hide="all">当前重试次数</th>
<th data-hide="all">最大重试次数</th>
<th data-hide="all">优先级</th>
<th data-hide="all">执行时间</th>
<th>Cron表达式</th>
Expand All @@ -121,6 +122,7 @@
<td>{{row.success | format:'successLabel'}}</td>
<td>{{row.level}}</td>
<td>{{row.retryTimes}}</td>
<td>{{row.maxRetryTimes}}</td>
<td>{{row.priority}}</td>
<td>{{row.triggerTime | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
<td>{{row.cronExpression}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@
placeholder="必须为数字,数值越小,优先级越大【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label w_120">最大重试次数</label>

<div class="col-sm-3 w_250">
<input type="text" class="form-control" name="maxRetryTimes" value="0"
placeholder="最大重试次数, 必须为非负数【必填】">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label w_120">提交节点组</label>

Expand Down Expand Up @@ -184,6 +192,7 @@
<th>执行节点组</th>
<th>Cron表达式</th>
<th data-hide="all">优先级</th>
<th data-hide="all">最大重试次数</th>
<th>反馈客户端</th>
<th data-hide="all">用户参数</th>
<th data-hide="phone,tablet">创建时间</th>
Expand All @@ -199,6 +208,7 @@
<td>{{row.taskTrackerNodeGroup}}</td>
<td>{{row.cronExpression}}</td>
<td>{{row.priority}}</td>
<td>{{row.maxRetryTimes}}</td>
<td>{{row.needFeedback | format:'needFeedbackLabel',row}}</td>
<td>{{row.extParams | format:'stringifyJSON'}}</td>
<td>{{row.gmtCreated | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
Expand Down Expand Up @@ -323,6 +333,10 @@
sweetAlert("请选择执行节点组", "如果列表中没有,请在节点组管理中添加,并启动改节点。", "error");
return;
}
if(!params['maxRetryTimes'] || !/^\d+$/.test(params['maxRetryTimes'])){
sweetAlert("最大重试次数必须为非负整数", "最大重试次数必须为非负整数", "error");
return;
}
var extParams = params['extParams'];
if (extParams) {
try {
Expand Down
68 changes: 0 additions & 68 deletions lts-admin/src/test/java/com/lts/H2DatabaseTest.java

This file was deleted.

10 changes: 10 additions & 0 deletions lts-core/src/main/java/com/lts/admin/request/JobQueueReq.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class JobQueueReq extends PaginationReq {

private Integer priority;

private Integer maxRetryTimes;

public String getJobId() {
return jobId;
}
Expand Down Expand Up @@ -137,4 +139,12 @@ public Date getTriggerTime() {
public void setTriggerTime(Date triggerTime) {
this.triggerTime = triggerTime;
}

public Integer getMaxRetryTimes() {
return maxRetryTimes;
}

public void setMaxRetryTimes(Integer maxRetryTimes) {
this.maxRetryTimes = maxRetryTimes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class JobLogPo {
private Long triggerTime;

private Integer retryTimes = 0;
private Integer maxRetryTimes = 0;

public Integer getRetryTimes() {
return retryTimes;
Expand Down Expand Up @@ -184,4 +185,12 @@ public Long getLogTime() {
public void setLogTime(Long logTime) {
this.logTime = logTime;
}

public Integer getMaxRetryTimes() {
return maxRetryTimes;
}

public void setMaxRetryTimes(Integer maxRetryTimes) {
this.maxRetryTimes = maxRetryTimes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ private InsertSql buildInsertSql() {
"need_feedback",
"cron_expression",
"trigger_time",
"retry_times");
"retry_times",
"max_retry_times");
}

private InsertSql setInsertSqlValues(InsertSql insertSql, JobLogPo jobLogPo) {
Expand All @@ -90,7 +91,8 @@ private InsertSql setInsertSqlValues(InsertSql insertSql, JobLogPo jobLogPo) {
jobLogPo.isNeedFeedback(),
jobLogPo.getCronExpression(),
jobLogPo.getTriggerTime(),
jobLogPo.getRetryTimes());
jobLogPo.getRetryTimes(),
jobLogPo.getMaxRetryTimes());
}

@Override
Expand Down
Loading

0 comments on commit 8c73213

Please sign in to comment.