Unverified Commit e5f21dbb authored by gaoyan's avatar gaoyan Committed by GitHub

[Fix]Fix deletion task failed when the job instance does not exist (#3107)

parent 05d3f608
...@@ -31,6 +31,7 @@ import org.dinky.data.exception.BusException; ...@@ -31,6 +31,7 @@ import org.dinky.data.exception.BusException;
import org.dinky.data.model.Catalogue; import org.dinky.data.model.Catalogue;
import org.dinky.data.model.Metrics; import org.dinky.data.model.Metrics;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
import org.dinky.data.model.ext.JobInfoDetail;
import org.dinky.data.model.job.History; import org.dinky.data.model.job.History;
import org.dinky.data.model.job.JobHistory; import org.dinky.data.model.job.JobHistory;
import org.dinky.data.model.job.JobInstance; import org.dinky.data.model.job.JobInstance;
...@@ -466,16 +467,18 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -466,16 +467,18 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
throw new BusException(Status.TASK_IS_PUBLISH_CANNOT_DELETE); throw new BusException(Status.TASK_IS_PUBLISH_CANNOT_DELETE);
} }
if (task.getJobInstanceId() != null) { if (task.getJobInstanceId() != null) {
// 获取前 先强制刷新一下, 避免获取任务信息状态不准确
jobInstanceService.refreshJobInfoDetail(task.getJobInstanceId(), true);
// 获取当前 job instance // 获取当前 job instance
JobInstance currentJobInstance = jobInstanceService.getById(task.getJobInstanceId()); JobInstance currentJobInstance = jobInstanceService.getById(task.getJobInstanceId());
if (currentJobInstance != null if (currentJobInstance != null) {
&& currentJobInstance.getStatus().equals(JobStatus.RUNNING.getValue())) { // 获取前 先强制刷新一下, 避免获取任务信息状态不准确
JobInfoDetail jobInfoDetail =
jobInstanceService.refreshJobInfoDetail(task.getJobInstanceId(), true);
if (jobInfoDetail.getInstance().getStatus().equals(JobStatus.RUNNING.getValue())) {
throw new BusException(Status.TASK_IS_RUNNING_CANNOT_DELETE); throw new BusException(Status.TASK_IS_RUNNING_CANNOT_DELETE);
} }
} }
} }
}
// 获取 metrics 表中的监控数据 // 获取 metrics 表中的监控数据
List<Metrics> metricListByTaskId = monitorService.getMetricsLayoutByTaskId(catalogue.getTaskId()); List<Metrics> metricListByTaskId = monitorService.getMetricsLayoutByTaskId(catalogue.getTaskId());
......
...@@ -170,9 +170,11 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper, ...@@ -170,9 +170,11 @@ public class JobInstanceServiceImpl extends SuperServiceImpl<JobInstanceMapper,
if (Asserts.isNotNull(history.getClusterConfigurationId())) { if (Asserts.isNotNull(history.getClusterConfigurationId())) {
ClusterConfiguration clusterConfig = ClusterConfiguration clusterConfig =
clusterConfigurationService.getClusterConfigById(history.getClusterConfigurationId()); clusterConfigurationService.getClusterConfigById(history.getClusterConfigurationId());
if (clusterConfig != null) {
jobInfoDetail.setClusterConfiguration(ClusterConfigurationDTO.fromBean(clusterConfig)); jobInfoDetail.setClusterConfiguration(ClusterConfigurationDTO.fromBean(clusterConfig));
} }
} }
}
JobDataDto jobDataDto = jobHistoryService.getJobHistoryDto(jobInstance.getId()); JobDataDto jobDataDto = jobHistoryService.getJobHistoryDto(jobInstance.getId());
if (jobDataDto == null) { if (jobDataDto == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment