kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lid...@apache.org
Subject kylin git commit: KYLIN-1741 Enhance diagnosis tool
Date Fri, 10 Jun 2016 15:31:19 GMT
Repository: kylin
Updated Branches:
  refs/heads/master b044ed770 -> 2d80bac7b


KYLIN-1741 Enhance diagnosis tool


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

Branch: refs/heads/master
Commit: 2d80bac7b51e7326b0645613a983274a85145535
Parents: b044ed7
Author: lidongsjtu <lidong@apache.org>
Authored: Fri Jun 10 23:30:38 2016 +0800
Committer: lidongsjtu <lidong@apache.org>
Committed: Fri Jun 10 23:30:38 2016 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/tool/DiagnosisInfoCLI.java | 47 ++++++++++++++------
 .../org/apache/kylin/tool/util/ToolUtil.java    |  2 +-
 2 files changed, 35 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/2d80bac7/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
----------------------------------------------------------------------
diff --git a/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java b/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
index 7e85c17..ab845fb 100644
--- a/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
+++ b/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java
@@ -21,15 +21,21 @@ package org.apache.kylin.tool;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.List;
 
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.io.FileUtils;
+import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.util.OptionsHelper;
+import org.apache.kylin.metadata.project.ProjectInstance;
+import org.apache.kylin.metadata.project.ProjectManager;
 import org.apache.kylin.tool.util.ToolUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Lists;
+
 public class DiagnosisInfoCLI extends AbstractInfoExtractor {
     private static final Logger logger = LoggerFactory.getLogger(DiagnosisInfoCLI.class);
 
@@ -61,25 +67,40 @@ public class DiagnosisInfoCLI extends AbstractInfoExtractor {
         diagnosisInfoCLI.execute(args);
     }
 
+    private List<String> getProjects(String projectSeed) {
+        List<String> result = Lists.newLinkedList();
+        if (projectSeed.equalsIgnoreCase("-all")) {
+            ProjectManager projectManager = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv());
+            for (ProjectInstance projectInstance : projectManager.listAllProjects()) {
+                result.add(projectInstance.getName());
+            }
+        } else {
+            result.add(projectSeed);
+        }
+        return result;
+    }
+
     @Override
     protected void executeExtract(OptionsHelper optionsHelper, File exportDir) throws IOException
{
-        final String project = optionsHelper.getOptionValue(options.getOption("project"));
+        final String projectInput = optionsHelper.getOptionValue(options.getOption("project"));
         boolean includeConf = optionsHelper.hasOption(OPTION_INCLUDE_CONF) ? Boolean.valueOf(optionsHelper.getOptionValue(OPTION_INCLUDE_CONF))
: true;
         boolean includeHBase = optionsHelper.hasOption(OPTION_INCLUDE_HBASE) ? Boolean.valueOf(optionsHelper.getOptionValue(OPTION_INCLUDE_HBASE))
: true;
         boolean includeClient = optionsHelper.hasOption(OPTION_INCLUDE_CLIENT) ? Boolean.valueOf(optionsHelper.getOptionValue(OPTION_INCLUDE_CLIENT))
: true;
 
-        // export cube metadata
-        String[] cubeMetaArgs = { "-destDir", new File(exportDir, "metadata").getAbsolutePath(),
"-project", project, "-compress", "false", "-submodule", "true" };
-        CubeMetaExtractor cubeMetaExtractor = new CubeMetaExtractor();
-        logger.info("CubeMetaExtractor args: " + Arrays.toString(cubeMetaArgs));
-        cubeMetaExtractor.execute(cubeMetaArgs);
-
-        // export HBase
-        if (includeHBase) {
-            String[] hbaseArgs = { "-destDir", new File(exportDir, "hbase").getAbsolutePath(),
"-project", project, "-compress", "false", "-submodule", "true" };
-            HBaseUsageExtractor hBaseUsageExtractor = new HBaseUsageExtractor();
-            logger.info("HBaseUsageExtractor args: " + Arrays.toString(hbaseArgs));
-            hBaseUsageExtractor.execute(hbaseArgs);
+        for (String project : getProjects(projectInput)) {
+            // export cube metadata
+            String[] cubeMetaArgs = { "-destDir", new File(exportDir, "metadata").getAbsolutePath(),
"-project", project, "-compress", "false", "-submodule", "true" };
+            CubeMetaExtractor cubeMetaExtractor = new CubeMetaExtractor();
+            logger.info("CubeMetaExtractor args: " + Arrays.toString(cubeMetaArgs));
+            cubeMetaExtractor.execute(cubeMetaArgs);
+
+            // export HBase
+            if (includeHBase) {
+                String[] hbaseArgs = { "-destDir", new File(exportDir, "hbase").getAbsolutePath(),
"-project", project, "-compress", "false", "-submodule", "true" };
+                HBaseUsageExtractor hBaseUsageExtractor = new HBaseUsageExtractor();
+                logger.info("HBaseUsageExtractor args: " + Arrays.toString(hbaseArgs));
+                hBaseUsageExtractor.execute(hbaseArgs);
+            }
         }
 
         // export conf

http://git-wip-us.apache.org/repos/asf/kylin/blob/2d80bac7/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
----------------------------------------------------------------------
diff --git a/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java b/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
index cbd1be9..a294038 100644
--- a/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
+++ b/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
@@ -46,7 +46,7 @@ public class ToolUtil {
         if (StringUtils.isNotEmpty(path)) {
             return path + File.separator + CONF;
         }
-        return null;
+        throw new RuntimeException("Cannot find conf folder.");
     }
 
     public static String getHBaseMetaStoreId() throws IOException {


Mime
View raw message