Repository: kylin Updated Branches: refs/heads/yang-m1 154b27fb1 -> e9979d660
KYLIN-1602 Simply diagnosis tool interface Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/e9979d66 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/e9979d66 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/e9979d66 Branch: refs/heads/yang-m1 Commit: e9979d660a430b02b5e77e652f6a4a140d3dbdcf Parents: 154b27f Author: lidongsjtu <lid...@apache.org> Authored: Thu Apr 21 18:45:48 2016 +0800 Committer: lidongsjtu <lid...@apache.org> Committed: Fri Apr 22 09:47:15 2016 +0800 ---------------------------------------------------------------------- build/bin/kylin.sh | 20 ++++++++++++++ .../org/apache/kylin/tool/DiagnosisInfoCLI.java | 28 +++++++++++++------- 2 files changed, 39 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/e9979d66/build/bin/kylin.sh ---------------------------------------------------------------------- diff --git a/build/bin/kylin.sh b/build/bin/kylin.sh index 336c2f1..af90e4c 100644 --- a/build/bin/kylin.sh +++ b/build/bin/kylin.sh @@ -199,6 +199,26 @@ then exec hbase ${KYLIN_EXTRA_START_OPTS} -Dlog4j.configuration=kylin-log4j.properties org.apache.kylin.common.KylinVersion exit 0 +elif [ "$1" = "diag" ] +then + project="$2" + if [ -n "$project" ] + then + echo "You need to specify a project for diagnosis." + exit 1 + fi + + destDir="$3" + if [ -n "$destDir" ] + then + $destDir="$KYLIN_HOME/diagnosis_dump/" + mkdir -p $destDir + fi + + export HBASE_CLASSPATH=${KYLIN_HOME}/lib/* + exec hbase ${KYLIN_EXTRA_START_OPTS} -Dlog4j.configuration=kylin-log4j.properties org.apache.kylin.tool.DiagnosisInfoCLI -project $project -destDir $destDir + exit 0 + # tool command elif [[ "$1" = org.apache.kylin.* ]] then http://git-wip-us.apache.org/repos/asf/kylin/blob/e9979d66/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 847f075..bcfba7f 100644 --- a/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java +++ b/tool/src/main/java/org/apache/kylin/tool/DiagnosisInfoCLI.java @@ -100,9 +100,11 @@ public class DiagnosisInfoCLI extends AbstractApplication { } // create new folder to contain the output + String packageName = "diagnosis_" + new SimpleDateFormat("YYYY_MM_dd_HH_mm_ss").format(new Date()); if (new File(exportDest).exists()) { - exportDest = exportDest + "diagnosis_" + new SimpleDateFormat("YYYY_MM_dd_HH_mm_ss").format(new Date()) + "/"; + exportDest = exportDest + packageName + "/"; } + File exportDir = new File(exportDest); // export cube metadata String[] cubeMetaArgs = { "-destDir", exportDest + "metadata", "-project", project }; @@ -125,7 +127,7 @@ public class DiagnosisInfoCLI extends AbstractApplication { final String logFolder = KylinConfig.getKylinHome() + "/logs/"; final String defaultLogFilename = "kylin.log"; - final File logsDir = new File(exportDest + "logs/"); + final File logsDir = new File(exportDir, "logs"); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); FileUtils.forceMkdir(logsDir); @@ -151,7 +153,7 @@ public class DiagnosisInfoCLI extends AbstractApplication { if (includeConf) { logger.info("Start to extract kylin conf files."); try { - FileUtils.copyDirectoryToDirectory(new File(getConfFolder()), new File(exportDest)); + FileUtils.copyDirectoryToDirectory(new File(getConfFolder()), exportDir); } catch (Exception e) { logger.warn("Error in export conf.", e); } @@ -159,7 +161,7 @@ public class DiagnosisInfoCLI extends AbstractApplication { // export commit id try { - FileUtils.copyFileToDirectory(new File(KylinConfig.getKylinHome(), "commit_SHA1"), new File(exportDest)); + FileUtils.copyFileToDirectory(new File(KylinConfig.getKylinHome(), "commit_SHA1"), exportDir); } catch (Exception e) { logger.warn("Error in export commit id.", e); } @@ -167,12 +169,20 @@ public class DiagnosisInfoCLI extends AbstractApplication { // compress to zip package if (compress) { File tempZipFile = File.createTempFile("diagnosis_", ".zip"); - ZipFileUtils.compressZipFile(exportDest, tempZipFile.getAbsolutePath()); - FileUtils.forceDelete(new File(exportDest)); - FileUtils.moveFileToDirectory(tempZipFile, new File(exportDest), true); - exportDest = exportDest + tempZipFile.getName(); + ZipFileUtils.compressZipFile(exportDir.getAbsolutePath(), tempZipFile.getAbsolutePath()); + FileUtils.cleanDirectory(exportDir); + + File zipFile = new File(exportDir, packageName + ".zip"); + FileUtils.moveFile(tempZipFile, zipFile); + exportDest = zipFile.getAbsolutePath(); + exportDir = new File(exportDest); } - logger.info("Diagnosis info locates at: " + new File(exportDest).getAbsolutePath()); + + StringBuffer output = new StringBuffer(); + output.append("\n========================================"); + output.append("\nDiagnosis package locates at: \n" + exportDir.getAbsolutePath()); + output.append("\n========================================"); + logger.info(output.toString()); } public String getExportDest() {