Skip to content

Commit

Permalink
增加运行时间
Browse files Browse the repository at this point in the history
  • Loading branch information
justlive1 committed May 23, 2018
1 parent 8b926b2 commit 1b71418
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions features/1.1.0.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[features]
- 支持钉钉预警通知
[features]
- 支持钉钉预警通知
- 调度记录增加执行时间
- 任务超时报警机制
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class JobRecordStatus {
private String msg;

private Date time;

private long duration;

public void fill(JobExecuteRecord record) {
if (Objects.equals(loggerId, record.getId())) {
Expand Down
4 changes: 2 additions & 2 deletions frost-center/src/main/resources/static/js/frost.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,11 @@ function logsController($rootScope, $scope, $http, $stateParams, $filter, $sce)
if (r.type == 0){
dispatchDetial += `<div class="form-group" style="text-align: center;"><label class="status-UNKNOWN">>>>任务调度<<<</label><div class="error-msg">${r.msg}</div></div>`;
} else if (r.type == 1) {
executeDetail += `<div class="form-group" style="text-align: center;"><label class="status-UNKNOWN">>>>任务执行<<<</label><div class="error-msg">${r.msg}</div></div>`;
executeDetail += `<div class="form-group" style="text-align: center;"><label class="status-UNKNOWN">>>>任务执行<<<</label><div class="error-msg">${r.msg} [耗时${r.duration}ms]</div></div>`;
} else if (r.type == 2) {
dispatchDetial += `<div class="form-group" style="text-align: center;"><label class="status-FAIL">>>>失败重试<<<</label><div class="error-msg">${r.msg}</div></div>`;
} else if (r.type == 3) {
executeDetail += `<div class="form-group" style="text-align: center;"><label class="status-FAIL">>>>失败重试<<<</label><div class="error-msg">${r.msg}</div></div>`;
executeDetail += `<div class="form-group" style="text-align: center;"><label class="status-FAIL">>>>失败重试<<<</label><div class="error-msg">${r.msg} [耗时${r.duration}ms]</div></div>`;
} else if (r.type == 5) {
executeDetail += `<div class="form-group" style="text-align: center;"><label class="status-UNKNOWN">>>>子任务<<<</label><div class="error-msg">${r.msg}[<span class="status-${r.status}">${r.status}</span>]</div></div>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ protected void before() {
@Override
public void success() {
success = true;
long end = ZonedDateTime.now().toInstant().toEpochMilli();
JobRepository jobRepository = SpringBeansHolder.getBean(JobRepository.class);
jobRecordStatus.setStatus(JobExecuteRecord.STATUS.SUCCESS.name());
jobRecordStatus.setMsg(String.format("执行成功 [%s]", address()));
jobRecordStatus.setDuration(end - jobRecordStatus.getTime().getTime());
jobRepository.addJobRecordStatus(jobRecordStatus);
// 触发任务执行成功事件
EventPublisher publisher = SpringBeansHolder.getBean(EventPublisher.class);
publisher.publish(new Event(jobExecuteParam, Event.TYPE.EXECUTE_SUCCESS.name(), null,
ZonedDateTime.now().toInstant().toEpochMilli()));
publisher.publish(new Event(jobExecuteParam, Event.TYPE.EXECUTE_SUCCESS.name(), null, end));
}

@Override
Expand All @@ -79,6 +80,8 @@ public void exception(Exception e) {
cause = e.getMessage();
}
jobRecordStatus.setMsg(String.format("执行失败 [%s] [%s]", address(), cause));
jobRecordStatus.setDuration(
ZonedDateTime.now().toInstant().toEpochMilli() - jobRecordStatus.getTime().getTime());
JobRepository jobRepository = SpringBeansHolder.getBean(JobRepository.class);
jobRepository.addJobRecordStatus(jobRecordStatus);

Expand Down

0 comments on commit 1b71418

Please sign in to comment.