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/10/03 12:54:54 UTC
[9/9] ambari git commit: AMBARI-18310. Logsearch - Refactor solr
query layer (oleewere)
AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)
Change-Id: I0e99217fea1de03135b86e007fcb2a3ff6c2e257
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6df5b1c2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6df5b1c2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6df5b1c2
Branch: refs/heads/branch-dev-logsearch
Commit: 6df5b1c24e5c2cbe62caafdaea79dc1e65b5e916
Parents: 3013589
Author: oleewere <ol...@gmail.com>
Authored: Mon Sep 12 21:35:08 2016 +0200
Committer: oleewere <ol...@gmail.com>
Committed: Mon Oct 3 11:56:22 2016 +0200
----------------------------------------------------------------------
.../ambari-logsearch-portal/pom.xml | 10 +
.../logsearch/common/ExternalServerClient.java | 4 +-
.../logsearch/common/LogSearchConstants.java | 66 +-
.../apache/ambari/logsearch/common/LogType.java | 34 +
.../ambari/logsearch/common/MessageData.java | 165 ++
.../ambari/logsearch/common/MessageEnums.java | 10 +-
.../ambari/logsearch/common/VResponse.java | 164 ++
.../logsearch/conf/ApplicationConfig.java | 13 +
.../ambari/logsearch/conf/SolrConfig.java | 11 +
.../AbstractAuditLogRequestQueryConverter.java | 59 +
.../converter/AbstractConverterAware.java | 47 +
.../AbstractDateRangeFacetQueryConverter.java | 55 +
.../AbstractLogRequestFacetQueryConverter.java | 85 +
.../AbstractLogRequestQueryConverter.java | 39 +
.../AbstractOperationHolderConverter.java | 160 ++
.../AbstractSearchRequestQueryConverter.java | 53 +
...AbstractServiceLogRequestQueryConverter.java | 44 +
.../AuditBarGraphRequestQueryConverter.java | 46 +
.../AuditComponentsRequestQueryConverter.java | 62 +
.../AuditLogRequestQueryConverter.java | 44 +
.../AuditServiceLoadRequestQueryConverter.java | 52 +
.../BaseServiceLogRequestQueryConverter.java | 86 +
.../FieldAuditLogRequestQueryConverter.java | 54 +
...ServiceLogAnyGraphRequestQueryConverter.java | 52 +
...eLogComponentLevelRequestQueryConverter.java | 66 +
...eLogComponentRequestFacetQueryConverter.java | 68 +
...rviceLogLevelCountRequestQueryConverter.java | 52 +
...eLogLevelDateRangeRequestQueryConverter.java | 61 +
...erviceLogTreeRequestFacetQueryConverter.java | 69 +
...erviceLogTruncatedRequestQueryConverter.java | 95 +
.../StringFieldFacetQueryConverter.java | 44 +
.../UserConfigRequestQueryConverter.java | 71 +
.../UserExportRequestQueryConverter.java | 55 +
.../ambari/logsearch/dao/AuditSolrDao.java | 23 +-
.../logsearch/dao/ServiceLogsSolrDao.java | 21 +-
.../ambari/logsearch/dao/SolrAliasDao.java | 8 +-
.../ambari/logsearch/dao/SolrCollectionDao.java | 4 +-
.../ambari/logsearch/dao/SolrDaoBase.java | 99 +-
.../logsearch/dao/SolrSchemaFieldDao.java | 24 +-
.../ambari/logsearch/dao/UserConfigSolrDao.java | 67 +-
.../ambari/logsearch/doc/DocConstants.java | 18 +-
.../logsearch/graph/GraphDataGenerator.java | 625 +++---
.../logsearch/graph/GraphDataGeneratorBase.java | 169 --
.../logsearch/manager/AuditLogsManager.java | 481 +----
.../ambari/logsearch/manager/ManagerBase.java | 169 +-
.../ambari/logsearch/manager/PublicManager.java | 4 +-
.../logsearch/manager/ServiceLogsManager.java | 1771 +++---------------
.../logsearch/manager/SessionManager.java | 5 +-
.../logsearch/manager/UserConfigManager.java | 199 +-
.../model/common/LogFeederDataMap.java | 50 +
.../model/common/LogfeederFilterData.java | 87 +
.../model/request/FieldParamDefinition.java | 2 +-
.../model/request/LogParamDefinition.java | 7 +
.../request/LogTruncatedParamDefinition.java | 4 +-
.../model/request/QueryParamDefinition.java | 32 -
.../request/ServiceLogParamDefinition.java | 13 -
.../model/request/TopParamDefinition.java | 31 +
.../model/request/impl/AnyGraphRequest.java | 109 --
.../request/impl/AuditBarGraphRequest.java | 2 +-
.../request/impl/AuditComponentRequest.java | 25 +
.../model/request/impl/AuditLogRequest.java | 2 +-
.../request/impl/AuditServiceLoadRequest.java | 25 +
.../model/request/impl/BaseAuditLogRequest.java | 53 -
.../model/request/impl/BaseLogRequest.java | 47 +-
.../request/impl/BaseServiceLogRequest.java | 54 +-
.../request/impl/FieldAuditLogRequest.java | 18 +-
.../model/request/impl/QueryRequest.java | 40 -
.../request/impl/ServiceAnyGraphRequest.java | 28 +-
.../impl/ServiceExtremeDatesRequest.java | 41 -
.../impl/ServiceLogAggregatedInfoRequest.java | 25 +
.../impl/ServiceLogComponentHostRequest.java | 25 +
.../impl/ServiceLogComponentLevelRequest.java | 25 +
.../impl/ServiceLogHostComponentRequest.java | 39 +
.../impl/ServiceLogLevelCountRequest.java | 25 +
.../impl/ServiceLogTruncatedRequest.java | 6 +-
.../model/request/impl/SimpleQueryRequest.java | 42 -
.../logsearch/model/response/TemplateData.java | 36 +
.../model/response/UserConfigData.java | 108 ++
.../response/UserConfigDataListResponse.java | 55 +
.../ambari/logsearch/query/QueryGeneration.java | 340 ----
.../logsearch/query/QueryGenerationBase.java | 282 ---
.../query/SearchCriteriaConstants.java | 70 -
.../AbstractCommonAuditLogRequestConverter.java | 44 -
.../AbstractCommonSearchRequestConverter.java | 55 -
...bstractCommonServiceLogRequestConverter.java | 51 -
.../query/converter/AbstractConverterAware.java | 47 -
.../converter/AnyGraphRequestConverter.java | 39 -
.../AuditBarGraphRequestConverter.java | 34 -
.../converter/AuditLogRequestConverter.java | 34 -
.../converter/BaseAuditLogRequestConverter.java | 33 -
.../BaseServiceLogRequestConverter.java | 33 -
.../FieldAuditLogRequestConverter.java | 34 -
.../FieldBarGraphRequestConverter.java | 35 -
.../ServiceAnyGraphRequestConverter.java | 39 -
.../ServiceExtremeDatesRequestConverter.java | 34 -
.../converter/ServiceGraphRequestConverter.java | 34 -
.../ServiceLogExportRequestConverter.java | 35 -
.../converter/ServiceLogRequestConverter.java | 39 -
.../ServiceLogTruncatedRequestConverter.java | 36 -
.../converter/SimpleQueryRequestConverter.java | 35 -
.../converter/UserConfigRequestConverter.java | 36 -
.../converter/UserExportRequestConverter.java | 36 -
.../query/model/AnyGraphSearchCriteria.java | 77 -
.../model/AuditBarGraphSearchCriteria.java | 33 -
.../query/model/AuditLogSearchCriteria.java | 33 -
.../query/model/CommonSearchCriteria.java | 95 -
.../model/CommonServiceLogSearchCriteria.java | 88 -
.../model/FieldAuditBarGraphSearchCriteria.java | 32 -
.../model/FieldAuditLogSearchCriteria.java | 32 -
.../logsearch/query/model/SearchCriteria.java | 135 --
.../model/ServiceAnyGraphSearchCriteria.java | 60 -
.../model/ServiceExtremeDatesCriteria.java | 32 -
.../query/model/ServiceGraphSearchCriteria.java | 32 -
.../model/ServiceLogExportSearchCriteria.java | 40 -
.../query/model/ServiceLogSearchCriteria.java | 65 -
.../ServiceLogTruncatedSearchCriteria.java | 48 -
.../query/model/UserConfigSearchCriteria.java | 48 -
.../query/model/UserExportSearchCriteria.java | 31 -
.../logsearch/rest/AuditLogsResource.java | 79 +-
.../ambari/logsearch/rest/PublicResource.java | 4 +-
.../logsearch/rest/ServiceLogsResource.java | 88 +-
.../logsearch/rest/UserConfigResource.java | 39 +-
.../ambari/logsearch/solr/SolrConstants.java | 113 ++
.../logsearch/solr/model/SolrAuditLogData.java | 51 +-
.../logsearch/solr/model/SolrCommonLogData.java | 36 +-
.../solr/model/SolrComponentTypeLogData.java | 4 +-
.../logsearch/solr/model/SolrHostLogData.java | 4 +-
.../solr/model/SolrServiceLogData.java | 50 +-
.../apache/ambari/logsearch/util/BizUtil.java | 261 ---
.../apache/ambari/logsearch/util/DateUtil.java | 9 +
.../ambari/logsearch/util/DownloadUtil.java | 176 ++
.../apache/ambari/logsearch/util/FileUtil.java | 84 -
.../ambari/logsearch/util/RESTErrorUtil.java | 6 +-
.../apache/ambari/logsearch/util/SolrUtil.java | 305 +--
.../org/apache/ambari/logsearch/view/VHost.java | 44 -
.../org/apache/ambari/logsearch/view/VList.java | 243 ---
.../ambari/logsearch/view/VLogfeederFilter.java | 91 -
.../logsearch/view/VLogfeederFilterWrapper.java | 55 -
.../apache/ambari/logsearch/view/VMessage.java | 165 --
.../apache/ambari/logsearch/view/VResponse.java | 164 --
.../apache/ambari/logsearch/view/VSummary.java | 103 -
.../ambari/logsearch/view/VUserConfig.java | 104 -
.../ambari/logsearch/view/VUserConfigList.java | 70 -
.../LogsearchKRBAuthenticationFilter.java | 1 -
.../LogsearchAuthenticationProvider.java | 4 +-
...rchExternalServerAuthenticationProvider.java | 9 +-
.../LogsearchFileAuthenticationProvider.java | 4 +-
.../LogsearchLdapAuthenticationProvider.java | 4 +-
.../LogsearchSimpleAuthenticationProvider.java | 4 +-
.../src/main/resources/default.properties | 1 -
.../main/resources/templates/audit_log_txt.ftl | 42 +
.../resources/templates/service_log_txt.ftl | 36 +
.../scripts/collection_bases/VLogListBase.js | 2 +-
.../src/main/webapp/scripts/utils/ViewUtils.js | 2 +-
.../scripts/views/audit/AuditAggregatedView.js | 6 +-
.../scripts/views/audit/AuditTabLayoutView.js | 4 +-
.../views/dashboard/ComponentListView.js | 2 +-
.../scripts/views/dashboard/LogLevelBoxView.js | 2 +-
.../views/filter/CreateLogfeederFilterView.js | 6 +-
.../views/tabs/HierarchyTabLayoutView.js | 5 +-
.../webapp/scripts/views/tabs/LogFileView.js | 94 +-
.../troubleshoot/TroubleShootLayoutView.js | 6 +-
.../src/main/webapp/static/schema_fields.json | 2 +-
.../webapp/templates/tabs/LogFileView_tmpl.html | 50 +-
.../converter/AbstractRequestConverterTest.java | 42 +
.../AuditBarGraphRequestQueryConverterTest.java | 62 +
...AuditComponentRequestQueryConverterTest.java | 66 +
.../converter/AuditLogRequestConverterTest.java | 64 +
...ditServiceLoadRequestQueryConverterTest.java | 61 +
...BaseServiceLogRequestQueryConverterTest.java | 70 +
.../FieldAuditLogRequestQueryConverterTest.java | 61 +
.../ServiceLogAnyGraphRequestConverterTest.java | 62 +
...ComponentLevelRequestQueryConverterTest.java | 65 +
...ComponentRequestFacetQueryConverterTest.java | 67 +
...eLogLevelCountRequestQueryConverterTest.java | 62 +
...LevelDateRangeRequestQueryConverterTest.java | 68 +
...ceLogTreeRequestFacetQueryConverterTest.java | 65 +
...ceLogTruncatedRequestQueryConverterTest.java | 64 +
.../StringFieldFacetQueryConverterTest.java | 48 +
.../UserConfigRequestQueryConverterTest.java | 54 +
.../UserExportRequestQueryConverterTest.java | 63 +
.../logging/LoggingRequestHelperImpl.java | 2 +-
182 files changed, 5294 insertions(+), 7461 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/pom.xml b/ambari-logsearch/ambari-logsearch-portal/pom.xml
index a1d1bfc..5485ca1 100755
--- a/ambari-logsearch/ambari-logsearch-portal/pom.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/pom.xml
@@ -757,5 +757,15 @@
<artifactId>spring-data-solr</artifactId>
<version>${spring-data-solr.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.20</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/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 9682a3d..c476b9d 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,6 +22,7 @@ import java.util.List;
import java.util.Map;
import javax.inject.Inject;
+import javax.inject.Named;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
@@ -33,12 +34,11 @@ import org.apache.log4j.Logger;
import org.glassfish.jersey.client.JerseyClient;
import org.glassfish.jersey.client.JerseyClientBuilder;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.springframework.stereotype.Component;
/**
* Layer to send REST request to External server using jersey client
*/
-@Component
+@Named
public class ExternalServerClient {
private static Logger LOG = Logger.getLogger(ExternalServerClient.class);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/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 d9d3b86..b13768f 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
@@ -29,7 +29,7 @@ public class LogSearchConstants {
public static final String FATAL = "FATAL";
public static final String UNKNOWN = "UNKNOWN";
- public static final String[] SUPPORTED_LOG_LEVEL ={FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN};
+ public static final String[] SUPPORTED_LOG_LEVELS = {FATAL, ERROR, WARN, INFO, DEBUG, TRACE, UNKNOWN};
// Application Constants
public static final String HOST = "H";
@@ -37,49 +37,10 @@ public class LogSearchConstants {
public static final String SCROLL_TYPE_AFTER = "after";
public static final String SCROLL_TYPE_BEFORE = "before";
- // UserConfig Constants
- public static final String ID = "id";
- public static final String USER_NAME = "username";
- public static final String VALUES = "jsons";
- public static final String FILTER_NAME = "filtername";
- public static final String ROW_TYPE = "rowtype";
- public static final String COMPOSITE_KEY = "composite_filtername-username";
- public static final String SHARE_NAME_LIST = "share_username_list";
-
- // SOLR Document Constants for ServiceLogs
- public static final String BUNDLE_ID = "bundle_id";
- public static final String LOGTIME = "logtime";
- public static final String SEQUNCE_ID = "seq_num";
- public static final String SOLR_COMPONENT = "type";
- public static final String SOLR_LOG_MESSAGE = "log_message";
- public static final String SOLR_KEY_LOG_MESSAGE = "key_log_message";
- public static final String SOLR_HOST = "host";
- public static final String SOLR_LEVEL = "level";
- public static final String SOLR_THREAD_NAME = "thread_name";
- public static final String SOLR_LOGGER_NAME = "logger_name";
- public static final String SOLR_FILE = "file";
- public static final String SOLR_LINE_NUMBER = "line_number";
- public static final String SOLR_PATH = "path";
-
- //SOLR Document Constant for audit log
- public static final String AUDIT_COMPONENT = "repo";
- public static final String AUDIT_EVTTIME = "evtTime";
- public static final String AUDIT_REQUEST_USER = "reqUser";
-
- // Operator's
- public static final String MINUS_OPERATOR = "-";
- public static final String NO_OPERATOR = "";
-
- //operation
- public static final String EXCLUDE_QUERY = "excludeQuery";
- public static final String INCLUDE_QUERY = "includeQuery";
-
// Seprator's
public static final String I_E_SEPRATOR = "\\|i\\:\\:e\\|";
//SUFFIX
- public static final String UI_SUFFIX = "@UI@";
- public static final String SOLR_SUFFIX = "@Solr@";
public static final String NGRAM_SUFFIX = "ngram_";
//Date Format for SOLR
@@ -90,41 +51,23 @@ public class LogSearchConstants {
public static final String ASCENDING_ORDER = "asc";
public static final String DESCENDING_ORDER = "desc";
- //Solr Facet Sort By
- public static final String FACET_INDEX = "index";
- public static final String FACET_COUNT = "count";
-
// logfeeder
public static final String LOGFEEDER_FILTER_NAME = "log_feeder_config";
- public static final String LIST_SEPARATOR = ",";
-
+
public static final String SORT = "sort";
- public static final String FL = "fl";
//Facet Constant
public static final String FACET_FIELD = "facet.field";
- public static final String FACET_MINCOUNT = "facet.mincount";
- public static final String FACET_JSON_FIELD = "json.facet";
public static final String FACET_PIVOT = "facet.pivot";
public static final String FACET_PIVOT_MINCOUNT = "facet.pivot.mincount";
- public static final String FACET_DATE = "facet.date";
- public static final String FACET_DATE_START = "facet.date.start";
- public static final String FACET_DATE_END = "facet.date.end";
- public static final String FACET_DATE_GAP = "facet.date.gap";
- public static final String FACET_RANGE = "facet.range";
- public static final String FACET_RANGE_START = "facet.range.start";
- public static final String FACET_RANGE_END = "facet.range.end";
- 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_INDEX = "index";
// 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_TOP = "top";
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";
@@ -151,7 +94,6 @@ public class LogSearchConstants {
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";
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java
new file mode 100644
index 0000000..2e6cddb
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/LogType.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+public enum LogType {
+ SERVICE("Service"),
+ AUDIT("Audit");
+
+ private String label;
+
+ private LogType(String label) {
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageData.java
new file mode 100644
index 0000000..34c83ee
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageData.java
@@ -0,0 +1,165 @@
+/*
+* 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 javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class MessageData implements java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Message key
+ */
+ protected String name;
+ /**
+ * Resource bundle key
+ */
+ protected String rbKey;
+ /**
+ * Message description. Use rbKey for doing localized lookup
+ */
+ protected String message;
+ /**
+ * Id of the object to which this message is related to
+ */
+ protected Long objectId;
+ /**
+ * Name of the field or attribute to which this message is related to
+ */
+ protected String fieldName;
+
+ /**
+ * This method sets the value to the member attribute <b>name</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param name
+ * Value to set member attribute <b>name</b>
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>name</b>
+ *
+ * @return String - value of member attribute <b>name</b>.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>rbKey</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param rbKey
+ * Value to set member attribute <b>rbKey</b>
+ */
+ public void setRbKey(String rbKey) {
+ this.rbKey = rbKey;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>rbKey</b>
+ *
+ * @return String - value of member attribute <b>rbKey</b>.
+ */
+ public String getRbKey() {
+ return this.rbKey;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>message</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param message
+ * Value to set member attribute <b>message</b>
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>message</b>
+ *
+ * @return String - value of member attribute <b>message</b>.
+ */
+ public String getMessage() {
+ return this.message;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>objectId</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param objectId
+ * Value to set member attribute <b>objectId</b>
+ */
+ public void setObjectId(Long objectId) {
+ this.objectId = objectId;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>objectId</b>
+ *
+ * @return Long - value of member attribute <b>objectId</b>.
+ */
+ public Long getObjectId() {
+ return this.objectId;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>fieldName</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param fieldName
+ * Value to set member attribute <b>fieldName</b>
+ */
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>fieldName</b>
+ *
+ * @return String - value of member attribute <b>fieldName</b>.
+ */
+ public String getFieldName() {
+ return this.fieldName;
+ }
+
+ /**
+ * This return the bean content in string format
+ *
+ * @return formatedStr
+ */
+ public String toString() {
+ String str = "MessageData={";
+ str += super.toString();
+ str += "name={" + name + "} ";
+ str += "rbKey={" + rbKey + "} ";
+ str += "message={" + message + "} ";
+ str += "objectId={" + objectId + "} ";
+ str += "fieldName={" + fieldName + "} ";
+ str += "}";
+ return str;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageEnums.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageEnums.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageEnums.java
index 786cf99..c0a7f32 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageEnums.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/MessageEnums.java
@@ -18,8 +18,6 @@
*/
package org.apache.ambari.logsearch.common;
-import org.apache.ambari.logsearch.view.VMessage;
-
public enum MessageEnums {
// Common Errors
@@ -51,16 +49,16 @@ public enum MessageEnums {
this.messageDesc = messageDesc;
}
- public VMessage getMessage() {
- VMessage msg = new VMessage();
+ public MessageData getMessage() {
+ MessageData msg = new MessageData();
msg.setName(this.toString());
msg.setRbKey(rbKey);
msg.setMessage(messageDesc);
return msg;
}
- public VMessage getMessage(Long objectId, String fieldName) {
- VMessage msg = new VMessage();
+ public MessageData getMessage(Long objectId, String fieldName) {
+ MessageData msg = new MessageData();
msg.setName(this.toString());
msg.setRbKey(rbKey);
msg.setMessage(messageDesc);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/VResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/VResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/VResponse.java
new file mode 100644
index 0000000..0c052ab
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/common/VResponse.java
@@ -0,0 +1,164 @@
+/*
+ * 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.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class VResponse implements
+ java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Enum values for ResponseStatus
+ */
+ /**
+ * STATUS_SUCCESS is an element of enum ResponseStatus. Its value is
+ * "STATUS_SUCCESS".
+ */
+ public static final int STATUS_SUCCESS = 0;
+ /**
+ * STATUS_ERROR is an element of enum ResponseStatus. Its value is
+ * "STATUS_ERROR".
+ */
+ public static final int STATUS_ERROR = 1;
+ /**
+ * STATUS_VALIDATION is an element of enum ResponseStatus. Its value is
+ * "STATUS_VALIDATION".
+ */
+ public static final int STATUS_VALIDATION = 2;
+ /**
+ * STATUS_WARN is an element of enum ResponseStatus. Its value is
+ * "STATUS_WARN".
+ */
+ public static final int STATUS_WARN = 3;
+ /**
+ * STATUS_INFO is an element of enum ResponseStatus. Its value is
+ * "STATUS_INFO".
+ */
+ public static final int STATUS_INFO = 4;
+ /**
+ * STATUS_PARTIAL_SUCCESS is an element of enum ResponseStatus. Its value is
+ * "STATUS_PARTIAL_SUCCESS".
+ */
+ public static final int STATUS_PARTIAL_SUCCESS = 5;
+
+ /**
+ * Max value for enum ResponseStatus_MAX
+ */
+ public static final int ResponseStatus_MAX = 5;
+
+ /**
+ * Status code This attribute is of type enum Response::ResponseStatus
+ */
+ protected int statusCode;
+ /**
+ * Message description
+ */
+ protected String msgDesc;
+ /**
+ * List of messages
+ */
+ protected List<MessageData> messageList;
+
+ /**
+ * Default constructor. This will set all the attributes to default value.
+ */
+ public VResponse() {
+ statusCode = 0;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>statusCode</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param statusCode
+ * Value to set member attribute <b>statusCode</b>
+ */
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>statusCode</b>
+ *
+ * @return int - value of member attribute <b>statusCode</b>.
+ */
+ public int getStatusCode() {
+ return this.statusCode;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>msgDesc</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param msgDesc
+ * Value to set member attribute <b>msgDesc</b>
+ */
+ public void setMsgDesc(String msgDesc) {
+ this.msgDesc = msgDesc;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>msgDesc</b>
+ *
+ * @return String - value of member attribute <b>msgDesc</b>.
+ */
+ public String getMsgDesc() {
+ return this.msgDesc;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>messageList</b>.
+ * You cannot set null to the attribute.
+ *
+ * @param messageList
+ * Value to set member attribute <b>messageList</b>
+ */
+ public void setMessageList(List<MessageData> messageList) {
+ this.messageList = messageList;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>messageList</b>
+ *
+ * @return List<MessageData> - value of member attribute <b>messageList</b>.
+ */
+ public List<MessageData> getMessageList() {
+ return this.messageList;
+ }
+
+ /**
+ * This return the bean content in string format
+ *
+ * @return formatedStr
+ */
+ public String toString() {
+ String str = "VResponse={";
+ str += super.toString();
+ str += "statusCode={" + statusCode + "} ";
+ str += "msgDesc={" + msgDesc + "} ";
+ str += "messageList={" + messageList + "} ";
+ str += "}";
+ return str;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/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
index b279a83..82a09b2 100644
--- 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
@@ -18,12 +18,16 @@
*/
package org.apache.ambari.logsearch.conf;
+import freemarker.template.TemplateException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean;
+
+import java.io.IOException;
@Configuration
@ComponentScan("org.apache.ambari.logsearch")
@@ -42,4 +46,13 @@ public class ApplicationConfig {
return conversionServiceFactoryBean;
}
+ @Bean
+ public freemarker.template.Configuration freemarkerConfiguration() throws IOException, TemplateException {
+ FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
+ factoryBean.setPreferFileSystemAccess(false);
+ factoryBean.setTemplateLoaderPath("classpath:/templates");
+ factoryBean.afterPropertiesSet();
+ return factoryBean.getObject();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/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
index 7508fb1..4868409 100644
--- 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
@@ -18,6 +18,7 @@
*/
package org.apache.ambari.logsearch.conf;
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
import org.apache.ambari.logsearch.solr.AmbariSolrCloudClient;
import org.apache.ambari.logsearch.solr.AmbariSolrCloudClientBuilder;
import org.apache.commons.lang.StringUtils;
@@ -79,6 +80,16 @@ public class SolrConfig {
solrUserConfigPropsConfig.getCollection()));
}
+ @Bean(name = "serviceSolrFieldDao")
+ public SolrSchemaFieldDao serviceSolrFieldDao() {
+ return new SolrSchemaFieldDao();
+ }
+
+ @Bean(name = "auditSolrFieldDao")
+ public SolrSchemaFieldDao auditSolrFieldDao() {
+ return new SolrSchemaFieldDao();
+ }
+
private CloudSolrClient createClient(String solrUrl, String zookeeperConnectString, String defaultCollection) {
if (StringUtils.isNotEmpty(zookeeperConnectString)) {
CloudSolrClient cloudSolrClient = new CloudSolrClient(zookeeperConnectString);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java
new file mode 100644
index 0000000..e4bce01
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.Query;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+
+public abstract class AbstractAuditLogRequestQueryConverter<SOURCE extends BaseLogRequest, RESULT extends Query>
+ extends AbstractLogRequestQueryConverter<SOURCE, RESULT>{
+
+ @Override
+ public Sort sort(SOURCE request) {
+ String sortBy = request.getSortBy();
+ String sortType = request.getSortType();
+ Sort.Order defaultSortOrder;
+ if (StringUtils.isNotBlank(sortBy)) {
+ Sort.Direction direction = StringUtils.equals(sortType , LogSearchConstants.ASCENDING_ORDER) ? Sort.Direction.ASC : Sort.Direction.DESC;
+ defaultSortOrder = new Sort.Order(direction, sortBy);
+ } else {
+ defaultSortOrder = new Sort.Order(Sort.Direction.DESC, AUDIT_EVTTIME);
+ }
+ Sort.Order secuqnceIdOrder = new Sort.Order(Sort.Direction.DESC, SEQUENCE_ID);
+ return new Sort(defaultSortOrder, secuqnceIdOrder);
+ }
+
+ @Override
+ public void addComponentFilters(SOURCE request, RESULT query) {
+ List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
+ List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
+ addInFilterQuery(query, AUDIT_COMPONENT, includeTypes);
+ addInFilterQuery(query, AUDIT_COMPONENT, excludeTypes, true);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java
new file mode 100644
index 0000000..a4db91f
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java
@@ -0,0 +1,47 @@
+/*
+ * 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.converter;
+
+import org.springframework.core.convert.ConversionService;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.core.convert.converter.ConverterRegistry;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public abstract class AbstractConverterAware<SOURCE, RESULT> implements Converter<SOURCE, RESULT> {
+
+ @Inject
+ @Named("conversionService")
+ private ConversionService conversionService;
+
+ public ConversionService getConversionService() {
+ return conversionService;
+ }
+
+ @PostConstruct
+ private void register() {
+ if (conversionService instanceof ConverterRegistry) {
+ ((ConverterRegistry) conversionService).addConverter(this);
+ } else {
+ throw new IllegalStateException("Can't register Converter to ConverterRegistry");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java
new file mode 100644
index 0000000..2143f56
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java
@@ -0,0 +1,55 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import java.util.Locale;
+
+public abstract class AbstractDateRangeFacetQueryConverter<SOURCE extends DateRangeParamDefinition & UnitParamDefinition>
+ extends AbstractOperationHolderConverter<SOURCE , SolrQuery> {
+
+ @Override
+ public SolrQuery convert(SOURCE request) {
+ SolrQuery solrQuery = new SolrQuery();
+ String unit = StringUtils.defaultIfEmpty(request.getUnit(), "+1HOUR");
+ solrQuery.setQuery("*:*");
+ solrQuery.setFacet(true);
+ solrQuery.addFacetPivotField("{!range=r1}" + getTypeFieldName());
+ solrQuery.setFacetMinCount(1);
+ solrQuery.setFacetLimit(-1);
+ solrQuery.setFacetSort(LogSearchConstants.FACET_INDEX);
+ solrQuery.add("facet.range", "{!tag=r1}" + getDateFieldName());
+ solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.start"}), request.getFrom());
+ solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.end"}), request.getTo());
+ solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.gap"}), unit);
+ solrQuery.remove("sort");
+ solrQuery.setRows(0);
+ solrQuery.setStart(0);
+ return solrQuery;
+ }
+
+ public abstract String getDateFieldName();
+
+ public abstract String getTypeFieldName();
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java
new file mode 100644
index 0000000..9dbab24
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java
@@ -0,0 +1,85 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+public abstract class AbstractLogRequestFacetQueryConverter<SOURCE extends BaseLogRequest> extends AbstractOperationHolderConverter<SOURCE, SimpleFacetQuery>{
+
+ @Override
+ public SimpleFacetQuery convert(SOURCE request) {
+ String fromValue = StringUtils.isNotEmpty(request.getFrom()) ? request.getFrom() : "*";
+ String toValue = StringUtils.isNotEmpty(request.getTo()) ? request.getTo() : "*";
+ Criteria criteria = new SimpleStringCriteria("*:*");
+ SimpleFacetQuery facetQuery = new SimpleFacetQuery();
+ facetQuery.addCriteria(criteria);
+ SimpleFilterQuery simpleFilterQuery = new SimpleFilterQuery();
+ simpleFilterQuery.addCriteria(new SimpleStringCriteria(getDateTimeField() + ":[" + fromValue +" TO "+ toValue+ "]" ));
+ facetQuery.addFilterQuery(simpleFilterQuery);
+ FacetOptions facetOptions = new FacetOptions();
+ facetOptions.setFacetMinCount(1);
+ facetOptions.setFacetSort(getFacetSort());
+ appendFacetOptions(facetOptions, request);
+ addIncludeFieldValues(facetQuery, StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
+ addExcludeFieldValues(facetQuery, StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
+ facetQuery.setFacetOptions(facetOptions);
+ facetQuery.setRows(0);
+ addComponentFilters(facetQuery, request);
+ appendFacetQuery(facetQuery, request);
+ return facetQuery;
+ }
+
+ public abstract FacetOptions.FacetSort getFacetSort();
+
+ public abstract String getDateTimeField();
+
+ public abstract LogType getLogType();
+
+ public void appendFacetQuery(SimpleFacetQuery facetQuery, SOURCE request) {
+ }
+
+ public void appendFacetOptions(FacetOptions facetOptions, SOURCE request) {
+ facetOptions.setFacetLimit(-1);
+ }
+
+ private void addComponentFilters(SimpleFacetQuery query, SOURCE request) {
+ List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
+ List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
+ if (LogType.AUDIT.equals(getLogType())) {
+ addInFilterQuery(query, AUDIT_COMPONENT, includeTypes);
+ addInFilterQuery(query, AUDIT_COMPONENT, excludeTypes, true);
+ } else if (LogType.SERVICE.equals(getLogType())) {
+ addInFilterQuery(query, COMPONENT, includeTypes);
+ addInFilterQuery(query, COMPONENT, excludeTypes, true);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java
new file mode 100644
index 0000000..9b7c9d2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java
@@ -0,0 +1,39 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.springframework.data.solr.core.query.Query;
+
+public abstract class AbstractLogRequestQueryConverter<REQUEST_TYPE extends BaseLogRequest, QUERY_TYPE extends Query>
+ extends AbstractSearchRequestQueryConverter<REQUEST_TYPE, QUERY_TYPE> {
+
+ @Override
+ public QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query) {
+ addComponentFilters(request, query);
+ addIncludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
+ addExcludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
+ return extendLogQuery(request, query);
+ }
+
+ public abstract QUERY_TYPE extendLogQuery(REQUEST_TYPE request, QUERY_TYPE query);
+
+ public abstract void addComponentFilters(REQUEST_TYPE request, QUERY_TYPE query);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java
new file mode 100644
index 0000000..5945d72
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java
@@ -0,0 +1,160 @@
+/*
+ * 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.converter;
+
+import com.google.common.base.Splitter;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.Query;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOG_MESSAGE;
+
+public abstract class AbstractOperationHolderConverter <REQUEST_TYPE, QUERY_TYPE>
+ extends AbstractConverterAware<REQUEST_TYPE, QUERY_TYPE> {
+
+ @Inject
+ @Named("serviceSolrFieldDao")
+ private SolrSchemaFieldDao serviceSolrSchemaFieldDao;
+
+ @Inject
+ @Named("auditSolrFieldDao")
+ private SolrSchemaFieldDao auditSolrSchemaFieldDao;
+
+ public List<String> splitValueAsList(String value, String separator) {
+ return StringUtils.isNotEmpty(value) ? Splitter.on(separator).omitEmptyStrings().splitToList(value) : null;
+ }
+
+ public Query addEqualsFilterQuery(Query query, String field, String value) {
+ return this.addEqualsFilterQuery(query, field, value, false);
+ }
+
+ public Query addEqualsFilterQuery(Query query, String field, String value, boolean negate) {
+ if (StringUtils.isNotEmpty(value)) {
+ addFilterQuery(query, new Criteria(field).is(value), negate);
+ }
+ return query;
+ }
+
+ public Query addContainsFilterQuery(Query query, String field, String value) {
+ return this.addContainsFilterQuery(query, field, value, false);
+ }
+
+ public Query addContainsFilterQuery(Query query, String field, String value, boolean negate) {
+ if (StringUtils.isNotEmpty(value)) {
+ addFilterQuery(query, new Criteria(field).contains(value), negate);
+ }
+ return query;
+ }
+
+ public Query addInFilterQuery(Query query, String field, List<String> values) {
+ return this.addInFilterQuery(query, field, values, false);
+ }
+
+ public Query addInFilterQuery(Query query, String field, List<String> values, boolean negate) {
+ if (CollectionUtils.isNotEmpty(values)) {
+ addFilterQuery(query, new Criteria(field).is(values), negate);
+ }
+ return query;
+ }
+
+ public Query addRangeFilter(Query query, String field, String from, String to) {
+ return this.addRangeFilter(query, field, from, to, false);
+ }
+
+ public Query addRangeFilter(Query query, String field, String from, String to, boolean negate) { // TODO use criteria.between without escaping
+ String fromValue = StringUtils.defaultIfEmpty(from, "*");
+ String toValue = StringUtils.defaultIfEmpty(to, "*");
+ addFilterQuery(query, new SimpleStringCriteria(field + ":[" + fromValue +" TO "+ toValue + "]" ), negate);
+ return query;
+ }
+
+ public void addFilterQuery(Query query, Criteria criteria, boolean negate) {
+ if (negate) {
+ criteria.not();
+ }
+ query.addFilterQuery(new SimpleFilterQuery(criteria));
+ }
+
+ public Query addIncludeFieldValues(Query query, String fieldValuesMapStr) {
+ if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
+ List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
+ new TypeToken<List<HashMap<String, String>>>(){}.getType());
+ for (Map<String, String> criteriaMap : criterias) {
+ for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
+ escapeFieldValueByType(fieldEntry);
+ if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
+ addFilterQuery(query, new Criteria(fieldEntry.getKey()).contains(escapeFieldValueByType(fieldEntry)), false);
+ } else {
+ addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeFieldValueByType(fieldEntry)), false);
+ }
+ }
+ }
+ }
+ return query;
+ }
+
+ public Query addExcludeFieldValues(Query query, String fieldValuesMapStr) {
+ if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
+ List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
+ new TypeToken<List<HashMap<String, String>>>(){}.getType());
+ for (Map<String, String> criteriaMap : criterias) {
+ for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
+ escapeFieldValueByType(fieldEntry);
+ if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
+ addFilterQuery(query, new Criteria(fieldEntry.getKey()).contains(escapeFieldValueByType(fieldEntry)), true);
+ } else {
+ addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeFieldValueByType(fieldEntry)), true);
+ }
+ }
+ }
+ }
+ return query;
+ }
+
+ public abstract LogType getLogType();
+
+ private String escapeFieldValueByType(Map.Entry<String, String> fieldEntry) {
+ String escapedFieldValue;
+ if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
+ escapedFieldValue = SolrUtil.escapeForLogMessage(fieldEntry.getValue());
+ } else {
+ escapedFieldValue = SolrUtil.putWildCardByType(fieldEntry.getValue(), fieldEntry.getKey(), getSchemaFieldsTypeMapByLogType(getLogType()));
+ }
+ return escapedFieldValue;
+ }
+
+ private Map<String, String> getSchemaFieldsTypeMapByLogType(LogType logType) {
+ return LogType.AUDIT.equals(logType) ? auditSolrSchemaFieldDao.getSchemaFieldTypeMap() : serviceSolrSchemaFieldDao.getSchemaFieldTypeMap();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java
new file mode 100644
index 0000000..2604f13
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java
@@ -0,0 +1,53 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
+import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.Query;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public abstract class AbstractSearchRequestQueryConverter<REQUEST_TYPE extends CommonSearchRequest, QUERY_TYPE extends Query>
+ extends AbstractOperationHolderConverter<REQUEST_TYPE, QUERY_TYPE> {
+
+ @Override
+ public QUERY_TYPE convert(REQUEST_TYPE request) {
+ QUERY_TYPE query = createQuery();
+ int page = StringUtils.isNumeric(request.getPage()) ? new Integer(request.getPage()) : 0;
+ int pageSize = StringUtils.isNumeric(request.getPageSize()) ? new Integer(request.getPageSize()) : 99999;
+ PageRequest pageRequest = new PageRequest(page, pageSize, sort(request));
+ query.setPageRequest(pageRequest);
+ Criteria criteria = new SimpleStringCriteria("*:*");
+ query.addCriteria(criteria);
+ return extendSolrQuery(request, query);
+ }
+
+ public abstract QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query);
+
+ public abstract Sort sort(REQUEST_TYPE request);
+
+ public abstract QUERY_TYPE createQuery();
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java
new file mode 100644
index 0000000..e1cd077
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java
@@ -0,0 +1,44 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
+import org.springframework.data.solr.core.query.Query;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+
+public abstract class AbstractServiceLogRequestQueryConverter<REQUEST_TYPE extends BaseLogRequest, QUERY_TYPE extends Query>
+ extends AbstractLogRequestQueryConverter<REQUEST_TYPE, QUERY_TYPE> {
+
+ @Override
+ public LogType getLogType() {
+ return LogType.SERVICE;
+ }
+
+ @Override
+ public void addComponentFilters(REQUEST_TYPE request, QUERY_TYPE query) {
+ List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
+ List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
+ addInFilterQuery(query, COMPONENT, includeTypes);
+ addInFilterQuery(query, COMPONENT, excludeTypes, true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java
new file mode 100644
index 0000000..897bb64
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java
@@ -0,0 +1,46 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+
+@Named
+public class AuditBarGraphRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<AuditBarGraphRequest> {
+
+ @Override
+ public String getDateFieldName() {
+ return AUDIT_EVTTIME;
+ }
+
+ @Override
+ public String getTypeFieldName() {
+ return AUDIT_COMPONENT;
+ }
+
+ @Override
+ public LogType getLogType() {
+ return LogType.AUDIT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java
new file mode 100644
index 0000000..d81bdbf
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java
@@ -0,0 +1,62 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class AuditComponentsRequestQueryConverter extends AbstractSearchRequestQueryConverter<AuditComponentRequest, SimpleFacetQuery> {
+
+ @Override
+ public SimpleFacetQuery extendSolrQuery(AuditComponentRequest request, SimpleFacetQuery query) {
+ FacetOptions facetOptions = new FacetOptions(); // TODO: check that date filtering is needed or not
+ facetOptions.addFacetOnField(AUDIT_COMPONENT);
+ facetOptions.setFacetSort(FacetOptions.FacetSort.INDEX);
+ facetOptions.setFacetLimit(-1);
+ query.setFacetOptions(facetOptions);
+ return query;
+ }
+
+ @Override
+ public Sort sort(AuditComponentRequest request) {
+ Sort.Direction direction = StringUtils.equals(request.getSortType(), LogSearchConstants.DESCENDING_ORDER)
+ ? Sort.Direction.DESC : Sort.Direction.ASC;
+ return new Sort(new Sort.Order(direction, AUDIT_COMPONENT));
+ }
+
+ @Override
+ public SimpleFacetQuery createQuery() {
+ return new SimpleFacetQuery();
+ }
+
+ @Override
+ public LogType getLogType() {
+ return LogType.AUDIT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java
new file mode 100644
index 0000000..a2c1d81
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java
@@ -0,0 +1,44 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
+import org.springframework.data.solr.core.query.SimpleQuery;
+
+import javax.inject.Named;
+
+@Named
+public class AuditLogRequestQueryConverter extends AbstractAuditLogRequestQueryConverter<AuditLogRequest, SimpleQuery> {
+
+ @Override
+ public SimpleQuery extendLogQuery(AuditLogRequest request, SimpleQuery query) {
+ return query;
+ }
+
+ @Override
+ public SimpleQuery createQuery() {
+ return new SimpleQuery();
+ }
+
+ @Override
+ public LogType getLogType() {
+ return LogType.AUDIT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java
new file mode 100644
index 0000000..fb1c763
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java
@@ -0,0 +1,52 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class AuditServiceLoadRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<AuditServiceLoadRequest> {
+
+ @Override
+ public FacetOptions.FacetSort getFacetSort() {
+ return FacetOptions.FacetSort.COUNT;
+ }
+
+ @Override
+ public String getDateTimeField() {
+ return AUDIT_EVTTIME;
+ }
+
+ @Override
+ public LogType getLogType() {
+ return LogType.AUDIT;
+ }
+
+ @Override
+ public void appendFacetOptions(FacetOptions facetOptions, AuditServiceLoadRequest request) {
+ facetOptions.addFacetOnField(AUDIT_COMPONENT);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverter.java
new file mode 100644
index 0000000..4894bfb
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverter.java
@@ -0,0 +1,86 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.SimpleQuery;
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.KEY_LOG_MESSAGE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.PATH;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.BUNDLE_ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID;
+
+@Named
+public class BaseServiceLogRequestQueryConverter extends AbstractServiceLogRequestQueryConverter<BaseServiceLogRequest, SimpleQuery> {
+
+ @Override
+ public SimpleQuery extendLogQuery(BaseServiceLogRequest request, SimpleQuery query) {
+ List<String> levels = splitValueAsList(request.getLevel(), ",");
+ addContainsFilterQuery(query, KEY_LOG_MESSAGE, SolrUtil.escapeForStandardTokenizer(request.getiMessage()));
+ addContainsFilterQuery(query, KEY_LOG_MESSAGE, SolrUtil.escapeForStandardTokenizer(request.geteMessage()), true);
+ addEqualsFilterQuery(query, HOST, SolrUtil.escapeQueryChars(request.getHostName()));
+ addEqualsFilterQuery(query, PATH, SolrUtil.escapeQueryChars(request.getFileName()));
+ addEqualsFilterQuery(query, COMPONENT, SolrUtil.escapeQueryChars(request.getComponentName()));
+ addEqualsFilterQuery(query, BUNDLE_ID, request.getBundleId());
+ addInFilterQuery(query, LEVEL, levels);
+ addRangeFilter(query, LOGTIME, request.getFrom(), request.getTo());
+ return query;
+ }
+
+ @Override
+ public Sort sort(BaseServiceLogRequest request) {
+ String sortBy = request.getSortBy();
+ String sortType = request.getSortType();
+ Sort.Order defaultSortOrder;
+ if (StringUtils.isNotBlank(sortBy)) {
+ Sort.Direction direction = StringUtils.equals(sortType, LogSearchConstants.ASCENDING_ORDER) ? Sort.Direction.ASC : Sort.Direction.DESC;
+ defaultSortOrder = new Sort.Order(direction, sortBy);
+ } else {
+ defaultSortOrder = new Sort.Order(Sort.Direction.DESC, LOGTIME);
+ }
+ Sort.Order secuqnceIdOrder = new Sort.Order(Sort.Direction.DESC, SEQUENCE_ID);
+ return new Sort(defaultSortOrder, secuqnceIdOrder);
+ }
+
+ @Override
+ public SimpleQuery createQuery() {
+ return new SimpleQuery();
+ }
+
+ @Override
+ public LogType getLogType() {
+ return LogType.SERVICE;
+ }
+
+ @Override
+ public void addComponentFilters(BaseServiceLogRequest request, SimpleQuery query) {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
new file mode 100644
index 0000000..a4e613b
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
@@ -0,0 +1,54 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+
+@Named
+public class FieldAuditLogRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<FieldAuditLogRequest> {
+
+ @Override
+ public void appendFacetOptions(FacetOptions facetOptions, FieldAuditLogRequest request) {
+ facetOptions.addFacetOnPivot(request.getField(), AUDIT_COMPONENT);
+ facetOptions.setFacetLimit(request.getTop());
+ }
+
+ @Override
+ public FacetOptions.FacetSort getFacetSort() {
+ return FacetOptions.FacetSort.COUNT;
+ }
+
+ @Override
+ public String getDateTimeField() {
+ return AUDIT_EVTTIME;
+ }
+
+ @Override
+ public LogType getLogType() {
+ return LogType.AUDIT;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6df5b1c2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestQueryConverter.java
new file mode 100644
index 0000000..1d2a657
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestQueryConverter.java
@@ -0,0 +1,52 @@
+/*
+ * 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.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+
+import javax.inject.Named;
+
+@Named
+public class ServiceLogAnyGraphRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceAnyGraphRequest>{
+
+ @Override
+ public void appendFacetOptions(FacetOptions facetOptions, ServiceAnyGraphRequest request) {
+ facetOptions.addFacetOnField(LEVEL);
+ }
+
+ @Override
+ public FacetOptions.FacetSort getFacetSort() {
+ return FacetOptions.FacetSort.COUNT;
+ }
+
+ @Override
+ public String getDateTimeField() {
+ return LOGTIME;
+ }
+
+ @Override
+ public LogType getLogType() {
+ return LogType.SERVICE;
+ }
+}