Unverified Commit be13e0c0 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Fix-1615] [api] Fix submit task error but return succeed when using dolphinscheduler (#2469)

parent 55252345
...@@ -24,6 +24,7 @@ import org.dinky.data.dto.TaskDTO; ...@@ -24,6 +24,7 @@ import org.dinky.data.dto.TaskDTO;
import org.dinky.data.enums.BusinessType; import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status; import org.dinky.data.enums.Status;
import org.dinky.data.exception.NotSupportExplainExcepition; import org.dinky.data.exception.NotSupportExplainExcepition;
import org.dinky.data.model.ID;
import org.dinky.data.model.JobInstance; import org.dinky.data.model.JobInstance;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.data.result.SqlExplainResult; import org.dinky.data.result.SqlExplainResult;
...@@ -64,11 +65,25 @@ public class APIController { ...@@ -64,11 +65,25 @@ public class APIController {
private final TaskService taskService; private final TaskService taskService;
private final JobInstanceService jobInstanceService; private final JobInstanceService jobInstanceService;
// Interface compatible with DolphinScheduler
@GetMapping("/submitTask")
@ApiOperation("Submit Task")
public Result<JobResult> submitTask(@RequestParam Integer id) throws Exception {
taskService.initTenantByTaskId(id);
JobResult jobResult = taskService.submitTask(id, null);
if (jobResult.isSuccess()) {
return Result.succeed(jobResult, Status.EXECUTE_SUCCESS);
} else {
return Result.failed(jobResult, jobResult.getError());
}
}
@PostMapping("/submitTask") @PostMapping("/submitTask")
@ApiOperation("Submit Task") @ApiOperation("Submit Task")
// @Log(title = "Submit Task", businessType = BusinessType.SUBMIT) // @Log(title = "Submit Task", businessType = BusinessType.SUBMIT)
public Result<JobResult> submitTask(@RequestBody TaskDTO taskDTO) throws Exception { public Result<JobResult> submitTask(@RequestBody ID id) throws Exception {
JobResult jobResult = taskService.submitTask(taskDTO.getId(), null); taskService.initTenantByTaskId(id.getId());
JobResult jobResult = taskService.submitTask(id.getId(), null);
if (jobResult.isSuccess()) { if (jobResult.isSuccess()) {
return Result.succeed(jobResult, Status.EXECUTE_SUCCESS); return Result.succeed(jobResult, Status.EXECUTE_SUCCESS);
} else { } else {
......
...@@ -256,8 +256,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -256,8 +256,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override @Override
@ProcessStep(type = ProcessStepType.SUBMIT_TASK) @ProcessStep(type = ProcessStepType.SUBMIT_TASK)
public JobResult submitTask(Integer id, String savePointPath) throws Exception { public JobResult submitTask(Integer id, String savePointPath) throws Exception {
initTenantByTaskId(id);
TaskDTO taskDTO = this.getTaskInfoById(id); TaskDTO taskDTO = this.getTaskInfoById(id);
if (StringUtils.isNotBlank(savePointPath)) { if (StringUtils.isNotBlank(savePointPath)) {
......
...@@ -128,7 +128,7 @@ public class JobResult { ...@@ -128,7 +128,7 @@ public class JobResult {
this.jobConfig = jobConfig; this.jobConfig = jobConfig;
this.jobManagerAddress = jobManagerAddress; this.jobManagerAddress = jobManagerAddress;
this.status = status; this.status = status;
this.success = (status == (Job.JobStatus.SUCCESS)) ? true : false; this.success = status == (Job.JobStatus.SUCCESS);
this.statement = statement; this.statement = statement;
this.jobId = jobId; this.jobId = jobId;
this.error = error; this.error = error;
......
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