You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by zj...@apache.org on 2020/04/04 15:29:42 UTC
[zeppelin] branch branch-0.9 updated: [ZEPPELIN-4718] Fix
Regression HDFS Notebook Storage
This is an automated email from the ASF dual-hosted git repository.
zjffdu pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/branch-0.9 by this push:
new abe6a95 [ZEPPELIN-4718] Fix Regression HDFS Notebook Storage
abe6a95 is described below
commit abe6a95bbefe84bae9b4d8bc1a537a676e20c3aa
Author: Philipp Dallig <ph...@gmail.com>
AuthorDate: Thu Apr 2 11:21:06 2020 +0200
[ZEPPELIN-4718] Fix Regression HDFS Notebook Storage
### What is this PR for?
Fixed a regression in #3668.
With this fix zeppelin can save the notebook in HDFS.
### What type of PR is it?
Regression Fix
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-4718
### How should this be tested?
* **Travis-Link**: https://travis-ci.org/github/Reamer/zeppelin/builds/670126594
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: Philipp Dallig <ph...@gmail.com>
Closes #3713 from Reamer/notebook_dir_hdfs and squashes the following commits:
0117609fd [Philipp Dallig] Check for filesystem with a scheme
(cherry picked from commit 6c10bb2652c8eb9777c68f07941e453ef59f7008)
Signed-off-by: Jeff Zhang <zj...@apache.org>
---
.../zeppelin/conf/ZeppelinConfiguration.java | 12 +++++++++-
.../zeppelin/conf/ZeppelinConfigurationTest.java | 27 +++++++++++++++++++++-
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
index cbd894e..75391de 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
@@ -20,6 +20,8 @@ package org.apache.zeppelin.conf;
import com.google.common.annotations.VisibleForTesting;
import java.io.File;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
@@ -583,7 +585,7 @@ public class ZeppelinConfiguration extends XMLConfiguration {
}
public String getRelativeDir(String path) {
- if (path != null && path.startsWith(File.separator) || isWindowsPath(path)) {
+ if (path != null && (path.startsWith(File.separator) || isWindowsPath(path) || isPathWithScheme(path))) {
return path;
} else {
return getString(ConfVars.ZEPPELIN_HOME) + File.separator + path;
@@ -602,6 +604,14 @@ public class ZeppelinConfiguration extends XMLConfiguration {
return path.matches("^[A-Za-z]:\\\\.*");
}
+ public boolean isPathWithScheme(String path){
+ try {
+ return StringUtils.isNotBlank(new URI(path).getScheme());
+ } catch (URISyntaxException e) {
+ return false;
+ }
+ }
+
public boolean isAnonymousAllowed() {
if (anonymousAllowed == null) {
anonymousAllowed = this.getShiroPath().equals(StringUtils.EMPTY);
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 c730e5f..001860b 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
@@ -16,9 +16,10 @@
*/
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.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -79,6 +80,30 @@ public class ZeppelinConfigurationTest {
}
@Test
+ public void isPathWithSchemeTestTrue() throws ConfigurationException {
+
+ ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml"));
+ Boolean isIt = conf.isPathWithScheme("hdfs://hadoop.example.com/zeppelin/notebook");
+ Assert.assertTrue(isIt);
+ }
+
+ @Test
+ public void isPathWithSchemeTestFalse() throws ConfigurationException {
+
+ ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml"));
+ Boolean isIt = conf.isPathWithScheme("~/test/file.xml");
+ Assert.assertFalse(isIt);
+ }
+
+ @Test
+ public void isPathWithInvalidSchemeTest() throws ConfigurationException {
+
+ ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml"));
+ Boolean isIt = conf.isPathWithScheme("c:\\test\\file.txt");
+ Assert.assertFalse(isIt);
+ }
+
+ @Test
public void getNotebookDirTest() throws ConfigurationException {
ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml"));
String notebookLocation = conf.getNotebookDir();