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

fix cache bug (#2397)

parent d2db3d90
......@@ -31,7 +31,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import lombok.NoArgsConstructor;
/**
* 任务
......@@ -41,7 +41,7 @@ import lombok.extern.slf4j.Slf4j;
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dinky_task")
@Slf4j
@NoArgsConstructor
@ApiModel(value = "Task", description = "Task Information")
public class Task extends SuperEntity<Task> {
......@@ -164,4 +164,9 @@ public class Task extends SuperEntity<Task> {
@ApiModelProperty(value = "Statement", dataType = "String", notes = "SQL statement for the task")
private String statement;
public Task(Integer id, Integer jobInstanceId) {
this.jobInstanceId = jobInstanceId;
this.setId(id);
}
}
......@@ -271,22 +271,22 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
public JobResult submitTask(Integer id, String savePointPath) throws Exception {
initTenantByTaskId(id);
TaskDTO task = this.getTaskInfoById(id);
TaskDTO taskDTO = this.getTaskInfoById(id);
if (StringUtils.isNotBlank(savePointPath)) {
task.setSavePointStrategy(SavePointStrategy.CUSTOM.getValue());
task.setSavePointPath(savePointPath);
taskDTO.setSavePointStrategy(SavePointStrategy.CUSTOM.getValue());
taskDTO.setSavePointPath(savePointPath);
}
// 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
taskServiceBean.preCheckTask(task);
taskServiceBean.preCheckTask(taskDTO);
JobResult jobResult = taskServiceBean.executeJob(task);
JobResult jobResult = taskServiceBean.executeJob(taskDTO);
if (Job.JobStatus.SUCCESS == jobResult.getStatus()) {
log.info("Job Submit success");
task.setJobInstanceId(jobResult.getJobInstanceId());
if (!this.updateById(task.buildTask())) {
Task task = new Task(id, jobResult.getJobInstanceId());
if (!this.updateById(task)) {
throw new BusException(Status.TASK_UPDATE_FAILED.getMessage());
}
} else {
......
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