kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaofeng...@apache.org
Subject incubator-kylin git commit: KYLIN-848 Couldn't resume or discard a cube job
Date Tue, 23 Jun 2015 13:01:12 GMT
Repository: incubator-kylin
Updated Branches:
  refs/heads/0.7-staging 6ab09034d -> 198be9e06


KYLIN-848 Couldn't resume or discard a cube job

Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/198be9e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/198be9e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/198be9e0

Branch: refs/heads/0.7-staging
Commit: 198be9e067742b7493a912cb84e09d618f54a8fd
Parents: 6ab0903
Author: shaofengshi <shaofengshi@apache.org>
Authored: Tue Jun 23 21:00:40 2015 +0800
Committer: shaofengshi <shaofengshi@apache.org>
Committed: Tue Jun 23 21:00:40 2015 +0800

----------------------------------------------------------------------
 .../kylin/rest/controller/JobController.java    |  6 +++--
 .../apache/kylin/rest/service/JobService.java   | 28 +++++++++++++-------
 2 files changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/198be9e0/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/controller/JobController.java b/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
index 2b79155..2f2d9cf 100644
--- a/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
+++ b/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
@@ -169,7 +169,8 @@ public class JobController extends BasicController implements InitializingBean
{
     @ResponseBody
     public JobInstance resume(@PathVariable String jobId) {
         try {
-            jobService.resumeJob(jobId);
+            final JobInstance jobInstance = jobService.getJobInstance(jobId);
+            jobService.resumeJob(jobInstance);
             return jobService.getJobInstance(jobId);
         } catch (Exception e) {
             logger.error(e.getLocalizedMessage(), e);
@@ -188,7 +189,8 @@ public class JobController extends BasicController implements InitializingBean
{
     public JobInstance cancel(@PathVariable String jobId) {
 
         try {
-            return jobService.cancelJob(jobId);
+            final JobInstance jobInstance = jobService.getJobInstance(jobId);
+            return jobService.cancelJob(jobInstance);
         } catch (Exception e) {
             logger.error(e.getLocalizedMessage(), e);
             throw new InternalErrorException(e);

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/198be9e0/server/src/main/java/org/apache/kylin/rest/service/JobService.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/service/JobService.java b/server/src/main/java/org/apache/kylin/rest/service/JobService.java
index b3aa4ee..c3a5f8c 100644
--- a/server/src/main/java/org/apache/kylin/rest/service/JobService.java
+++ b/server/src/main/java/org/apache/kylin/rest/service/JobService.java
@@ -44,6 +44,7 @@ import org.apache.kylin.metadata.model.SegmentStatusEnum;
 import org.apache.kylin.rest.constant.Constant;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Component;
 
@@ -59,6 +60,9 @@ public class JobService extends BasicService {
     @SuppressWarnings("unused")
     private static final Logger logger = LoggerFactory.getLogger(JobService.class);
 
+    @Autowired
+    private AccessService accessService;
+
     public List<JobInstance> listAllJobs(final String cubeName, final String projectName,
final List<JobStatusEnum> statusList, final Integer limitValue, final Integer offsetValue)
throws IOException, JobException {
         Integer limit = (null == limitValue) ? 30 : limitValue;
         Integer offset = (null == offsetValue) ? 0 : offsetValue;
@@ -150,7 +154,13 @@ public class JobService extends BasicService {
             throw new JobException("invalid build type:" + buildType);
         }
         getExecutableManager().addJob(job);
-        return getSingleJobInstance(job);
+        JobInstance jobInstance = getSingleJobInstance(job);
+
+        accessService.init(jobInstance, null);
+        accessService.inherit(jobInstance, cube);
+
+        return jobInstance;
+
     }
 
     public JobInstance getJobInstance(String uuid) throws IOException, JobException {
@@ -274,26 +284,26 @@ public class JobService extends BasicService {
     }
 
     @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#job, 'ADMINISTRATION')
or hasPermission(#job, 'OPERATION') or hasPermission(#job, 'MANAGEMENT')")
-    public void resumeJob(String jobId) throws IOException, JobException {
-        getExecutableManager().resumeJob(jobId);
+    public void resumeJob(JobInstance job) throws IOException, JobException {
+        getExecutableManager().resumeJob(job.getId());
     }
 
     @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#job, 'ADMINISTRATION')
or hasPermission(#job, 'OPERATION') or hasPermission(#job, 'MANAGEMENT')")
-    public JobInstance cancelJob(String jobId) throws IOException, JobException {
+    public JobInstance cancelJob(JobInstance job) throws IOException, JobException {
         //        CubeInstance cube = this.getCubeManager().getCube(job.getRelatedCube());
         //        for (BuildCubeJob cubeJob: listAllCubingJobs(cube.getName(), null, EnumSet.of(ExecutableState.READY,
ExecutableState.RUNNING))) {
         //            getExecutableManager().stopJob(cubeJob.getId());
         //        }
-        final JobInstance jobInstance = getJobInstance(jobId);
-        final String segmentId = jobInstance.getRelatedSegment();
-        CubeInstance cubeInstance = getCubeManager().getCube(jobInstance.getRelatedCube());
+
+        final String segmentId = job.getRelatedSegment();
+        CubeInstance cubeInstance = getCubeManager().getCube(job.getRelatedCube());
         final CubeSegment segment = cubeInstance.getSegmentById(segmentId);
         if (segment.getStatus() == SegmentStatusEnum.NEW) {
             cubeInstance.getSegments().remove(segment);
             getCubeManager().updateCube(cubeInstance);
         }
-        getExecutableManager().discardJob(jobId);
-        return jobInstance;
+        getExecutableManager().discardJob(job.getId());
+        return job;
     }
 
 }


Mime
View raw message