kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billy...@apache.org
Subject kylin git commit: KYLIN-2306 fall back to abstract when NoClassFoundException
Date Fri, 23 Dec 2016 15:49:33 GMT
Repository: kylin
Updated Branches:
  refs/heads/master 488283d3d -> 73a40296e


KYLIN-2306 fall back to abstract when NoClassFoundException


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

Branch: refs/heads/master
Commit: 73a40296e33921a000cb97faa3321dd53b8dbf41
Parents: 488283d
Author: Billy Liu <billyliu@apache.org>
Authored: Fri Dec 23 23:49:02 2016 +0800
Committer: Billy Liu <billyliu@apache.org>
Committed: Fri Dec 23 23:49:20 2016 +0800

----------------------------------------------------------------------
 .../kylin/job/execution/ExecutableManager.java  | 59 ++++++++++++--------
 1 file changed, 35 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/73a40296/core-job/src/main/java/org/apache/kylin/job/execution/ExecutableManager.java
----------------------------------------------------------------------
diff --git a/core-job/src/main/java/org/apache/kylin/job/execution/ExecutableManager.java
b/core-job/src/main/java/org/apache/kylin/job/execution/ExecutableManager.java
index 0c49a3e..0273fd8 100644
--- a/core-job/src/main/java/org/apache/kylin/job/execution/ExecutableManager.java
+++ b/core-job/src/main/java/org/apache/kylin/job/execution/ExecutableManager.java
@@ -44,10 +44,16 @@ public class ExecutableManager {
 
     private static final Logger logger = LoggerFactory.getLogger(ExecutableManager.class);
     private static final ConcurrentHashMap<KylinConfig, ExecutableManager> CACHE =
new ConcurrentHashMap<KylinConfig, ExecutableManager>();
-    
+
     private final KylinConfig config;
     private final ExecutableDao executableDao;
 
+    private ExecutableManager(KylinConfig config) {
+        logger.info("Using metadata url: " + config);
+        this.config = config;
+        this.executableDao = ExecutableDao.getInstance(config);
+    }
+
     public static ExecutableManager getInstance(KylinConfig config) {
         ExecutableManager r = CACHE.get(config);
         if (r == null) {
@@ -69,10 +75,20 @@ public class ExecutableManager {
         CACHE.clear();
     }
 
-    private ExecutableManager(KylinConfig config) {
-        logger.info("Using metadata url: " + config);
-        this.config = config;
-        this.executableDao = ExecutableDao.getInstance(config);
+    private static ExecutablePO parse(AbstractExecutable executable) {
+        ExecutablePO result = new ExecutablePO();
+        result.setName(executable.getName());
+        result.setUuid(executable.getId());
+        result.setType(executable.getClass().getName());
+        result.setParams(executable.getParams());
+        if (executable instanceof ChainedExecutable) {
+            List<ExecutablePO> tasks = Lists.newArrayList();
+            for (AbstractExecutable task : ((ChainedExecutable) executable).getTasks()) {
+                tasks.add(parse(task));
+            }
+            result.setTasks(tasks);
+        }
+        return result;
     }
 
     public void addJob(AbstractExecutable executable) {
@@ -321,7 +337,6 @@ public class ExecutableManager {
         updateJobOutput(jobId, ExecutableState.DISCARDED, null, null);
     }
 
-
     public void rollbackJob(String jobId, String stepId) {
         AbstractExecutable job = getJob(jobId);
         if (job == null) {
@@ -409,22 +424,6 @@ public class ExecutableManager {
         addJobInfo(id, info);
     }
 
-    private static ExecutablePO parse(AbstractExecutable executable) {
-        ExecutablePO result = new ExecutablePO();
-        result.setName(executable.getName());
-        result.setUuid(executable.getId());
-        result.setType(executable.getClass().getName());
-        result.setParams(executable.getParams());
-        if (executable instanceof ChainedExecutable) {
-            List<ExecutablePO> tasks = Lists.newArrayList();
-            for (AbstractExecutable task : ((ChainedExecutable) executable).getTasks()) {
-                tasks.add(parse(task));
-            }
-            result.setTasks(tasks);
-        }
-        return result;
-    }
-
     private AbstractExecutable parseTo(ExecutablePO executablePO) {
         if (executablePO == null) {
             logger.warn("executablePO is null");
@@ -457,8 +456,14 @@ public class ExecutableManager {
             logger.warn("executablePO is null");
             return null;
         }
+        String type = executablePO.getType();
         try {
-            Class<? extends AbstractExecutable> clazz = ClassUtil.forName(expectedClass.getName(),
AbstractExecutable.class);
+            Class<? extends AbstractExecutable> clazz = null;
+            try {
+                clazz = ClassUtil.forName(type, AbstractExecutable.class);
+            } catch (ClassNotFoundException e) {
+                clazz = ClassUtil.forName(expectedClass.getName(), AbstractExecutable.class);
+            }
             Constructor<? extends AbstractExecutable> constructor = clazz.getConstructor();
             AbstractExecutable result = constructor.newInstance();
             result.initConfig(config);
@@ -469,7 +474,13 @@ public class ExecutableManager {
             if (tasks != null && !tasks.isEmpty()) {
                 Preconditions.checkArgument(result instanceof ChainedExecutable);
                 for (ExecutablePO subTask : tasks) {
-                    ((ChainedExecutable) result).addTask(parseToAbstract(subTask, DefaultChainedExecutable.class));
+                    AbstractExecutable parseToTask = null;
+                    try {
+                        parseToTask = parseTo(subTask);
+                    } catch (IllegalStateException e) {
+                        parseToTask = parseToAbstract(subTask, DefaultChainedExecutable.class);
+                    }
+                    ((ChainedExecutable) result).addTask(parseToTask);
                 }
             }
             return result;


Mime
View raw message