You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2016/04/18 11:18:37 UTC
[5/5] ambari git commit: AMBARI-15842. Logsearch: reading config
values from external property files (oleewere)
AMBARI-15842. Logsearch: reading config values from external property files (oleewere)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/10cda6ed
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/10cda6ed
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/10cda6ed
Branch: refs/heads/trunk
Commit: 10cda6ed6e86bc16e2c57fbb0468d8e4f8d2b136
Parents: b40ae34
Author: Oliver Szabo <ol...@gmail.com>
Authored: Mon Apr 18 11:14:13 2016 +0200
Committer: oleewere <ol...@gmail.com>
Committed: Mon Apr 18 11:15:43 2016 +0200
----------------------------------------------------------------------
.../server/stack/ConfigurationDirectory.java | 8 +
.../apache/ambari/server/utils/XmlUtils.java | 50 +
.../0.5.0/configuration/logfeeder-env.xml | 45 +-
.../0.5.0/configuration/logfeeder-log4j.xml | 56 +-
.../logsearch-audit_logs-solrconfig.xml | 1897 +----------------
.../0.5.0/configuration/logsearch-env.xml | 48 +-
.../0.5.0/configuration/logsearch-log4j.xml | 86 +-
.../logsearch-service_logs-solrconfig.xml | 1898 +-----------------
.../0.5.0/configuration/logsearch-solr-env.xml | 101 +-
.../configuration/logsearch-solr-log4j.xml | 36 +-
.../0.5.0/configuration/logsearch-solr-xml.xml | 18 +-
.../LOGSEARCH/0.5.0/metainfo.xml | 2 +-
.../properties/audit_logs-solrconfig.xml.j2 | 1887 +++++++++++++++++
.../0.5.0/properties/logfeeder-env.sh.j2 | 33 +
.../0.5.0/properties/logfeeder-log4j.xml.j2 | 57 +
.../0.5.0/properties/logsearch-env.sh.j2 | 37 +
.../0.5.0/properties/logsearch-log4j.xml.j2 | 75 +
.../0.5.0/properties/logsearch-solr-env.sh.j2 | 104 +
.../properties/service_logs-solrconfig.xml.j2 | 1887 +++++++++++++++++
.../0.5.0/properties/solr-log4j.properties.j2 | 40 +
.../LOGSEARCH/0.5.0/properties/solr.xml.j2 | 26 +
21 files changed, 4268 insertions(+), 4123 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/10cda6ed/ambari-server/src/main/java/org/apache/ambari/server/stack/ConfigurationDirectory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/ConfigurationDirectory.java b/ambari-server/src/main/java/org/apache/ambari/server/stack/ConfigurationDirectory.java
index 84842e2..f40f19e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/ConfigurationDirectory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/ConfigurationDirectory.java
@@ -23,6 +23,7 @@ import org.apache.ambari.server.state.ConfigHelper;
import org.apache.ambari.server.state.PropertyInfo;
import org.apache.ambari.server.state.stack.ConfigurationXml;
import org.apache.ambari.server.utils.JsonUtils;
+import org.apache.ambari.server.utils.XmlUtils;
import org.apache.commons.io.FileUtils;
import org.eclipse.jetty.util.StringUtil;
import org.slf4j.Logger;
@@ -148,6 +149,13 @@ public class ConfigurationDirectory extends StackDefinitionDirectory {
try {
String propertyValue = FileUtils.readFileToString(propertyFile);
switch (propertyFileType.toLowerCase()) {
+ case "xml" :
+ if (!XmlUtils.isValidXml(propertyValue)) {
+ LOG.error("Failed to load value from property file. Property file {} is not a valid XML file", propertyFilePath);
+ break;
+ }
+ pi.setValue(propertyValue);
+ break;
case "json":
if(!JsonUtils.isValidJson(propertyValue)) {
LOG.error("Failed to load value from property file. Property file {} is not a valid JSON file", propertyFilePath);
http://git-wip-us.apache.org/repos/asf/ambari/blob/10cda6ed/ambari-server/src/main/java/org/apache/ambari/server/utils/XmlUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/XmlUtils.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/XmlUtils.java
new file mode 100644
index 0000000..b5ee9cc
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/XmlUtils.java
@@ -0,0 +1,50 @@
+/*
+ * 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.ambari.server.utils;
+
+
+import org.apache.commons.lang.StringUtils;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.ByteArrayInputStream;
+
+/**
+ * Static Helper methods for XML processing.
+ */
+public class XmlUtils {
+
+ public static boolean isValidXml(String input) {
+ boolean result = true;
+ try {
+ if (StringUtils.isBlank(input)) {
+ result = false;
+ } else {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ // skip dtd references
+ dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ dBuilder.parse(new ByteArrayInputStream(input.getBytes("UTF-8")));
+ }
+ } catch (Exception e) {
+ result = false;
+ }
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/10cda6ed/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-env.xml b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-env.xml
index 94ed27d..93311fb 100644
--- a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-env.xml
+++ b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-env.xml
@@ -77,42 +77,13 @@
<property>
<name>content</name>
- <description>This is the jinja template for config.json file</description>
- <value>#!/bin/bash
-# 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.
-
-set -e
-
-export LOGFEEDER_PATH={{logfeeder_dir}}
-
-export LOGFEEDER_CONF_DIR={{logsearch_logfeeder_conf}}
-
-#Logfile e.g. /var/log/logfeeder.log
-export LOGFILE={{logfeeder_log}}
-
-#pid file e.g. /var/run/logfeeder.pid
-export PID_FILE={{logfeeder_pid_file}}
-
-export JAVA_HOME={{java64_home}}
-
-if [ "$LOGFEEDER_JAVA_MEM" = "" ]; then
- export LOGFEEDER_JAVA_MEM=-Xmx{{logfeeder_max_mem}}
-fi
- </value>
+ <description>This is the jinja template for logsearch-env.sh file</description>
+ <value></value>
+ <property-type>VALUE_FROM_PROPERTY_FILE</property-type>
+ <value-attributes>
+ <property-file-name>logfeeder-env.sh.j2</property-file-name>
+ <property-file-type>text</property-file-type>
+ </value-attributes>
</property>
-
-</configuration>
+</configuration>
http://git-wip-us.apache.org/repos/asf/ambari/blob/10cda6ed/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-log4j.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-log4j.xml b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-log4j.xml
index 91fc0ce..944b559 100644
--- a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-log4j.xml
+++ b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/configuration/logfeeder-log4j.xml
@@ -23,57 +23,15 @@
<configuration supports_adding_forbidden="true">
<!-- solrconfig.xml -->
-
<property>
<name>content</name>
- <description>This is the jinja template for solrconfig.xml file for service logs</description>
- <value><?xml version="1.0" encoding="UTF-8" ?>
-<!--
- 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.
--->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d [%t] %-5p %C{6} (%F:%L) - %m%n" />
- </layout>
- </appender>
-
- <appender name="rolling_file" class="org.apache.log4j.RollingFileAppender">
- <param name="file" value="{{logfeeder_log_dir}}/logfeeder.log" />
- <param name="append" value="true" />
- <param name="maxFileSize" value="10MB" />
- <param name="maxBackupIndex" value="10" />
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d [%t] %-5p %C{6} (%F:%L) - %m%n"/>
- </layout>
- </appender>
-
- <category name="org.apache.ambari.logfeeder" additivity="false">
- <priority value="info" />
- <appender-ref ref="rolling_file" />
- </category>
-
- <root>
- <priority value="warn" />
- <appender-ref ref="rolling_file" />
- </root>
-</log4j:configuration>
- </value>
+ <description>This is the jinja template for log4j.xml file for logfeeder</description>
+ <value></value>
+ <property-type>VALUE_FROM_PROPERTY_FILE</property-type>
+ <value-attributes>
+ <property-file-name>logfeeder-log4j.xml.j2</property-file-name>
+ <property-file-type>xml</property-file-type>
+ </value-attributes>
</property>
</configuration>
\ No newline at end of file