You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2020/02/05 09:15:52 UTC

[kylin] branch master updated: KYLIN-4357: throw Exception when cannot find job (#1073)

This is an automated email from the ASF dual-hosted git repository.

nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/master by this push:
     new c51b708  KYLIN-4357: throw Exception when cannot find job (#1073)
c51b708 is described below

commit c51b708000354a1b16650ddd730b6728cad75fd4
Author: Kang <zh...@gmail.com>
AuthorDate: Wed Feb 5 17:15:39 2020 +0800

    KYLIN-4357: throw Exception when cannot find job (#1073)
    
    * KYLIN-4357: throw Exception when cannot find job
    
    * update UT
    
    * KYLIN-4357: throw Exception when jobInstance is null
---
 .../apache/kylin/rest/controller/JobController.java   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller/JobController.java b/server-base/src/main/java/org/apache/kylin/rest/controller/JobController.java
index 2dd8fe4..8fa9e5c 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/controller/JobController.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/controller/JobController.java
@@ -27,6 +27,7 @@ import java.util.Map;
 import org.apache.kylin.job.JobInstance;
 import org.apache.kylin.job.constant.JobStatusEnum;
 import org.apache.kylin.job.constant.JobTimeFilterEnum;
+import org.apache.kylin.rest.exception.BadRequestException;
 import org.apache.kylin.rest.exception.InternalErrorException;
 import org.apache.kylin.rest.request.JobListRequest;
 import org.apache.kylin.rest.service.JobService;
@@ -181,6 +182,9 @@ public class JobController extends BasicController {
     public JobInstance resume(@PathVariable String jobId) {
         try {
             final JobInstance jobInstance = jobService.getJobInstance(jobId);
+            if (jobInstance == null) {
+                throw new BadRequestException("Cannot find job: " + jobId);
+            }
             jobService.resumeJob(jobInstance);
             return jobService.getJobInstance(jobId);
         } catch (Exception e) {
@@ -200,6 +204,9 @@ public class JobController extends BasicController {
     public void resubmitJob(@PathVariable String jobId) throws IOException {
         try {
             final JobInstance jobInstance = jobService.getJobInstance(jobId);
+            if (jobInstance == null) {
+                throw new BadRequestException("Cannot find job: " + jobId);
+            }
             jobService.resubmitJob(jobInstance);
         } catch (Exception e) {
             logger.error(e.getLocalizedMessage(), e);
@@ -219,6 +226,9 @@ public class JobController extends BasicController {
 
         try {
             final JobInstance jobInstance = jobService.getJobInstance(jobId);
+            if (jobInstance == null) {
+                throw new BadRequestException("Cannot find job: " + jobId);
+            }
             jobService.cancelJob(jobInstance);
             return jobService.getJobInstance(jobId);
         } catch (Exception e) {
@@ -239,6 +249,9 @@ public class JobController extends BasicController {
 
         try {
             final JobInstance jobInstance = jobService.getJobInstance(jobId);
+            if (jobInstance == null) {
+                throw new BadRequestException("Cannot find job: " + jobId);
+            }
             jobService.pauseJob(jobInstance);
             return jobService.getJobInstance(jobId);
         } catch (Exception e) {
@@ -260,6 +273,9 @@ public class JobController extends BasicController {
     public JobInstance rollback(@PathVariable String jobId, @PathVariable String stepId) {
         try {
             final JobInstance jobInstance = jobService.getJobInstance(jobId);
+            if (jobInstance == null) {
+                throw new BadRequestException("Cannot find job: " + jobId);
+            }
             jobService.rollbackJob(jobInstance, stepId);
             return jobService.getJobInstance(jobId);
         } catch (Exception e) {
@@ -280,6 +296,9 @@ public class JobController extends BasicController {
         JobInstance jobInstance = null;
         try {
             jobInstance = jobService.getJobInstance(jobId);
+            if (jobInstance == null) {
+                throw new BadRequestException("Cannot find job: " + jobId);
+            }
             jobService.dropJob(jobInstance);
         } catch (Exception e) {
             logger.error(e.getLocalizedMessage(), e);