kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [2/2] kylin git commit: KYLIN-1962 Split configuration into normal and account two files
Date Wed, 17 Aug 2016 06:08:06 GMT
KYLIN-1962 Split configuration into normal and account two files

Signed-off-by: Li Yang <liyang@apache.org>


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

Branch: refs/heads/master
Commit: d6745eafefc102f7a52742c0189c5b61c2a5e436
Parents: 83419cf
Author: Yiming Liu <liuyiming.vip@gmail.com>
Authored: Sun Jul 31 11:24:16 2016 +0800
Committer: Li Yang <liyang@apache.org>
Committed: Wed Aug 17 14:07:51 2016 +0800

----------------------------------------------------------------------
 build/conf/kylin.properties                     |  51 +-------
 build/conf/kylin_account.properties             |  50 +++++++
 .../org/apache/kylin/common/KylinConfig.java    | 130 +++++++++++--------
 .../apache/kylin/common/KylinConfigBase.java    |  14 +-
 .../apache/kylin/common/KylinConfigTest.java    |  12 ++
 .../test_case_data/localmeta/kylin.properties   |   3 +
 .../localmeta/kylin_account.properties          |  50 +++++++
 .../security/PasswordPlaceholderConfigurer.java |  16 ++-
 .../PasswordPlaceHolderConfigurerTest.java      |  16 +++
 .../kylin/rest/service/CacheServiceTest.java    |   2 +-
 .../coprocessor/endpoint/CubeVisitService.java  |   8 +-
 11 files changed, 234 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/build/conf/kylin.properties
----------------------------------------------------------------------
diff --git a/build/conf/kylin.properties b/build/conf/kylin.properties
index 0139a6b..9cc0ec1 100644
--- a/build/conf/kylin.properties
+++ b/build/conf/kylin.properties
@@ -28,7 +28,7 @@ kylin.owner=whoami@kylin.apache.org
 kylin.rest.servers=localhost:7070
 
 # Display timezone on UI,format like[GMT+N or GMT-N]
-kylin.rest.timezone=GMT-8
+kylin.rest.timezone=GMT+8
 
 ### SOURCE ###
 
@@ -87,12 +87,6 @@ kylin.job.remote.cli.hostname=
 
 kylin.job.remote.cli.port=22
 
-# Only necessary when kylin.job.run.as.remote.cmd=true
-kylin.job.remote.cli.username=
-
-# Only necessary when kylin.job.run.as.remote.cmd=true
-kylin.job.remote.cli.password=
-
 # Used by test cases to prepare synthetic data for sample cube
 kylin.job.remote.cli.working.dir=/tmp/kylin
 
@@ -146,49 +140,6 @@ kylin.query.security.enabled=true
 
 kylin.query.cache.enabled=true
 
