You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/06/24 03:44:08 UTC
[2/2] incubator-kylin git commit: KYLIN-848 Couldn't resume or
discard a cube job as a normal user
KYLIN-848 Couldn't resume or discard a cube job as a normal user
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/c40fac8d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/c40fac8d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/c40fac8d
Branch: refs/heads/0.8
Commit: c40fac8d93bef72ca3f8820e18ca06894b77b72f
Parents: 76644fe
Author: shaofengshi <sh...@apache.org>
Authored: Wed Jun 24 09:43:22 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Wed Jun 24 09:43:22 2015 +0800
----------------------------------------------------------------------
.../kylin/rest/controller/JobController.java | 6 +++--
.../apache/kylin/rest/service/JobService.java | 26 +++++++++++++-------
2 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/c40fac8d/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 ed0901e..6427a98 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
@@ -168,7 +168,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);
@@ -187,7 +188,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/c40fac8d/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 b671383..02e0527 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
@@ -45,6 +45,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;
@@ -60,6 +61,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;
@@ -151,7 +155,12 @@ 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 {
@@ -275,19 +284,18 @@ 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 != null && segment.getStatus() == SegmentStatusEnum.NEW) {
// Remove this segments
@@ -296,8 +304,8 @@ public class JobService extends BasicService {
getCubeManager().updateCube(cubeBuilder);
}
- getExecutableManager().discardJob(jobId);
- return jobInstance;
+ getExecutableManager().discardJob(job.getId());
+ return job;
}
}