Repository: incubator-zeppelin Updated Branches: refs/heads/master 44991ba04 -> 831f426db
[ZEPPELIN-408] Properly honor notebook dir from xml configuration This is a fork of #420 (stalled since December) which address the provided comments and also add minor test case on the property being addressed. Author: Luciano Resende <[email protected]> Closes #731 from lresende/ZEPPELIN-408 and squashes the following commits: d700872 [Luciano Resende] [ZEPPELIN-408] Properly honor notebook dir from xml configuration Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/831f426d Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/831f426d Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/831f426d Branch: refs/heads/master Commit: 831f426dba8a89dbdfc32144a65df99662af2c47 Parents: 44991ba Author: Luciano Resende <[email protected]> Authored: Sat Feb 20 00:40:46 2016 -0800 Committer: Lee moon soo <[email protected]> Committed: Sun Feb 21 09:10:10 2016 -0800 ---------------------------------------------------------------------- bin/common.sh | 4 ---- bin/zeppelin-daemon.sh | 5 ----- .../zeppelin/notebook/repo/VFSNotebookRepo.java | 6 ++++++ .../zeppelin/conf/ZeppelinConfigurationTest.java | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/831f426d/bin/common.sh ---------------------------------------------------------------------- diff --git a/bin/common.sh b/bin/common.sh index 1a8e2d7..3e3ffc5 100644 --- a/bin/common.sh +++ b/bin/common.sh @@ -36,10 +36,6 @@ if [[ -z "${ZEPPELIN_LOG_DIR}" ]]; then export ZEPPELIN_LOG_DIR="${ZEPPELIN_HOME}/logs" fi -if [[ -z "${ZEPPELIN_NOTEBOOK_DIR}" ]]; then - export ZEPPELIN_NOTEBOOK_DIR="${ZEPPELIN_HOME}/notebook" -fi - if [[ -z "$ZEPPELIN_PID_DIR" ]]; then export ZEPPELIN_PID_DIR="${ZEPPELIN_HOME}/run" fi http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/831f426d/bin/zeppelin-daemon.sh ---------------------------------------------------------------------- diff --git a/bin/zeppelin-daemon.sh b/bin/zeppelin-daemon.sh index 5d1ce4e..041c7a4 100755 --- a/bin/zeppelin-daemon.sh +++ b/bin/zeppelin-daemon.sh @@ -91,11 +91,6 @@ function initialize_default_directories() { echo "Pid dir doesn't exist, create ${ZEPPELIN_PID_DIR}" $(mkdir -p "${ZEPPELIN_PID_DIR}") fi - - if [[ ! -d "${ZEPPELIN_NOTEBOOK_DIR}" ]]; then - echo "Notebook dir doesn't exist, create ${ZEPPELIN_NOTEBOOK_DIR}" - $(mkdir -p "${ZEPPELIN_NOTEBOOK_DIR}") - fi } function wait_for_zeppelin_to_die() { http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/831f426d/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java index db074a4..1f9308f 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java @@ -75,7 +75,13 @@ public class VFSNotebookRepo implements NotebookRepo { } else { this.filesystemRoot = filesystemRoot; } + fsManager = VFS.getManager(); + FileObject file = fsManager.resolveFile(filesystemRoot.getPath()); + if (!file.exists()) { + logger.info("Notebook dir doesn't exist, create."); + file.createFolder(); + } } private String getPath(String path) { http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/831f426d/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java index dc13eb0..f9d8ca3 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java @@ -17,7 +17,11 @@ package org.apache.zeppelin.conf; import junit.framework.Assert; + import org.apache.commons.configuration.ConfigurationException; +import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; + +import org.junit.Before; import org.junit.Test; import java.net.MalformedURLException; @@ -28,6 +32,11 @@ import java.util.List; * Created by joelz on 8/19/15. */ public class ZeppelinConfigurationTest { + @Before + public void clearSystemVariables() { + System.clearProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName()); + } + @Test public void getAllowedOrigins2Test() throws MalformedURLException, ConfigurationException { @@ -70,4 +79,12 @@ public class ZeppelinConfigurationTest { Boolean isIt = conf.isWindowsPath("~/test/file.xml"); Assert.assertFalse(isIt); } + + @Test + public void getNotebookDirTest() throws ConfigurationException { + + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + String notebookLocation = conf.getNotebookDir(); + Assert.assertEquals("notebook", notebookLocation); + } }