-### SECURITY ###
-
-# Spring security profile, options: testing, ldap, saml
-# with "testing" profile, user can use pre-defined name/pwd like KYLIN/ADMIN to login
-kylin.security.profile=testing
-
-# Default roles and admin roles in LDAP, for ldap and saml
-acl.defaultRole=ROLE_ANALYST,ROLE_MODELER
-acl.adminRole=ROLE_ADMIN
-
-# LDAP authentication configuration
-ldap.server=ldap://ldap_server:389
-ldap.username=
-ldap.password=
-
-# LDAP user account directory; 
-ldap.user.searchBase=
-ldap.user.searchPattern=
-ldap.user.groupSearchBase=
-
-# LDAP service account directory
-ldap.service.searchBase=
-ldap.service.searchPattern=
-ldap.service.groupSearchBase=
-
-# SAML configurations for SSO
-# SAML IDP metadata file location
-saml.metadata.file=classpath:sso_metadata.xml
-saml.metadata.entityBaseURL=https://hostname/kylin
-saml.context.scheme=https
-saml.context.serverName=hostname
-saml.context.serverPort=443
-saml.context.contextPath=/kylin
-
-### MAIL ###
-
-# If true, will send email notification;
-mail.enabled=false
-mail.host=
-mail.username=
-mail.password=
-mail.sender=
-
 ### WEB ###
 
 # Help info, format{name|displayName|link}, optional

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/build/conf/kylin_account.properties
----------------------------------------------------------------------
diff --git a/build/conf/kylin_account.properties b/build/conf/kylin_account.properties
new file mode 100644
index 0000000..39efd89
--- /dev/null
+++ b/build/conf/kylin_account.properties
@@ -0,0 +1,50 @@
+### JOB ###
+
+# Only necessary when kylin.job.run.as.remote.cmd=true
+kylin.job.remote.cli.username=
+
+# Only necessary when kylin.job.run.as.remote.cmd=true
+kylin.job.remote.cli.password=
+
+### SECURITY ###
+
+# Spring security profile, options: testing, ldap, saml
+# with "testing" profile, user can use pre-defined name/pwd like KYLIN/ADMIN to login
+kylin.security.profile=testing
+
+# Default roles and admin roles in LDAP, for ldap and saml
+acl.defaultRole=ROLE_ANALYST,ROLE_MODELER
+acl.adminRole=ROLE_ADMIN
+
+# LDAP authentication configuration
+ldap.server=ldap://ldap_server:389
+ldap.username=
+ldap.password=
+
+# LDAP user account directory;
+ldap.user.searchBase=
+ldap.user.searchPattern=
+ldap.user.groupSearchBase=
+
+# LDAP service account directory
+ldap.service.searchBase=
+ldap.service.searchPattern=
+ldap.service.groupSearchBase=
+
+# SAML configurations for SSO
+# SAML IDP metadata file location
+saml.metadata.file=classpath:sso_metadata.xml
+saml.metadata.entityBaseURL=https://hostname/kylin
+saml.context.scheme=https
+saml.context.serverName=hostname
+saml.context.serverPort=443
+saml.context.contextPath=/kylin
+
+### MAIL ###
+
+# If true, will send email notification;
+mail.enabled=false
+mail.host=
+mail.username=
+mail.password=
+mail.sender=
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java b/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
index f650cd2..20ff8e4 100644
--- a/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
+++ b/core-common/src/main/java/org/apache/kylin/common/KylinConfig.java
@@ -18,16 +18,11 @@
 
 package org.apache.kylin.common;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.nio.charset.Charset;
