[ZEPPELIN-408] Properly honor notebook dir from xml configuration

This commit is contained in:
Luciano Resende 2016-02-20 00:40:46 -08:00
parent 39417c073b
commit d700872761
4 changed files with 23 additions and 9 deletions

View file

@ -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

View file

@ -93,11 +93,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() {

View file

@ -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) {

View file

@ -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);
}
}