Skip to content

Commit

Permalink
fix Transition
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyan1998 committed Dec 13, 2023
1 parent 4034302 commit 180f4c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ public static boolean refreshJob(JobInfoDetail jobInfoDetail, boolean needSave)

if (Asserts.isNull(jobDataDto.getJob()) || jobDataDto.isError()) {
// If the job fails to get it, the default Finish Time is the current time
jobInstance.setStatus(JobStatus.UNKNOWN.getValue());
jobInstance.setFinishTime(LocalDateTime.now());
jobInstance.setStatus(JobStatus.RECONNECTING.getValue());
jobInstance.setError(jobDataDto.getErrorMsg());
jobInfoDetail.getJobDataDto().setError(true);
jobInfoDetail.getJobDataDto().setErrorMsg(jobDataDto.getErrorMsg());
if (TimeUtil.localDateTimeToLong(jobInstance.getFinishTime()) < 1) {
jobInstance.setFinishTime(LocalDateTime.now());
}
} else {
jobInfoDetail.setJobDataDto(jobDataDto);
FlinkJobDetailInfo flinkJobDetailInfo = jobDataDto.getJob();
Expand All @@ -139,22 +141,28 @@ public static boolean refreshJob(JobInfoDetail jobInfoDetail, boolean needSave)
// If the job status is transition and the status fails to be updated for 1 minute, set to true and discard the
// update

boolean isTransition = JobStatus.isTransition(jobInstance.getStatus())
&& (TimeUtil.localDateTimeToLong(jobInstance.getFinishTime()) > 0
&& Duration.between(jobInstance.getFinishTime(), LocalDateTime.now())
.toMinutes()
< 1);
boolean isTransition = false;

if (isTransition) {
log.debug("Job is transition: {}->{}", jobInstance.getId(), jobInstance.getName());
return false;
if (JobStatus.isTransition(jobInstance.getStatus())) {
Long finishTime = TimeUtil.localDateTimeToLong(jobInstance.getFinishTime());
long duration = Duration.between(jobInstance.getFinishTime(), LocalDateTime.now()).toMinutes();
if (finishTime > 0 && duration < 1) {
log.debug("Job is transition: {}->{}", jobInstance.getId(), jobInstance.getName());
isTransition = true;
} else if (JobStatus.RECONNECTING.getValue().equals(jobInstance.getStatus())) {
log.debug("Job is not reconnected success at the specified time,set as UNKNOWN: {}->{}",
jobInstance.getId(), jobInstance.getName());
jobInstance.setStatus(JobStatus.UNKNOWN.getValue());
}
}

boolean isDone = (JobStatus.isDone(jobInstance.getStatus()))
|| (TimeUtil.localDateTimeToLong(jobInstance.getFinishTime()) > 0
&& Duration.between(jobInstance.getFinishTime(), LocalDateTime.now())
.toMinutes()
>= 1);
&& Duration.between(jobInstance.getFinishTime(), LocalDateTime.now())
.toMinutes()
>= 1);

isDone = !isTransition && isDone;

if (!oldStatus.equals(jobInstance.getStatus()) || isDone || needSave) {
log.debug("Dump JobInfo to database: {}->{}", jobInstance.getId(), jobInstance.getName());
Expand Down
4 changes: 2 additions & 2 deletions dinky-web/src/components/JobTags/StatusTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const StatusTag = (props: StatusTagProps) => {
};
case JOB_STATUS.RECONNECTING:
return {
icon: <ClockCircleOutlined />,
color: 'default',
icon: <SyncOutlined spin />,
color: 'warning',
text: 'RECONNECTING'
};
case JOB_STATUS.UNKNOWN:
Expand Down

0 comments on commit 180f4c1

Please sign in to comment.