Skip to content

Commit

Permalink
[Fix-1615] [api] Fix submit task error but return succeed when using …
Browse files Browse the repository at this point in the history
…dolphinscheduler
  • Loading branch information
aiwenmo committed Oct 31, 2023
1 parent bce0f34 commit 95097bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
19 changes: 17 additions & 2 deletions dinky-admin/src/main/java/org/dinky/controller/APIController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
import org.dinky.data.exception.NotSupportExplainExcepition;
import org.dinky.data.model.ID;
import org.dinky.data.model.JobInstance;
import org.dinky.data.result.Result;
import org.dinky.data.result.SqlExplainResult;
Expand Down Expand Up @@ -64,11 +65,25 @@ public class APIController {
private final TaskService taskService;
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")
@ApiOperation("Submit Task")
// @Log(title = "Submit Task", businessType = BusinessType.SUBMIT)
public Result<JobResult> submitTask(@RequestBody TaskDTO taskDTO) throws Exception {
JobResult jobResult = taskService.submitTask(taskDTO.getId(), null);
public Result<JobResult> submitTask(@RequestBody ID id) throws Exception {
taskService.initTenantByTaskId(id.getId());
JobResult jobResult = taskService.submitTask(id.getId(), null);
if (jobResult.isSuccess()) {
return Result.succeed(jobResult, Status.EXECUTE_SUCCESS);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ public String buildEnvSql(AbstractStatementDTO task) {
@Override
@ProcessStep(type = ProcessStepType.SUBMIT_TASK)
public JobResult submitTask(Integer id, String savePointPath) throws Exception {
initTenantByTaskId(id);

TaskDTO taskDTO = this.getTaskInfoById(id);

if (StringUtils.isNotBlank(savePointPath)) {
Expand Down
2 changes: 1 addition & 1 deletion dinky-core/src/main/java/org/dinky/job/JobResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public JobResult(
this.jobConfig = jobConfig;
this.jobManagerAddress = jobManagerAddress;
this.status = status;
this.success = (status == (Job.JobStatus.SUCCESS)) ? true : false;
this.success = status == (Job.JobStatus.SUCCESS);
this.statement = statement;
this.jobId = jobId;
this.error = error;
Expand Down

0 comments on commit 95097bf

Please sign in to comment.