Skip to content

Commit

Permalink
script_history add submit_time and refactor execTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jjiey committed Jul 5, 2021
1 parent a91c011 commit 3428271
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion script/big-whale.sql
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ ALTER TABLE `script_history`
CHANGE COLUMN `state` `state` VARCHAR(255) NOT NULL COLLATE 'utf8_general_ci' AFTER `content`,
CHANGE COLUMN `steps` `steps` VARCHAR(255) NOT NULL COLLATE 'utf8_general_ci' AFTER `state`,
ADD COLUMN `job_params` VARCHAR(255) NULL DEFAULT NULL AFTER `finish_time`,
DROP COLUMN `schedule_snapshot_id`;
DROP COLUMN `schedule_snapshot_id`,
ADD COLUMN `submit_time` DATETIME NULL DEFAULT NULL AFTER `create_by`;


DROP TABLE `schedule_snapshot`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class ScriptHistory {
private String errors;
private Date createTime;
private Integer createBy;
private Date submitTime;
private Date startTime;
private Date finishTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void execute(JobExecutionContext jobExecutionContext) {
}
}
scriptHistory.updateState(state);
scriptHistory.setSubmitTime(new Date());
if (Constant.JobState.INITED.equals(state)) {
scriptHistory = scriptHistoryService.save(scriptHistory);
ScriptHistoryShellRunnerJob.build(scriptHistory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ public void missingScheduling(ScriptHistory scriptHistory) {
public boolean execTimeout(ScriptHistory scriptHistory) {
Date ago = DateUtils.addMinutes(new Date(), -scriptHistory.getTimeout());
// 执行超时
Date time;
if (scriptHistory.getStartTime() != null) {
time = scriptHistory.getStartTime();
} else if (scriptHistory.getScheduleOperateTime() != null) {
time = scriptHistory.getScheduleOperateTime();
} else {
time = scriptHistory.getCreateTime();
}
// submitTime is definitely not null here
Date time = scriptHistory.getSubmitTime();
return time.compareTo(ago) <= 0;
}

Expand Down

0 comments on commit 3428271

Please sign in to comment.