Repository: zeppelin
Updated Branches:
  refs/heads/master 21dc20d88 -> bfc93dc03


ZEPPELIN-3281. Apply getRelativePath when it is LocalConfigStorage

### What is this PR for?
When it is LocalConfigStorage, we should use getRelativePath to get the config 
path.

### What type of PR is it?
[Bug Fix]

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3281

### How should this be tested?
* Unit test added

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jeff Zhang <zjf...@apache.org>

Closes #2831 from zjffdu/ZEPPELIN-3281 and squashes the following commits:

3438577 [Jeff Zhang] ZEPPELIN-3281. Apply getRelativePath when it is 
LocalConfigStorage


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

Branch: refs/heads/master
Commit: bfc93dc030f94be0ac624fa8d58279d553e3ff07
Parents: 21dc20d
Author: Jeff Zhang <zjf...@apache.org>
Authored: Fri Mar 2 18:57:10 2018 +0800
Committer: Jeff Zhang <zjf...@apache.org>
Committed: Sat Mar 3 14:42:16 2018 +0800

----------------------------------------------------------------------
 .../org/apache/zeppelin/conf/ZeppelinConfiguration.java |  8 +++++++-
 .../org/apache/zeppelin/storage/LocalConfigStorage.java |  1 +
 .../apache/zeppelin/conf/ZeppelinConfigurationTest.java | 12 ++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/bfc93dc0/zeppelin-interpreter/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
----------------------------------------------------------------------
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 e0ebfa2..81f9341 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
@@ -524,7 +524,13 @@ public class ZeppelinConfiguration extends 
XMLConfiguration {
           "conf directory " + ConfVars.ZEPPELIN_CONF_DIR.varName);
       return getConfDir();
     }
-    return fsConfigDir;
+    if (getString(ConfVars.ZEPPELIN_CONFIG_STORAGE_CLASS)
+                .equals("org.apache.zeppelin.storage.LocalConfigStorage")) {
+      // only apply getRelativeDir when it is LocalConfigStorage
+      return getRelativeDir(fsConfigDir);
+    } else {
+      return fsConfigDir;
+    }
   }
 
   public List<String> getAllowedOrigins()

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/bfc93dc0/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java
 
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java
index c1edbb5..464d6ce 100644
--- 
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java
+++ 
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java
@@ -50,6 +50,7 @@ public class LocalConfigStorage extends ConfigStorage {
 
   @Override
   public void save(InterpreterInfoSaving settingInfos) throws IOException {
+    LOGGER.info("Save Interpreter Setting to " + 
interpreterSettingPath.getAbsolutePath());
     writeToFile(settingInfos.toJson(), interpreterSettingPath);
   }
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/bfc93dc0/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 2b50427..1771fd3 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
@@ -22,6 +22,7 @@ import 
org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.net.MalformedURLException;
@@ -100,4 +101,15 @@ public class ZeppelinConfigurationTest {
     Assert.assertEquals("/usr/lib/zeppelin", conf.getZeppelinHome());
     Assert.assertEquals("/usr/lib/zeppelin/conf", conf.getConfDir());
   }
+
+  @Test
+  public void getConfigFSPath() throws ConfigurationException {
+    System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), 
"/usr/lib/zeppelin");
+    System.setProperty(ConfVars.ZEPPELIN_CONFIG_FS_DIR.getVarName(), "conf");
+    ZeppelinConfiguration conf = new 
ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml"));
+    assertEquals("/usr/lib/zeppelin/conf", conf.getConfigFSDir());
+
+    System.setProperty(ConfVars.ZEPPELIN_CONFIG_STORAGE_CLASS.getVarName(), 
"org.apache.zeppelin.storage.FileSystemConfigStorage");
+    assertEquals("conf", conf.getConfigFSDir());
+  }
 }

Reply via email to