@@ -55,6 +50,7 @@ public class KylinConfig extends KylinConfigBase {
 
     /** Kylin properties file name */
     public static final String KYLIN_CONF_PROPERTIES_FILE = "kylin.properties";
+    public static final String KYLIN_SECURITY_CONF_PROPERTIES_FILE = "kylin_account.properties";
     public static final String KYLIN_CONF = "KYLIN_CONF";
 
     // static cached instances
@@ -134,8 +130,10 @@ public class KylinConfig extends KylinConfigBase {
             try {
                 config = new KylinConfig();
                 InputStream is = new FileInputStream(uri);
-                config.reloadKylinConfig(is);
-                is.close();
+                Properties prop = new Properties();
+                prop.load(is);
+                IOUtils.closeQuietly(is);
+                config.reloadKylinConfig(prop);
             } catch (IOException e) {
                 throw new RuntimeException(e);
             }
@@ -146,8 +144,10 @@ public class KylinConfig extends KylinConfigBase {
                 RestClient client = new RestClient(uri);
                 String propertyText = client.getKylinProperties();
                 InputStream is = IOUtils.toInputStream(propertyText, Charset.defaultCharset());
-                config.reloadKylinConfig(is);
-                is.close();
+                Properties prop = new Properties();
+                prop.load(is);
+                IOUtils.closeQuietly(is);
+                config.reloadKylinConfig(prop);
                 return config;
             } catch (IOException e) {
                 throw new RuntimeException(e);
@@ -155,11 +155,12 @@ public class KylinConfig extends KylinConfigBase {
         }
     }
 
-    public static void setKylinConfigFromInputStream(InputStream is) {
+    public static void setKylinConfig(Properties prop) {
         synchronized (KylinConfig.class) {
             if (ENV_INSTANCE == null) {
                 try {
-                    KylinConfig config = createKylinConfigFromInputStream(is);
+                    KylinConfig config = new KylinConfig();
+                    config.reloadKylinConfig(prop);
                     logger.info("Resetting ENV_INSTANCE by a input stream: " + System.identityHashCode(config));
                     ENV_INSTANCE = config;
                 } catch (IllegalArgumentException e) {
@@ -169,10 +170,10 @@ public class KylinConfig extends KylinConfigBase {
         }
     }
 
-    public static KylinConfig createKylinConfigFromInputStream(InputStream is) {
-        KylinConfig config = new KylinConfig();
-        config.reloadKylinConfig(is);
-        return config;
+    public static KylinConfig createKylinConfig(Properties prop) {
+        KylinConfig kylinConfig = new KylinConfig();
+        kylinConfig.reloadKylinConfig(prop);
+        return kylinConfig;
     }
 
     static File getKylinPropertiesFile() {
@@ -190,48 +191,69 @@ public class KylinConfig extends KylinConfigBase {
 
         String path = kylinHome + File.separator + "conf";
         return getKylinPropertiesFile(path);
+    }
+
+    static File getKylinSecurityPropertiesFile() {
+        String kylinConfHome = System.getProperty(KYLIN_CONF);
+        if (!StringUtils.isEmpty(kylinConfHome)) {
+            logger.info("Use KYLIN_CONF=" + kylinConfHome);
+            return getKylinSecurityPropertiesFile(kylinConfHome);
+        }
+
+        logger.warn("KYLIN_CONF property was not set, will seek KYLIN_HOME env variable");
+
+        String kylinHome = getKylinHome();
+        if (StringUtils.isEmpty(kylinHome))
+            throw new KylinConfigCannotInitException("Didn't find KYLIN_CONF or KYLIN_HOME,
please set one of them");
 
+        String path = kylinHome + File.separator + "conf";
+        return getKylinSecurityPropertiesFile(path);
     }
 
-    public static InputStream getKylinPropertiesAsInputStream() {
+    public static Properties getKylinProperties() {
         File propFile = getKylinPropertiesFile();
         if (propFile == null || !propFile.exists()) {
-            logger.error("fail to locate kylin.properties");
-            throw new RuntimeException("fail to locate kylin.properties");
+            logger.error("fail to locate " + KYLIN_CONF_PROPERTIES_FILE);
+            throw new RuntimeException("fail to locate " + KYLIN_CONF_PROPERTIES_FILE);
         }
+        Properties conf = new Properties();
+        try {
+            FileInputStream is = new FileInputStream(propFile);
+            conf.load(is);
+            IOUtils.closeQuietly(is);
+
+            File propOverrideFile = new File(propFile.getParentFile(), propFile.getName()
+ ".override");
+            if (propOverrideFile.exists()) {
+                FileInputStream ois = new FileInputStream(propOverrideFile);
+                Properties propOverride = new Properties();
+                propOverride.load(ois);
+                IOUtils.closeQuietly(ois);
+                conf.putAll(propOverride);
+            }
 
-        File overrideFile = new File(propFile.getParentFile(), propFile.getName() + ".override");
-        if (overrideFile.exists()) {
-            FileInputStream fis = null;
-            FileInputStream fis2 = null;
-            try {
-                fis = new FileInputStream(propFile);
-                fis2 = new FileInputStream(overrideFile);
-                Properties conf = new Properties();
-                conf.load(new BufferedReader(new InputStreamReader(fis, "UTF-8")));
-                Properties override = new Properties();
-                override.load(new BufferedReader(new InputStreamReader(fis2, "UTF-8")));
-                for (Map.Entry<Object, Object> entries : override.entrySet()) {
-                    conf.setProperty(entries.getKey().toString(), entries.getValue().toString());
-                }
-                ByteArrayOutputStream bout = new ByteArrayOutputStream();
-                conf.store(bout, "output");
-                return new ByteArrayInputStream(bout.toByteArray());
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            } finally {
-                IOUtils.closeQuietly(fis);
-                IOUtils.closeQuietly(fis2);
+            File securityPropFile = getKylinSecurityPropertiesFile();
+            if (securityPropFile.exists()) {
+                FileInputStream ois = new FileInputStream(securityPropFile);
+                Properties propSecurity = new Properties();
+                propSecurity.load(ois);
+                IOUtils.closeQuietly(ois);
+                conf.putAll(propSecurity);
             }
-        } else {
-            try {
-                return new FileInputStream(propFile);
-            } catch (FileNotFoundException e) {
-                logger.error("this should not happen");
-                throw new RuntimeException(e);
+
+            File securityPropOverrideFile = new File(securityPropFile.getParentFile(), securityPropFile.getName()
+ ".override");
+            if (securityPropOverrideFile.exists()) {
+                FileInputStream ois = new FileInputStream(securityPropOverrideFile);
+                Properties propSecurityOverride = new Properties();
+                propSecurityOverride.load(ois);
+                IOUtils.closeQuietly(ois);
+                conf.putAll(propSecurityOverride);
             }
+
+        } catch (IOException e) {
+            throw new RuntimeException(e);
         }
 
+        return conf;
     }
 
     /**
@@ -248,19 +270,23 @@ public class KylinConfig extends KylinConfigBase {
         return new File(path, KYLIN_CONF_PROPERTIES_FILE);
     }
 
+    private static File getKylinSecurityPropertiesFile(String path) {
+        if (path == null) {
+            return null;
+        }
+
+        return new File(path, KYLIN_SECURITY_CONF_PROPERTIES_FILE);
+    }
+
     /**
      * Find config from environment. The Search process: 1. Check the
      * $KYLIN_CONF/kylin.properties 2. Check the $KYLIN_HOME/conf/kylin.properties
      */
     private static KylinConfig loadKylinConfig() {
+        Properties prop = getKylinProperties();
 
-        InputStream is = getKylinPropertiesAsInputStream();
-        if (is == null) {
-            throw new IllegalArgumentException("Failed to load kylin config");
-        }
         KylinConfig config = new KylinConfig();
-        config.reloadKylinConfig(is);
-
+        config.reloadKylinConfig(prop);
         return config;
     }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
index eb4102a..65a7fb9 100644
--- a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
+++ b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
@@ -20,7 +20,6 @@ package org.apache.kylin.common;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Serializable;
 import java.util.Map;
 import java.util.Properties;
@@ -29,7 +28,6 @@ import java.util.Map.Entry;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.kylin.common.util.CliCommandExecutor;
 import org.slf4j.Logger;
@@ -124,16 +122,8 @@ abstract public class KylinConfigBase implements Serializable {
         properties.setProperty(key, value);
     }
 
-    final protected void reloadKylinConfig(InputStream is) {
-        Properties newProperties = new Properties();
-        try {
-            newProperties.load(is);
-        } catch (IOException e) {
-            throw new RuntimeException("Cannot load kylin config.", e);
-        } finally {
-            IOUtils.closeQuietly(is);
-        }
-        this.properties = newProperties;
+    final protected void reloadKylinConfig(Properties properties) {
+        this.properties = properties;
     }
 
     // ============================================================================

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java
----------------------------------------------------------------------
diff --git a/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java b/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java
index 097fe11..0e11c22 100644
--- a/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java
+++ b/core-common/src/test/java/org/apache/kylin/common/KylinConfigTest.java
@@ -48,4 +48,16 @@ public class KylinConfigTest extends LocalFileMetadataTestCase {
         assertEquals("test2", override.get("test2"));
     }
 
+    @Test
+    public void testAccountConfig() {
+        KylinConfig config = KylinConfig.getInstanceFromEnv();
+        assertEquals("need_reset", config.getMailPassword());
+    }
+
+    @Test
+    public void testAccountOverrideConfig(){
+        KylinConfig config = KylinConfig.getInstanceFromEnv();
+        assertEquals("override.mail.com", config.getMailHost());
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/examples/test_case_data/localmeta/kylin.properties
----------------------------------------------------------------------
diff --git a/examples/test_case_data/localmeta/kylin.properties b/examples/test_case_data/localmeta/kylin.properties
index c80a08f..47d9577 100644
--- a/examples/test_case_data/localmeta/kylin.properties
+++ b/examples/test_case_data/localmeta/kylin.properties
@@ -81,6 +81,9 @@ kylin.job.yarn.app.rest.check.interval.seconds=10
 # with "testing" profile, user can use pre-defined name/pwd like KYLIN/ADMIN to login
 kylin.security.profile=testing
 
+### MAIL ###
+mail.host=origin.mail.com
+
 ### OTHER ###
 
 # for tests

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/examples/test_case_data/localmeta/kylin_account.properties
----------------------------------------------------------------------
diff --git a/examples/test_case_data/localmeta/kylin_account.properties b/examples/test_case_data/localmeta/kylin_account.properties
new file mode 100644
index 0000000..6350d7f
--- /dev/null
+++ b/examples/test_case_data/localmeta/kylin_account.properties
@@ -0,0 +1,50 @@
+### JOB ###
+
+# Only necessary when kylin.job.run.as.remote.cmd=true
+kylin.job.remote.cli.username=
+
+# Only necessary when kylin.job.run.as.remote.cmd=true
+kylin.job.remote.cli.password=
+
+### SECURITY ###
+
+# Spring security profile, options: testing, ldap, saml
+# with "testing" profile, user can use pre-defined name/pwd like KYLIN/ADMIN to login
+kylin.security.profile=testing
+
+# Default roles and admin roles in LDAP, for ldap and saml
+acl.defaultRole=ROLE_ANALYST,ROLE_MODELER
+acl.adminRole=ROLE_ADMIN
+
+# LDAP authentication configuration
+ldap.server=ldap://ldap_server:389
+ldap.username=
+ldap.password=
+
+# LDAP user account directory;
+ldap.user.searchBase=
+ldap.user.searchPattern=
+ldap.user.groupSearchBase=
+
+# LDAP service account directory
+ldap.service.searchBase=
+ldap.service.searchPattern=
+ldap.service.groupSearchBase=
+
+# SAML configurations for SSO
+# SAML IDP metadata file location
+saml.metadata.file=classpath:sso_metadata.xml
+saml.metadata.entityBaseURL=https://hostname/kylin
+saml.context.scheme=https
+saml.context.serverName=hostname
+saml.context.serverPort=443
+saml.context.contextPath=/kylin
+
+### MAIL ###
+
+# If true, will send email notification;
+mail.enabled=false
+mail.host=override.mail.com
+mail.username=
+mail.password=need_reset
+mail.sender=
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/server-base/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
b/server-base/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
index 2692da9..8212b9d 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
@@ -18,12 +18,17 @@
 
 package org.apache.kylin.rest.security;
 
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
 import java.util.Properties;
 
 import javax.crypto.Cipher;
 import javax.crypto.spec.SecretKeySpec;
 
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.IOUtils;
 import org.apache.kylin.common.KylinConfig;
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 import org.springframework.core.io.InputStreamResource;
@@ -36,11 +41,20 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  */
 public class PasswordPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
 
+    /**
+     * thisIsAsecretKey
+     */
     private static byte[] key = { 0x74, 0x68, 0x69, 0x73, 0x49, 0x73, 0x41, 0x53, 0x65, 0x63,
0x72, 0x65, 0x74, 0x4b, 0x65, 0x79 };
 
     public PasswordPlaceholderConfigurer() {
         Resource[] resources = new Resource[1];
-        resources[0] = new InputStreamResource(KylinConfig.getKylinPropertiesAsInputStream());
+        Properties prop = KylinConfig.getKylinProperties();
+        StringWriter writer = new StringWriter();
+        prop.list(new PrintWriter(writer));
+        String propString = writer.getBuffer().toString();
+        IOUtils.closeQuietly(writer);
+        InputStream is = IOUtils.toInputStream(propString, Charset.defaultCharset());
+        resources[0] = new InputStreamResource(is);
         this.setLocations(resources);
     }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/server-base/src/test/java/org/apache/kylin/rest/security/PasswordPlaceHolderConfigurerTest.java
----------------------------------------------------------------------
diff --git a/server-base/src/test/java/org/apache/kylin/rest/security/PasswordPlaceHolderConfigurerTest.java
b/server-base/src/test/java/org/apache/kylin/rest/security/PasswordPlaceHolderConfigurerTest.java
new file mode 100644
index 0000000..3afd2ca
--- /dev/null
+++ b/server-base/src/test/java/org/apache/kylin/rest/security/PasswordPlaceHolderConfigurerTest.java
@@ -0,0 +1,16 @@
+package org.apache.kylin.rest.security;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+
+public class PasswordPlaceHolderConfigurerTest {
+
+    @Test
+    public void testAESEncrypt(){
+        String input = "hello world";
+        String result = PasswordPlaceholderConfigurer.encrypt(input);
+        Assert.assertEquals("4stv/RRleOtvie/8SLHmXA==", result);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java b/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
index 7620f8c..250c79f 100644
--- a/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
+++ b/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
@@ -73,7 +73,7 @@ public class CacheServiceTest extends LocalFileMetadataTestCase {
         staticCreateTestMetadata();
         configA = KylinConfig.getInstanceFromEnv();
         configA.setProperty("kylin.rest.servers", "localhost:7777");
-        configB = KylinConfig.createKylinConfigFromInputStream(KylinConfig.getKylinPropertiesAsInputStream());
+        configB = KylinConfig.createKylinConfig(KylinConfig.getKylinProperties());
         configB.setProperty("kylin.rest.servers", "localhost:7777");
         configB.setMetadataUrl("../examples/test_metadata");
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/d6745eaf/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/coprocessor/endpoint/CubeVisitService.java
----------------------------------------------------------------------
diff --git a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/coprocessor/endpoint/CubeVisitService.java
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/coprocessor/endpoint/CubeVisitService.java
index cbccac6..407890c 100644
--- a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/coprocessor/endpoint/CubeVisitService.java
+++ b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/coprocessor/endpoint/CubeVisitService.java
@@ -20,13 +20,14 @@ package org.apache.kylin.storage.hbase.cube.v2.coprocessor.endpoint;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.StringReader;
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Properties;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.ArrayUtils;
@@ -184,7 +185,10 @@ public class CubeVisitService extends CubeVisitProtos.CubeVisitService
implement
             region.startRegionOperation();
 
             // if user change kylin.properties on kylin server, need to manually redeploy
coprocessor jar to update KylinConfig of Env.
-            KylinConfig.setKylinConfigFromInputStream(IOUtils.toInputStream(request.getKylinProperties(),
Charset.defaultCharset()));
+            String serverPropString = request.getKylinProperties();
+            Properties serverProp = new Properties();
+            serverProp.load(new StringReader(serverPropString));
+            KylinConfig.setKylinConfig(serverProp);
             KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
 
             debugGitTag = region.getTableDesc().getValue(IRealizationConstants.HTableGitTag);


Mime
View raw message