http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/audit_logs/conf/managed-schema ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/audit_logs/conf/managed-schema b/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/audit_logs/conf/managed-schema index f58652c..f77bec0 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/audit_logs/conf/managed-schema +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/audit_logs/conf/managed-schema @@ -106,7 +106,6 @@ <field name="file" type="key_lower_case" multiValued="false"/> <field name="log_message" type="key_lower_case" multiValued="false" omitNorms="false"/> <field name="logfile_line_number" type="tint" omitNorms="false"/> - <!-- <field name="message" type="text_std_token_lower_case" indexed="true" stored="true"/> --> <field name="message_md5" type="string" multiValued="false"/> <field name="type" type="key_lower_case" multiValued="false"/>
http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/hadoop_logs/conf/managed-schema ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/hadoop_logs/conf/managed-schema b/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/hadoop_logs/conf/managed-schema index 3b4cf19..c6f498b 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/hadoop_logs/conf/managed-schema +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/configsets/hadoop_logs/conf/managed-schema @@ -101,7 +101,6 @@ <field name="logger_name" type="key_lower_case" multiValued="false"/> <field name="logtime" type="tdate" multiValued="false" docValues="true"/> <field name="logtype" type="key_lower_case" multiValued="false"/> - <!-- <field name="message" type="text_std_token_lower_case" indexed="true" stored="true"/> --> <field name="message_md5" type="string" multiValued="false"/> <field name="method" type="key_lower_case" multiValued="false" omitNorms="false"/> <field name="path" type="key_lower_case" multiValued="false"/> @@ -117,28 +116,5 @@ <dynamicField name='key_*' type="key_lower_case" multiValued="false" stored="false"/> <dynamicField name="ws_*" type="text_ws" multiValued="false" omitNorms="false" stored="false"/> <copyField source="log_message" dest="key_log_message"/> - <!-- <copyField source="log_message" dest="ws_log_message"/> --> - - <!-- Copy Fields--> - <!-- ngram fields --> - <!-- Whenever using a copy field provide following structure "ngram_"<OriginalFieldName> --> -<!-- Commenting till we test properly. Now it is not used and it is taking unnecessary cpu, memory and disk space - <copyField source="bundle_id" dest="ngram_bundle_id"/> - <copyField source="case_id" dest="ngram_case_id"/> - <copyField source="cluster" dest="ngram_cluster"/> - <copyField source="file" dest="ngram_file"/> - <copyField source="host" dest="ngram_host"/> - <copyField source="level" dest="ngram_level"/> - <copyField source="log_message" dest="ngram_log_message"/> - <copyField source="logger_name" dest="ngram_logger_name"/> - <copyField source="logtype" dest="ngram_logtype"/> - <copyField source="method" dest="ngram_method"/> - <copyField source="path" dest="ngram_path"/> - <copyField source="thread_name" dest="ngram_thread_name"/> - <copyField source="type" dest="ngram_type"/> - ---> - - </schema> http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/README.md ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/README.md b/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/README.md deleted file mode 100644 index 3cc4915..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/README.md +++ /dev/null @@ -1,35 +0,0 @@ -<!-- -{% comment %} -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. -{% endcomment %} ---> - -This folder contains scripts to configure and run SolrCloud for development. - -This helps in seting up SolrCloud using embedded zookeeper. - -##Setup Solr Collections -```./update_config.sh <path to solr install folder> -``` - - -##Run Solr -```./restart_solr.sh -``` - -##Delete collections -```./reset_collections.sh -``` \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/reset_collections.sh ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/reset_collections.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/reset_collections.sh deleted file mode 100755 index 7c742c0..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/reset_collections.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/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. - -# This script is used to delete all the documents in Solr -host_port=localhost:8983 -if [ $# -eq 1 ]; then - host_port=$1 -fi -set -x -curl http://${host_port}/solr/hadoop_logs/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8' -curl http://${host_port}/solr/hadoop_logs/update --data '<commit/>' -H 'Content-type:text/xml; charset=utf-8' - -curl http://${host_port}/solr/audit_logs/update --data '<delete><query>*:*</query></delete>' -H 'Content-type:text/xml; charset=utf-8' -curl http://${host_port}/solr/audit_logs/update --data '<commit/>' -H 'Content-type:text/xml; charset=utf-8' - http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/restart_solr.sh ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/restart_solr.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/restart_solr.sh deleted file mode 100755 index bd436bb..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/restart_solr.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/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. - - -function usage { - echo "Usage: $0 <Solr Install Folder>" -} - -if [ $# -ne 1 ]; then - usage - exit 1 -fi - -SOLR_INSTALL=$1 -if [ -x $SOLR_INSTALL/bin/solr ]; then - SOLR_BIN=$SOLR_INSTALL/bin/solr -else - echo "ERROR: Invalid Solr install folder $SOLR_INSTALL" - usage - exit 1 -fi - -set -x -$SOLR_BIN restart -c http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/update_config.sh ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/update_config.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/update_config.sh deleted file mode 100755 index 93e3496..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/dev/solrcloud/update_config.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/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. - -function usage { - echo "Usage: $0 <Solr Install Folder> [zk_hosts]" -} - -if [ $# -lt 1 ]; then - usage - exit 1 -fi - -curr_dir=`pwd` -cd `dirname $0`; script_dir=`pwd`; cd $curr_dir - -SOLR_INSTALL=$1 -if [ -x $SOLR_INSTALL/server/scripts/cloud-scripts/zkcli.sh ]; then - ZK_CLI=$SOLR_INSTALL/server/scripts/cloud-scripts/zkcli.sh -else - echo "ERROR: Invalid Solr install folder $SOLR_INSTALL" - usage - exit 1 -fi - -zk_hosts="localhost:9983" -if [ $# -eq 2 ]; then - zk_hosts=$2 -fi - - -CONFIGSET_FOLDER=$script_dir/../../configsets - -set -x -$ZK_CLI -zkhost $zk_hosts -cmd upconfig -confdir $CONFIGSET_FOLDER/audit_logs/conf -confname audit_logs -$ZK_CLI -zkhost $zk_hosts -cmd upconfig -confdir $CONFIGSET_FOLDER/hadoop_logs/conf -confname hadoop_logs -$ZK_CLI -zkhost $zk_hosts -cmd upconfig -confdir $CONFIGSET_FOLDER/history/conf -confname history http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java index 15355a1..27b943a 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java @@ -92,7 +92,6 @@ public class LogSearch { logger.debug(server.dump()); logger .debug("=============================================================================="); - ConfigHelper.initializeApplicationConfig(); server.join(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java index edb4ffa..a3a71ea 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ConfigHelper.java @@ -25,48 +25,18 @@ import java.util.List; import java.util.Map; import org.apache.ambari.logsearch.dao.SolrDaoBase; -import org.apache.ambari.logsearch.manager.MgrBase; +import org.apache.ambari.logsearch.manager.ManagerBase; import org.apache.commons.lang.ArrayUtils; import org.apache.log4j.Logger; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; public class ConfigHelper { - private static final Logger logger = Logger.getLogger(MgrBase.class); - - public static HashMap<String, String> serviceLogsColumnMapping = new HashMap<String, String>(); - public static HashMap<String, String> auditLogsColumnMapping = new HashMap<String, String>(); + private static final Logger logger = Logger.getLogger(ManagerBase.class); private ConfigHelper() { throw new UnsupportedOperationException(); } - - public static void initializeApplicationConfig() { - String serviceLogsColumnMappingArray[] = PropertiesHelper.getPropertyStringList("logsearch.solr.service.logs.column.mapping"); - String auditLogsColumnMappingArray[] = PropertiesHelper.getPropertyStringList("logsearch.solr.audit.logs.column.mapping"); - - // Initializing column mapping for Service Logs - intializeUISolrColumnMapping(serviceLogsColumnMappingArray, serviceLogsColumnMapping); - - // Initializing column mapping for Audit Logs - intializeUISolrColumnMapping(auditLogsColumnMappingArray, auditLogsColumnMapping); - } - - private static void intializeUISolrColumnMapping(String columnMappingArray[], HashMap<String, String> columnMappingMap) { - - if (columnMappingArray != null && columnMappingArray.length > 0) { - for (String columnMapping : columnMappingArray) { - String mapping[] = columnMapping.split(":"); - if (mapping.length > 1) { - String solrField = mapping[0]; - String uiField = mapping[1]; - - columnMappingMap.put(solrField + LogSearchConstants.SOLR_SUFFIX, uiField); - columnMappingMap.put(uiField + LogSearchConstants.UI_SUFFIX, solrField); - } - } - } - } public static void extractSchemaFieldsName(String responseString, HashMap<String, String> schemaFieldsNameMap, HashMap<String, String> schemaFieldTypeMap) { http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java index 5235fab..edc78d1 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/ExternalServerClient.java @@ -22,11 +22,13 @@ import java.util.List; import java.util.Map; import javax.annotation.PostConstruct; +import javax.inject.Inject; import javax.ws.rs.client.Invocation; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; +import org.apache.ambari.logsearch.conf.AuthConfig; import org.apache.ambari.logsearch.web.security.LogsearchAbstractAuthenticationProvider; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -41,6 +43,7 @@ import org.springframework.stereotype.Component; */ @Component public class ExternalServerClient { + private static Logger LOG = Logger.getLogger(ExternalServerClient.class); private static final ThreadLocal<JerseyClient> localJerseyClient = new ThreadLocal<JerseyClient>(){ @Override @@ -48,15 +51,11 @@ public class ExternalServerClient { return JerseyClientBuilder.createClient(); } }; - private String hostURL = "http://host:ip";// default - private boolean enableLog = false;// default - @PostConstruct - public void initialization() { - hostURL = PropertiesHelper.getProperty( - LogsearchAbstractAuthenticationProvider.AUTH_METHOD_PROP_START_WITH - + "external_auth.host_url", hostURL); - } + @Inject + private AuthConfig authConfig; + + private boolean enableLog = false;// default /** * Send GET request to an external server @@ -65,7 +64,7 @@ public class ExternalServerClient { public Object sendGETRequest(String url, Class klass, MultivaluedMap<String, String> queryParam, String username, String password) throws Exception { - url = hostURL + url; + url = authConfig.getExternalAuthHostUrl() + url; JerseyClient client = localJerseyClient.get(); HttpAuthenticationFeature authFeature = HttpAuthenticationFeature.basicBuilder().build(); http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java index 142b29b..36ecb81 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogSearchConstants.java @@ -118,6 +118,60 @@ public class LogSearchConstants { public static final String FACET_RANGE_GAP = "facet.range.gap"; public static final String FACET_GROUP = "group"; public static final String FACET_GROUP_MAIN = "group.main"; - public static final String FACET_GROUP_FIELD = "group.field"; - + public static final String FACET_GROUP_FIELD = "group.field"; + + // Request params + public static final String REQUEST_PARAM_QUERY = "q"; + public static final String REQUEST_PARAM_XAXIS = "xAxis"; + public static final String REQUEST_PARAM_YAXIS = "yAxis"; + public static final String REQUEST_PARAM_STACK_BY = "stackBy"; + public static final String REQUEST_PARAM_UNIT = "unit"; + public static final String REQUEST_PARAM_BUNDLE_ID = "bundle_id"; + public static final String REQUEST_PARAM_START_INDEX = "startIndex"; + public static final String REQUEST_PARAM_PAGE = "page"; + public static final String REQUEST_PARAM_PAGE_SIZE = "pageSize"; + public static final String REQUEST_PARAM_SORT_BY = "sortBy"; + public static final String REQUEST_PARAM_SORT_TYPE = "sortType"; + public static final String REQUEST_PARAM_START_TIME = "start_time"; + public static final String REQUEST_PARAM_END_TIME = "end_time"; + public static final String REQUEST_PARAM_FROM = "from"; + public static final String REQUEST_PARAM_TO = "to"; + public static final String REQUEST_PARAM_FIELD = "field"; + public static final String REQUEST_PARAM_FORMAT = "format"; + public static final String REQUEST_PARAM_LAST_PAGE = "lastPage"; + public static final String REQUEST_PARAM_LOG_TYPE = "logType"; + public static final String REQUEST_PARAM_COMPONENT = "component"; + public static final String REQUEST_PARAM_HOST = "host"; + public static final String REQUEST_PARAM_TAIL_SIZE = "tailSize"; + public static final String REQUEST_PARAM_COLUMN_QUERY = "columnQuery"; + public static final String REQUEST_PARAM_I_MESSAGE = "iMessage"; + public static final String REQUEST_PARAM_G_E_MESSAGE = "gEMessage"; + public static final String REQUEST_PARAM_MUST_BE = "mustBe"; + public static final String REQUEST_PARAM_MUST_NOT = "mustNot"; + public static final String REQUEST_PARAM_INCLUDE_QUERY = "includeQuery"; + public static final String REQUEST_PARAM_EXCLUDE_QUERY = "excludeQuery"; + public static final String REQUEST_PARAM_ID = "id"; + public static final String REQUEST_PARAM_SCROLL_TYPE = "scrollType"; + public static final String REQUEST_PARAM_NUMBER_ROWS = "numberRows"; + public static final String REQUEST_PARAM_HOST_LOG_FILE = "host"; + public static final String REQUEST_PARAM_COMPONENT_LOG_FILE = "component"; + public static final String REQUEST_PARAM_LEVEL = "level"; + public static final String REQUEST_PARAM_ADVANCED_SEARCH = "advancedSearch"; + public static final String REQUEST_PARAM_TREE_PARAMS = "treeParams"; + public static final String REQUEST_PARAM_E_MESSAGE = "eMessage"; + public static final String REQUEST_PARAM_G_MUST_NOT = "gMustNot"; + public static final String REQUEST_PARAM_HOST_NAME = "host_name"; + public static final String REQUEST_PARAM_COMPONENT_NAME = "component_name"; + public static final String REQUEST_PARAM_FILE_NAME = "file_name"; + public static final String REQUEST_PARAM_DATE_RANGE_LABEL = "dateRangeLabel"; + public static final String REQUEST_PARAM_KEYWORD = "find"; + public static final String REQUEST_PARAM_SOURCE_LOG_ID = "sourceLogId"; + public static final String REQUEST_PARAM_KEYWORD_TYPE = "keywordType"; + public static final String REQUEST_PARAM_TOKEN = "token"; + public static final String REQUEST_PARAM_USER_ID = "userId"; + public static final String REQUEST_PARAM_FILTER_NAME = "filterName"; + public static final String REQUEST_PARAM_ROW_TYPE = "rowType"; + public static final String REQUEST_PARAM_UTC_OFFSET = "utcOffset"; + + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/Marker.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/Marker.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/Marker.java new file mode 100644 index 0000000..3e088ba --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/Marker.java @@ -0,0 +1,29 @@ +/* + * 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.logsearch.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Marker { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java new file mode 100644 index 0000000..90e2114 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/PropertyMapper.java @@ -0,0 +1,59 @@ +/* + * 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.logsearch.common; + +import com.google.common.base.Splitter; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component("propertyMapper") +public class PropertyMapper { + + public Map<String, String> map(String property) { + return this.map(property, ","); + } + + public List<String> list(String property) { + return this.list(property, ","); + } + + public Map<String, String> solrUiMap(String property) { return this.solrUiMap(property, ","); } + + private List<String> list(String property, String splitter) { + return Splitter.on(splitter).omitEmptyStrings().trimResults().splitToList(property); + } + + private Map<String, String> map(String property, String splitter) { + return Splitter.on(splitter).omitEmptyStrings().trimResults().withKeyValueSeparator(":").split(property); + } + + private Map<String, String> solrUiMap(String property, String splitter) { + Map<String, String> result = new HashMap<>(); + Map<String, String> map = this.map(property, splitter); + for (Map.Entry<String, String> propEntry : map.entrySet()) { + result.put(propEntry.getKey() + LogSearchConstants.SOLR_SUFFIX, propEntry.getValue()); + result.put(propEntry.getValue() + LogSearchConstants.UI_SUFFIX, propEntry.getKey()); + } + return result; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/SearchCriteria.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/SearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/SearchCriteria.java deleted file mode 100644 index 6b74144..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/SearchCriteria.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 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.logsearch.common; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.lang.StringEscapeUtils; - -public class SearchCriteria { - private int startIndex = 0; - private int maxRows = Integer.MAX_VALUE; - private String sortBy = null; - private String sortType = null; - private int page = 0; - - private String globalStartTime = null; - private String globalEndTime = null; - - private boolean getCount = true; - private boolean isDistinct = false; - private HashMap<String, Object> paramList = new HashMap<String, Object>(); - final private Set<String> nullParamList = new HashSet<String>(); - final private Set<String> notNullParamList = new HashSet<String>(); - - private Map<String, Object> urlParamMap = new HashMap<String, Object>(); - - public SearchCriteria(HttpServletRequest request) { - try { - if (request.getParameter("startIndex") != null && (!request.getParameter("startIndex").isEmpty())) { - this.startIndex = new Integer(request.getParameter("startIndex")); - } - if (request.getParameter("page") != null && (!request.getParameter("page").isEmpty())) { - this.page = new Integer(request.getParameter("page")); - } - if (request.getParameter("pageSize") != null && (!request.getParameter("pageSize").isEmpty())) { - this.maxRows = new Integer(request.getParameter("pageSize")); - } else { - this.maxRows = PropertiesHelper.getIntProperty("db.maxResults", 50); - } - } catch (NumberFormatException e) { - // do nothing - } - - // Sort fields - if (request.getParameter("sortBy") != null && (!request.getParameter("sortBy").isEmpty())) { - this.sortBy = "" + request.getParameter("sortBy"); - } - if (request.getParameter("sortType") != null && (!request.getParameter("sortType").isEmpty())) { - this.sortType = "" + request.getParameter("sortType"); - } - - // url params - if (request.getParameter("start_time") != null && (!request.getParameter("start_time").isEmpty())) { - this.globalStartTime = "" + request.getParameter("start_time"); - this.urlParamMap.put("globalStartTime", request.getParameter("start_time")); - } - if (request.getParameter("end_time") != null && (!request.getParameter("end_time").isEmpty())) { - this.globalEndTime = "" + request.getParameter("end_time"); - this.urlParamMap.put("globalEndTime", request.getParameter("end_time")); - } - } - - public SearchCriteria() { - // Auto-generated constructor stub - } - - /** - * @return the startIndex - */ - public int getStartIndex() { - return startIndex; - } - - /** - * @param startIndex the startIndex to set - */ - public void setStartIndex(int startIndex) { - this.startIndex = startIndex; - } - - /** - * @return the maxRows - */ - public int getMaxRows() { - return maxRows; - } - - /** - * @param maxRows the maxRows to set - */ - public void setMaxRows(int maxRows) { - this.maxRows = maxRows; - } - - /** - * @return the sortType - */ - - public String getSortType() { - return sortType; - } - - /** - * @param sortType the sortType to set - */ - - public boolean isGetCount() { - return getCount; - } - - public void setGetCount(boolean getCount) { - this.getCount = getCount; - } - - /** - * @return the paramList - */ - public HashMap<String, Object> getParamList() { - return paramList; - } - - /** - * @param paramList the paramList to set - */ - public void setParamList(HashMap<String, Object> paramList) { - this.paramList = paramList; - } - - /** - * @param request - */ - public void addRequiredServiceLogsParams(HttpServletRequest request) { - this.addParam("advanceSearch", StringEscapeUtils.unescapeXml(request.getParameter("advanceSearch"))); - this.addParam("q", request.getParameter("q")); - this.addParam("treeParams", StringEscapeUtils.unescapeHtml(request.getParameter("treeParams"))); - this.addParam("level", request.getParameter("level")); - this.addParam("gMustNot", request.getParameter("gMustNot")); - this.addParam("from", request.getParameter("from")); - this.addParam("to", request.getParameter("to")); - this.addParam("selectComp", request.getParameter("mustBe")); - this.addParam("unselectComp", request.getParameter("mustNot")); - this.addParam("iMessage", StringEscapeUtils.unescapeXml(request.getParameter("iMessage"))); - this.addParam("gEMessage", StringEscapeUtils.unescapeXml(request.getParameter("gEMessage"))); - this.addParam("eMessage", StringEscapeUtils.unescapeXml(request.getParameter("eMessage"))); - this.addParam(LogSearchConstants.BUNDLE_ID, request.getParameter(LogSearchConstants.BUNDLE_ID)); - this.addParam("host_name", request.getParameter("host_name")); - this.addParam("component_name", request.getParameter("component_name")); - this.addParam("file_name", request.getParameter("file_name")); - this.addParam("startDate", request.getParameter("start_time")); - this.addParam("endDate", request.getParameter("end_time")); - this.addParam("excludeQuery", StringEscapeUtils.unescapeXml(request.getParameter("excludeQuery"))); - this.addParam("includeQuery", StringEscapeUtils.unescapeXml(request.getParameter("includeQuery"))); - } - - /** - * @param request - */ - public void addRequiredAuditLogsParams(HttpServletRequest request) { - this.addParam("q", request.getParameter("q")); - this.addParam("columnQuery", StringEscapeUtils.unescapeXml(request.getParameter("columnQuery"))); - this.addParam("iMessage", StringEscapeUtils.unescapeXml(request.getParameter("iMessage"))); - this.addParam("gEMessage", StringEscapeUtils.unescapeXml(request.getParameter("gEMessage"))); - this.addParam("eMessage", StringEscapeUtils.unescapeXml(request.getParameter("eMessage"))); - this.addParam("includeString", request.getParameter("mustBe")); - this.addParam("unselectComp", request.getParameter("mustNot")); - this.addParam("excludeQuery", StringEscapeUtils.unescapeXml(request.getParameter("excludeQuery"))); - this.addParam("includeQuery", StringEscapeUtils.unescapeXml(request.getParameter("includeQuery"))); - this.addParam("startTime", request.getParameter("from")); - this.addParam("endTime", request.getParameter("to")); - } - - /** - * @param string - * @param caId - */ - public void addParam(String name, Object value) { - String solrValue = PropertiesHelper.getProperty(name); - if (solrValue == null || solrValue.isEmpty()) { - paramList.put(name, value); - } else { - try { - String propertyFieldMappings[] = solrValue.split(","); - HashMap<String, String> propertyFieldValue = new HashMap<String, String>(); - for (String temp : propertyFieldMappings) { - String arrayValue[] = temp.split(":"); - propertyFieldValue.put(arrayValue[0].toLowerCase(Locale.ENGLISH), arrayValue[1].toLowerCase(Locale.ENGLISH)); - } - String originalValue = propertyFieldValue.get(value.toString().toLowerCase(Locale.ENGLISH)); - if (originalValue != null && !originalValue.isEmpty()) - paramList.put(name, originalValue); - - } catch (Exception e) { - //do nothing - } - } - } - - public void setNullParam(String name) { - nullParamList.add(name); - } - - public void setNotNullParam(String name) { - notNullParamList.add(name); - } - - public Object getParamValue(String name) { - return paramList.get(name); - } - - /** - * @return the nullParamList - */ - public Set<String> getNullParamList() { - return nullParamList; - } - - /** - * @return the notNullParamList - */ - public Set<String> getNotNullParamList() { - return notNullParamList; - } - - /** - * @return the isDistinct - */ - public boolean isDistinct() { - return isDistinct; - } - - public String getSortBy() { - return sortBy; - } - - public void setSortBy(String sortBy) { - this.sortBy = sortBy; - } - - public void setSortType(String sortType) { - this.sortType = sortType; - } - - /** - * @param isDistinct the isDistinct to set - */ - public void setDistinct(boolean isDistinct) { - this.isDistinct = isDistinct; - } - - public int getPage() { - return page; - } - - public void setPage(int page) { - this.page = page; - } - - public String getGlobalStartTime() { - return globalStartTime; - } - - public void setGlobalStartTime(String globalStartTime) { - this.globalStartTime = globalStartTime; - } - - public String getGlobalEndTime() { - return globalEndTime; - } - - public void setGlobalEndTime(String globalEndTime) { - this.globalEndTime = globalEndTime; - } - - public Map<String, Object> getUrlParamMap() { - return urlParamMap; - } - - public void setUrlParamMap(Map<String, Object> urlParamMap) { - this.urlParamMap = urlParamMap; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java new file mode 100644 index 0000000..0ddad65 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApiDocConfig.java @@ -0,0 +1,59 @@ +/* + * 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.logsearch.conf; + +import io.swagger.jaxrs.config.BeanConfig; +import io.swagger.jaxrs.listing.ApiListingResource; +import io.swagger.jaxrs.listing.SwaggerSerializers; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +@Configuration +public class ApiDocConfig { + + @Bean + public ApiListingResource apiListingResource() { + return new ApiListingResource(); + } + + @Bean + public SwaggerSerializers swaggerSerializers() { + return new SwaggerSerializers(); + } + + @Bean + public BeanConfig swaggerConfig() throws UnknownHostException { + BeanConfig beanConfig = new BeanConfig(); + beanConfig.setSchemes(new String[]{"http", "https"}); + beanConfig.setHost(InetAddress.getLocalHost().getHostAddress() + ":61888"); // TODO: port from property + beanConfig.setBasePath("/api/v1"); + beanConfig.setTitle("Log Search REST API"); + beanConfig.setDescription("Log aggregation, analysis, and visualization."); + beanConfig.setLicense("Apache 2.0"); + beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html"); + beanConfig.setScan(true); + beanConfig.setVersion("1.0.0"); + beanConfig.setResourcePackage("org.apache.ambari.logsearch.rest"); + return beanConfig; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java new file mode 100644 index 0000000..72ea942 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/ApplicationConfig.java @@ -0,0 +1,84 @@ +/* + * 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.logsearch.conf; + +import org.apache.ambari.logsearch.query.converter.AnyGraphRequestConverter; +import org.apache.ambari.logsearch.query.converter.AuditBarGraphRequestConverter; +import org.apache.ambari.logsearch.query.converter.AuditLogRequestConverter; +import org.apache.ambari.logsearch.query.converter.BaseAuditLogRequestConverter; +import org.apache.ambari.logsearch.query.converter.BaseServiceLogRequestConverter; +import org.apache.ambari.logsearch.query.converter.FieldAuditLogRequestConverter; +import org.apache.ambari.logsearch.query.converter.FieldBarGraphRequestConverter; +import org.apache.ambari.logsearch.query.converter.ServiceAnyGraphRequestConverter; +import org.apache.ambari.logsearch.query.converter.ServiceExtremeDatesRequestConverter; +import org.apache.ambari.logsearch.query.converter.ServiceGraphRequestConverter; +import org.apache.ambari.logsearch.query.converter.ServiceLogExportRequestConverter; +import org.apache.ambari.logsearch.query.converter.ServiceLogFileRequestConverter; +import org.apache.ambari.logsearch.query.converter.ServiceLogRequestConverter; +import org.apache.ambari.logsearch.query.converter.ServiceLogTruncatedRequestConverter; +import org.apache.ambari.logsearch.query.converter.SimpleQueryRequestConverter; +import org.apache.ambari.logsearch.query.converter.UserExportRequestConverter; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.ConversionServiceFactoryBean; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.convert.converter.Converter; + +import java.util.HashSet; +import java.util.Set; + +@Configuration +@ComponentScan("org.apache.ambari.logsearch") +@PropertySource(value = {"classpath:default.properties", "classpath:logsearch.properties"}) +@ImportResource("META-INF/security-applicationContext.xml") +public class ApplicationConfig { + + @Bean + public static PropertySourcesPlaceholderConfigurer propertyConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + + @Bean(name="conversionService") + public ConversionServiceFactoryBean conversionServiceFactoryBean() { + ConversionServiceFactoryBean conversionServiceFactoryBean = new ConversionServiceFactoryBean(); + Set<Converter> converters = new HashSet<>(); + converters.add(new AnyGraphRequestConverter()); + converters.add(new AuditBarGraphRequestConverter()); + converters.add(new AuditLogRequestConverter()); + converters.add(new BaseAuditLogRequestConverter()); + converters.add(new BaseServiceLogRequestConverter()); + converters.add(new FieldAuditLogRequestConverter()); + converters.add(new FieldBarGraphRequestConverter()); + converters.add(new SimpleQueryRequestConverter()); + converters.add(new UserExportRequestConverter()); + converters.add(new ServiceAnyGraphRequestConverter()); + converters.add(new ServiceExtremeDatesRequestConverter()); + converters.add(new ServiceGraphRequestConverter()); + converters.add(new ServiceLogExportRequestConverter()); + converters.add(new ServiceLogFileRequestConverter()); + converters.add(new ServiceLogRequestConverter()); + converters.add(new ServiceLogTruncatedRequestConverter()); + conversionServiceFactoryBean.setConverters(converters); + return conversionServiceFactoryBean; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java new file mode 100644 index 0000000..3398a83 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/AuthConfig.java @@ -0,0 +1,87 @@ +/* + * 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.logsearch.conf; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class AuthConfig { + + @Value("${logsearch.auth.file.enable:true}") + boolean authFileEnabled; + @Value("${logsearch.auth.ldap.enable:false}") + boolean authLdapEnabled; + @Value("${logsearch.auth.simple.enable:false}") + boolean authSimpleEnabled; + @Value("${logsearch.auth.external_auth.host_url:'http://ip:port'}") + private String externalAuthHostUrl; + @Value("${logsearch.auth.login_url:/api/v1/users/$USERNAME/privileges?fields=*}") + private String externalAuthLoginUrl; + @Value("${logsearch.login.credentials.file:user_pass.json}") + private String credentialsFile; + + public boolean isAuthFileEnabled() { + return authFileEnabled; + } + + public void setAuthFileEnabled(boolean authFileEnabled) { + this.authFileEnabled = authFileEnabled; + } + + public boolean isAuthLdapEnabled() { + return authLdapEnabled; + } + + public void setAuthLdapEnabled(boolean authLdapEnabled) { + this.authLdapEnabled = authLdapEnabled; + } + + public boolean isAuthSimpleEnabled() { + return authSimpleEnabled; + } + + public void setAuthSimpleEnabled(boolean authSimpleEnabled) { + this.authSimpleEnabled = authSimpleEnabled; + } + + public String getCredentialsFile() { + return credentialsFile; + } + + public void setCredentialsFile(String credentialsFile) { + this.credentialsFile = credentialsFile; + } + + public String getExternalAuthHostUrl() { + return externalAuthHostUrl; + } + + public void setExternalAuthHostUrl(String externalAuthHostUrl) { + this.externalAuthHostUrl = externalAuthHostUrl; + } + + public String getExternalAuthLoginUrl() { + return externalAuthLoginUrl; + } + + public void setExternalAuthLoginUrl(String externalAuthLoginUrl) { + this.externalAuthLoginUrl = externalAuthLoginUrl; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java new file mode 100644 index 0000000..ae4dca9 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrAuditLogConfig.java @@ -0,0 +1,181 @@ +/* + * 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.logsearch.conf; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import java.util.List; +import java.util.Map; + +@Configuration +public class SolrAuditLogConfig implements SolrConfig, SolrColumnConfig { + + @Value("${logsearch.solr.audit.logs.url:}") + private String solrUrl; + + @Value("${logsearch.solr.audit.logs.zk_connect_string:}") + private String zkConnectString; + + @Value("${logsearch.solr.collection.audit.logs:audit_logs}") + private String collection; + + @Value("${logsearch.ranger.audit.logs.collection.name:}") + private String rangerCollection; + + @Value("${logsearch.solr.audit.logs.config.name:audit_logs}") + private String configName; + + @Value("${logsearch.solr.audit.logs.alias.name:audit_logs_alias}") + private String aliasNameIn; + + @Value("${logsearch.audit.logs.split.interval.mins:none}") + private String splitInterval; + + @Value("${logsearch.collection.audit.logs.numshards:1}") + private Integer numberOfShards; + + @Value("${logsearch.collection.audit.logs.replication.factor:1}") + private Integer replicationFactor; + + @Value("#{propertyMapper.map('${logsearch.solr.audit.logs.column.mapping}')}") + private Map<String, String> columnMapping; + + @Value("#{propertyMapper.list('${logsearch.solr.audit.logs.exclude.columnlist}')}") + private List<String> excludeColumnList; + + @Value("#{propertyMapper.solrUiMap('${logsearch.solr.audit.logs.column.mapping}')}") + private Map<String, String> solrAndUiColumns; + + @Override + public String getSolrUrl() { + return solrUrl; + } + + @Override + public void setSolrUrl(String solrUrl) { + this.solrUrl = solrUrl; + } + + @Override + public String getCollection() { + return collection; + } + + @Override + public void setCollection(String collection) { + this.collection = collection; + } + + @Override + public String getZkConnectString() { + return zkConnectString; + } + + @Override + public void setZkConnectString(String zkConnectString) { + this.zkConnectString = zkConnectString; + } + + @Override + public String getConfigName() { + return configName; + } + + @Override + public void setConfigName(String configName) { + this.configName = configName; + } + + @Override + public Integer getNumberOfShards() { + return numberOfShards; + } + + @Override + public void setNumberOfShards(Integer numberOfShards) { + this.numberOfShards = numberOfShards; + } + + @Override + public Integer getReplicationFactor() { + return replicationFactor; + } + + @Override + public void setReplicationFactor(Integer replicationFactor) { + this.replicationFactor = replicationFactor; + } + + @Override + public String getSplitInterval() { + return splitInterval; + } + + @Override + public void setSplitInterval(String splitInterval) { + this.splitInterval = splitInterval; + } + + @Override + public List<String> getExcludeColumnList() { + return excludeColumnList; + } + + @Override + public void setExcludeColumnList(List<String> excludeColumnList) { + this.excludeColumnList = excludeColumnList; + } + + @Override + public Map<String, String> getColumnMapping() { + return columnMapping; + } + + @Override + public void setColumnMapping(Map<String, String> columnMappings) { + this.columnMapping = columnMappings; + } + + @Override + public Map<String, String> getSolrAndUiColumns() { + return solrAndUiColumns; + } + + @Override + public void setSolrAndUiColumns(Map<String, String> solrAndUiColumns) { + this.solrAndUiColumns = solrAndUiColumns; + } + + public String getRangerCollection() { + return rangerCollection; + } + + public void setRangerCollection(String rangerCollection) { + this.rangerCollection = rangerCollection; + } + + public String getAliasNameIn() { + return aliasNameIn; + } + + public void setAliasNameIn(String aliasNameIn) { + this.aliasNameIn = aliasNameIn; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java new file mode 100644 index 0000000..a12b2ce --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrColumnConfig.java @@ -0,0 +1,36 @@ +/* + * 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.logsearch.conf; + +import java.util.List; +import java.util.Map; + +public interface SolrColumnConfig { + Map<String, String> getColumnMapping(); + + void setColumnMapping(Map<String, String> columnMapping); + + List<String> getExcludeColumnList(); + + void setExcludeColumnList(List<String> excludeColumnList); + + Map<String, String> getSolrAndUiColumns(); + + void setSolrAndUiColumns(Map<String, String> solrAndUiColumns); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java new file mode 100644 index 0000000..cfbe097 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.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.logsearch.conf; + +public interface SolrConfig { + String getSolrUrl(); + + void setSolrUrl(String solrUrl); + + String getZkConnectString(); + + void setZkConnectString(String zkConnectString); + + String getCollection(); + + void setCollection(String collection); + + String getConfigName(); + + void setConfigName(String configName); + + Integer getNumberOfShards(); + + void setNumberOfShards(Integer numberOfShards); + + Integer getReplicationFactor(); + + void setReplicationFactor(Integer replicationFactor); + + String getSplitInterval(); + + void setSplitInterval(String splitInterval); + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java new file mode 100644 index 0000000..b3dceea --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrConnectionConfig.java @@ -0,0 +1,49 @@ +/* + * 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.logsearch.conf; + +import org.springframework.beans.factory.annotation.Value; + +public abstract class SolrConnectionConfig implements SolrConfig { + @Value("${logsearch.solr.url:}") + private String solrUrl; + + @Value("${logsearch.solr.zk_connect_string:}") + private String zkConnectString; + + @Override + public String getSolrUrl() { + return solrUrl; + } + + @Override + public void setSolrUrl(String solrUrl) { + this.solrUrl = solrUrl; + } + + @Override + public String getZkConnectString() { + return zkConnectString; + } + + @Override + public void setZkConnectString(String zkConnectString) { + this.zkConnectString = zkConnectString; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrKerberosConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrKerberosConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrKerberosConfig.java new file mode 100644 index 0000000..7cf79b0 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrKerberosConfig.java @@ -0,0 +1,48 @@ +/* + * 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.logsearch.conf; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SolrKerberosConfig { + + @Value("${logsearch.solr.jaas.file:/usr/lib/ambari-logsearch-portal/logsearch_solr_jaas.conf}") + private String jaasFile; + + @Value("${logsearch.solr.kerberos.enable:false}") + private boolean enabled; + + public String getJaasFile() { + return jaasFile; + } + + public void setJaasFile(String jaasFile) { + this.jaasFile = jaasFile; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java new file mode 100644 index 0000000..e768402 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogConfig.java @@ -0,0 +1,144 @@ +/* + * 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.logsearch.conf; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import java.util.List; +import java.util.Map; + +@Configuration +public class SolrServiceLogConfig extends SolrConnectionConfig implements SolrColumnConfig { + + @Value("${logsearch.solr.collection.service.logs:hadoop_logs}") + private String collection; + + @Value("${logsearch.service.logs.split.interval.mins:none}") + private String splitInterval; + + @Value("${logsearch.solr.service.logs.config.name:hadoop_logs}") + private String configName; + + @Value("${logsearch.collection.service.logs.numshards:1}") + private Integer numberOfShards; + + @Value("${logsearch.collection.service.logs.replication.factor:1}") + private Integer replicationFactor; + + @Value("#{propertyMapper.list('${logsearch.service.logs.fields}')}") + private List<String> fields; + + @Value("#{propertyMapper.map('${logsearch.solr.audit.logs.column.mapping}')}") + private Map<String, String> columnMapping; + + @Value("#{propertyMapper.list('${logsearch.solr.audit.logs.exclude.columnlist}')}") + private List<String> excludeColumnList; + + @Value("#{propertyMapper.solrUiMap('${logsearch.solr.audit.logs.column.mapping}}')}") + private Map<String, String> solrAndUiColumns; + + @Override + public String getCollection() { + return collection; + } + + @Override + public void setCollection(String collection) { + this.collection = collection; + } + + @Override + public String getSplitInterval() { + return splitInterval; + } + + @Override + public void setSplitInterval(String splitInterval) { + this.splitInterval = splitInterval; + } + + @Override + public String getConfigName() { + return configName; + } + + @Override + public void setConfigName(String configName) { + this.configName = configName; + } + + @Override + public Integer getNumberOfShards() { + return numberOfShards; + } + + @Override + public void setNumberOfShards(Integer numberOfShards) { + this.numberOfShards = numberOfShards; + } + + @Override + public Integer getReplicationFactor() { + return replicationFactor; + } + + @Override + public void setReplicationFactor(Integer replicationFactor) { + this.replicationFactor = replicationFactor; + } + + @Override + public Map<String, String> getColumnMapping() { + return columnMapping; + } + + @Override + public void setColumnMapping(Map<String, String> columnMapping) { + this.columnMapping = columnMapping; + } + + @Override + public List<String> getExcludeColumnList() { + return excludeColumnList; + } + + @Override + public void setExcludeColumnList(List<String> excludeColumnList) { + this.excludeColumnList = excludeColumnList; + } + + @Override + public Map<String, String> getSolrAndUiColumns() { + return solrAndUiColumns; + } + + @Override + public void setSolrAndUiColumns(Map<String, String> solrAndUiColumns) { + this.solrAndUiColumns = solrAndUiColumns; + } + + public List<String> getFields() { + return fields; + } + + public void setFields(List<String> fields) { + this.fields = fields; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java new file mode 100644 index 0000000..8ae630a --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserConfig.java @@ -0,0 +1,104 @@ +/* + * 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.logsearch.conf; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +@Configuration +public class SolrUserConfig extends SolrConnectionConfig { + + @Value("${logsearch.solr.collection.history:history}") + private String collection; + + @Value("${logsearch.history.split.interval.mins:none}") + private String splitInterval; + + @Value("${logsearch.solr.history.config.name:history}") + private String configName; + + @Value("${logsearch.collection.history.numshards:1}") + private Integer numberOfShards; + + @Value("${logsearch.collection.history.replication.factor:2}") + private Integer replicationFactor; + + @Value("#{'${logsearch.logfeeder.include.default.level:FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN}'.split(',')}") + private List<String> logLevels; + + @Override + public String getCollection() { + return collection; + } + + @Override + public void setCollection(String collection) { + this.collection = collection; + } + + @Override + public String getSplitInterval() { + return splitInterval; + } + + @Override + public void setSplitInterval(String splitInterval) { + this.splitInterval = splitInterval; + } + + @Override + public String getConfigName() { + return configName; + } + + @Override + public void setConfigName(String configName) { + this.configName = configName; + } + + @Override + public Integer getNumberOfShards() { + return numberOfShards; + } + + @Override + public void setNumberOfShards(Integer numberOfShards) { + this.numberOfShards = numberOfShards; + } + + @Override + public Integer getReplicationFactor() { + return replicationFactor; + } + + @Override + public void setReplicationFactor(Integer replicationFactor) { + this.replicationFactor = replicationFactor; + } + + public List<String> getLogLevels() { + return logLevels; + } + + public void setLogLevels(List<String> logLevels) { + this.logLevels = logLevels; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java index 64aa776..4f5e734 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java @@ -23,9 +23,11 @@ import java.util.Arrays; import java.util.Collection; import javax.annotation.PostConstruct; +import javax.inject.Inject; import org.apache.ambari.logsearch.common.PropertiesHelper; -import org.apache.ambari.logsearch.manager.MgrBase.LogType; +import org.apache.ambari.logsearch.conf.SolrAuditLogConfig; +import org.apache.ambari.logsearch.manager.ManagerBase.LogType; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -33,23 +35,26 @@ import org.springframework.stereotype.Component; @Component public class AuditSolrDao extends SolrDaoBase { - static private Logger logger = Logger.getLogger(AuditSolrDao.class); - + private static final Logger logger = Logger.getLogger(AuditSolrDao.class); + + @Inject + private SolrAuditLogConfig solrAuditLogConfig; + public AuditSolrDao() { super(LogType.AUDIT); } @PostConstruct public void postConstructor() { - String solrUrl = PropertiesHelper.getProperty("logsearch.solr.audit.logs.url"); - String zkConnectString = PropertiesHelper.getProperty("logsearch.solr.audit.logs.zk_connect_string"); - String collection = PropertiesHelper.getProperty("logsearch.solr.collection.audit.logs", "audit_logs"); - String aliasNameIn = PropertiesHelper.getProperty("logsearch.solr.audit.logs.alias.name", "audit_logs_alias"); - String rangerAuditCollection = PropertiesHelper.getProperty("logsearch.ranger.audit.logs.collection.name"); - String splitInterval = PropertiesHelper.getProperty("logsearch.audit.logs.split.interval.mins", "none"); - String configName = PropertiesHelper.getProperty("logsearch.solr.audit.logs.config.name", "audit_logs"); - int numberOfShards = PropertiesHelper.getIntProperty("logsearch.collection.audit.logs.numshards", 1); - int replicationFactor = PropertiesHelper.getIntProperty("logsearch.collection.audit.logs.replication.factor", 1); + String solrUrl = solrAuditLogConfig.getSolrUrl(); + String zkConnectString = solrAuditLogConfig.getZkConnectString(); + String collection = solrAuditLogConfig.getCollection(); + String aliasNameIn = solrAuditLogConfig.getAliasNameIn(); + String rangerAuditCollection = solrAuditLogConfig.getRangerCollection(); + String splitInterval = solrAuditLogConfig.getSplitInterval(); + String configName = solrAuditLogConfig.getConfigName(); + int numberOfShards = solrAuditLogConfig.getNumberOfShards(); + int replicationFactor = solrAuditLogConfig.getReplicationFactor(); try { connectToSolr(solrUrl, zkConnectString, collection); http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java index 6e2bb4b..e338b7c 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java @@ -20,9 +20,11 @@ package org.apache.ambari.logsearch.dao; import javax.annotation.PostConstruct; +import javax.inject.Inject; import org.apache.ambari.logsearch.common.PropertiesHelper; -import org.apache.ambari.logsearch.manager.MgrBase.LogType; +import org.apache.ambari.logsearch.conf.SolrServiceLogConfig; +import org.apache.ambari.logsearch.manager.ManagerBase.LogType; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -30,6 +32,9 @@ import org.springframework.stereotype.Component; public class ServiceLogsSolrDao extends SolrDaoBase { private static final Logger logger = Logger.getLogger(ServiceLogsSolrDao.class); + + @Inject + private SolrServiceLogConfig solrServiceLogConfig; public ServiceLogsSolrDao() { super(LogType.SERVICE); @@ -38,13 +43,13 @@ public class ServiceLogsSolrDao extends SolrDaoBase { @PostConstruct public void postConstructor() { logger.info("postConstructor() called."); - String solrUrl = PropertiesHelper.getProperty("logsearch.solr.url"); - String zkConnectString = PropertiesHelper.getProperty("logsearch.solr.zk_connect_string"); - String collection = PropertiesHelper.getProperty("logsearch.solr.collection.service.logs", "hadoop_logs"); - String splitInterval = PropertiesHelper.getProperty("logsearch.service.logs.split.interval.mins", "none"); - String configName = PropertiesHelper.getProperty("logsearch.solr.service.logs.config.name", "hadoop_logs"); - int numberOfShards = PropertiesHelper.getIntProperty("logsearch.collection.service.logs.numshards", 1); - int replicationFactor = PropertiesHelper.getIntProperty("logsearch.collection.service.logs.replication.factor", 1); + String solrUrl = solrServiceLogConfig.getSolrUrl(); + String zkConnectString = solrServiceLogConfig.getZkConnectString(); + String collection = solrServiceLogConfig.getCollection(); + String splitInterval = solrServiceLogConfig.getSplitInterval(); + String configName = solrServiceLogConfig.getConfigName(); + int numberOfShards = solrServiceLogConfig.getNumberOfShards(); + int replicationFactor = solrServiceLogConfig.getReplicationFactor(); try { connectToSolr(solrUrl, zkConnectString, collection); http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java index 8cdb6eb..b325171 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java @@ -30,7 +30,9 @@ import org.apache.ambari.logsearch.common.ConfigHelper; import org.apache.ambari.logsearch.common.LogSearchContext; import org.apache.ambari.logsearch.common.MessageEnums; import org.apache.ambari.logsearch.common.PropertiesHelper; -import org.apache.ambari.logsearch.manager.MgrBase.LogType; +import org.apache.ambari.logsearch.conf.SolrKerberosConfig; +import org.apache.ambari.logsearch.conf.SolrUserConfig; +import org.apache.ambari.logsearch.manager.ManagerBase.LogType; import org.apache.ambari.logsearch.util.RESTErrorUtil; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; @@ -58,6 +60,8 @@ import org.apache.solr.common.util.NamedList; import com.google.common.annotations.VisibleForTesting; +import javax.inject.Inject; + public abstract class SolrDaoBase { private static final Logger logger = Logger.getLogger(SolrDaoBase.class); private static final Logger logPerformance = Logger.getLogger("org.apache.ambari.logsearch.performance"); @@ -85,6 +89,11 @@ public abstract class SolrDaoBase { private String solrDetail = ""; private boolean populateFieldsThreadActive = false; + + @Inject + private SolrKerberosConfig solrKerberosConfig; + @Inject + private SolrUserConfig solrUserConfig; protected SolrDaoBase(LogType logType) { this.logType = logType; @@ -461,8 +470,8 @@ public abstract class SolrDaoBase { } private void setupSecurity() { - String jaasFile = PropertiesHelper.getProperty("logsearch.solr.jaas.file", "/etc/security/keytabs/logsearch_solr.service.keytab"); - boolean securityEnabled = PropertiesHelper.getBooleanProperty("logsearch.solr.kerberos.enable", false); + String jaasFile = solrKerberosConfig.getJaasFile(); + boolean securityEnabled = solrKerberosConfig.isEnabled(); if (securityEnabled) { System.setProperty("java.security.auth.login.config", jaasFile); HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); @@ -512,12 +521,12 @@ public abstract class SolrDaoBase { SolrRequest<SchemaResponse> request = new SchemaRequest(); request.setMethod(METHOD.GET); request.setPath("/schema"); - String historyCollection = PropertiesHelper.getProperty("logsearch.solr.collection.history","history"); + String historyCollection = solrUserConfig.getCollection(); if (solrClient != null && !collectionName.equals(historyCollection)) { NamedList<Object> namedList = null; try { namedList = solrClient.request(request); - logger.info("populateSchemaFields() collection=" + collectionName + ", fields=" + namedList); + logger.debug("populateSchemaFields() collection=" + collectionName + ", fields=" + namedList); } catch (SolrException | SolrServerException | IOException e) { logger.error("Error occured while popuplating field. collection=" + collectionName, e); } http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java index 026c78f..a9fb8d2 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java @@ -21,15 +21,17 @@ package org.apache.ambari.logsearch.dao; import java.io.File; import java.io.IOException; -import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Scanner; import javax.annotation.PostConstruct; +import javax.inject.Inject; + +import org.apache.ambari.logsearch.conf.SolrUserConfig; import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper; import org.apache.ambari.logsearch.common.LogSearchConstants; -import org.apache.ambari.logsearch.common.PropertiesHelper; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.response.QueryResponse; @@ -42,7 +44,7 @@ import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import com.google.gson.JsonParseException; -import org.apache.ambari.logsearch.manager.MgrBase.LogType; +import org.apache.ambari.logsearch.manager.ManagerBase.LogType; import org.apache.ambari.logsearch.util.JSONUtil; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -52,7 +54,9 @@ import org.springframework.util.CollectionUtils; public class UserConfigSolrDao extends SolrDaoBase { private static final Logger logger = Logger.getLogger(UserConfigSolrDao.class); - private static final String DEFAULT_LEVELS = "FATAL,ERROR,WARN,INFO,DEBUG,TRACE"; + + @Inject + private SolrUserConfig solrUserConfig; public UserConfigSolrDao() { super(LogType.SERVICE); @@ -60,13 +64,13 @@ public class UserConfigSolrDao extends SolrDaoBase { @PostConstruct public void postConstructor() { - String solrUrl = PropertiesHelper.getProperty("logsearch.solr.url"); - String zkConnectString = PropertiesHelper.getProperty("logsearch.solr.zk_connect_string"); - String collection = PropertiesHelper.getProperty("logsearch.solr.collection.history", "history"); - String configName = PropertiesHelper.getProperty("logsearch.solr.history.config.name", "history"); - int replicationFactor = PropertiesHelper.getIntProperty("logsearch.collection.history.replication.factor", 2); - String splitInterval = "none"; - int numberOfShards = 1; + String solrUrl = solrUserConfig.getSolrUrl(); + String zkConnectString = solrUserConfig.getZkConnectString(); + String collection = solrUserConfig.getCollection(); + String configName = solrUserConfig.getConfigName(); + int replicationFactor = solrUserConfig.getReplicationFactor(); + String splitInterval = solrUserConfig.getSplitInterval(); + int numberOfShards = solrUserConfig.getNumberOfShards(); try { connectToSolr(solrUrl, zkConnectString, collection); @@ -117,14 +121,14 @@ public class UserConfigSolrDao extends SolrDaoBase { if (!CollectionUtils.isEmpty(documentList)) { SolrDocument configDoc = documentList.get(0); String configJson = JSONUtil.objToJson(configDoc); - HashMap<String, Object> configMap = (HashMap<String, Object>) JSONUtil.jsonToMapObject(configJson); + HashMap<String, Object> configMap = JSONUtil.jsonToMapObject(configJson); String json = (String) configMap.get(LogSearchConstants.VALUES); logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(json, VLogfeederFilterWrapper.class); logfeederFilterWrapper.setId("" + configDoc.get(LogSearchConstants.ID)); } else { - String logfeederDefaultLevels = PropertiesHelper.getProperty("logsearch.logfeeder.include.default.level", DEFAULT_LEVELS); - JSONArray levelJsonArray = new JSONArray(Arrays.asList(logfeederDefaultLevels.split(","))); + List<String> logfeederDefaultLevels = solrUserConfig.getLogLevels(); + JSONArray levelJsonArray = new JSONArray(logfeederDefaultLevels); String hadoopServiceString = getHadoopServiceConfigJSON(); String key = null; http://git-wip-us.apache.org/repos/asf/ambari/blob/cc429d48/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java index 39f0e25..a04dee4 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java @@ -24,8 +24,9 @@ import java.util.Arrays; import java.util.HashMap; import javax.annotation.PostConstruct; +import javax.inject.Inject; -import org.springframework.beans.factory.annotation.Autowired; +import org.apache.ambari.logsearch.conf.AuthConfig; import org.springframework.security.core.GrantedAuthority; import org.springframework.stereotype.Repository; import org.apache.ambari.logsearch.common.PropertiesHelper; @@ -50,9 +51,12 @@ public class UserDao { private static final String ENC_PASSWORD = "en_password"; private static final String NAME = "name"; - @Autowired + @Inject private LogsearchFileAuthenticationProvider fileAuthenticationProvider; + @Inject + private AuthConfig authConfig; + private ArrayList<HashMap<String, String>> userList = null; @SuppressWarnings("unchecked") @@ -60,7 +64,7 @@ public class UserDao { public void initialization() { if (fileAuthenticationProvider.isEnable()) { try { - String userPassJsonFileName = PropertiesHelper.getProperty("logsearch.login.credentials.file"); + String userPassJsonFileName = authConfig.getCredentialsFile(); logger.info("USER PASS JSON file NAME:" + userPassJsonFileName); File jsonFile = FileUtil.getFileFromClasspath(userPassJsonFileName); if (jsonFile == null || !jsonFile.exists()) {
