minor, add option to listAllCubingJobs precisely

Signed-off-by: Hongbin Ma <mahong...@apache.org>


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

Branch: refs/heads/master-hbase0.98
Commit: 872036241c6f8255a07e0f160ba54c9473bf0501
Parents: 3ce4819
Author: Cheng Wang <cheng.w...@kyligence.io>
Authored: Tue Mar 14 14:52:38 2017 +0800
Committer: Hongbin Ma <mahong...@apache.org>
Committed: Tue Mar 14 16:43:35 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/kylin/blob/87203624/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
index 9aa7b2a..a4f7c76 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
@@ -218,7 +218,7 @@ public class CubeService extends BasicService {
     @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#cube, 
'ADMINISTRATION') or hasPermission(#cube, 'MANAGEMENT')")
     public CubeDesc updateCubeAndDesc(CubeInstance cube, CubeDesc desc, String 
newProjectName, boolean forceUpdate) throws IOException, JobException {
 
-        final List<CubingJob> cubingJobs = 
jobService.listAllCubingJobs(cube.getName(), null, 
EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING));
+        final List<CubingJob> cubingJobs = 
jobService.listAllCubingJobs(cube.getName(), null, 
EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING), true);
         if (!cubingJobs.isEmpty()) {
             throw new JobException("Cube schema shouldn't be changed with 
running job.");
         }
@@ -248,7 +248,7 @@ public class CubeService extends BasicService {
 
     @PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#cube, 
'ADMINISTRATION') or hasPermission(#cube, 'MANAGEMENT')")
     public void deleteCube(CubeInstance cube) throws IOException, JobException 
{
-        final List<CubingJob> cubingJobs = 
jobService.listAllCubingJobs(cube.getName(), null, 
EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING, 
ExecutableState.ERROR));
+        final List<CubingJob> cubingJobs = 
jobService.listAllCubingJobs(cube.getName(), null, 
EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING, 
ExecutableState.ERROR), true);
         if (!cubingJobs.isEmpty()) {
             throw new JobException("The cube " + cube.getName() + " has 
running or failed job, please discard it and try again.");
         }
@@ -340,7 +340,7 @@ public class CubeService extends BasicService {
             throw new InternalErrorException("Cube " + cubeName + " doesn't 
contain any READY segment");
         }
 
-        final List<CubingJob> cubingJobs = 
jobService.listAllCubingJobs(cube.getName(), null, 
EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING));
+        final List<CubingJob> cubingJobs = 
jobService.listAllCubingJobs(cube.getName(), null, 
EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING), true);
         if (!cubingJobs.isEmpty()) {
             throw new JobException("Enable is not allowed with a running 
job.");
         }

http://git-wip-us.apache.org/repos/asf/kylin/blob/87203624/server-base/src/main/java/org/apache/kylin/rest/service/JobService.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/JobService.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/JobService.java
index 9618be1..3f17a81 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/JobService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/JobService.java
@@ -187,7 +187,7 @@ public class JobService extends BasicService implements 
InitializingBean {
     private List<JobInstance> listCubeJobInstance(final String cubeName, final 
String projectName, List<JobStatusEnum> statusList, final long 
timeStartInMillis, final long timeEndInMillis) {
         Set<ExecutableState> states = convertStatusEnumToStates(statusList);
         final Map<String, Output> allOutputs = 
getExecutableManager().getAllOutputs(timeStartInMillis, timeEndInMillis);
-        return 
Lists.newArrayList(FluentIterable.from(listAllCubingJobs(cubeName, projectName, 
states, timeStartInMillis, timeEndInMillis, allOutputs)).transform(new 
Function<CubingJob, JobInstance>() {
+        return 
Lists.newArrayList(FluentIterable.from(listAllCubingJobs(cubeName, projectName, 
states, timeStartInMillis, timeEndInMillis, allOutputs, false)).transform(new 
Function<CubingJob, JobInstance>() {
             @Override
             public JobInstance apply(CubingJob cubingJob) {
                 return parseToJobInstance(cubingJob, allOutputs);
@@ -198,7 +198,7 @@ public class JobService extends BasicService implements 
InitializingBean {
     private List<JobInstance> listCubeJobInstance(final String cubeName, final 
String projectName, List<JobStatusEnum> statusList) {
         Set<ExecutableState> states = convertStatusEnumToStates(statusList);
         final Map<String, Output> allOutputs = 
getExecutableManager().getAllOutputs();
-        return 
Lists.newArrayList(FluentIterable.from(listAllCubingJobs(cubeName, projectName, 
states, allOutputs)).transform(new Function<CubingJob, JobInstance>() {
+        return 
Lists.newArrayList(FluentIterable.from(listAllCubingJobs(cubeName, projectName, 
states, allOutputs, false)).transform(new Function<CubingJob, JobInstance>() {
             @Override
             public JobInstance apply(CubingJob cubingJob) {
                 return parseToJobInstance(cubingJob, allOutputs);
@@ -484,11 +484,11 @@ public class JobService extends BasicService implements 
InitializingBean {
         return job;
     }
 
-    public List<CubingJob> listAllCubingJobs(final String cubeName, final 
String projectName, final Set<ExecutableState> statusList, final Map<String, 
Output> allOutputs) {
-        return listAllCubingJobs(cubeName, projectName, statusList, 0L, 
Long.MAX_VALUE, allOutputs);
+    public List<CubingJob> listAllCubingJobs(final String cubeName, final 
String projectName, final Set<ExecutableState> statusList, final Map<String, 
Output> allOutputs, final boolean bEqual) {
+        return listAllCubingJobs(cubeName, projectName, statusList, 0L, 
Long.MAX_VALUE, allOutputs, bEqual);
     }
 
-    public List<CubingJob> listAllCubingJobs(final String cubeName, final 
String projectName, final Set<ExecutableState> statusList, long 
timeStartInMillis, long timeEndInMillis, final Map<String, Output> allOutputs) {
+    public List<CubingJob> listAllCubingJobs(final String cubeName, final 
String projectName, final Set<ExecutableState> statusList, long 
timeStartInMillis, long timeEndInMillis, final Map<String, Output> allOutputs, 
final boolean bEqual) {
         List<CubingJob> results = 
Lists.newArrayList(FluentIterable.from(getExecutableManager().getAllAbstractExecutables(timeStartInMillis,
 timeEndInMillis, CubingJob.class)).filter(new Predicate<AbstractExecutable>() {
             @Override
             public boolean apply(AbstractExecutable executable) {
@@ -499,7 +499,10 @@ public class JobService extends BasicService implements 
InitializingBean {
                     String executableCubeName = 
CubingExecutableUtil.getCubeName(executable.getParams());
                     if (executableCubeName == null)
                         return true;
-                    return executableCubeName.contains(cubeName);
+                    if (bEqual)
+                        return executableCubeName.equalsIgnoreCase(cubeName);
+                    else
+                        return executableCubeName.contains(cubeName);
                 } else {
                     return false;
                 }
@@ -534,11 +537,15 @@ public class JobService extends BasicService implements 
InitializingBean {
         return results;
     }
 
+    public List<CubingJob> listAllCubingJobs(final String cubeName, final 
String projectName, final Set<ExecutableState> statusList, final boolean 
bEqual) {
+        return listAllCubingJobs(cubeName, projectName, statusList, 
getExecutableManager().getAllOutputs(), bEqual);
+    }
+
     public List<CubingJob> listAllCubingJobs(final String cubeName, final 
String projectName, final Set<ExecutableState> statusList) {
-        return listAllCubingJobs(cubeName, projectName, statusList, 
getExecutableManager().getAllOutputs());
+        return listAllCubingJobs(cubeName, projectName, statusList, 
getExecutableManager().getAllOutputs(), false);
     }
 
     public List<CubingJob> listAllCubingJobs(final String cubeName, final 
String projectName) {
-        return listAllCubingJobs(cubeName, projectName, 
EnumSet.allOf(ExecutableState.class), getExecutableManager().getAllOutputs());
+        return listAllCubingJobs(cubeName, projectName, 
EnumSet.allOf(ExecutableState.class), getExecutableManager().getAllOutputs(), 
false);
     }
 }

Reply via email to