You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/12/31 13:19:48 UTC
[31/50] [abbrv] kylin git commit: KYLIN-1664,
add default properties and ut.
KYLIN-1664, add default properties and ut.
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/19c4eb79
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/19c4eb79
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/19c4eb79
Branch: refs/heads/master
Commit: 19c4eb79576c102cb1475d7a96ff13db14496712
Parents: 17ce7d7
Author: tttMelody <24...@qq.com>
Authored: Mon Dec 25 23:01:05 2017 +0800
Committer: Jiatao Tao <24...@qq.com>
Committed: Tue Dec 26 19:44:40 2017 +0800
----------------------------------------------------------------------
.../org/apache/kylin/common/KylinConfig.java | 1 +
.../main/resources/kylin-defaults.properties | 16 ++++-
.../kylin/rest/controller/AdminController.java | 15 +---
.../apache/kylin/rest/service/AdminService.java | 15 ++++
.../kylin/rest/service/AdminServiceTest.java | 72 ++++++++++++++++++++
server/src/test/resources/kylin.properties | 17 +++++
6 files changed, 121 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/19c4eb79/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 c662a16..8872f45 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
@@ -55,6 +55,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_DEFAULT_CONF_PROPERTIES_FILE = "kylin-defaults.properties";
public static final String KYLIN_CONF = "KYLIN_CONF";
// static cached instances
http://git-wip-us.apache.org/repos/asf/kylin/blob/19c4eb79/core-common/src/main/resources/kylin-defaults.properties
----------------------------------------------------------------------
diff --git a/core-common/src/main/resources/kylin-defaults.properties b/core-common/src/main/resources/kylin-defaults.properties
index d8b2d6a..51e5a2d 100644
--- a/core-common/src/main/resources/kylin-defaults.properties
+++ b/core-common/src/main/resources/kylin-defaults.properties
@@ -55,6 +55,21 @@ kylin.restclient.connection.default-max-per-route=20
#max connections of one rest-client
kylin.restclient.connection.max-total=200
+### PUBLIC CONFIG ###
+kylin.engine.default=2
+kylin.storage.default=2
+kylin.web.hive-limit=20
+kylin.web.help.length=4
+kylin.web.help.0=start|Getting Started|
+kylin.web.help.1=odbc|ODBC Driver|
+kylin.web.help.2=tableau|Tableau Guide|
+kylin.web.help.3=onboard|Cube Design Tutorial|
+kylin.web.link-streaming-guide=http://kylin.apache.org/
+kylin.htrace.show-gui-trace-toggle=false
+kylin.web.link-hadoop=
+kylin.web.link-diagnostic=
+kylin.web.contact-mail=
+kylin.server.external-acl-provider=
### SOURCE ###
@@ -244,7 +259,6 @@ kylin.security.saml.context-server-name=hostname
kylin.security.saml.context-server-port=443
kylin.security.saml.context-path=/kylin
-
### SPARK ENGINE CONFIGS ###
# Hadoop conf folder, will export this as "HADOOP_CONF_DIR" to run spark-submit
http://git-wip-us.apache.org/repos/asf/kylin/blob/19c4eb79/server-base/src/main/java/org/apache/kylin/rest/controller/AdminController.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller/AdminController.java b/server-base/src/main/java/org/apache/kylin/rest/controller/AdminController.java
index bb71190..963a945 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/controller/AdminController.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/controller/AdminController.java
@@ -19,12 +19,8 @@
package org.apache.kylin.rest.controller;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import com.google.common.collect.Lists;
import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.lang3.StringUtils;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.rest.msg.Message;
import org.apache.kylin.rest.msg.MsgPicker;
@@ -87,21 +83,12 @@ public class AdminController extends BasicController {
@RequestMapping(value = "/public_config", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getPublicConfig() throws IOException {
- final String whiteListProperties = KylinConfig.getInstanceFromEnv().getPropertiesWhiteList();
-
- Collection<String> propertyKeys = Lists.newArrayList();
- if (StringUtils.isNotEmpty(whiteListProperties)) {
- propertyKeys.addAll(Arrays.asList(whiteListProperties.split(",")));
- }
-
- final String config = KylinConfig.getInstanceFromEnv().exportToString(propertyKeys);
+ final String config = adminService.getPublicConfig();
GeneralResponse configRes = new GeneralResponse();
configRes.put("config", config);
-
return configRes;
}
-
@RequestMapping(value = "/metrics/cubes", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public MetricsResponse cubeMetrics(MetricsRequest request) {
http://git-wip-us.apache.org/repos/asf/kylin/blob/19c4eb79/server-base/src/main/java/org/apache/kylin/rest/service/AdminService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/AdminService.java b/server-base/src/main/java/org/apache/kylin/rest/service/AdminService.java
index f98a1d4..1da423b 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/AdminService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/AdminService.java
@@ -19,12 +19,17 @@
package org.apache.kylin.rest.service;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
+import com.google.common.collect.Lists;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang3.StringUtils;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.common.util.OrderedProperties;
import org.apache.kylin.rest.constant.Constant;
@@ -89,4 +94,14 @@ public class AdminService extends BasicService {
job.execute(args);
}
+ public String getPublicConfig() throws IOException {
+ final String whiteListProperties = KylinConfig.getInstanceFromEnv().getPropertiesWhiteList();
+
+ Collection<String> propertyKeys = Lists.newArrayList();
+ if (StringUtils.isNotEmpty(whiteListProperties)) {
+ propertyKeys.addAll(Arrays.asList(whiteListProperties.split(",")));
+ }
+
+ return KylinConfig.getInstanceFromEnv().exportToString(propertyKeys);
+ }
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/19c4eb79/server/src/test/java/org/apache/kylin/rest/service/AdminServiceTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/kylin/rest/service/AdminServiceTest.java b/server/src/test/java/org/apache/kylin/rest/service/AdminServiceTest.java
new file mode 100644
index 0000000..75b8f21
--- /dev/null
+++ b/server/src/test/java/org/apache/kylin/rest/service/AdminServiceTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.rest.service;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.kylin.common.KylinConfig;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+/**
+ *
+ */
+public class AdminServiceTest extends ServiceTestBase {
+
+ @Autowired
+ @Qualifier("adminService")
+ private AdminService adminService;
+
+ @Test
+ public void testGetPublicConfig() throws IOException {
+ //set ../examples/test_metadata/kylin.properties empty
+ File file = FileUtils.getFile(LOCALMETA_TEMP_DATA + "kylin.properties");
+ FileUtils.deleteQuietly(file);
+ FileUtils.touch(file);
+ String path = Thread.currentThread().getContextClassLoader().getResource("kylin.properties").getPath();
+ KylinConfig.setKylinConfigThreadLocal(KylinConfig.createInstanceFromUri(path));
+ String expected = "kylin.web.link-streaming-guide=http://kylin.apache.org/\n" +
+ "kylin.web.contact-mail=\n" +
+ "kylin.query.cache-enabled=true\n" +
+ "kylin.web.link-diagnostic=\n" +
+ "kylin.web.help.length=4\n" +
+ "kylin.web.timezone=GMT+8\n" +
+ "kylin.server.external-acl-provider=\n" +
+ "kylin.storage.default=2\n" +
+ "kylin.web.help=\n" +
+ "kylin.web.export-allow-other=true\n" +
+ "kylin.web.link-hadoop=\n" +
+ "kylin.web.hide-measures=\n" +
+ "kylin.htrace.show-gui-trace-toggle=false\n" +
+ "kylin.web.export-allow-admin=true\n" +
+ "kylin.env=QA\n" +
+ "kylin.web.hive-limit=20\n" +
+ "kylin.engine.default=2\n" +
+ "kylin.web.help.3=onboard|Cube Design Tutorial|\n" +
+ "kylin.web.help.2=tableau|Tableau Guide|\n" +
+ "kylin.web.help.1=odbc|ODBC Driver|\n" +
+ "kylin.web.help.0=start|Getting Started|\n" +
+ "kylin.security.profile=testing\n";
+ Assert.assertEquals(expected, adminService.getPublicConfig());
+ }
+}
http://git-wip-us.apache.org/repos/asf/kylin/blob/19c4eb79/server/src/test/resources/kylin.properties
----------------------------------------------------------------------
diff --git a/server/src/test/resources/kylin.properties b/server/src/test/resources/kylin.properties
new file mode 100644
index 0000000..9f96dd8
--- /dev/null
+++ b/server/src/test/resources/kylin.properties
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# empty, then program can use kylin-defaults.properties
\ No newline at end of file