From 180f4c12b632db768e994d08f941a0e61b62717d Mon Sep 17 00:00:00 2001 From: ikiler Date: Wed, 13 Dec 2023 18:37:49 +0800 Subject: [PATCH] fix Transition --- .../dinky/job/handler/JobRefreshHandler.java | 34 ++++++++++++------- .../src/components/JobTags/StatusTag.tsx | 4 +-- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/job/handler/JobRefreshHandler.java b/dinky-admin/src/main/java/org/dinky/job/handler/JobRefreshHandler.java index c1d28374f7..3c3cc40612 100644 --- a/dinky-admin/src/main/java/org/dinky/job/handler/JobRefreshHandler.java +++ b/dinky-admin/src/main/java/org/dinky/job/handler/JobRefreshHandler.java @@ -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(); @@ -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()); diff --git a/dinky-web/src/components/JobTags/StatusTag.tsx b/dinky-web/src/components/JobTags/StatusTag.tsx index 3a7dac6419..a05f9a6f06 100644 --- a/dinky-web/src/components/JobTags/StatusTag.tsx +++ b/dinky-web/src/components/JobTags/StatusTag.tsx @@ -79,8 +79,8 @@ const StatusTag = (props: StatusTagProps) => { }; case JOB_STATUS.RECONNECTING: return { - icon: , - color: 'default', + icon: , + color: 'warning', text: 'RECONNECTING' }; case JOB_STATUS.UNKNOWN: