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/09/05 16:28:21 UTC
[01/15] ambari git commit: AMBARI-18301. Log search,
url params description. (Dharmesh Makwana via oleewere)
Repository: ambari
Updated Branches:
refs/heads/branch-dev-logsearch e3d4c2612 -> 1d76f8fec
AMBARI-18301. Log search, url params description. (Dharmesh Makwana via oleewere)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0a10cbe2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0a10cbe2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0a10cbe2
Branch: refs/heads/branch-dev-logsearch
Commit: 0a10cbe2676162209f7f4a13b97a1f6621b78826
Parents: e3d4c26
Author: oleewere <ol...@gmail.com>
Authored: Fri Sep 2 12:02:39 2016 +0200
Committer: oleewere <ol...@gmail.com>
Committed: Fri Sep 2 12:02:39 2016 +0200
----------------------------------------------------------------------
.../ambari/logsearch/doc/DocConstants.java | 152 +++++++++----------
1 file changed, 76 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0a10cbe2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
index c14fc08..0ceb76b 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
@@ -21,96 +21,96 @@ package org.apache.ambari.logsearch.doc;
public class DocConstants {
public class CommonDescriptions {
- public static final String X_AXIS_D = "";
- public static final String Y_AXIS_D = "";
- public static final String STACK_BY_D = "";
- public static final String EXCLUDE_QUERY_D = "";
- public static final String INCLUDE_QUERY_D = "";
- public static final String MUST_BE_D = "";
- public static final String MUST_NOT_D = "";
- public static final String FROM_D = "";
- public static final String TO_D = "";
- public static final String UNIT_D = "";
- public static final String QUERY_D = "";
- public static final String COLUMN_QUERY_D = "";
- public static final String I_MESSAGE_D = "";
- public static final String G_E_MESSAGE_D = "";
- public static final String E_MESSAGE_D = "";
+ public static final String X_AXIS_D = "The column which can be value for x-axis in graph formation";
+ public static final String Y_AXIS_D = "The column which can be value for y-axis in graph formation";
+ public static final String STACK_BY_D = "The graph property for stacking the plot";
+ public static final String EXCLUDE_QUERY_D = "Exclude the values in query result e.g.: [{message:*timeout*}]";
+ public static final String INCLUDE_QUERY_D = "Include the values in query result e.g.: [{message:*exception*}]";
+ public static final String MUST_BE_D = "Include the components, comman separated values";
+ public static final String MUST_NOT_D = "Exclude the components, comman separated values";
+ public static final String FROM_D = "Date range param, start date";
+ public static final String TO_D = "Date range param, end date";
+ public static final String UNIT_D = "Aggregate the data with time gap as unit i.e 1MINUTE";
+ public static final String QUERY_D = "not required";
+ public static final String COLUMN_QUERY_D = "not required";
+ public static final String I_MESSAGE_D = "Include query which will query againt message column";
+ public static final String G_E_MESSAGE_D = "not required";
+ public static final String E_MESSAGE_D = "Exclude query which will query againt message column";
public static final String IS_LAST_PAGE_D = "";
- public static final String FIELD_D = "";
- public static final String FORMAT_D = "";
+ public static final String FIELD_D = "Get top ten values for particular field";
+ public static final String FORMAT_D = "File Export format, can be 'txt' or 'json'";
}
public class AuditOperationDescriptions {
- public static final String GET_AUDIT_SCHEMA_FIELD_LIST_OD = "";
- public static final String GET_AUDIT_LOGS_OD = "";
- public static final String GET_AUDIT_COMPONENTS_OD = "";
- public static final String GET_AUDIT_LINE_GRAPH_DATA_OD = "";
- public static final String GET_TOP_AUDIT_USERS_OD = "";
- public static final String GET_TOP_AUDIT_RESOURCES_OD = "";
- public static final String GET_TOP_AUDIT_COMPONENTS_OD = "";
- public static final String GET_LIVE_LOGS_COUNT_OD = "";
- public static final String GET_REQUEST_USER_LINE_GRAPH_OD = "";
- public static final String GET_ANY_GRAPH_DATA_OD = "";
- public static final String EXPORT_USER_TALBE_TO_TEXT_FILE_OD = "";
- public static final String GET_SERVICE_LOAD_OD = "";
+ public static final String GET_AUDIT_SCHEMA_FIELD_LIST_OD = "Get list of schema fields in audit collection";
+ public static final String GET_AUDIT_LOGS_OD = "Get the list of logs details";
+ public static final String GET_AUDIT_COMPONENTS_OD = "Get the list of audit components currently active or having data in Solr";
+ public static final String GET_AUDIT_LINE_GRAPH_DATA_OD = "Get the data required for line graph";
+ public static final String GET_TOP_AUDIT_USERS_OD = "Get the top audit users having maximum access";
+ public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resources having maximum access";
+ public static final String GET_TOP_AUDIT_COMPONENTS_OD = "not required";
+ public static final String GET_LIVE_LOGS_COUNT_OD = "not required";
+ public static final String GET_REQUEST_USER_LINE_GRAPH_OD = "not required";
+ public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
+ public static final String EXPORT_USER_TALBE_TO_TEXT_FILE_OD = "Export the tables shown on Audit tab";
+ public static final String GET_SERVICE_LOAD_OD = "The graph for showing the top users accessing the services";
}
public class ServiceDescriptions {
- public static final String LEVEL_D = "";
- public static final String ADVANCED_SEARCH_D = "";
- public static final String TREE_PARAMS_D = "";
- public static final String START_TIME_D = "";
- public static final String END_TIME_D = "";
- public static final String FILE_NAME_D = "";
- public static final String HOST_NAME_D = "";
- public static final String COMPONENT_NAME_D = "";
- public static final String FIND_D = "";
- public static final String ID_D = "";
- public static final String HOST_D = "";
- public static final String COMPONENT_D = "";
- public static final String KEYWORD_TYPE_D = "";
- public static final String TOKEN_D = "";
- public static final String SOURCE_LOG_ID_D = "";
- public static final String G_MUST_NOT_D = "";
- public static final String NUMBER_ROWS_D = "";
- public static final String SCROLL_TYPE_D = "";
- public static final String UTC_OFFSET_D = "";
+ public static final String LEVEL_D = "filter for log level";
+ public static final String ADVANCED_SEARCH_D = "not required";
+ public static final String TREE_PARAMS_D = "Host hierarchy shown on UI,filtering there is supported by this param";
+ public static final String START_TIME_D = "Date range param which is suportted from browser url";
+ public static final String END_TIME_D = "Date range param which is supported from browser url";
+ public static final String FILE_NAME_D = "File name filter which is supported from browser url";
+ public static final String HOST_NAME_D = "Host name filter which is supported from browser url";
+ public static final String COMPONENT_NAME_D = "Component name filter which is supported from browser url";
+ public static final String FIND_D = "Finding particular text on subsequent pages in case of table view with pagination";
+ public static final String ID_D = "Log id value for traversing to that particular record with that log id";
+ public static final String HOST_D = "filter for host";
+ public static final String COMPONENT_D = "filter for component";
+ public static final String KEYWORD_TYPE_D = "Serching the find param value in previous or next in paginated table";
+ public static final String TOKEN_D = "unique number used along with FIND_D. The request can be canceled using this token";
+ public static final String SOURCE_LOG_ID_D = "fetch the record set having that log Id";
+ public static final String G_MUST_NOT_D = "not required";
+ public static final String NUMBER_ROWS_D = "Getting rows after particular log entry - used in 'Preview' option";
+ public static final String SCROLL_TYPE_D = "Used in 'Preview' feature for getting records 'after' or 'before'";
+ public static final String UTC_OFFSET_D = "timezone offset";
}
public class ServiceOperationDescriptions {
- public static final String SEARCH_LOGS_OD = "";
- public static final String GET_HOSTS_OD = "";
- public static final String GET_COMPONENTS_OD = "";
- public static final String GET_AGGREGATED_INFO_OD = "";
- public static final String GET_LOG_LEVELS_COUNT_OD = "";
- public static final String GET_COMPONENTS_COUNT_OD = "";
- public static final String GET_HOSTS_COUNT_OD = "";
- public static final String GET_TREE_EXTENSION_OD = "";
- public static final String GET_HISTOGRAM_DATA_OD = "";
- public static final String CANCEL_FIND_REQUEST_OD = "";
- public static final String EXPORT_TO_TEXT_FILE_OD = "";
- public static final String GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD = "";
- public static final String GET_EXTREME_DATES_FOR_BUNDLE_ID_OD = "";
- public static final String GET_SERVICE_LOGS_FIELD_NAME_OD = "";
- public static final String GET_ANY_GRAPH_DATA_OD = "";
- public static final String GET_AFTER_BEFORE_LOGS_OD = "";
- public static final String GET_HOST_LIST_BY_COMPONENT_OD = "";
- public static final String GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD = "";
- public static final String GET_HADOOP_SERVICE_CONFIG_JSON_OD = "";
+ public static final String SEARCH_LOGS_OD = "Searching logs entry";
+ public static final String GET_HOSTS_OD = "Get the list of service hosts currently active or having data in Solr";
+ public static final String GET_COMPONENTS_OD = "Get the list of service components currently active or having data in Solr";
+ public static final String GET_AGGREGATED_INFO_OD = "not required";
+ public static final String GET_LOG_LEVELS_COUNT_OD = "Get Log levels with their counts";
+ public static final String GET_COMPONENTS_COUNT_OD = "Get components with their counts";
+ public static final String GET_HOSTS_COUNT_OD = "Get hosts with their counts";
+ public static final String GET_TREE_EXTENSION_OD = "Get host and compoenets hierarchy";
+ public static final String GET_HISTOGRAM_DATA_OD = "Get data for histogram";
+ public static final String CANCEL_FIND_REQUEST_OD = "Cancel the FIND_D param request using TOKEN_D";
+ public static final String EXPORT_TO_TEXT_FILE_OD = "Export the table data in file";
+ public static final String GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD = "Get components with log level distribution count";
+ public static final String GET_EXTREME_DATES_FOR_BUNDLE_ID_OD = "Get the start and end time of particular bundle_id";
+ public static final String GET_SERVICE_LOGS_FIELD_NAME_OD = "Get service logs schema fields name (Human readable)";
+ public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
+ public static final String GET_AFTER_BEFORE_LOGS_OD = "Preview feature data";
+ public static final String GET_HOST_LIST_BY_COMPONENT_OD = "Get host list of components";
+ public static final String GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD = "Get service logs schema fields";
+ public static final String GET_HADOOP_SERVICE_CONFIG_JSON_OD = "Get the json having meta data of services supported by logsearch";
}
public class LogFileDescriptions {
- public static final String HOST_D = "";
- public static final String COMPONENT_D = "";
- public static final String LOG_TYPE_D = "";
- public static final String TAIL_SIZE_D = "";
+ public static final String HOST_D = "not required";
+ public static final String COMPONENT_D = "not required";
+ public static final String LOG_TYPE_D = "not required";
+ public static final String TAIL_SIZE_D = "not required";
}
public class LogFileOperationDescriptions {
- public static final String SEARCH_LOG_FILES_OD = "";
- public static final String GET_LOG_FILE_TAIL_OD = "";
+ public static final String SEARCH_LOG_FILES_OD = "not required";
+ public static final String GET_LOG_FILE_TAIL_OD = "not required";
}
public class PublicOperationDescriptions {
@@ -118,9 +118,9 @@ public class DocConstants {
}
public class UserConfigDescriptions {
- public static final String USER_ID_D = "";
- public static final String FILTER_NAME_D = "";
- public static final String ROW_TYPE_D = "";
+ public static final String USER_ID_D = "Get config for a particular user id";
+ public static final String FILTER_NAME_D = "The saved query as filter in Solr, search is sopprted by this param";
+ public static final String ROW_TYPE_D = "Row type is solr to identify as filter query";
}
public class UserConfigOperationDescriptions {
[09/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
new file mode 100644
index 0000000..c4d14a9
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java
@@ -0,0 +1,1917 @@
+/*
+ * 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.manager;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TimeZone;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.inject.Inject;
+import javax.ws.rs.core.Response;
+
+import org.apache.ambari.logsearch.common.ConfigHelper;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.ambari.logsearch.common.PropertiesHelper;
+import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
+import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
+import org.apache.ambari.logsearch.graph.GraphDataGenerator;
+import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.CountData;
+import org.apache.ambari.logsearch.model.response.CountDataListResponse;
+import org.apache.ambari.logsearch.model.response.GraphData;
+import org.apache.ambari.logsearch.model.response.GraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.GroupListResponse;
+import org.apache.ambari.logsearch.model.response.LogData;
+import org.apache.ambari.logsearch.model.response.LogListResponse;
+import org.apache.ambari.logsearch.model.response.LogSearchResponse;
+import org.apache.ambari.logsearch.model.response.NameValueData;
+import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
+import org.apache.ambari.logsearch.model.response.NodeData;
+import org.apache.ambari.logsearch.model.response.NodeListResponse;
+import org.apache.ambari.logsearch.model.response.ServiceLogData;
+import org.apache.ambari.logsearch.model.response.ServiceLogResponse;
+import org.apache.ambari.logsearch.query.QueryGenerationBase;
+import org.apache.ambari.logsearch.solr.model.SolrComponentTypeLogData;
+import org.apache.ambari.logsearch.solr.model.SolrHostLogData;
+import org.apache.ambari.logsearch.solr.model.SolrServiceLogData;
+import org.apache.ambari.logsearch.util.BizUtil;
+import org.apache.ambari.logsearch.util.DateUtil;
+import org.apache.ambari.logsearch.util.FileUtil;
+import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.ambari.logsearch.view.VSummary;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.FacetField;
+import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.PivotField;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.RangeFacet;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import com.google.common.collect.Lists;
+
+@Component
+public class ServiceLogsManager extends ManagerBase<SolrServiceLogData, ServiceLogResponse> {
+
+ private static final Logger logger = Logger.getLogger(ServiceLogsManager.class);
+
+ private static List<String> cancelByDate = new CopyOnWriteArrayList<String>();
+
+ private static Map<String, String> mapUniqueId = new ConcurrentHashMap<String, String>();
+
+ private enum CONDITION {
+ OR, AND
+ }
+
+ @Inject
+ private ServiceLogsSolrDao serviceLogsSolrDao;
+ @Inject
+ private GraphDataGenerator graphDataGenerator;
+ @Inject
+ private SolrServiceLogConfig solrServiceLogConfig;
+
+ public ServiceLogResponse searchLogs(SearchCriteria searchCriteria) {
+ String keyword = (String) searchCriteria.getParamValue("keyword");
+ String logId = (String) searchCriteria.getParamValue("sourceLogId");
+ Boolean isLastPage = (Boolean) searchCriteria.getParamValue("isLastPage");
+
+ if (!StringUtils.isBlank(keyword)) {
+ try {
+ return (ServiceLogResponse) getPageByKeyword(searchCriteria);
+ } catch (SolrException | SolrServerException e) {
+ logger.error("Error while getting keyword=" + keyword, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ } else if (!StringUtils.isBlank(logId)) {
+ try {
+ return (ServiceLogResponse) getPageByLogId(searchCriteria);
+ } catch (SolrException e) {
+ logger.error("Error while getting keyword=" + keyword, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ } else if (isLastPage) {
+ SolrQuery lastPageQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ ServiceLogResponse logResponse = getLastPage(searchCriteria,LogSearchConstants.LOGTIME,serviceLogsSolrDao,lastPageQuery);
+ if(logResponse == null){
+ logResponse = new ServiceLogResponse();
+ }
+ return logResponse;
+ } else {
+ SolrQuery solrQuery = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+
+ solrQuery.setParam("event", "/service/logs");
+
+ return getLogAsPaginationProvided(solrQuery,
+ serviceLogsSolrDao);
+ }
+ }
+
+ public GroupListResponse getHosts() {
+ return getFields(LogSearchConstants.SOLR_HOST, SolrHostLogData.class);
+ }
+
+ private <T extends LogData> GroupListResponse getFields(String field, Class<T> clazz) {
+
+ SolrQuery solrQuery = new SolrQuery();
+ GroupListResponse collection = new GroupListResponse();
+ SolrUtil.setMainQuery(solrQuery, null);
+ SolrUtil.setFacetField(solrQuery,
+ field);
+ SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
+ try {
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if(response == null){
+ return collection;
+ }
+ FacetField facetField = response
+ .getFacetField(field);
+ if (facetField == null){
+ return collection;
+ }
+ List<Count> fieldList = facetField.getValues();
+ if (fieldList == null){
+ return collection;
+ }
+ SolrDocumentList docList = response.getResults();
+ if(docList == null){
+ return collection;
+ }
+ List<LogData> groupList = getLogDataListByFieldType(clazz, response, fieldList);
+
+ collection.setGroupList(groupList);
+ if(!docList.isEmpty()){
+ collection.setStartIndex((int) docList.getStart());
+ collection.setTotalCount(docList.getNumFound());
+ }
+ return collection;
+ } catch (IOException | SolrServerException | SolrException e) {
+ logger.error(e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ }
+
+ public GroupListResponse getComponents() {
+ return getFields(LogSearchConstants.SOLR_COMPONENT, SolrComponentTypeLogData.class);
+ }
+
+ public GraphDataListResponse getAggregatedInfo(SearchCriteria searchCriteria) {
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ String hierarchy = "host,type,level";
+ GraphDataListResponse graphInfo = new GraphDataListResponse();
+ try {
+ SolrUtil.setMainQuery(solrQuery, null);
+ SolrUtil.setFacetPivot(solrQuery, 1, hierarchy);
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if (response == null) {
+ return graphInfo;
+ }
+
+ List<List<PivotField>> hirarchicalPivotField = new ArrayList<List<PivotField>>();
+ List<GraphData> dataList = new ArrayList<>();
+ NamedList<List<PivotField>> namedList = response.getFacetPivot();
+ if (namedList != null) {
+ hirarchicalPivotField = namedList.getAll(hierarchy);
+ }
+ if (!hirarchicalPivotField.isEmpty()) {
+ dataList = buidGraphData(hirarchicalPivotField.get(0));
+ }
+ if (!dataList.isEmpty()) {
+ graphInfo.setGraphData(dataList);
+ }
+
+ return graphInfo;
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ public List<GraphData> buidGraphData(List<PivotField> pivotFields) {
+ List<GraphData> logList = new ArrayList<>();
+ if (pivotFields != null) {
+ for (PivotField pivotField : pivotFields) {
+ if (pivotField != null) {
+ GraphData logLevel = new GraphData();
+ logLevel.setName("" + pivotField.getValue());
+ logLevel.setCount(Long.valueOf(pivotField.getCount()));
+ if (pivotField.getPivot() != null) {
+ logLevel.setDataList(buidGraphData(pivotField.getPivot()));
+ }
+ logList.add(logLevel);
+ }
+ }
+ }
+ return logList;
+ }
+
+ public CountDataListResponse getFieldCount(String field){
+ CountDataListResponse collection = new CountDataListResponse();
+ List<CountData> vCounts = new ArrayList<>();
+ SolrQuery solrQuery = new SolrQuery();
+ SolrUtil.setMainQuery(solrQuery, null);
+ if(field == null){
+ return collection;
+ }
+ SolrUtil.setFacetField(solrQuery, field);
+ try {
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if (response == null){
+ return collection;
+ }
+ FacetField facetFields = response.getFacetField(field);
+ if (facetFields == null){
+ return collection;
+ }
+ List<Count> fieldList = facetFields.getValues();
+
+ if(fieldList == null){
+ return collection;
+ }
+
+ for (Count cnt : fieldList) {
+ if (cnt != null) {
+ CountData vCount = new CountData();
+ vCount.setName(cnt.getName());
+ vCount.setCount(cnt.getCount());
+ vCounts.add(vCount);
+ }
+ }
+
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ collection.setvCounts(vCounts);
+ return collection;
+ }
+
+ public CountDataListResponse getLogLevelCount() {
+ return getFieldCount(LogSearchConstants.SOLR_LEVEL);
+ }
+
+ public CountDataListResponse getComponentsCount() {
+ return getFieldCount(LogSearchConstants.SOLR_COMPONENT);
+ }
+
+ public CountDataListResponse getHostsCount() {
+ return getFieldCount(LogSearchConstants.SOLR_HOST);
+ }
+
+ public List<NodeData> buidTreeData(List<PivotField> pivotFields,
+ List<PivotField> pivotFieldHost, SolrQuery query,
+ String firstPriority, String secondPriority) {
+ List<NodeData> extensionTree = new ArrayList<>();
+ String hostQuery = null;
+ if (pivotFields != null) {
+ // For Host
+ for (PivotField pivotHost : pivotFields) {
+ if (pivotHost != null) {
+ NodeData hostNode = new NodeData();
+ String name = (pivotHost.getValue() == null ? "" : ""+ pivotHost.getValue());
+ String value = "" + pivotHost.getCount();
+ if(!StringUtils.isBlank(name)){
+ hostNode.setName(name);
+ }
+ if(!StringUtils.isBlank(value)){
+ hostNode.setValue(value);
+ }
+ if(!StringUtils.isBlank(firstPriority)){
+ hostNode.setType(firstPriority);
+ }
+
+ hostNode.setParent(true);
+ hostNode.setRoot(true);
+ PivotField hostPivot = null;
+ for (PivotField searchHost : pivotFieldHost) {
+ if (!StringUtils.isBlank(hostNode.getName())
+ && hostNode.getName().equals(searchHost.getValue())) {
+ hostPivot = searchHost;
+ break;
+ }
+ }
+ List<PivotField> pivotLevelHost = hostPivot.getPivot();
+ if (pivotLevelHost != null) {
+ Collection<NameValueData> logLevelCount = new ArrayList<>();
+ for (PivotField pivotLevel : pivotLevelHost) {
+ if (pivotLevel != null) {
+ NameValueData vnameValue = new NameValueData();
+ String levelName = (pivotLevel.getValue() == null ? "" : ""
+ + pivotLevel.getValue());
+ vnameValue.setName(levelName.toUpperCase());
+ vnameValue.setValue("" + pivotLevel.getCount());
+ logLevelCount.add(vnameValue);
+ }
+ }
+ hostNode.setLogLevelCount(logLevelCount);
+ }
+
+ query.addFilterQuery(hostQuery);
+ List<PivotField> pivotComponents = pivotHost.getPivot();
+ // For Components
+ if (pivotComponents != null) {
+ Collection<NodeData> componentNodes = new ArrayList<>();
+ for (PivotField pivotComp : pivotComponents) {
+ if (pivotComp != null) {
+ NodeData compNode = new NodeData();
+ String compName = (pivotComp.getValue() == null ? "" : ""
+ + pivotComp.getValue());
+ compNode.setName(compName);
+ if (!StringUtils.isBlank(secondPriority)) {
+ compNode.setType(secondPriority);
+ }
+ compNode.setValue("" + pivotComp.getCount());
+ compNode.setParent(false);
+ compNode.setRoot(false);
+ List<PivotField> pivotLevels = pivotComp.getPivot();
+ if (pivotLevels != null) {
+ Collection<NameValueData> logLevelCount = new ArrayList<>();
+ for (PivotField pivotLevel : pivotLevels) {
+ if (pivotLevel != null) {
+ NameValueData vnameValue = new NameValueData();
+ String compLevel = pivotLevel.getValue() == null ? ""
+ : "" + pivotLevel.getValue();
+ vnameValue.setName((compLevel).toUpperCase());
+
+ vnameValue.setValue("" + pivotLevel.getCount());
+ logLevelCount.add(vnameValue);
+ }
+ }
+ compNode.setLogLevelCount(logLevelCount);
+ }
+ componentNodes.add(compNode);
+ }}
+ hostNode.setChilds(componentNodes);
+ }
+ extensionTree.add(hostNode);
+ }}
+ }
+
+ return extensionTree;
+ }
+
+ public NodeListResponse getTreeExtension(SearchCriteria searchCriteria) {
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ solrQuery.setParam("event", "/getTreeExtension");
+
+ if (searchCriteria.getSortBy() == null) {
+ searchCriteria.setSortBy(LogSearchConstants.SOLR_HOST);
+ searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
+ }
+ queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
+ String hostName = ""
+ + ((searchCriteria.getParamValue("hostName") == null) ? ""
+ : searchCriteria.getParamValue("hostName"));
+ if (!StringUtils.isBlank(hostName)){
+ solrQuery.addFilterQuery(LogSearchConstants.SOLR_HOST + ":*"
+ + hostName + "*");
+ }
+ String firstHirarchy = "host,type,level";
+ String secondHirarchy = "host,level";
+ NodeListResponse list = new NodeListResponse();
+ try {
+
+ SolrUtil.setFacetPivot(solrQuery, 1, firstHirarchy,
+ secondHirarchy);
+
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ List<List<PivotField>> listFirstHirarchicalPivotFields = new ArrayList<List<PivotField>>();
+ NamedList<List<PivotField>> firstNamedList = response
+ .getFacetPivot();
+ if (firstNamedList != null) {
+ listFirstHirarchicalPivotFields = firstNamedList
+ .getAll(firstHirarchy);
+ }
+ List<List<PivotField>> listSecondHirarchicalPivotFields = new ArrayList<List<PivotField>>();
+ NamedList<List<PivotField>> secondNamedList = response
+ .getFacetPivot();
+ if (secondNamedList != null) {
+ listSecondHirarchicalPivotFields = secondNamedList
+ .getAll(secondHirarchy);
+ }
+ List<PivotField> firstHirarchicalPivotFields = new ArrayList<PivotField>();
+ List<PivotField> secondHirarchicalPivotFields = new ArrayList<PivotField>();
+ if (!listFirstHirarchicalPivotFields.isEmpty()) {
+ firstHirarchicalPivotFields = listFirstHirarchicalPivotFields
+ .get(0);
+ }
+ if (!listSecondHirarchicalPivotFields.isEmpty()) {
+ secondHirarchicalPivotFields = listSecondHirarchicalPivotFields
+ .get(0);
+ }
+ List<NodeData> dataList = buidTreeData(firstHirarchicalPivotFields,
+ secondHirarchicalPivotFields, solrQuery,
+ LogSearchConstants.HOST, LogSearchConstants.COMPONENT);
+
+ list.setvNodeList(dataList);
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ return list;
+ }
+
+ public NodeListResponse getHostListByComponent(SearchCriteria searchCriteria) {
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ solrQuery.setParam("event", "/service/hosts/components");
+
+ NodeListResponse list = new NodeListResponse();
+ if (searchCriteria.getSortBy() == null) {
+ searchCriteria.setSortBy(LogSearchConstants.SOLR_HOST);
+ searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
+ }
+ queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
+ String componentName = ""
+ + ((searchCriteria.getParamValue("componentName") == null) ? ""
+ : searchCriteria.getParamValue("componentName"));
+ if (!StringUtils.isBlank(componentName)){
+ solrQuery.addFilterQuery(LogSearchConstants.SOLR_COMPONENT + ":"
+ + componentName);
+ } else {
+ return list;
+ }
+
+ String firstHirarchy = "type,host,level";
+ String secondHirarchy = "type,level";
+
+ try {
+ SolrUtil.setFacetPivot(solrQuery, 1, firstHirarchy,
+ secondHirarchy);
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ List<List<PivotField>> firstHirarchicalPivotFields = null;
+ List<List<PivotField>> secondHirarchicalPivotFields = null;
+ NamedList<List<PivotField>> firstNamedList = response
+ .getFacetPivot();
+ if (firstNamedList != null) {
+ firstHirarchicalPivotFields = firstNamedList
+ .getAll(firstHirarchy);
+ secondHirarchicalPivotFields = firstNamedList
+ .getAll(secondHirarchy);
+ }
+
+ if (firstHirarchicalPivotFields == null
+ || secondHirarchicalPivotFields == null) {
+ return list;
+ }
+
+ List<NodeData> dataList = buidTreeData(
+ firstHirarchicalPivotFields.get(0),
+ secondHirarchicalPivotFields.get(0), solrQuery,
+ LogSearchConstants.COMPONENT, LogSearchConstants.HOST);
+ if(dataList == null){
+ return list;
+ }
+
+ list.setvNodeList(dataList);
+ return list;
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ public NameValueDataListResponse getLogsLevelCount(SearchCriteria sc) {
+ NameValueDataListResponse nameValueList = new NameValueDataListResponse();
+ SolrQuery query = queryGenerator.commonServiceFilterQuery(sc);
+ query.setParam("event", "/service/logs/levels/counts/namevalues");
+ List<NameValueData> logsCounts = getLogLevelFacets(query);
+ nameValueList.setvNameValues(logsCounts);
+
+ return nameValueList;
+ }
+
+ public List<NameValueData> getLogLevelFacets(SolrQuery query) {
+ String defalutValue = "0";
+ HashMap<String, String> map = new HashMap<String, String>();
+ List<NameValueData> logsCounts = new ArrayList<>();
+ try {
+ SolrUtil.setFacetField(query, LogSearchConstants.SOLR_LEVEL);
+ List<Count> logLevelCounts = getFacetCounts(query,
+ LogSearchConstants.SOLR_LEVEL);
+ if (logLevelCounts == null) {
+ return logsCounts;
+ }
+ for (Count count : logLevelCounts) {
+ map.put(count.getName().toUpperCase(), "" + count.getCount());
+ }
+ for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
+ NameValueData nameValue = new NameValueData();
+ String value = map.get(level);
+ if (StringUtils.isBlank(value)) {
+ value = defalutValue;
+ }
+ nameValue.setName(level);
+ nameValue.setValue(value);
+ logsCounts.add(nameValue);
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + query, e);
+ }
+ return logsCounts;
+ }
+
+ // Get Facet Count According to FacetFeild
+ public List<Count> getFacetCounts(SolrQuery solrQuery, String facetField)
+ throws SolrServerException, IOException, SolrException {
+ List<Count> list = new ArrayList<FacetField.Count>();
+
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if(response == null){
+ return list;
+ }
+
+ FacetField field = response.getFacetField(facetField);
+ if (field == null) {
+ return list;
+ }
+ list = field.getValues();
+
+
+ return list;
+ }
+
+ public LogListResponse getPageByKeyword(SearchCriteria searchCriteria)
+ throws SolrServerException {
+ String defaultChoice = "0";
+
+ String key = (String) searchCriteria.getParamValue("keyword");
+ if(StringUtils.isBlank(key)){
+ throw RESTErrorUtil.createRESTException("Keyword was not given",
+ MessageEnums.DATA_NOT_FOUND);
+ }
+
+ String keyword = SolrUtil.escapeForStandardTokenizer(key);
+
+ if(keyword.startsWith("\"") && keyword.endsWith("\"")){
+ keyword = keyword.substring(1);
+ keyword = keyword.substring(0, keyword.length()-1);
+ }
+ keyword = "*" + keyword + "*";
+
+
+ String keyType = (String) searchCriteria.getParamValue("keywordType");
+ QueryResponse queryResponse = null;
+
+ if (!defaultChoice.equals(keyType)) {
+ try {
+ int currentPageNumber = searchCriteria.getPage();
+ int maxRows = searchCriteria.getMaxRows();
+ String nextPageLogID = "";
+
+ int lastLogIndexNumber = ((currentPageNumber + 1)
+ * maxRows);
+ String nextPageLogTime = "";
+
+
+ // Next Page Start Time Calculation
+ SolrQuery nextPageLogTimeQuery = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ nextPageLogTimeQuery.remove("start");
+ nextPageLogTimeQuery.remove("rows");
+ nextPageLogTimeQuery.setStart(lastLogIndexNumber);
+ nextPageLogTimeQuery.setRows(1);
+
+ queryResponse = serviceLogsSolrDao.process(
+ nextPageLogTimeQuery);
+ if(queryResponse == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocumentList docList = queryResponse.getResults();
+ if(docList ==null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocument solrDoc = docList.get(0);
+
+ Date logDate = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
+ if(logDate == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ nextPageLogTime = DateUtil
+ .convertDateWithMillisecondsToSolrDate(logDate);
+ nextPageLogID = ""
+ + solrDoc.get(LogSearchConstants.ID);
+
+ if (StringUtils.isBlank(nextPageLogID)){
+ nextPageLogID = "0";
+ }
+
+ String filterQueryListIds = "";
+ // Remove the same Time Ids
+ SolrQuery listRemoveIds = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ listRemoveIds.remove("start");
+ listRemoveIds.remove("rows");
+ queryGenerator.setSingleIncludeFilter(listRemoveIds,
+ LogSearchConstants.LOGTIME, "\"" + nextPageLogTime + "\"");
+ queryGenerator.setSingleExcludeFilter(listRemoveIds,
+ LogSearchConstants.ID, nextPageLogID);
+ SolrUtil.setFl(listRemoveIds, LogSearchConstants.ID);
+ queryResponse = serviceLogsSolrDao.process(
+ listRemoveIds);
+ if(queryResponse == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocumentList docListIds = queryResponse.getResults();
+ if(docListIds ==null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ boolean isFirst = true;
+ for (SolrDocument solrDocId : docListIds ) {
+ String id = "" + solrDocId.get(LogSearchConstants.ID);
+ if (isFirst) {
+ filterQueryListIds += LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
+ isFirst = false;
+ } else {
+ filterQueryListIds += " "+CONDITION.AND+" " + LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
+ }
+ }
+
+ // Keyword Sequence Number Calculation
+ String endTime = (String) searchCriteria.getParamValue("to");
+ String startTime = (String) searchCriteria
+ .getParamValue("from");
+ SolrQuery logTimeThroughRangeQuery = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ logTimeThroughRangeQuery.remove("start");
+ logTimeThroughRangeQuery.remove("rows");
+ logTimeThroughRangeQuery.setRows(1);
+ if (!StringUtils.isBlank(filterQueryListIds)){
+ logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
+ }
+
+ String sortByType = searchCriteria.getSortType();
+
+ if (!StringUtils.isBlank(sortByType) && sortByType
+ .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
+
+ queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
+ LogSearchConstants.LOGTIME, nextPageLogTime,
+ endTime);
+ logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
+ LogSearchConstants.LOGTIME + " "
+ + LogSearchConstants.ASCENDING_ORDER);
+
+ } else {
+
+ queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
+ LogSearchConstants.LOGTIME, startTime,
+ nextPageLogTime);
+ logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
+ LogSearchConstants.LOGTIME + " "
+ + LogSearchConstants.DESCENDING_ORDER);
+ }
+ queryGenerator.setSingleIncludeFilter(logTimeThroughRangeQuery,
+ LogSearchConstants.SOLR_KEY_LOG_MESSAGE, keyword);
+
+
+ queryResponse = serviceLogsSolrDao.process(
+ logTimeThroughRangeQuery);
+ if(queryResponse == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocumentList documentList = queryResponse.getResults();
+ if(documentList ==null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocument solrDocument = new SolrDocument();
+ if (!documentList.isEmpty()){
+ solrDocument = documentList.get(0);
+ }
+
+ Date keywordLogDate = (Date) solrDocument.get(LogSearchConstants.LOGTIME);
+ if(keywordLogDate == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ String originalKeywordDate = DateUtil
+ .convertDateWithMillisecondsToSolrDate(keywordLogDate);
+ String keywordId = "" + solrDocument.get(LogSearchConstants.ID);
+
+ // Getting Range Count from StartTime To Keyword Log Time
+ SolrQuery rangeLogQuery = nextPageLogTimeQuery.getCopy();
+ rangeLogQuery.remove("start");
+ rangeLogQuery.remove("rows");
+
+ if (!StringUtils.isBlank(sortByType) && sortByType
+ .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
+ keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, 1);
+ String keywordDateTime = DateUtil
+ .convertDateWithMillisecondsToSolrDate(keywordLogDate);
+ queryGenerator.setSingleRangeFilter(rangeLogQuery,
+ LogSearchConstants.LOGTIME, startTime,
+ keywordDateTime);
+ } else {
+ keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, -1);
+ String keywordDateTime = DateUtil
+ .convertDateWithMillisecondsToSolrDate(keywordLogDate);
+ queryGenerator.setSingleRangeFilter(rangeLogQuery,
+ LogSearchConstants.LOGTIME, keywordDateTime,
+ endTime);
+ }
+
+
+ long countNumberLogs = countQuery(rangeLogQuery,serviceLogsSolrDao) - 1;
+
+
+ //Adding numbers on
+
+
+ try {
+ SolrQuery sameIdQuery = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ queryGenerator.setSingleIncludeFilter(sameIdQuery,
+ LogSearchConstants.LOGTIME, "\"" + originalKeywordDate + "\"");
+ SolrUtil.setFl(sameIdQuery, LogSearchConstants.ID);
+ SolrDocumentList sameQueryDocList = serviceLogsSolrDao.process(sameIdQuery)
+ .getResults();
+ for (SolrDocument solrDocumenent : sameQueryDocList) {
+ String id = (String) solrDocumenent
+ .getFieldValue(LogSearchConstants.ID);
+ countNumberLogs++;
+
+ if (StringUtils.isBlank(id) && id.equals(keywordId)){
+ break;
+ }
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error(e);
+ }
+
+ int start = (int) ((countNumberLogs / maxRows) * maxRows);
+ SolrQuery logIdQuery = nextPageLogTimeQuery.getCopy();
+ rangeLogQuery.remove("start");
+ rangeLogQuery.remove("rows");
+ logIdQuery.setStart(start);
+ logIdQuery.setRows(searchCriteria.getMaxRows());
+ LogListResponse logResponse = getLogAsPaginationProvided(logIdQuery, serviceLogsSolrDao);
+ return logResponse;
+
+ } catch (Exception e) {
+ //do nothing
+ }
+
+ } else {
+ try {
+ int currentPageNumber = searchCriteria.getPage();
+ int maxRows = searchCriteria.getMaxRows();
+
+ if (currentPageNumber == 0) {
+ throw RESTErrorUtil.createRESTException("This is first Page Not",
+ MessageEnums.DATA_NOT_FOUND);
+ }
+
+ int firstLogCurrentPage = (currentPageNumber * maxRows);
+ String lastLogsLogTime = "";
+
+ // Next Page Start Time Calculation
+ SolrQuery lastLogTime = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ lastLogTime.remove("start");
+ lastLogTime.remove("rows");
+
+ lastLogTime.setStart(firstLogCurrentPage);
+ lastLogTime.setRows(1);
+
+ queryResponse = serviceLogsSolrDao.process(
+ lastLogTime);
+ if(queryResponse == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocumentList docList = queryResponse.getResults();
+ if(docList ==null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ SolrDocument solrDoc = docList.get(0);
+
+ Date logDate = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
+ String sortByType = searchCriteria.getSortType();
+ lastLogsLogTime = DateUtil
+ .convertDateWithMillisecondsToSolrDate(logDate);
+ String lastLogsLogId = ""
+ + solrDoc.get(LogSearchConstants.ID);
+
+
+ String filterQueryListIds = "";
+ // Remove the same Time Ids
+ SolrQuery listRemoveIds = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ listRemoveIds.remove("start");
+ listRemoveIds.remove("rows");
+ queryGenerator.setSingleIncludeFilter(listRemoveIds,
+ LogSearchConstants.LOGTIME, "\"" + lastLogsLogTime + "\"");
+ queryGenerator.setSingleExcludeFilter(listRemoveIds,
+ LogSearchConstants.ID, lastLogsLogId);
+ SolrUtil.setFl(listRemoveIds, LogSearchConstants.ID);
+ queryResponse = serviceLogsSolrDao.process(
+ lastLogTime);
+ if(queryResponse == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocumentList docListIds = queryResponse.getResults();
+ if(docListIds == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ boolean isFirst = true;
+ for (SolrDocument solrDocId : docListIds) {
+ if (solrDocId != null) {
+ String id = "" + solrDocId.get(LogSearchConstants.ID);
+ if (isFirst) {
+ filterQueryListIds += LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
+ isFirst = false;
+ } else {
+ filterQueryListIds += " "+CONDITION.AND+" " + LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":"
+ + id;
+ }
+ }
+ }
+
+
+ // Keyword LogTime Calculation
+ String endTime = (String) searchCriteria.getParamValue("to");
+ String startTime = (String) searchCriteria
+ .getParamValue("from");
+ SolrQuery logTimeThroughRangeQuery = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ logTimeThroughRangeQuery.remove("start");
+ logTimeThroughRangeQuery.remove("rows");
+ logTimeThroughRangeQuery.setRows(1);
+ queryGenerator.setSingleExcludeFilter(logTimeThroughRangeQuery,
+ LogSearchConstants.ID, lastLogsLogId);
+ if (!StringUtils.isBlank(filterQueryListIds)){
+ logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
+ }
+
+ if (!StringUtils.isBlank(sortByType) && sortByType
+ .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
+
+ logTimeThroughRangeQuery.remove(LogSearchConstants.SORT);
+ logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
+ LogSearchConstants.LOGTIME + " "
+ + LogSearchConstants.DESCENDING_ORDER);
+
+
+ queryGenerator.setSingleRangeFilter(
+ logTimeThroughRangeQuery,
+ LogSearchConstants.LOGTIME, startTime,
+ lastLogsLogTime);
+
+ } else {
+
+ logTimeThroughRangeQuery.remove(LogSearchConstants.SORT);
+ logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
+ LogSearchConstants.LOGTIME + " "
+ + LogSearchConstants.ASCENDING_ORDER);
+
+
+ queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
+ LogSearchConstants.LOGTIME, lastLogsLogTime, endTime);
+ }
+ queryGenerator.setSingleIncludeFilter(logTimeThroughRangeQuery,
+ LogSearchConstants.SOLR_KEY_LOG_MESSAGE, keyword);
+
+
+ queryResponse = serviceLogsSolrDao.process(
+ logTimeThroughRangeQuery);
+ if(queryResponse == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrDocumentList documentList = queryResponse.getResults();
+ if(documentList == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ SolrDocument solrDocument = new SolrDocument();
+ if (!documentList.isEmpty()){
+ solrDocument = documentList.get(0);
+ }
+
+ Date keywordLogDate = (Date) solrDocument.get(LogSearchConstants.LOGTIME);
+ if(keywordLogDate == null){
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ String originalKeywordDate = DateUtil
+ .convertDateWithMillisecondsToSolrDate(keywordLogDate);
+ String keywordId = "" + solrDocument.get(LogSearchConstants.ID);
+
+ // Getting Range Count from StartTime To Keyword Log Time
+ SolrQuery rangeLogQuery = lastLogTime.getCopy();
+ rangeLogQuery.remove("start");
+ rangeLogQuery.remove("rows");
+
+ if (!StringUtils.isBlank(sortByType) && sortByType
+ .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
+ // keywordLogDate = DateUtil.addMilliSecondsToDate(keywordLogDate, 1);
+ String keywordDateTime = DateUtil
+ .convertDateWithMillisecondsToSolrDate(keywordLogDate);
+ queryGenerator.setSingleRangeFilter(rangeLogQuery,
+ LogSearchConstants.LOGTIME, startTime,
+ keywordDateTime);
+
+
+ } else {
+ // keywordLogDate = DateUtil.addMilliSecondsToDate(keywordLogDate, -1);
+ String keywordDateTime = DateUtil
+ .convertDateWithMillisecondsToSolrDate(keywordLogDate);
+ queryGenerator.setSingleRangeFilter(rangeLogQuery,
+ LogSearchConstants.LOGTIME, keywordDateTime,
+ endTime);
+ }
+
+
+ long countNumberLogs = countQuery(rangeLogQuery,serviceLogsSolrDao) - 1;
+
+ //Adding numbers on
+ try {
+ SolrQuery sameIdQuery = queryGenerator
+ .commonServiceFilterQuery(searchCriteria);
+ queryGenerator.setSingleIncludeFilter(sameIdQuery,
+ LogSearchConstants.LOGTIME, "\"" + originalKeywordDate + "\"");
+ SolrUtil.setFl(sameIdQuery, LogSearchConstants.ID);
+ SolrDocumentList sameQueryDocList = serviceLogsSolrDao.process(sameIdQuery)
+ .getResults();
+ for (SolrDocument solrDocumenent : sameQueryDocList) {
+ if (solrDocumenent != null) {
+ String id = (String) solrDocumenent
+ .getFieldValue(LogSearchConstants.ID);
+ countNumberLogs++;
+ if ( StringUtils.isBlank(id) && id.equals(keywordId)) {
+ break;
+ }
+ }
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error(e);
+ }
+ int start = (int) ((countNumberLogs / maxRows) * maxRows);
+
+ SolrQuery logIdQuery = lastLogTime.getCopy();
+ rangeLogQuery.remove("start");
+ rangeLogQuery.remove("rows");
+ logIdQuery.setStart(start);
+ logIdQuery.setRows(searchCriteria.getMaxRows());
+ return getLogAsPaginationProvided(logIdQuery, serviceLogsSolrDao);
+ } catch (Exception e) {
+ //do nothing
+ }
+
+ }
+ throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ private LogSearchResponse getPageByLogId(SearchCriteria searchCriteria) {
+ LogSearchResponse logResponse = new ServiceLogResponse();
+ String endLogTime = (String) searchCriteria.getParamValue("to");
+ if(StringUtils.isBlank(endLogTime)){
+ return logResponse;
+ }
+ long startIndex = 0l;
+
+ String logId = (String) searchCriteria.getParamValue("sourceLogId");
+ if(StringUtils.isBlank(logId)){
+ return logResponse;
+ }
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+
+ String endTimeMinusOneMilli = "";
+ String logTime = "";
+ try {
+
+ SolrQuery logTimeByIdQuery = new SolrQuery();
+ SolrUtil.setMainQuery(logTimeByIdQuery, null);
+ queryGenerator.setSingleIncludeFilter(logTimeByIdQuery,
+ LogSearchConstants.ID, logId);
+ SolrUtil.setRowCount(solrQuery, 1);
+
+ QueryResponse queryResponse = serviceLogsSolrDao
+ .process(logTimeByIdQuery);
+
+ if(queryResponse == null){
+ return new ServiceLogResponse();
+ }
+
+ SolrDocumentList docList = queryResponse.getResults();
+ Date dateOfLogId = null;
+ if (docList != null && !docList.isEmpty()) {
+ SolrDocument dateLogIdDoc = docList.get(0);
+ if(dateLogIdDoc != null){
+ dateOfLogId = (Date) dateLogIdDoc.get(LogSearchConstants.LOGTIME);
+ }
+ }
+
+ if (dateOfLogId != null) {
+ logTime = DateUtil.convertDateWithMillisecondsToSolrDate(dateOfLogId);
+ Date endDate = DateUtils.addMilliseconds(dateOfLogId, 1);
+ endTimeMinusOneMilli = (String) DateUtil
+ .convertDateWithMillisecondsToSolrDate(endDate);
+ }
+
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error(e);
+ }
+
+ try {
+ solrQuery.remove(LogSearchConstants.ID);
+ solrQuery.remove(LogSearchConstants.LOGTIME);
+ queryGenerator.setSingleRangeFilter(solrQuery,
+ LogSearchConstants.LOGTIME, endTimeMinusOneMilli, endLogTime);
+ SolrUtil.setRowCount(solrQuery, 0);
+ startIndex = countQuery(solrQuery,serviceLogsSolrDao);
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error(e);
+ }
+
+ try {
+ SolrQuery sameIdQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ queryGenerator.setSingleIncludeFilter(sameIdQuery,
+ LogSearchConstants.LOGTIME, "\"" + logTime + "\"");
+ sameIdQuery.set("fl", LogSearchConstants.ID);
+
+ QueryResponse sameIdResponse = serviceLogsSolrDao.process(sameIdQuery);
+ SolrDocumentList docList = sameIdResponse.getResults();
+
+ for (SolrDocument solrDocumenent : docList) {
+ String id = (String) solrDocumenent
+ .getFieldValue(LogSearchConstants.ID);
+ startIndex++;
+ if (!StringUtils.isBlank(id)) {
+ if (id.equals(logId)) {
+ break;
+ }
+ }
+ }
+
+ SolrQuery logIdQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ logIdQuery.remove("rows");
+ logIdQuery.remove("start");
+ int start = (int) ((startIndex / searchCriteria.getMaxRows()) * searchCriteria
+ .getMaxRows());
+ logIdQuery.setStart(start);
+ logIdQuery.setRows(searchCriteria.getMaxRows());
+ logResponse = getLogAsPaginationProvided(logIdQuery,
+ serviceLogsSolrDao);
+ return logResponse;
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error(e);
+ }
+
+ throw RESTErrorUtil.createRESTException("LogId not Found",
+ MessageEnums.ERROR_SYSTEM);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<NameValueData> getHistogramCounts(SolrQuery solrQuery,
+ String from, String to, String unit) {
+ List<NameValueData> logsCounts = new ArrayList<>();
+ try {
+
+ SolrUtil.setFacetRange(solrQuery, LogSearchConstants.LOGTIME,
+ from, to, unit);
+
+ List<RangeFacet.Count> logLevelCounts = null;
+
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if(response == null){
+ return logsCounts;
+ }
+ @SuppressWarnings("rawtypes")
+ List<RangeFacet> rangeFacetList = response.getFacetRanges();
+ if (rangeFacetList == null) {
+ return logsCounts;
+
+ }
+
+ @SuppressWarnings("rawtypes")
+ RangeFacet rangeFacet=rangeFacetList.get(0);
+ if (rangeFacet == null) {
+ return logsCounts;
+ }
+ logLevelCounts = rangeFacet.getCounts();
+
+ if(logLevelCounts == null){
+ return logsCounts;
+ }
+ for (RangeFacet.Count logCount : logLevelCounts) {
+ NameValueData nameValue = new NameValueData();
+ nameValue.setName(logCount.getValue());
+ nameValue.setValue("" + logCount.getCount());
+ logsCounts.add(nameValue);
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ }
+ return logsCounts;
+ }
+
+ public List<Count> getFacetCountsByDate(SolrQuery solrQuery,
+ String facetField) throws SolrServerException, IOException,
+ SolrException {
+
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+
+ FacetField field = response.getFacetDate(facetField);
+ return field.getValues();
+ }
+
+ @SuppressWarnings("unchecked")
+ public BarGraphDataListResponse getHistogramData(SearchCriteria searchCriteria) {
+ String deafalutValue = "0";
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ solrQuery.set("event", "/audit/logs/histogram");
+ String from = getFrom((String) searchCriteria.getParamValue("from"));
+ String to = getTo((String) searchCriteria.getParamValue("to"));
+ String unit = getUnit((String) searchCriteria.getParamValue("unit"));
+
+ List<BarGraphData> histogramData = new ArrayList<>();
+
+ String jsonHistogramQuery = queryGenerator
+ .buildJSONFacetTermTimeRangeQuery(
+ LogSearchConstants.SOLR_LEVEL,
+ LogSearchConstants.LOGTIME, from, to, unit).replace(
+ "\\", "");
+
+ try {
+ SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
+ SolrUtil.setRowCount(solrQuery,Integer.parseInt(deafalutValue));
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if (response == null){
+ return dataList;
+ }
+ SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response
+ .getResponse().get("facets");
+
+ if (jsonFacetResponse == null
+ || jsonFacetResponse.toString().equals("{count=0}")){
+ return dataList;
+ }
+
+ extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
+
+ Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
+ List<BarGraphData> graphDatas = new ArrayList<BarGraphData>();
+ for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
+ boolean isLevelPresent = false;
+ BarGraphData vData1 = null;
+ for (BarGraphData vData2 : histogramData) {
+ String name = vData2.getName();
+ if (level.contains(name)) {
+ isLevelPresent = true;
+ vData1 = vData2;
+ break;
+ }
+ if (vNameValues.isEmpty()) {
+ Collection<NameValueData> vNameValues2 = vData2
+ .getDataCount();
+ for (NameValueData value : vNameValues2) {
+ NameValueData value2 = new NameValueData();
+ value2.setValue(deafalutValue);
+ value2.setName(value.getName());
+ vNameValues.add(value2);
+ }
+ }
+ }
+ if (!isLevelPresent) {
+ BarGraphData vBarGraphData = new BarGraphData();
+ vBarGraphData.setName(level);
+ vBarGraphData.setDataCount(vNameValues);
+ graphDatas.add(vBarGraphData);
+ } else {
+ graphDatas.add(vData1);
+ }
+ }
+
+ dataList.setGraphData(graphDatas);
+ return dataList;
+
+ } catch (SolrServerException | SolrException | IOException e) {
+ logger.error(e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+
+ }
+ }
+
+ public void arrangeLevel(String level,
+ List<BarGraphData> histogramDataLocal,
+ List<BarGraphData> histogramData) {
+ for (BarGraphData histData : histogramData) {
+ if (histData != null && level.equals(histData.getName())) {
+ histogramDataLocal.add(histData);
+ }
+ }
+ }
+
+ public String cancelFindRequestByDate(String uniqueId) {
+ if (StringUtils.isEmpty(uniqueId)) {
+ logger.error("Unique id is Empty");
+ throw RESTErrorUtil.createRESTException("Unique id is Empty",
+ MessageEnums.DATA_NOT_FOUND);
+ }
+
+ if (cancelByDate.remove(uniqueId)) {
+ mapUniqueId.remove(uniqueId);
+ return "Cancel Request Successfully Procssed ";
+ }
+ return "Cancel Request Unable to Process";
+ }
+
+ public boolean cancelRequest(String uniqueId) {
+ if (StringUtils.isBlank(uniqueId)) {
+ logger.error("Unique id is Empty");
+ throw RESTErrorUtil.createRESTException("Unique id is Empty",
+ MessageEnums.DATA_NOT_FOUND);
+ }
+ for (String date : cancelByDate) {
+ if (uniqueId.equalsIgnoreCase(date)){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public Response exportToTextFile(SearchCriteria searchCriteria) {
+ String defaultFormat = "text";
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ String from = (String) searchCriteria.getParamValue("from");
+ String to = (String) searchCriteria.getParamValue("to");
+ String utcOffset = (String) searchCriteria.getParamValue("utcOffset");
+ String format = (String) searchCriteria.getParamValue("format");
+
+ format = defaultFormat.equalsIgnoreCase(format) && format != null ? ".txt"
+ : ".json";
+
+ if(StringUtils.isBlank(utcOffset)){
+ utcOffset = "0";
+ }
+
+ if (!DateUtil.isDateValid(from) || !DateUtil.isDateValid(to)) {
+ logger.error("Not valid date format. Valid format should be"
+ + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z);
+ throw RESTErrorUtil.createRESTException("Not valid date format. Valid format should be"
+ + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z,
+ MessageEnums.INVALID_INPUT_DATA);
+
+ } else {
+ from = from.replace("T", " ");
+ from = from.replace(".", ",");
+
+ to = to.replace("T", " ");
+ to = to.replace(".", ",");
+
+ to = DateUtil.addOffsetToDate(to, Long.parseLong(utcOffset),
+ "yyyy-MM-dd HH:mm:ss,SSS");
+ from = DateUtil.addOffsetToDate(from, Long.parseLong(utcOffset),
+ "yyyy-MM-dd HH:mm:ss,SSS");
+ }
+
+ String fileName = DateUtil.getCurrentDateInString();
+ if (searchCriteria.getParamValue("hostLogFile") != null
+ && searchCriteria.getParamValue("compLogFile") != null) {
+ fileName = searchCriteria.getParamValue("hostLogFile") + "_"
+ + searchCriteria.getParamValue("compLogFile");
+ }
+
+ String textToSave = "";
+ try {
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if (response == null) {
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ SolrDocumentList docList = response.getResults();
+ if (docList == null) {
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ VSummary vsummary = BizUtil.buildSummaryForLogFile(docList);
+ vsummary.setFormat(format);
+ vsummary.setFrom(from);
+ vsummary.setTo(to);
+
+ String includeString = (String) searchCriteria.getParamValue("iMessage");
+ if (StringUtils.isBlank(includeString)) {
+ includeString = "";
+ }
+
+ String include[] = includeString.split(LogSearchConstants.I_E_SEPRATOR);
+
+ for (String inc : include) {
+ includeString = includeString + ",\"" + inc + "\"";
+ }
+ includeString = includeString.replaceFirst(",", "");
+ if (!StringUtils.isBlank(includeString)) {
+ vsummary.setIncludeString(includeString);
+ }
+
+ String excludeString = null;
+ boolean isNormalExcluded = false;
+
+ excludeString = (String) searchCriteria.getParamValue("eMessage");
+ if (StringUtils.isBlank(excludeString)) {
+ excludeString = "";
+ }
+
+ String exclude[] = excludeString.split(LogSearchConstants.I_E_SEPRATOR);
+ for (String exc : exclude) {
+ excludeString = excludeString + ",\"" + exc + "\"";
+ }
+
+ excludeString = excludeString.replaceFirst(",", "");
+ if (!StringUtils.isBlank(excludeString)) {
+ vsummary.setExcludeString(excludeString);
+ isNormalExcluded = true;
+ }
+
+ String globalExcludeString = (String) searchCriteria
+ .getParamValue("gEMessage");
+ if (StringUtils.isBlank(globalExcludeString)) {
+ globalExcludeString = "";
+ }
+
+ String globalExclude[] = globalExcludeString
+ .split(LogSearchConstants.I_E_SEPRATOR);
+
+ for (String exc : globalExclude) {
+ excludeString = excludeString + ",\"" + exc + "\"";
+ }
+
+ if (!StringUtils.isBlank(excludeString)) {
+ if (!isNormalExcluded) {
+ excludeString = excludeString.replaceFirst(",", "");
+ }
+ vsummary.setExcludeString(excludeString);
+ }
+
+ for (SolrDocument solrDoc : docList) {
+
+ Date logTimeDateObj = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
+ if(logTimeDateObj != null){
+ String logTime = DateUtil.convertSolrDateToNormalDateFormat(
+ logTimeDateObj.getTime(), Long.parseLong(utcOffset));
+ solrDoc.remove(LogSearchConstants.LOGTIME);
+ solrDoc.addField(LogSearchConstants.LOGTIME, logTime);
+ }
+ }
+
+ if (format.toLowerCase(Locale.ENGLISH).equals(".txt")) {
+ textToSave = BizUtil.convertObjectToNormalText(docList);
+ } else if (format.toLowerCase(Locale.ENGLISH).equals(".json")) {
+ textToSave = convertObjToString(docList);
+ } else {
+ throw RESTErrorUtil.createRESTException(
+ "unsoported format either should be json or text",
+ MessageEnums.ERROR_SYSTEM);
+ }
+ return FileUtil.saveToFile(textToSave, fileName, vsummary);
+
+ } catch (SolrException | SolrServerException | IOException
+ | ParseException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ public NodeListResponse getComponentListWithLevelCounts(SearchCriteria searchCriteria) {
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ solrQuery.setParam("event", "/service/logs/components/levels/counts");
+
+ if (searchCriteria.getSortBy() == null) {
+ searchCriteria.setSortBy(LogSearchConstants.SOLR_COMPONENT);
+ searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
+ }
+ queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
+ String componentLevelHirachy = "type,level";
+ NodeListResponse list = new NodeListResponse();
+ try {
+
+ SolrUtil.setFacetPivot(solrQuery, 1, componentLevelHirachy);
+
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+
+ List<List<PivotField>> listPivotField = new ArrayList<List<PivotField>>();
+ NamedList<List<PivotField>> namedList = response.getFacetPivot();
+ if (namedList != null) {
+ listPivotField = namedList.getAll(componentLevelHirachy);
+ }
+ List<PivotField> secondHirarchicalPivotFields = null;
+ if (listPivotField == null || listPivotField.isEmpty()) {
+ return list;
+ } else {
+ secondHirarchicalPivotFields = listPivotField.get(0);
+ }
+ List<NodeData> datatList = new ArrayList<>();
+ for (PivotField singlePivotField : secondHirarchicalPivotFields) {
+ if (singlePivotField != null) {
+ NodeData comp = new NodeData();
+ comp.setName("" + singlePivotField.getValue());
+ List<PivotField> levelList = singlePivotField.getPivot();
+ List<NameValueData> levelCountList = new ArrayList<>();
+ comp.setLogLevelCount(levelCountList);
+ if(levelList != null){
+ for (PivotField levelPivot : levelList) {
+ NameValueData level = new NameValueData();
+ level.setName(("" + levelPivot.getValue()).toUpperCase());
+ level.setValue("" + levelPivot.getCount());
+ levelCountList.add(level);
+ }
+ }
+ datatList.add(comp);
+ }
+ }
+ list.setvNodeList(datatList);
+ return list;
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error(e.getMessage() + "SolrQuery"+solrQuery);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ public NameValueDataListResponse getExtremeDatesForBundelId(SearchCriteria searchCriteria) {
+ SolrQuery solrQuery = new SolrQuery();
+ NameValueDataListResponse nameValueList = new NameValueDataListResponse();
+ try {
+ String bundelId = (String) searchCriteria
+ .getParamValue(LogSearchConstants.BUNDLE_ID);
+ if(StringUtils.isBlank(bundelId)){
+ bundelId = "";
+ }
+
+ queryGenerator.setSingleIncludeFilter(solrQuery,
+ LogSearchConstants.BUNDLE_ID, bundelId);
+
+ SolrUtil.setMainQuery(solrQuery, null);
+ solrQuery.setSort(LogSearchConstants.LOGTIME, SolrQuery.ORDER.asc);
+ SolrUtil.setRowCount(solrQuery, 1);
+
+ List<NameValueData> vNameValues = new ArrayList<>();
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+
+ if(response == null){
+ return nameValueList;
+ }
+
+ SolrDocumentList solrDocList = response.getResults();
+ if(solrDocList == null){
+ return nameValueList;
+ }
+ for (SolrDocument solrDoc : solrDocList) {
+
+ Date logTimeAsc = (Date) solrDoc
+ .getFieldValue(LogSearchConstants.LOGTIME);
+ if (logTimeAsc != null) {
+ NameValueData nameValue = new NameValueData();
+ nameValue.setName("From");
+ nameValue.setValue("" + logTimeAsc.getTime());
+ vNameValues.add(nameValue);
+ }
+ }
+
+ solrQuery.clear();
+ SolrUtil.setMainQuery(solrQuery, null);
+ queryGenerator.setSingleIncludeFilter(solrQuery,
+ LogSearchConstants.BUNDLE_ID, bundelId);
+ solrQuery.setSort(LogSearchConstants.LOGTIME, SolrQuery.ORDER.desc);
+ SolrUtil.setRowCount(solrQuery, 1);
+
+ solrDocList.clear();
+ response = serviceLogsSolrDao.process(solrQuery);
+
+ solrDocList = response.getResults();
+ for (SolrDocument solrDoc : solrDocList) {
+ if (solrDoc != null) {
+ Date logTimeDesc = (Date) solrDoc
+ .getFieldValue(LogSearchConstants.LOGTIME);
+
+ if (logTimeDesc != null) {
+ NameValueData nameValue = new NameValueData();
+ nameValue.setName("To");
+ nameValue.setValue("" + logTimeDesc.getTime());
+ vNameValues.add(nameValue);
+ }
+ }
+ }
+ nameValueList.setvNameValues(vNameValues);
+
+
+ } catch (SolrServerException | SolrException | IOException e) {
+ logger.error(e.getMessage() + "SolrQuery"+solrQuery);
+ nameValueList = new NameValueDataListResponse();
+ }
+ return nameValueList;
+ }
+
+ public String getServiceLogsFieldsName() {
+ List<String> fieldsNames = solrServiceLogConfig.getFields();
+ if (fieldsNames.size() > 0) {
+
+ List<String> uiFieldNames = new ArrayList<String>();
+ String temp = null;
+ for (String field : fieldsNames) {
+ temp = solrServiceLogConfig.getSolrAndUiColumns().get(field + LogSearchConstants.SOLR_SUFFIX);
+ if (temp == null){
+ uiFieldNames.add(field);
+ }else{
+ uiFieldNames.add(temp);
+ }
+ }
+ return convertObjToString(uiFieldNames);
+
+ }
+ throw RESTErrorUtil.createRESTException(
+ "No field name found in property file",
+ MessageEnums.DATA_NOT_FOUND);
+
+ }
+
+ public String getServiceLogsSchemaFieldsName() {
+
+ List<String> fieldNames = new ArrayList<String>();
+ String excludeArray[] = Arrays.copyOf(solrServiceLogConfig.getExcludeColumnList().toArray(),
+ solrServiceLogConfig.getExcludeColumnList().size(), String[].class);
+
+ HashMap<String, String> uiFieldColumnMapping = new LinkedHashMap<String, String>();
+ ConfigHelper.getSchemaFieldsName(excludeArray, fieldNames,serviceLogsSolrDao);
+
+ for (String fieldName : fieldNames) {
+ String uiField = solrServiceLogConfig.getSolrAndUiColumns().get(fieldName + LogSearchConstants.SOLR_SUFFIX);
+ if (uiField != null) {
+ uiFieldColumnMapping.put(fieldName, uiField);
+ } else {
+ uiFieldColumnMapping.put(fieldName, fieldName);
+ }
+ }
+
+ HashMap<String, String> uiFieldColumnMappingSorted = new LinkedHashMap<String, String>();
+ uiFieldColumnMappingSorted.put(LogSearchConstants.SOLR_LOG_MESSAGE, LogSearchConstants.SOLR_LOG_MESSAGE);
+
+ Iterator<Entry<String, String>> it = BizUtil
+ .sortHashMapByValues(uiFieldColumnMapping).entrySet().iterator();
+ while (it.hasNext()) {
+ @SuppressWarnings("rawtypes")
+ Map.Entry pair = (Map.Entry) it.next();
+ uiFieldColumnMappingSorted.put("" + pair.getKey(), "" + pair.getValue());
+ }
+
+ return convertObjToString(uiFieldColumnMappingSorted);
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public void extractValuesFromBuckets(
+ SimpleOrderedMap<Object> jsonFacetResponse, String outerField,
+ String innerField, List<BarGraphData> histogramData) {
+ NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse
+ .get(outerField);
+ ArrayList<Object> stackBuckets = (ArrayList<Object>) stack
+ .get("buckets");
+ for (Object temp : stackBuckets) {
+ BarGraphData vBarGraphData = new BarGraphData();
+
+ SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
+ String name = ((String) level.getVal(0)).toUpperCase();
+ vBarGraphData.setName(name);
+
+ Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
+ vBarGraphData.setDataCount(vNameValues);
+ ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level
+ .get(innerField)).get("buckets");
+ for (Object temp1 : levelBuckets) {
+ SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
+ String value = DateUtil
+ .convertDateWithMillisecondsToSolrDate((Date) countValue
+ .getVal(0));
+
+ String count = "" + countValue.getVal(1);
+ NameValueData vNameValue = new NameValueData();
+ vNameValue.setName(value);
+ vNameValue.setValue(count);
+ vNameValues.add(vNameValue);
+ }
+ histogramData.add(vBarGraphData);
+ }
+ }
+
+ public BarGraphDataListResponse getAnyGraphData(SearchCriteria searchCriteria) {
+ searchCriteria.addParam("fieldTime", LogSearchConstants.LOGTIME);
+ SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
+ BarGraphDataListResponse result = graphDataGenerator.getAnyGraphData(searchCriteria, serviceLogsSolrDao, solrQuery);
+ if (result == null) {
+ result = new BarGraphDataListResponse();
+ }
+ return result;
+
+ }
+
+ public ServiceLogResponse getAfterBeforeLogs(SearchCriteria searchCriteria) {
+ ServiceLogResponse logResponse = new ServiceLogResponse();
+ List<SolrServiceLogData> docList = null;
+ String id = (String) searchCriteria
+ .getParamValue(LogSearchConstants.ID);
+ if (StringUtils.isBlank(id)) {
+ return logResponse;
+
+ }
+ String maxRows = "";
+
+ maxRows = (String) searchCriteria.getParamValue("numberRows");
+ if (StringUtils.isBlank(maxRows)){
+ maxRows = ""+maxRows;
+ }
+ String scrollType = (String) searchCriteria.getParamValue("scrollType");
+ if(StringUtils.isBlank(scrollType)){
+ scrollType = "";
+ }
+
+ String logTime = null;
+ String sequenceId = null;
+ try {
+ SolrQuery solrQuery = new SolrQuery();
+ SolrUtil.setMainQuery(solrQuery,
+ queryGenerator.buildFilterQuery(LogSearchConstants.ID, id));
+ SolrUtil.setRowCount(solrQuery, 1);
+ QueryResponse response = serviceLogsSolrDao.process(solrQuery);
+ if(response == null){
+ return logResponse;
+ }
+ docList = convertToSolrBeans(response);
+ if (docList != null && !docList.isEmpty()) {
+ Date date = docList.get(0).getLogTime();
+ logTime = DateUtil.convertDateWithMillisecondsToSolrDate(date);
+ sequenceId = ""
+ + docList.get(0).getSeqNum();
+ }
+ if (StringUtils.isBlank(logTime)) {
+ return logResponse;
+ }
+ } catch (SolrServerException | SolrException | IOException e) {
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
+ .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType)) {
+ logResponse = whenScrollUp(searchCriteria, logTime,
+ sequenceId, maxRows);
+
+ List<ServiceLogData> solrDocList = new ArrayList<>();
+ for (ServiceLogData solrDoc : logResponse.getLogList()) {
+ solrDocList.add(solrDoc);
+ }
+ logResponse.setLogList(solrDocList);
+ return logResponse;
+
+ } else if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
+ List<ServiceLogData> solrDocList = new ArrayList<>();
+ logResponse = new ServiceLogResponse();
+ for (ServiceLogData solrDoc : whenScrollDown(searchCriteria, logTime,
+ sequenceId, maxRows).getLogList()) {
+ solrDocList.add(solrDoc);
+ }
+ logResponse.setLogList(solrDocList);
+ return logResponse;
+
+ } else {
+ logResponse = new ServiceLogResponse();
+ List<ServiceLogData> initial = new ArrayList<>();
+ List<ServiceLogData> before = whenScrollUp(searchCriteria, logTime,
+ sequenceId, maxRows).getLogList();
+ List<ServiceLogData> after = whenScrollDown(searchCriteria, logTime,
+ sequenceId, maxRows).getLogList();
+ if (before != null && !before.isEmpty()) {
+ for (ServiceLogData solrDoc : Lists.reverse(before)) {
+ initial.add(solrDoc);
+ }
+ }
+
+ initial.add(docList.get(0));
+ if (after != null && !after.isEmpty()) {
+ for (ServiceLogData solrDoc : after) {
+ initial.add(solrDoc);
+ }
+ }
+
+ logResponse.setLogList(initial);
+
+ return logResponse;
+
+ }
+ }
+
+ private ServiceLogResponse whenScrollUp(SearchCriteria searchCriteria,
+ String logTime, String sequenceId, String maxRows) {
+ SolrQuery solrQuery = new SolrQuery();
+ SolrUtil.setMainQuery(solrQuery, null);
+ try {
+ int seq_num = Integer.parseInt(sequenceId) - 1;
+ sequenceId = "" + seq_num;
+ } catch (Exception e) {
+
+ }
+ queryGenerator.setSingleRangeFilter(
+ solrQuery,
+ LogSearchConstants.SEQUNCE_ID, "*", sequenceId);
+
+ queryGenerator.applyLogFileFilter(solrQuery, searchCriteria);
+
+ queryGenerator.setSingleRangeFilter(solrQuery,
+ LogSearchConstants.LOGTIME, "*", logTime);
+ SolrUtil.setRowCount(solrQuery, Integer.parseInt(maxRows));
+ String order1 = LogSearchConstants.LOGTIME + " "
+ + LogSearchConstants.DESCENDING_ORDER;
+ String order2 = LogSearchConstants.SEQUNCE_ID + " "
+ + LogSearchConstants.DESCENDING_ORDER;
+ List<String> sortOrder = new ArrayList<String>();
+ sortOrder.add(order1);
+ sortOrder.add(order2);
+ searchCriteria.addParam(LogSearchConstants.SORT, sortOrder);
+ queryGenerator.setMultipleSortOrder(solrQuery, searchCriteria);
+
+ return (ServiceLogResponse) getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao);
+ }
+
+ private ServiceLogResponse whenScrollDown(SearchCriteria searchCriteria,
+ String logTime, String sequenceId, String maxRows) {
+ SolrQuery solrQuery = new SolrQuery();
+ SolrUtil.setMainQuery(solrQuery, null);
+ queryGenerator.applyLogFileFilter(solrQuery, searchCriteria);
+
+ try {
+ int seq_num = Integer.parseInt(sequenceId) + 1;
+ sequenceId = "" + seq_num;
+ } catch (Exception e) {
+
+ }
+ queryGenerator.setSingleRangeFilter(
+ solrQuery,
+ LogSearchConstants.SEQUNCE_ID, sequenceId, "*");
+ queryGenerator.setSingleRangeFilter(solrQuery,
+ LogSearchConstants.LOGTIME, logTime, "*");
+ SolrUtil.setRowCount(solrQuery, Integer.parseInt(maxRows));
+
+ String order1 = LogSearchConstants.LOGTIME + " "
+ + LogSearchConstants.ASCENDING_ORDER;
+ String order2 = LogSearchConstants.SEQUNCE_ID + " "
+ + LogSearchConstants.ASCENDING_ORDER;
+ List<String> sortOrder = new ArrayList<String>();
+ sortOrder.add(order1);
+ sortOrder.add(order2);
+ searchCriteria.addParam(LogSearchConstants.SORT, sortOrder);
+ queryGenerator.setMultipleSortOrder(solrQuery, searchCriteria);
+
+ return (ServiceLogResponse) getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao);
+ }
+
+ @Scheduled(cron = "${logsearch.solr.warming.cron}")
+ public void warmingSolrServer(){
+ logger.info("solr warming triggered.");
+ SolrQuery solrQuery = new SolrQuery();
+ TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
+ GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
+ utc.setTimeInMillis(new Date().getTime());
+ utc.set(Calendar.HOUR, 0);
+ utc.set(Calendar.MINUTE, 0);
+ utc.set(Calendar.MILLISECOND, 001);
+ utc.set(Calendar.SECOND, 0);
+ DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
+ String from = DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
+ utc.set(Calendar.MILLISECOND, 999);
+ utc.set(Calendar.SECOND, 59);
+ utc.set(Calendar.MINUTE, 59);
+ utc.set(Calendar.HOUR, 23);
+ String to = DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
+ queryGenerator.setSingleRangeFilter(solrQuery,
+ LogSearchConstants.LOGTIME, from,to);
+ String level = LogSearchConstants.FATAL+","+LogSearchConstants.ERROR+","+LogSearchConstants.WARN;
+ queryGenerator.setFilterClauseWithFieldName(solrQuery, level,
+ LogSearchConstants.SOLR_LEVEL, "", QueryGenerationBase.Condition.OR);
+ try {
+ serviceLogsSolrDao.process(solrQuery);
+ } catch (SolrServerException | IOException e) {
+ logger.error("Error while warming solr server",e);
+ }
+ }
+
+ @Override
+ protected List<SolrServiceLogData> convertToSolrBeans(QueryResponse response) {
+ return response.getBeans(SolrServiceLogData.class);
+ }
+
+ @Override
+ protected ServiceLogResponse createLogSearchResponse() {
+ return new ServiceLogResponse();
+ }
+
+ private List<LogData> getLogDataListByFieldType(Class clazz, QueryResponse response, List<Count> fieldList) {
+ List<LogData> groupList = getComponentBeans(clazz, response);
+ String temp = "";
+ for (Count cnt : fieldList) {
+ LogData logData = createNewFieldByType(clazz, cnt, temp);
+ groupList.add(logData);
+ }
+ return groupList;
+ }
+
+ private <T extends LogData> List<LogData> getComponentBeans(Class<T> clazz, QueryResponse response) {
+ if (clazz.isAssignableFrom(SolrHostLogData.class) || clazz.isAssignableFrom(SolrComponentTypeLogData.class)) {
+ return (List<LogData>) response.getBeans(clazz);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private <T extends LogData> LogData createNewFieldByType(Class<T> clazz, Count count, String temp) {
+ temp = count.getName();
+ LogData result = null;
+ if (clazz.isAssignableFrom(SolrHostLogData.class)) {
+ SolrHostLogData fieldData = new SolrHostLogData();
+ fieldData.setHost(temp);
+ result = fieldData;
+ } else if (clazz.isAssignableFrom(SolrComponentTypeLogData.class)) {
+ SolrComponentTypeLogData fieldData = new SolrComponentTypeLogData();
+ fieldData.setType(temp);
+ result = fieldData;
+ }
+ if (result != null) {
+ return result;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
new file mode 100644
index 0000000..206636a
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java
@@ -0,0 +1,76 @@
+/*
+ * 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.manager;
+
+import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.web.model.User;
+import org.apache.log4j.Logger;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.web.authentication.WebAuthenticationDetails;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SessionManager {
+
+ private static final Logger logger = Logger.getLogger(SessionManager.class);
+
+ public SessionManager() {
+ logger.debug("SessionManager created");
+ }
+
+ public User processSuccessLogin() {
+ boolean newSessionCreation = true;
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails();
+ String currentLoginId = authentication.getName();
+ LogSearchContext context = LogSearchContext.getContext();
+ User user = context.getUser();
+ if (user != null) {
+ if (validateUser(user, currentLoginId)) {
+ newSessionCreation = false;
+ }
+ }
+ //
+ if (newSessionCreation) {
+ user = new User();
+ user.setUsername(currentLoginId);
+ if (details != null) {
+ logger.info("Login Success: loginId=" + currentLoginId + ", sessionId=" + details.getSessionId()
+ + ", requestId=" + details.getRemoteAddress());
+ } else {
+ logger.info("Login Success: loginId=" + currentLoginId + ", msaSessionId=" + ", details is null");
+ }
+
+ }
+
+ return user;
+ }
+
+ private boolean validateUser(User user, String currentUsername) {
+ if (currentUsername.equalsIgnoreCase(user.getUsername())) {
+ return true;
+ } else {
+ logger.info("loginId doesn't match loginId from HTTPSession. Will create new session. loginId="
+ + currentUsername + ", user=" + user, new Exception());
+ return false;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java
deleted file mode 100644
index c6f7dc5..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/SessionMgr.java
+++ /dev/null
@@ -1,76 +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.manager;
-
-import org.apache.ambari.logsearch.common.LogSearchContext;
-import org.apache.ambari.logsearch.web.model.User;
-import org.apache.log4j.Logger;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.web.authentication.WebAuthenticationDetails;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SessionMgr {
-
- private static final Logger logger = Logger.getLogger(SessionMgr.class);
-
- public SessionMgr() {
- logger.debug("SessionManager created");
- }
-
- public User processSuccessLogin() {
- boolean newSessionCreation = true;
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails();
- String currentLoginId = authentication.getName();
- LogSearchContext context = LogSearchContext.getContext();
- User user = context.getUser();
- if (user != null) {
- if (validateUser(user, currentLoginId)) {
- newSessionCreation = false;
- }
- }
- //
- if (newSessionCreation) {
- user = new User();
- user.setUsername(currentLoginId);
- if (details != null) {
- logger.info("Login Success: loginId=" + currentLoginId + ", sessionId=" + details.getSessionId()
- + ", requestId=" + details.getRemoteAddress());
- } else {
- logger.info("Login Success: loginId=" + currentLoginId + ", msaSessionId=" + ", details is null");
- }
-
- }
-
- return user;
- }
-
- private boolean validateUser(User user, String currentUsername) {
- if (currentUsername.equalsIgnoreCase(user.getUsername())) {
- return true;
- } else {
- logger.info("loginId doesn't match loginId from HTTPSession. Will create new session. loginId="
- + currentUsername + ", user=" + user, new Exception());
- return false;
- }
- }
-
-}
[10/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
new file mode 100644
index 0000000..13df470
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/ManagerBase.java
@@ -0,0 +1,221 @@
+/*
+ * 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.manager;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Scanner;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.ambari.logsearch.model.response.LogData;
+import org.apache.ambari.logsearch.model.response.LogSearchResponse;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.ambari.logsearch.dao.SolrDaoBase;
+import org.apache.ambari.logsearch.query.QueryGeneration;
+import org.apache.ambari.logsearch.util.DateUtil;
+import org.apache.ambari.logsearch.util.JSONUtil;
+import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.SolrException;
+
+import javax.inject.Inject;
+
+public abstract class ManagerBase<LOG_DATA_TYPE extends LogData, SEARCH_RESPONSE extends LogSearchResponse> extends JsonManagerBase {
+ private static final Logger logger = Logger.getLogger(ManagerBase.class);
+
+ @Inject
+ protected QueryGeneration queryGenerator;
+
+ public enum LogType {
+ SERVICE("Service"),
+ AUDIT("Audit");
+
+ private String label;
+
+ private LogType(String label) {
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+ }
+
+ public ManagerBase() {
+ super();
+ }
+
+ public String getHadoopServiceConfigJSON() {
+ StringBuilder result = new StringBuilder("");
+
+ // Get file from resources folder
+ ClassLoader classLoader = getClass().getClassLoader();
+ File file = new File(classLoader.getResource("HadoopServiceConfig.json").getFile());
+
+ try (Scanner scanner = new Scanner(file)) {
+
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine();
+ result.append(line).append("\n");
+ }
+
+ scanner.close();
+
+ } catch (IOException e) {
+ logger.error("Unable to read HadoopServiceConfig.json", e);
+ throw RESTErrorUtil.createRESTException(e.getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ String hadoopServiceConfig = result.toString();
+ if (JSONUtil.isJSONValid(hadoopServiceConfig)) {
+ return hadoopServiceConfig;
+ }
+ throw RESTErrorUtil.createRESTException("Improper JSON", MessageEnums.ERROR_SYSTEM);
+
+ }
+
+ protected SEARCH_RESPONSE getLastPage(SearchCriteria searchCriteria, String logTimeField, SolrDaoBase solrDoaBase,
+ SolrQuery lastPageQuery) {
+
+ Integer maxRows = searchCriteria.getMaxRows();
+ String givenSortType = searchCriteria.getSortType();
+ searchCriteria = new SearchCriteria();
+ searchCriteria.setSortBy(logTimeField);
+ if (givenSortType == null || givenSortType.equals(LogSearchConstants.DESCENDING_ORDER)) {
+ lastPageQuery.removeSort(LogSearchConstants.LOGTIME);
+ searchCriteria.setSortType(LogSearchConstants.ASCENDING_ORDER);
+ } else {
+ searchCriteria.setSortType(LogSearchConstants.DESCENDING_ORDER);
+ }
+ queryGenerator.setSingleSortOrder(lastPageQuery, searchCriteria);
+
+
+ Long totalLogs = 0l;
+ int startIndex = 0;
+ int numberOfLogsOnLastPage = 0;
+ SEARCH_RESPONSE logResponse = null;
+ try {
+ SolrUtil.setStart(lastPageQuery, 0);
+ SolrUtil.setRowCount(lastPageQuery, maxRows);
+ logResponse = getLogAsPaginationProvided(lastPageQuery, solrDoaBase);
+ totalLogs = countQuery(lastPageQuery,solrDoaBase);
+ startIndex = Integer.parseInt("" + ((totalLogs / maxRows) * maxRows));
+ numberOfLogsOnLastPage = Integer.parseInt("" + (totalLogs - startIndex));
+ logResponse.setStartIndex(startIndex);
+ logResponse.setTotalCount(totalLogs);
+ logResponse.setPageSize(maxRows);
+ List<LOG_DATA_TYPE> docList = logResponse.getLogList();
+ List<LOG_DATA_TYPE> lastPageDocList = new ArrayList<>();
+ logResponse.setLogList(lastPageDocList);
+ int cnt = 0;
+ for(LOG_DATA_TYPE doc:docList){
+ if(cnt<numberOfLogsOnLastPage){
+ lastPageDocList.add(doc);
+ }
+ cnt++;
+ }
+ Collections.reverse(lastPageDocList);
+
+ } catch (SolrException | SolrServerException | IOException | NumberFormatException e) {
+ logger.error("Count Query was not executed successfully",e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ return logResponse;
+ }
+
+ protected SEARCH_RESPONSE getLogAsPaginationProvided(SolrQuery solrQuery, SolrDaoBase solrDaoBase) {
+ try {
+ QueryResponse response = solrDaoBase.process(solrQuery);
+ SEARCH_RESPONSE logResponse = createLogSearchResponse();
+ SolrDocumentList docList = response.getResults();
+ List<LOG_DATA_TYPE> serviceLogDataList = convertToSolrBeans(response);
+ if (docList != null && !docList.isEmpty()) {
+ logResponse.setLogList(serviceLogDataList);
+ logResponse.setStartIndex((int) docList.getStart());
+ logResponse.setTotalCount(docList.getNumFound());
+ Integer rowNumber = solrQuery.getRows();
+ if (rowNumber == null) {
+ logger.error("No RowNumber was set in solrQuery");
+ return createLogSearchResponse();
+ }
+ logResponse.setPageSize(rowNumber);
+ }
+ return logResponse;
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ protected Long countQuery(SolrQuery query,SolrDaoBase solrDaoBase) throws SolrException, SolrServerException, IOException {
+ query.setRows(0);
+ QueryResponse response = solrDaoBase.process(query);
+ if (response == null) {
+ return 0l;
+ }
+ SolrDocumentList docList = response.getResults();
+ if (docList == null) {
+ return 0l;
+ }
+ return docList.getNumFound();
+ }
+
+ protected String getUnit(String unit) {
+ if (StringUtils.isBlank(unit)) {
+ unit = "+1HOUR";
+ }
+ return unit;
+ }
+
+ protected String getFrom(String from) {
+ if (StringUtils.isBlank(from)) {
+ Date date = DateUtil.getTodayFromDate();
+ try {
+ from = DateUtil.convertGivenDateFormatToSolrDateFormat(date);
+ } catch (ParseException e) {
+ from = "NOW";
+ }
+ }
+ return from;
+ }
+
+ protected String getTo(String to) {
+ if (StringUtils.isBlank(to)) {
+ to = "NOW";
+ }
+ return to;
+ }
+
+ protected abstract List<LOG_DATA_TYPE> convertToSolrBeans(QueryResponse response);
+
+ protected abstract SEARCH_RESPONSE createLogSearchResponse();
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java
deleted file mode 100644
index c0be79d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/MgrBase.java
+++ /dev/null
@@ -1,256 +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.manager;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Scanner;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.query.QueryGeneration;
-import org.apache.ambari.logsearch.util.DateUtil;
-import org.apache.ambari.logsearch.util.JSONUtil;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VSolrLogList;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
-public class MgrBase {
- private static final Logger logger = Logger.getLogger(MgrBase.class);
-
- @Autowired
- protected QueryGeneration queryGenerator;
-
- private JsonSerializer<Date> jsonDateSerialiazer = null;
- private JsonDeserializer<Date> jsonDateDeserialiazer = null;
-
- public enum LogType {
- SERVICE("Service"),
- AUDIT("Audit");
-
- private String label;
-
- private LogType(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
- }
-
- public MgrBase() {
- jsonDateSerialiazer = new JsonSerializer<Date>() {
-
- @Override
- public JsonElement serialize(Date paramT, java.lang.reflect.Type paramType, JsonSerializationContext paramJsonSerializationContext) {
- return paramT == null ? null : new JsonPrimitive(paramT.getTime());
- }
- };
-
- jsonDateDeserialiazer = new JsonDeserializer<Date>() {
-
- @Override
- public Date deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
- return json == null ? null : new Date(json.getAsLong());
- }
-
- };
- }
-
- protected String convertObjToString(Object obj) {
- if (obj == null) {
- return "";
- }
-
- Gson gson = new GsonBuilder()
- .registerTypeAdapter(Date.class, jsonDateSerialiazer)
- .registerTypeAdapter(Date.class, jsonDateDeserialiazer).create();
-
- return gson.toJson(obj);
- }
-
- public String getHadoopServiceConfigJSON() {
- StringBuilder result = new StringBuilder("");
-
- // Get file from resources folder
- ClassLoader classLoader = getClass().getClassLoader();
- File file = new File(classLoader.getResource("HadoopServiceConfig.json").getFile());
-
- try (Scanner scanner = new Scanner(file)) {
-
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine();
- result.append(line).append("\n");
- }
-
- scanner.close();
-
- } catch (IOException e) {
- logger.error("Unable to read HadoopServiceConfig.json", e);
- throw RESTErrorUtil.createRESTException(e.getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- String hadoopServiceConfig = result.toString();
- if (JSONUtil.isJSONValid(hadoopServiceConfig)) {
- return hadoopServiceConfig;
- }
- throw RESTErrorUtil.createRESTException("Improper JSON", MessageEnums.ERROR_SYSTEM);
-
- }
-
- protected VSolrLogList getLastPage(SearchCriteria searchCriteria, String logTimeField, SolrDaoBase solrDoaBase,
- SolrQuery lastPageQuery) {
-
- Integer maxRows = searchCriteria.getMaxRows();
- String givenSortType = searchCriteria.getSortType();
- searchCriteria = new SearchCriteria();
- searchCriteria.setSortBy(logTimeField);
- if (givenSortType == null || givenSortType.equals(LogSearchConstants.DESCENDING_ORDER)) {
- lastPageQuery.removeSort(LogSearchConstants.LOGTIME);
- searchCriteria.setSortType(LogSearchConstants.ASCENDING_ORDER);
- } else {
- searchCriteria.setSortType(LogSearchConstants.DESCENDING_ORDER);
- }
- queryGenerator.setSingleSortOrder(lastPageQuery, searchCriteria);
-
-
- Long totalLogs = 0l;
- int startIndex = 0;
- int numberOfLogsOnLastPage = 0;
- VSolrLogList collection = null;
- try {
- SolrUtil.setStart(lastPageQuery, 0);
- SolrUtil.setRowCount(lastPageQuery, maxRows);
- collection = getLogAsPaginationProvided(lastPageQuery, solrDoaBase);
- totalLogs = countQuery(lastPageQuery,solrDoaBase);
- if(maxRows != null){
- startIndex = Integer.parseInt("" + ((totalLogs/maxRows) * maxRows));
- numberOfLogsOnLastPage = Integer.parseInt("" + (totalLogs-startIndex));
- }
- collection.setStartIndex(startIndex);
- collection.setTotalCount(totalLogs);
- collection.setPageSize(maxRows);
- SolrDocumentList docList = collection.getList();
- SolrDocumentList lastPageDocList = new SolrDocumentList();
- collection.setSolrDocuments(lastPageDocList);
- int cnt = 0;
- for(SolrDocument doc:docList){
- if(cnt<numberOfLogsOnLastPage){
- lastPageDocList.add(doc);
- }
- cnt++;
- }
- Collections.reverse(lastPageDocList);
-
- } catch (SolrException | SolrServerException | IOException | NumberFormatException e) {
- logger.error("Count Query was not executed successfully",e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- return collection;
- }
-
- protected VSolrLogList getLogAsPaginationProvided(SolrQuery solrQuery, SolrDaoBase solrDaoBase) {
- try {
- QueryResponse response = solrDaoBase.process(solrQuery);
- VSolrLogList collection = new VSolrLogList();
- SolrDocumentList docList = response.getResults();
- if (docList != null && !docList.isEmpty()) {
- collection.setSolrDocuments(docList);
- collection.setStartIndex((int) docList.getStart());
- collection.setTotalCount(docList.getNumFound());
- Integer rowNumber = solrQuery.getRows();
- if (rowNumber == null) {
- logger.error("No RowNumber was set in solrQuery");
- return new VSolrLogList();
- }
- collection.setPageSize(rowNumber);
- }
- return collection;
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- protected Long countQuery(SolrQuery query,SolrDaoBase solrDaoBase) throws SolrException, SolrServerException, IOException {
- query.setRows(0);
- QueryResponse response = solrDaoBase.process(query);
- if (response == null) {
- return 0l;
- }
- SolrDocumentList docList = response.getResults();
- if (docList == null) {
- return 0l;
- }
- return docList.getNumFound();
- }
-
- protected String getUnit(String unit) {
- if (StringUtils.isBlank(unit)) {
- unit = "+1HOUR";
- }
- return unit;
- }
-
- protected String getFrom(String from) {
- if (StringUtils.isBlank(from)) {
- Date date = DateUtil.getTodayFromDate();
- try {
- from = DateUtil.convertGivenDateFormatToSolrDateFormat(date);
- } catch (ParseException e) {
- from = "NOW";
- }
- }
- return from;
- }
-
- protected String getTo(String to) {
- if (StringUtils.isBlank(to)) {
- to = "NOW";
- }
- return to;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.java
new file mode 100644
index 0000000..23f62aa
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicManager.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.manager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ambari.logsearch.model.response.NameValueData;
+import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
+import org.apache.ambari.logsearch.web.security.LogsearchSimpleAuthenticationProvider;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+
+@Component
+public class PublicManager extends JsonManagerBase {
+
+ @Inject
+ private LogsearchSimpleAuthenticationProvider simpleAuthenticationProvider;
+
+ public String getGeneralConfig() {
+ NameValueDataListResponse nameValueList = new NameValueDataListResponse();
+ List<NameValueData> nameValues = new ArrayList<>();
+ NameValueData nameValue = new NameValueData();
+ nameValue.setName("simpleAuth");
+ nameValue.setValue("" + simpleAuthenticationProvider.isEnable());
+ nameValues.add(nameValue);
+ nameValueList.setvNameValues(nameValues);
+ return convertObjToString(nameValueList);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java
deleted file mode 100644
index 398d270..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/PublicMgr.java
+++ /dev/null
@@ -1,46 +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.manager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ambari.logsearch.view.VNameValue;
-import org.apache.ambari.logsearch.view.VNameValueList;
-import org.apache.ambari.logsearch.web.security.LogsearchSimpleAuthenticationProvider;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class PublicMgr extends MgrBase {
- @Autowired
- private LogsearchSimpleAuthenticationProvider simpleAuthenticationProvider;
-
- public String getGeneralConfig() {
- VNameValueList nameValueList = new VNameValueList();
- List<VNameValue> nameValues = new ArrayList<VNameValue>();
- VNameValue nameValue = new VNameValue();
- nameValue.setName("simpleAuth");
- nameValue.setValue("" + simpleAuthenticationProvider.isEnable());
- nameValues.add(nameValue);
- nameValueList.setVNameValues(nameValues);
- return convertObjToString(nameValueList);
- }
-}
[14/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/production/r.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/production/r.js b/ambari-logsearch/ambari-logsearch-portal/production/r.js
deleted file mode 100644
index 6e6ffd0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/production/r.js
+++ /dev/null
@@ -1,32140 +0,0 @@
-/**
- * @license r.js 2.1.22 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
- * Available via the MIT or new BSD license.
- * see: http://github.com/jrburke/requirejs for details
- */
-
-/*
- * This is a bootstrap script to allow running RequireJS in the command line
- * in either a Java/Rhino or Node environment. It is modified by the top-level
- * dist.js file to inject other files to completely enable this file. It is
- * the shell of the r.js file.
- */
-
-/*jslint evil: true, nomen: true, sloppy: true */
-/*global readFile: true, process: false, Packages: false, print: false,
-console: false, java: false, module: false, requirejsVars, navigator,
-document, importScripts, self, location, Components, FileUtils */
-
-var requirejs, require, define, xpcUtil;
-(function (console, args, readFileFunc) {
- var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
- nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
- version = '2.1.22',
- jsSuffixRegExp = /\.js$/,
- commandOption = '',
- useLibLoaded = {},
- //Used by jslib/rhino/args.js
- rhinoArgs = args,
- //Used by jslib/xpconnect/args.js
- xpconnectArgs = args,
- readFile = typeof readFileFunc !== 'undefined' ? readFileFunc : null;
-
- function showHelp() {
- console.log('See https://github.com/jrburke/r.js for usage.');
- }
-
- if ((typeof navigator !== 'undefined' && typeof document !== 'undefined') ||
- (typeof importScripts !== 'undefined' && typeof self !== 'undefined')) {
- env = 'browser';
-
- readFile = function (path) {
- return fs.readFileSync(path, 'utf8');
- };
-
- exec = function (string) {
- return eval(string);
- };
-
- exists = function () {
- console.log('x.js exists not applicable in browser env');
- return false;
- };
-
- } else if (typeof process !== 'undefined' && process.versions && !!process.versions.node) {
- env = 'node';
-
- //Get the fs module via Node's require before it
- //gets replaced. Used in require/node.js
- fs = require('fs');
- vm = require('vm');
- path = require('path');
- //In Node 0.7+ existsSync is on fs.
- existsForNode = fs.existsSync || path.existsSync;
-
- nodeRequire = require;
- nodeDefine = define;
- reqMain = require.main;
-
- //Temporarily hide require and define to allow require.js to define
- //them.
- require = undefined;
- define = undefined;
-
- readFile = function (path) {
- return fs.readFileSync(path, 'utf8');
- };
-
- exec = function (string, name) {
- return vm.runInThisContext(this.requirejsVars.require.makeNodeWrapper(string),
- name ? fs.realpathSync(name) : '');
- };
-
- exists = function (fileName) {
- return existsForNode(fileName);
- };
-
-
- fileName = process.argv[2];
-
- if (fileName && fileName.indexOf('-') === 0) {
- commandOption = fileName.substring(1);
- fileName = process.argv[3];
- }
- } else if (typeof Packages !== 'undefined') {
- env = 'rhino';
-
- fileName = args[0];
-
- if (fileName && fileName.indexOf('-') === 0) {
- commandOption = fileName.substring(1);
- fileName = args[1];
- }
-
- //Exec/readFile differs between Rhino and Nashorn. Rhino has an
- //importPackage where Nashorn does not, so branch on that. This is a
- //coarser check -- detecting readFile existence might also be enough for
- //this spot. However, sticking with importPackage to keep it the same
- //as other Rhino/Nashorn detection branches.
- if (typeof importPackage !== 'undefined') {
- rhinoContext = Packages.org.mozilla.javascript.ContextFactory.getGlobal().enterContext();
-
- exec = function (string, name) {
- return rhinoContext.evaluateString(this, string, name, 0, null);
- };
- } else {
- exec = function (string, name) {
- load({ script: string, name: name});
- };
- readFile = readFully;
- }
-
- exists = function (fileName) {
- return (new java.io.File(fileName)).exists();
- };
-
- //Define a console.log for easier logging. Don't
- //get fancy though.
- if (typeof console === 'undefined') {
- console = {
- log: function () {
- print.apply(undefined, arguments);
- }
- };
- }
- } else if (typeof Components !== 'undefined' && Components.classes && Components.interfaces) {
- env = 'xpconnect';
-
- Components.utils['import']('resource://gre/modules/FileUtils.jsm');
- Cc = Components.classes;
- Ci = Components.interfaces;
-
- fileName = args[0];
-
- if (fileName && fileName.indexOf('-') === 0) {
- commandOption = fileName.substring(1);
- fileName = args[1];
- }
-
- xpcUtil = {
- isWindows: ('@mozilla.org/windows-registry-key;1' in Cc),
- cwd: function () {
- return FileUtils.getFile("CurWorkD", []).path;
- },
-
- //Remove . and .. from paths, normalize on front slashes
- normalize: function (path) {
- //There has to be an easier way to do this.
- var i, part, ary,
- firstChar = path.charAt(0);
-
- if (firstChar !== '/' &&
- firstChar !== '\\' &&
- path.indexOf(':') === -1) {
- //A relative path. Use the current working directory.
- path = xpcUtil.cwd() + '/' + path;
- }
-
- ary = path.replace(/\\/g, '/').split('/');
-
- for (i = 0; i < ary.length; i += 1) {
- part = ary[i];
- if (part === '.') {
- ary.splice(i, 1);
- i -= 1;
- } else if (part === '..') {
- ary.splice(i - 1, 2);
- i -= 2;
- }
- }
- return ary.join('/');
- },
-
- xpfile: function (path) {
- var fullPath;
- try {
- fullPath = xpcUtil.normalize(path);
- if (xpcUtil.isWindows) {
- fullPath = fullPath.replace(/\//g, '\\');
- }
- return new FileUtils.File(fullPath);
- } catch (e) {
- throw new Error((fullPath || path) + ' failed: ' + e);
- }
- },
-
- readFile: function (/*String*/path, /*String?*/encoding) {
- //A file read function that can deal with BOMs
- encoding = encoding || "utf-8";
-
- var inStream, convertStream,
- readData = {},
- fileObj = xpcUtil.xpfile(path);
-
- //XPCOM, you so crazy
- try {
- inStream = Cc['@mozilla.org/network/file-input-stream;1']
- .createInstance(Ci.nsIFileInputStream);
- inStream.init(fileObj, 1, 0, false);
-
- convertStream = Cc['@mozilla.org/intl/converter-input-stream;1']
- .createInstance(Ci.nsIConverterInputStream);
- convertStream.init(inStream, encoding, inStream.available(),
- Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
-
- convertStream.readString(inStream.available(), readData);
- return readData.value;
- } catch (e) {
- throw new Error((fileObj && fileObj.path || '') + ': ' + e);
- } finally {
- if (convertStream) {
- convertStream.close();
- }
- if (inStream) {
- inStream.close();
- }
- }
- }
- };
-
- readFile = xpcUtil.readFile;
-
- exec = function (string) {
- return eval(string);
- };
-
- exists = function (fileName) {
- return xpcUtil.xpfile(fileName).exists();
- };
-
- //Define a console.log for easier logging. Don't
- //get fancy though.
- if (typeof console === 'undefined') {
- console = {
- log: function () {
- print.apply(undefined, arguments);
- }
- };
- }
- }
-
- /** vim: et:ts=4:sw=4:sts=4
- * @license RequireJS 2.1.22 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved.
- * Available via the MIT or new BSD license.
- * see: http://github.com/jrburke/requirejs for details
- */
-//Not using strict: uneven strict support in browsers, #392, and causes
-//problems with requirejs.exec()/transpiler plugins that may not be strict.
-/*jslint regexp: true, nomen: true, sloppy: true */
-/*global window, navigator, document, importScripts, setTimeout, opera */
-
-
-(function (global) {
- var req, s, head, baseElement, dataMain, src,
- interactiveScript, currentlyAddingScript, mainScript, subPath,
- version = '2.1.22',
- commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
- cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
- jsSuffixRegExp = /\.js$/,
- currDirRegExp = /^\.\//,
- op = Object.prototype,
- ostring = op.toString,
- hasOwn = op.hasOwnProperty,
- ap = Array.prototype,
- isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
- isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
- //PS3 indicates loaded and complete, but need to wait for complete
- //specifically. Sequence is 'loading', 'loaded', execution,
- // then 'complete'. The UA check is unfortunate, but not sure how
- //to feature test w/o causing perf issues.
- readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
- /^complete$/ : /^(complete|loaded)$/,
- defContextName = '_',
- //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
- isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
- contexts = {},
- cfg = {},
- globalDefQueue = [],
- useInteractive = false;
-
- function isFunction(it) {
- return ostring.call(it) === '[object Function]';
- }
-
- function isArray(it) {
- return ostring.call(it) === '[object Array]';
- }
-
- /**
- * Helper function for iterating over an array. If the func returns
- * a true value, it will break out of the loop.
- */
- function each(ary, func) {
- if (ary) {
- var i;
- for (i = 0; i < ary.length; i += 1) {
- if (ary[i] && func(ary[i], i, ary)) {
- break;
- }
- }
- }
- }
-
- /**
- * Helper function for iterating over an array backwards. If the func
- * returns a true value, it will break out of the loop.
- */
- function eachReverse(ary, func) {
- if (ary) {
- var i;
- for (i = ary.length - 1; i > -1; i -= 1) {
- if (ary[i] && func(ary[i], i, ary)) {
- break;
- }
- }
- }
- }
-
- function hasProp(obj, prop) {
- return hasOwn.call(obj, prop);
- }
-
- function getOwn(obj, prop) {
- return hasProp(obj, prop) && obj[prop];
- }
-
- /**
- * Cycles over properties in an object and calls a function for each
- * property value. If the function returns a truthy value, then the
- * iteration is stopped.
- */
- function eachProp(obj, func) {
- var prop;
- for (prop in obj) {
- if (hasProp(obj, prop)) {
- if (func(obj[prop], prop)) {
- break;
- }
- }
- }
- }
-
- /**
- * Simple function to mix in properties from source into target,
- * but only if target does not already have a property of the same name.
- */
- function mixin(target, source, force, deepStringMixin) {
- if (source) {
- eachProp(source, function (value, prop) {
- if (force || !hasProp(target, prop)) {
- if (deepStringMixin && typeof value === 'object' && value &&
- !isArray(value) && !isFunction(value) &&
- !(value instanceof RegExp)) {
-
- if (!target[prop]) {
- target[prop] = {};
- }
- mixin(target[prop], value, force, deepStringMixin);
- } else {
- target[prop] = value;
- }
- }
- });
- }
- return target;
- }
-
- //Similar to Function.prototype.bind, but the 'this' object is specified
- //first, since it is easier to read/figure out what 'this' will be.
- function bind(obj, fn) {
- return function () {
- return fn.apply(obj, arguments);
- };
- }
-
- function scripts() {
- return document.getElementsByTagName('script');
- }
-
- function defaultOnError(err) {
- throw err;
- }
-
- //Allow getting a global that is expressed in
- //dot notation, like 'a.b.c'.
- function getGlobal(value) {
- if (!value) {
- return value;
- }
- var g = global;
- each(value.split('.'), function (part) {
- g = g[part];
- });
- return g;
- }
-
- /**
- * Constructs an error with a pointer to an URL with more information.
- * @param {String} id the error ID that maps to an ID on a web page.
- * @param {String} message human readable error.
- * @param {Error} [err] the original error, if there is one.
- *
- * @returns {Error}
- */
- function makeError(id, msg, err, requireModules) {
- var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
- e.requireType = id;
- e.requireModules = requireModules;
- if (err) {
- e.originalError = err;
- }
- return e;
- }
-
- if (typeof define !== 'undefined') {
- //If a define is already in play via another AMD loader,
- //do not overwrite.
- return;
- }
-
- if (typeof requirejs !== 'undefined') {
- if (isFunction(requirejs)) {
- //Do not overwrite an existing requirejs instance.
- return;
- }
- cfg = requirejs;
- requirejs = undefined;
- }
-
- //Allow for a require config object
- if (typeof require !== 'undefined' && !isFunction(require)) {
- //assume it is a config object.
- cfg = require;
- require = undefined;
- }
-
- function newContext(contextName) {
- var inCheckLoaded, Module, context, handlers,
- checkLoadedTimeoutId,
- config = {
- //Defaults. Do not set a default for map
- //config to speed up normalize(), which
- //will run faster if there is no default.
- waitSeconds: 7,
- baseUrl: './',
- paths: {},
- bundles: {},
- pkgs: {},
- shim: {},
- config: {}
- },
- registry = {},
- //registry of just enabled modules, to speed
- //cycle breaking code when lots of modules
- //are registered, but not activated.
- enabledRegistry = {},
- undefEvents = {},
- defQueue = [],
- defined = {},
- urlFetched = {},
- bundlesMap = {},
- requireCounter = 1,
- unnormalizedCounter = 1;
-
- /**
- * Trims the . and .. from an array of path segments.
- * It will keep a leading path segment if a .. will become
- * the first path segment, to help with module name lookups,
- * which act like paths, but can be remapped. But the end result,
- * all paths that use this function should look normalized.
- * NOTE: this method MODIFIES the input array.
- * @param {Array} ary the array of path segments.
- */
- function trimDots(ary) {
- var i, part;
- for (i = 0; i < ary.length; i++) {
- part = ary[i];
- if (part === '.') {
- ary.splice(i, 1);
- i -= 1;
- } else if (part === '..') {
- // If at the start, or previous value is still ..,
- // keep them so that when converted to a path it may
- // still work when converted to a path, even though
- // as an ID it is less than ideal. In larger point
- // releases, may be better to just kick out an error.
- if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') {
- continue;
- } else if (i > 0) {
- ary.splice(i - 1, 2);
- i -= 2;
- }
- }
- }
- }
-
- /**
- * Given a relative module name, like ./something, normalize it to
- * a real name that can be mapped to a path.
- * @param {String} name the relative name
- * @param {String} baseName a real name that the name arg is relative
- * to.
- * @param {Boolean} applyMap apply the map config to the value. Should
- * only be done if this normalization is for a dependency ID.
- * @returns {String} normalized name
- */
- function normalize(name, baseName, applyMap) {
- var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,
- foundMap, foundI, foundStarMap, starI, normalizedBaseParts,
- baseParts = (baseName && baseName.split('/')),
- map = config.map,
- starMap = map && map['*'];
-
- //Adjust any relative paths.
- if (name) {
- name = name.split('/');
- lastIndex = name.length - 1;
-
- // If wanting node ID compatibility, strip .js from end
- // of IDs. Have to do this here, and not in nameToUrl
- // because node allows either .js or non .js to map
- // to same file.
- if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
- name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
- }
-
- // Starts with a '.' so need the baseName
- if (name[0].charAt(0) === '.' && baseParts) {
- //Convert baseName to array, and lop off the last part,
- //so that . matches that 'directory' and not name of the baseName's
- //module. For instance, baseName of 'one/two/three', maps to
- //'one/two/three.js', but we want the directory, 'one/two' for
- //this normalization.
- normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
- name = normalizedBaseParts.concat(name);
- }
-
- trimDots(name);
- name = name.join('/');
- }
-
- //Apply map config if available.
- if (applyMap && map && (baseParts || starMap)) {
- nameParts = name.split('/');
-
- outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
- nameSegment = nameParts.slice(0, i).join('/');
-
- if (baseParts) {
- //Find the longest baseName segment match in the config.
- //So, do joins on the biggest to smallest lengths of baseParts.
- for (j = baseParts.length; j > 0; j -= 1) {
- mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
-
- //baseName segment has config, find if it has one for
- //this name.
- if (mapValue) {
- mapValue = getOwn(mapValue, nameSegment);
- if (mapValue) {
- //Match, update name to the new value.
- foundMap = mapValue;
- foundI = i;
- break outerLoop;
- }
- }
- }
- }
-
- //Check for a star map match, but just hold on to it,
- //if there is a shorter segment match later in a matching
- //config, then favor over this star map.
- if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
- foundStarMap = getOwn(starMap, nameSegment);
- starI = i;
- }
- }
-
- if (!foundMap && foundStarMap) {
- foundMap = foundStarMap;
- foundI = starI;
- }
-
- if (foundMap) {
- nameParts.splice(0, foundI, foundMap);
- name = nameParts.join('/');
- }
- }
-
- // If the name points to a package's name, use
- // the package main instead.
- pkgMain = getOwn(config.pkgs, name);
-
- return pkgMain ? pkgMain : name;
- }
-
- function removeScript(name) {
- if (isBrowser) {
- each(scripts(), function (scriptNode) {
- if (scriptNode.getAttribute('data-requiremodule') === name &&
- scriptNode.getAttribute('data-requirecontext') === context.contextName) {
- scriptNode.parentNode.removeChild(scriptNode);
- return true;
- }
- });
- }
- }
-
- function hasPathFallback(id) {
- var pathConfig = getOwn(config.paths, id);
- if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
- //Pop off the first array value, since it failed, and
- //retry
- pathConfig.shift();
- context.require.undef(id);
-
- //Custom require that does not do map translation, since
- //ID is "absolute", already mapped/resolved.
- context.makeRequire(null, {
- skipMap: true
- })([id]);
-
- return true;
- }
- }
-
- //Turns a plugin!resource to [plugin, resource]
- //with the plugin being undefined if the name
- //did not have a plugin prefix.
- function splitPrefix(name) {
- var prefix,
- index = name ? name.indexOf('!') : -1;
- if (index > -1) {
- prefix = name.substring(0, index);
- name = name.substring(index + 1, name.length);
- }
- return [prefix, name];
- }
-
- /**
- * Creates a module mapping that includes plugin prefix, module
- * name, and path. If parentModuleMap is provided it will
- * also normalize the name via require.normalize()
- *
- * @param {String} name the module name
- * @param {String} [parentModuleMap] parent module map
- * for the module name, used to resolve relative names.
- * @param {Boolean} isNormalized: is the ID already normalized.
- * This is true if this call is done for a define() module ID.
- * @param {Boolean} applyMap: apply the map config to the ID.
- * Should only be true if this map is for a dependency.
- *
- * @returns {Object}
- */
- function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
- var url, pluginModule, suffix, nameParts,
- prefix = null,
- parentName = parentModuleMap ? parentModuleMap.name : null,
- originalName = name,
- isDefine = true,
- normalizedName = '';
-
- //If no name, then it means it is a require call, generate an
- //internal name.
- if (!name) {
- isDefine = false;
- name = '_@r' + (requireCounter += 1);
- }
-
- nameParts = splitPrefix(name);
- prefix = nameParts[0];
- name = nameParts[1];
-
- if (prefix) {
- prefix = normalize(prefix, parentName, applyMap);
- pluginModule = getOwn(defined, prefix);
- }
-
- //Account for relative paths if there is a base name.
- if (name) {
- if (prefix) {
- if (pluginModule && pluginModule.normalize) {
- //Plugin is loaded, use its normalize method.
- normalizedName = pluginModule.normalize(name, function (name) {
- return normalize(name, parentName, applyMap);
- });
- } else {
- // If nested plugin references, then do not try to
- // normalize, as it will not normalize correctly. This
- // places a restriction on resourceIds, and the longer
- // term solution is not to normalize until plugins are
- // loaded and all normalizations to allow for async
- // loading of a loader plugin. But for now, fixes the
- // common uses. Details in #1131
- normalizedName = name.indexOf('!') === -1 ?
- normalize(name, parentName, applyMap) :
- name;
- }
- } else {
- //A regular module.
- normalizedName = normalize(name, parentName, applyMap);
-
- //Normalized name may be a plugin ID due to map config
- //application in normalize. The map config values must
- //already be normalized, so do not need to redo that part.
- nameParts = splitPrefix(normalizedName);
- prefix = nameParts[0];
- normalizedName = nameParts[1];
- isNormalized = true;
-
- url = context.nameToUrl(normalizedName);
- }
- }
-
- //If the id is a plugin id that cannot be determined if it needs
- //normalization, stamp it with a unique ID so two matching relative
- //ids that may conflict can be separate.
- suffix = prefix && !pluginModule && !isNormalized ?
- '_unnormalized' + (unnormalizedCounter += 1) :
- '';
-
- return {
- prefix: prefix,
- name: normalizedName,
- parentMap: parentModuleMap,
- unnormalized: !!suffix,
- url: url,
- originalName: originalName,
- isDefine: isDefine,
- id: (prefix ?
- prefix + '!' + normalizedName :
- normalizedName) + suffix
- };
- }
-
- function getModule(depMap) {
- var id = depMap.id,
- mod = getOwn(registry, id);
-
- if (!mod) {
- mod = registry[id] = new context.Module(depMap);
- }
-
- return mod;
- }
-
- function on(depMap, name, fn) {
- var id = depMap.id,
- mod = getOwn(registry, id);
-
- if (hasProp(defined, id) &&
- (!mod || mod.defineEmitComplete)) {
- if (name === 'defined') {
- fn(defined[id]);
- }
- } else {
- mod = getModule(depMap);
- if (mod.error && name === 'error') {
- fn(mod.error);
- } else {
- mod.on(name, fn);
- }
- }
- }
-
- function onError(err, errback) {
- var ids = err.requireModules,
- notified = false;
-
- if (errback) {
- errback(err);
- } else {
- each(ids, function (id) {
- var mod = getOwn(registry, id);
- if (mod) {
- //Set error on module, so it skips timeout checks.
- mod.error = err;
- if (mod.events.error) {
- notified = true;
- mod.emit('error', err);
- }
- }
- });
-
- if (!notified) {
- req.onError(err);
- }
- }
- }
-
- /**
- * Internal method to transfer globalQueue items to this context's
- * defQueue.
- */
- function takeGlobalQueue() {
- //Push all the globalDefQueue items into the context's defQueue
- if (globalDefQueue.length) {
- each(globalDefQueue, function(queueItem) {
- var id = queueItem[0];
- if (typeof id === 'string') {
- context.defQueueMap[id] = true;
- }
- defQueue.push(queueItem);
- });
- globalDefQueue = [];
- }
- }
-
- handlers = {
- 'require': function (mod) {
- if (mod.require) {
- return mod.require;
- } else {
- return (mod.require = context.makeRequire(mod.map));
- }
- },
- 'exports': function (mod) {
- mod.usingExports = true;
- if (mod.map.isDefine) {
- if (mod.exports) {
- return (defined[mod.map.id] = mod.exports);
- } else {
- return (mod.exports = defined[mod.map.id] = {});
- }
- }
- },
- 'module': function (mod) {
- if (mod.module) {
- return mod.module;
- } else {
- return (mod.module = {
- id: mod.map.id,
- uri: mod.map.url,
- config: function () {
- return getOwn(config.config, mod.map.id) || {};
- },
- exports: mod.exports || (mod.exports = {})
- });
- }
- }
- };
-
- function cleanRegistry(id) {
- //Clean up machinery used for waiting modules.
- delete registry[id];
- delete enabledRegistry[id];
- }
-
- function breakCycle(mod, traced, processed) {
- var id = mod.map.id;
-
- if (mod.error) {
- mod.emit('error', mod.error);
- } else {
- traced[id] = true;
- each(mod.depMaps, function (depMap, i) {
- var depId = depMap.id,
- dep = getOwn(registry, depId);
-
- //Only force things that have not completed
- //being defined, so still in the registry,
- //and only if it has not been matched up
- //in the module already.
- if (dep && !mod.depMatched[i] && !processed[depId]) {
- if (getOwn(traced, depId)) {
- mod.defineDep(i, defined[depId]);
- mod.check(); //pass false?
- } else {
- breakCycle(dep, traced, processed);
- }
- }
- });
- processed[id] = true;
- }
- }
-
- function checkLoaded() {
- var err, usingPathFallback,
- waitInterval = config.waitSeconds * 1000,
- //It is possible to disable the wait interval by using waitSeconds of 0.
- expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
- noLoads = [],
- reqCalls = [],
- stillLoading = false,
- needCycleCheck = true;
-
- //Do not bother if this call was a result of a cycle break.
- if (inCheckLoaded) {
- return;
- }
-
- inCheckLoaded = true;
-
- //Figure out the state of all the modules.
- eachProp(enabledRegistry, function (mod) {
- var map = mod.map,
- modId = map.id;
-
- //Skip things that are not enabled or in error state.
- if (!mod.enabled) {
- return;
- }
-
- if (!map.isDefine) {
- reqCalls.push(mod);
- }
-
- if (!mod.error) {
- //If the module should be executed, and it has not
- //been inited and time is up, remember it.
- if (!mod.inited && expired) {
- if (hasPathFallback(modId)) {
- usingPathFallback = true;
- stillLoading = true;
- } else {
- noLoads.push(modId);
- removeScript(modId);
- }
- } else if (!mod.inited && mod.fetched && map.isDefine) {
- stillLoading = true;
- if (!map.prefix) {
- //No reason to keep looking for unfinished
- //loading. If the only stillLoading is a
- //plugin resource though, keep going,
- //because it may be that a plugin resource
- //is waiting on a non-plugin cycle.
- return (needCycleCheck = false);
- }
- }
- }
- });
-
- if (expired && noLoads.length) {
- //If wait time expired, throw error of unloaded modules.
- err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
- err.contextName = context.contextName;
- return onError(err);
- }
-
- //Not expired, check for a cycle.
- if (needCycleCheck) {
- each(reqCalls, function (mod) {
- breakCycle(mod, {}, {});
- });
- }
-
- //If still waiting on loads, and the waiting load is something
- //other than a plugin resource, or there are still outstanding
- //scripts, then just try back later.
- if ((!expired || usingPathFallback) && stillLoading) {
- //Something is still waiting to load. Wait for it, but only
- //if a timeout is not already in effect.
- if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
- checkLoadedTimeoutId = setTimeout(function () {
- checkLoadedTimeoutId = 0;
- checkLoaded();
- }, 50);
- }
- }
-
- inCheckLoaded = false;
- }
-
- Module = function (map) {
- this.events = getOwn(undefEvents, map.id) || {};
- this.map = map;
- this.shim = getOwn(config.shim, map.id);
- this.depExports = [];
- this.depMaps = [];
- this.depMatched = [];
- this.pluginMaps = {};
- this.depCount = 0;
-
- /* this.exports this.factory
- this.depMaps = [],
- this.enabled, this.fetched
- */
- };
-
- Module.prototype = {
- init: function (depMaps, factory, errback, options) {
- options = options || {};
-
- //Do not do more inits if already done. Can happen if there
- //are multiple define calls for the same module. That is not
- //a normal, common case, but it is also not unexpected.
- if (this.inited) {
- return;
- }
-
- this.factory = factory;
-
- if (errback) {
- //Register for errors on this module.
- this.on('error', errback);
- } else if (this.events.error) {
- //If no errback already, but there are error listeners
- //on this module, set up an errback to pass to the deps.
- errback = bind(this, function (err) {
- this.emit('error', err);
- });
- }
-
- //Do a copy of the dependency array, so that
- //source inputs are not modified. For example
- //"shim" deps are passed in here directly, and
- //doing a direct modification of the depMaps array
- //would affect that config.
- this.depMaps = depMaps && depMaps.slice(0);
-
- this.errback = errback;
-
- //Indicate this module has be initialized
- this.inited = true;
-
- this.ignore = options.ignore;
-
- //Could have option to init this module in enabled mode,
- //or could have been previously marked as enabled. However,
- //the dependencies are not known until init is called. So
- //if enabled previously, now trigger dependencies as enabled.
- if (options.enabled || this.enabled) {
- //Enable this module and dependencies.
- //Will call this.check()
- this.enable();
- } else {
- this.check();
- }
- },
-
- defineDep: function (i, depExports) {
- //Because of cycles, defined callback for a given
- //export can be called more than once.
- if (!this.depMatched[i]) {
- this.depMatched[i] = true;
- this.depCount -= 1;
- this.depExports[i] = depExports;
- }
- },
-
- fetch: function () {
- if (this.fetched) {
- return;
- }
- this.fetched = true;
-
- context.startTime = (new Date()).getTime();
-
- var map = this.map;
-
- //If the manager is for a plugin managed resource,
- //ask the plugin to load it now.
- if (this.shim) {
- context.makeRequire(this.map, {
- enableBuildCallback: true
- })(this.shim.deps || [], bind(this, function () {
- return map.prefix ? this.callPlugin() : this.load();
- }));
- } else {
- //Regular dependency.
- return map.prefix ? this.callPlugin() : this.load();
- }
- },
-
- load: function () {
- var url = this.map.url;
-
- //Regular dependency.
- if (!urlFetched[url]) {
- urlFetched[url] = true;
- context.load(this.map.id, url);
- }
- },
-
- /**
- * Checks if the module is ready to define itself, and if so,
- * define it.
- */
- check: function () {
- if (!this.enabled || this.enabling) {
- return;
- }
-
- var err, cjsModule,
- id = this.map.id,
- depExports = this.depExports,
- exports = this.exports,
- factory = this.factory;
-
- if (!this.inited) {
- // Only fetch if not already in the defQueue.
- if (!hasProp(context.defQueueMap, id)) {
- this.fetch();
- }
- } else if (this.error) {
- this.emit('error', this.error);
- } else if (!this.defining) {
- //The factory could trigger another require call
- //that would result in checking this module to
- //define itself again. If already in the process
- //of doing that, skip this work.
- this.defining = true;
-
- if (this.depCount < 1 && !this.defined) {
- if (isFunction(factory)) {
- try {
- exports = context.execCb(id, factory, depExports, exports);
- } catch (e) {
- err = e;
- }
-
- // Favor return value over exports. If node/cjs in play,
- // then will not have a return value anyway. Favor
- // module.exports assignment over exports object.
- if (this.map.isDefine && exports === undefined) {
- cjsModule = this.module;
- if (cjsModule) {
- exports = cjsModule.exports;
- } else if (this.usingExports) {
- //exports already set the defined value.
- exports = this.exports;
- }
- }
-
- if (err) {
- // If there is an error listener, favor passing
- // to that instead of throwing an error. However,
- // only do it for define()'d modules. require
- // errbacks should not be called for failures in
- // their callbacks (#699). However if a global
- // onError is set, use that.
- if ((this.events.error && this.map.isDefine) ||
- req.onError !== defaultOnError) {
- err.requireMap = this.map;
- err.requireModules = this.map.isDefine ? [this.map.id] : null;
- err.requireType = this.map.isDefine ? 'define' : 'require';
- return onError((this.error = err));
- } else if (typeof console !== 'undefined' &&
- console.error) {
- // Log the error for debugging. If promises could be
- // used, this would be different, but making do.
- console.error(err);
- } else {
- // Do not want to completely lose the error. While this
- // will mess up processing and lead to similar results
- // as bug 1440, it at least surfaces the error.
- req.onError(err);
- }
- }
- } else {
- //Just a literal value
- exports = factory;
- }
-
- this.exports = exports;
-
- if (this.map.isDefine && !this.ignore) {
- defined[id] = exports;
-
- if (req.onResourceLoad) {
- var resLoadMaps = [];
- each(this.depMaps, function (depMap) {
- resLoadMaps.push(depMap.normalizedMap || depMap);
- });
- req.onResourceLoad(context, this.map, resLoadMaps);
- }
- }
-
- //Clean up
- cleanRegistry(id);
-
- this.defined = true;
- }
-
- //Finished the define stage. Allow calling check again
- //to allow define notifications below in the case of a
- //cycle.
- this.defining = false;
-
- if (this.defined && !this.defineEmitted) {
- this.defineEmitted = true;
- this.emit('defined', this.exports);
- this.defineEmitComplete = true;
- }
-
- }
- },
-
- callPlugin: function () {
- var map = this.map,
- id = map.id,
- //Map already normalized the prefix.
- pluginMap = makeModuleMap(map.prefix);
-
- //Mark this as a dependency for this plugin, so it
- //can be traced for cycles.
- this.depMaps.push(pluginMap);
-
- on(pluginMap, 'defined', bind(this, function (plugin) {
- var load, normalizedMap, normalizedMod,
- bundleId = getOwn(bundlesMap, this.map.id),
- name = this.map.name,
- parentName = this.map.parentMap ? this.map.parentMap.name : null,
- localRequire = context.makeRequire(map.parentMap, {
- enableBuildCallback: true
- });
-
- //If current map is not normalized, wait for that
- //normalized name to load instead of continuing.
- if (this.map.unnormalized) {
- //Normalize the ID if the plugin allows it.
- if (plugin.normalize) {
- name = plugin.normalize(name, function (name) {
- return normalize(name, parentName, true);
- }) || '';
- }
-
- //prefix and name should already be normalized, no need
- //for applying map config again either.
- normalizedMap = makeModuleMap(map.prefix + '!' + name,
- this.map.parentMap);
- on(normalizedMap,
- 'defined', bind(this, function (value) {
- this.map.normalizedMap = normalizedMap;
- this.init([], function () { return value; }, null, {
- enabled: true,
- ignore: true
- });
- }));
-
- normalizedMod = getOwn(registry, normalizedMap.id);
- if (normalizedMod) {
- //Mark this as a dependency for this plugin, so it
- //can be traced for cycles.
- this.depMaps.push(normalizedMap);
-
- if (this.events.error) {
- normalizedMod.on('error', bind(this, function (err) {
- this.emit('error', err);
- }));
- }
- normalizedMod.enable();
- }
-
- return;
- }
-
- //If a paths config, then just load that file instead to
- //resolve the plugin, as it is built into that paths layer.
- if (bundleId) {
- this.map.url = context.nameToUrl(bundleId);
- this.load();
- return;
- }
-
- load = bind(this, function (value) {
- this.init([], function () { return value; }, null, {
- enabled: true
- });
- });
-
- load.error = bind(this, function (err) {
- this.inited = true;
- this.error = err;
- err.requireModules = [id];
-
- //Remove temp unnormalized modules for this module,
- //since they will never be resolved otherwise now.
- eachProp(registry, function (mod) {
- if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
- cleanRegistry(mod.map.id);
- }
- });
-
- onError(err);
- });
-
- //Allow plugins to load other code without having to know the
- //context or how to 'complete' the load.
- load.fromText = bind(this, function (text, textAlt) {
- /*jslint evil: true */
- var moduleName = map.name,
- moduleMap = makeModuleMap(moduleName),
- hasInteractive = useInteractive;
-
- //As of 2.1.0, support just passing the text, to reinforce
- //fromText only being called once per resource. Still
- //support old style of passing moduleName but discard
- //that moduleName in favor of the internal ref.
- if (textAlt) {
- text = textAlt;
- }
-
- //Turn off interactive script matching for IE for any define
- //calls in the text, then turn it back on at the end.
- if (hasInteractive) {
- useInteractive = false;
- }
-
- //Prime the system by creating a module instance for
- //it.
- getModule(moduleMap);
-
- //Transfer any config to this other module.
- if (hasProp(config.config, id)) {
- config.config[moduleName] = config.config[id];
- }
-
- try {
- req.exec(text);
- } catch (e) {
- return onError(makeError('fromtexteval',
- 'fromText eval for ' + id +
- ' failed: ' + e,
- e,
- [id]));
- }
-
- if (hasInteractive) {
- useInteractive = true;
- }
-
- //Mark this as a dependency for the plugin
- //resource
- this.depMaps.push(moduleMap);
-
- //Support anonymous modules.
- context.completeLoad(moduleName);
-
- //Bind the value of that module to the value for this
- //resource ID.
- localRequire([moduleName], load);
- });
-
- //Use parentName here since the plugin's name is not reliable,
- //could be some weird string with no path that actually wants to
- //reference the parentName's path.
- plugin.load(map.name, localRequire, load, config);
- }));
-
- context.enable(pluginMap, this);
- this.pluginMaps[pluginMap.id] = pluginMap;
- },
-
- enable: function () {
- enabledRegistry[this.map.id] = this;
- this.enabled = true;
-
- //Set flag mentioning that the module is enabling,
- //so that immediate calls to the defined callbacks
- //for dependencies do not trigger inadvertent load
- //with the depCount still being zero.
- this.enabling = true;
-
- //Enable each dependency
- each(this.depMaps, bind(this, function (depMap, i) {
- var id, mod, handler;
-
- if (typeof depMap === 'string') {
- //Dependency needs to be converted to a depMap
- //and wired up to this module.
- depMap = makeModuleMap(depMap,
- (this.map.isDefine ? this.map : this.map.parentMap),
- false,
- !this.skipMap);
- this.depMaps[i] = depMap;
-
- handler = getOwn(handlers, depMap.id);
-
- if (handler) {
- this.depExports[i] = handler(this);
- return;
- }
-
- this.depCount += 1;
-
- on(depMap, 'defined', bind(this, function (depExports) {
- if (this.undefed) {
- return;
- }
- this.defineDep(i, depExports);
- this.check();
- }));
-
- if (this.errback) {
- on(depMap, 'error', bind(this, this.errback));
- } else if (this.events.error) {
- // No direct errback on this module, but something
- // else is listening for errors, so be sure to
- // propagate the error correctly.
- on(depMap, 'error', bind(this, function(err) {
- this.emit('error', err);
- }));
- }
- }
-
- id = depMap.id;
- mod = registry[id];
-
- //Skip special modules like 'require', 'exports', 'module'
- //Also, don't call enable if it is already enabled,
- //important in circular dependency cases.
- if (!hasProp(handlers, id) && mod && !mod.enabled) {
- context.enable(depMap, this);
- }
- }));
-
- //Enable each plugin that is used in
- //a dependency
- eachProp(this.pluginMaps, bind(this, function (pluginMap) {
- var mod = getOwn(registry, pluginMap.id);
- if (mod && !mod.enabled) {
- context.enable(pluginMap, this);
- }
- }));
-
- this.enabling = false;
-
- this.check();
- },
-
- on: function (name, cb) {
- var cbs = this.events[name];
- if (!cbs) {
- cbs = this.events[name] = [];
- }
- cbs.push(cb);
- },
-
- emit: function (name, evt) {
- each(this.events[name], function (cb) {
- cb(evt);
- });
- if (name === 'error') {
- //Now that the error handler was triggered, remove
- //the listeners, since this broken Module instance
- //can stay around for a while in the registry.
- delete this.events[name];
- }
- }
- };
-
- function callGetModule(args) {
- //Skip modules already defined.
- if (!hasProp(defined, args[0])) {
- getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
- }
- }
-
- function removeListener(node, func, name, ieName) {
- //Favor detachEvent because of IE9
- //issue, see attachEvent/addEventListener comment elsewhere
- //in this file.
- if (node.detachEvent && !isOpera) {
- //Probably IE. If not it will throw an error, which will be
- //useful to know.
- if (ieName) {
- node.detachEvent(ieName, func);
- }
- } else {
- node.removeEventListener(name, func, false);
- }
- }
-
- /**
- * Given an event from a script node, get the requirejs info from it,
- * and then removes the event listeners on the node.
- * @param {Event} evt
- * @returns {Object}
- */
- function getScriptData(evt) {
- //Using currentTarget instead of target for Firefox 2.0's sake. Not
- //all old browsers will be supported, but this one was easy enough
- //to support and still makes sense.
- var node = evt.currentTarget || evt.srcElement;
-
- //Remove the listeners once here.
- removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
- removeListener(node, context.onScriptError, 'error');
-
- return {
- node: node,
- id: node && node.getAttribute('data-requiremodule')
- };
- }
-
- function intakeDefines() {
- var args;
-
- //Any defined modules in the global queue, intake them now.
- takeGlobalQueue();
-
- //Make sure any remaining defQueue items get properly processed.
- while (defQueue.length) {
- args = defQueue.shift();
- if (args[0] === null) {
- return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
- args[args.length - 1]));
- } else {
- //args are id, deps, factory. Should be normalized by the
- //define() function.
- callGetModule(args);
- }
- }
- context.defQueueMap = {};
- }
-
- context = {
- config: config,
- contextName: contextName,
- registry: registry,
- defined: defined,
- urlFetched: urlFetched,
- defQueue: defQueue,
- defQueueMap: {},
- Module: Module,
- makeModuleMap: makeModuleMap,
- nextTick: req.nextTick,
- onError: onError,
-
- /**
- * Set a configuration for the context.
- * @param {Object} cfg config object to integrate.
- */
- configure: function (cfg) {
- //Make sure the baseUrl ends in a slash.
- if (cfg.baseUrl) {
- if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
- cfg.baseUrl += '/';
- }
- }
-
- //Save off the paths since they require special processing,
- //they are additive.
- var shim = config.shim,
- objs = {
- paths: true,
- bundles: true,
- config: true,
- map: true
- };
-
- eachProp(cfg, function (value, prop) {
- if (objs[prop]) {
- if (!config[prop]) {
- config[prop] = {};
- }
- mixin(config[prop], value, true, true);
- } else {
- config[prop] = value;
- }
- });
-
- //Reverse map the bundles
- if (cfg.bundles) {
- eachProp(cfg.bundles, function (value, prop) {
- each(value, function (v) {
- if (v !== prop) {
- bundlesMap[v] = prop;
- }
- });
- });
- }
-
- //Merge shim
- if (cfg.shim) {
- eachProp(cfg.shim, function (value, id) {
- //Normalize the structure
- if (isArray(value)) {
- value = {
- deps: value
- };
- }
- if ((value.exports || value.init) && !value.exportsFn) {
- value.exportsFn = context.makeShimExports(value);
- }
- shim[id] = value;
- });
- config.shim = shim;
- }
-
- //Adjust packages if necessary.
- if (cfg.packages) {
- each(cfg.packages, function (pkgObj) {
- var location, name;
-
- pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
-
- name = pkgObj.name;
- location = pkgObj.location;
- if (location) {
- config.paths[name] = pkgObj.location;
- }
-
- //Save pointer to main module ID for pkg name.
- //Remove leading dot in main, so main paths are normalized,
- //and remove any trailing .js, since different package
- //envs have different conventions: some use a module name,
- //some use a file name.
- config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
- .replace(currDirRegExp, '')
- .replace(jsSuffixRegExp, '');
- });
- }
-
- //If there are any "waiting to execute" modules in the registry,
- //update the maps for them, since their info, like URLs to load,
- //may have changed.
- eachProp(registry, function (mod, id) {
- //If module already has init called, since it is too
- //late to modify them, and ignore unnormalized ones
- //since they are transient.
- if (!mod.inited && !mod.map.unnormalized) {
- mod.map = makeModuleMap(id, null, true);
- }
- });
-
- //If a deps array or a config callback is specified, then call
- //require with those args. This is useful when require is defined as a
- //config object before require.js is loaded.
- if (cfg.deps || cfg.callback) {
- context.require(cfg.deps || [], cfg.callback);
- }
- },
-
- makeShimExports: function (value) {
- function fn() {
- var ret;
- if (value.init) {
- ret = value.init.apply(global, arguments);
- }
- return ret || (value.exports && getGlobal(value.exports));
- }
- return fn;
- },
-
- makeRequire: function (relMap, options) {
- options = options || {};
-
- function localRequire(deps, callback, errback) {
- var id, map, requireMod;
-
- if (options.enableBuildCallback && callback && isFunction(callback)) {
- callback.__requireJsBuild = true;
- }
-
- if (typeof deps === 'string') {
- if (isFunction(callback)) {
- //Invalid call
- return onError(makeError('requireargs', 'Invalid require call'), errback);
- }
-
- //If require|exports|module are requested, get the
- //value for them from the special handlers. Caveat:
- //this only works while module is being defined.
- if (relMap && hasProp(handlers, deps)) {
- return handlers[deps](registry[relMap.id]);
- }
-
- //Synchronous access to one module. If require.get is
- //available (as in the Node adapter), prefer that.
- if (req.get) {
- return req.get(context, deps, relMap, localRequire);
- }
-
- //Normalize module name, if it contains . or ..
- map = makeModuleMap(deps, relMap, false, true);
- id = map.id;
-
- if (!hasProp(defined, id)) {
- return onError(makeError('notloaded', 'Module name "' +
- id +
- '" has not been loaded yet for context: ' +
- contextName +
- (relMap ? '' : '. Use require([])')));
- }
- return defined[id];
- }
-
- //Grab defines waiting in the global queue.
- intakeDefines();
-
- //Mark all the dependencies as needing to be loaded.
- context.nextTick(function () {
- //Some defines could have been added since the
- //require call, collect them.
- intakeDefines();
-
- requireMod = getModule(makeModuleMap(null, relMap));
-
- //Store if map config should be applied to this require
- //call for dependencies.
- requireMod.skipMap = options.skipMap;
-
- requireMod.init(deps, callback, errback, {
- enabled: true
- });
-
- checkLoaded();
- });
-
- return localRequire;
- }
-
- mixin(localRequire, {
- isBrowser: isBrowser,
-
- /**
- * Converts a module name + .extension into an URL path.
- * *Requires* the use of a module name. It does not support using
- * plain URLs like nameToUrl.
- */
- toUrl: function (moduleNamePlusExt) {
- var ext,
- index = moduleNamePlusExt.lastIndexOf('.'),
- segment = moduleNamePlusExt.split('/')[0],
- isRelative = segment === '.' || segment === '..';
-
- //Have a file extension alias, and it is not the
- //dots from a relative path.
- if (index !== -1 && (!isRelative || index > 1)) {
- ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
- moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
- }
-
- return context.nameToUrl(normalize(moduleNamePlusExt,
- relMap && relMap.id, true), ext, true);
- },
-
- defined: function (id) {
- return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
- },
-
- specified: function (id) {
- id = makeModuleMap(id, relMap, false, true).id;
- return hasProp(defined, id) || hasProp(registry, id);
- }
- });
-
- //Only allow undef on top level require calls
- if (!relMap) {
- localRequire.undef = function (id) {
- //Bind any waiting define() calls to this context,
- //fix for #408
- takeGlobalQueue();
-
- var map = makeModuleMap(id, relMap, true),
- mod = getOwn(registry, id);
-
- mod.undefed = true;
- removeScript(id);
-
- delete defined[id];
- delete urlFetched[map.url];
- delete undefEvents[id];
-
- //Clean queued defines too. Go backwards
- //in array so that the splices do not
- //mess up the iteration.
- eachReverse(defQueue, function(args, i) {
- if (args[0] === id) {
- defQueue.splice(i, 1);
- }
- });
- delete context.defQueueMap[id];
-
- if (mod) {
- //Hold on to listeners in case the
- //module will be attempted to be reloaded
- //using a different config.
- if (mod.events.defined) {
- undefEvents[id] = mod.events;
- }
-
- cleanRegistry(id);
- }
- };
- }
-
- return localRequire;
- },
-
- /**
- * Called to enable a module if it is still in the registry
- * awaiting enablement. A second arg, parent, the parent module,
- * is passed in for context, when this method is overridden by
- * the optimizer. Not shown here to keep code compact.
- */
- enable: function (depMap) {
- var mod = getOwn(registry, depMap.id);
- if (mod) {
- getModule(depMap).enable();
- }
- },
-
- /**
- * Internal method used by environment adapters to complete a load event.
- * A load event could be a script load or just a load pass from a synchronous
- * load call.
- * @param {String} moduleName the name of the module to potentially complete.
- */
- completeLoad: function (moduleName) {
- var found, args, mod,
- shim = getOwn(config.shim, moduleName) || {},
- shExports = shim.exports;
-
- takeGlobalQueue();
-
- while (defQueue.length) {
- args = defQueue.shift();
- if (args[0] === null) {
- args[0] = moduleName;
- //If already found an anonymous module and bound it
- //to this name, then this is some other anon module
- //waiting for its completeLoad to fire.
- if (found) {
- break;
- }
- found = true;
- } else if (args[0] === moduleName) {
- //Found matching define call for this script!
- found = true;
- }
-
- callGetModule(args);
- }
- context.defQueueMap = {};
-
- //Do this after the cycle of callGetModule in case the result
- //of those calls/init calls changes the registry.
- mod = getOwn(registry, moduleName);
-
- if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
- if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
- if (hasPathFallback(moduleName)) {
- return;
- } else {
- return onError(makeError('nodefine',
- 'No define call for ' + moduleName,
- null,
- [moduleName]));
- }
- } else {
- //A script that does not call define(), so just simulate
- //the call for it.
- callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
- }
- }
-
- checkLoaded();
- },
-
- /**
- * Converts a module name to a file path. Supports cases where
- * moduleName may actually be just an URL.
- * Note that it **does not** call normalize on the moduleName,
- * it is assumed to have already been normalized. This is an
- * internal API, not a public one. Use toUrl for the public API.
- */
- nameToUrl: function (moduleName, ext, skipExt) {
- var paths, syms, i, parentModule, url,
- parentPath, bundleId,
- pkgMain = getOwn(config.pkgs, moduleName);
-
- if (pkgMain) {
- moduleName = pkgMain;
- }
-
- bundleId = getOwn(bundlesMap, moduleName);
-
- if (bundleId) {
- return context.nameToUrl(bundleId, ext, skipExt);
- }
-
- //If a colon is in the URL, it indicates a protocol is used and it is just
- //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
- //or ends with .js, then assume the user meant to use an url and not a module id.
- //The slash is important for protocol-less URLs as well as full paths.
- if (req.jsExtRegExp.test(moduleName)) {
- //Just a plain path, not module name lookup, so just return it.
- //Add extension if it is included. This is a bit wonky, only non-.js things pass
- //an extension, this method probably needs to be reworked.
- url = moduleName + (ext || '');
- } else {
- //A module that needs to be converted to a path.
- paths = config.paths;
-
- syms = moduleName.split('/');
- //For each module name segment, see if there is a path
- //registered for it. Start with most specific name
- //and work up from it.
- for (i = syms.length; i > 0; i -= 1) {
- parentModule = syms.slice(0, i).join('/');
-
- parentPath = getOwn(paths, parentModule);
- if (parentPath) {
- //If an array, it means there are a few choices,
- //Choose the one that is desired
- if (isArray(parentPath)) {
- parentPath = parentPath[0];
- }
- syms.splice(0, i, parentPath);
- break;
- }
- }
-
- //Join the path parts together, then figure out if baseUrl is needed.
- url = syms.join('/');
- url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
- url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
- }
-
- return config.urlArgs ? url +
- ((url.indexOf('?') === -1 ? '?' : '&') +
- config.urlArgs) : url;
- },
-
- //Delegates to req.load. Broken out as a separate function to
- //allow overriding in the optimizer.
- load: function (id, url) {
- req.load(context, id, url);
- },
-
- /**
- * Executes a module callback function. Broken out as a separate function
- * solely to allow the build system to sequence the files in the built
- * layer in the right sequence.
- *
- * @private
- */
- execCb: function (name, callback, args, exports) {
- return callback.apply(exports, args);
- },
-
- /**
- * callback for script loads, used to check status of loading.
- *
- * @param {Event} evt the event from the browser for the script
- * that was loaded.
- */
- onScriptLoad: function (evt) {
- //Using currentTarget instead of target for Firefox 2.0's sake. Not
- //all old browsers will be supported, but this one was easy enough
- //to support and still makes sense.
- if (evt.type === 'load' ||
- (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
- //Reset interactive script so a script node is not held onto for
- //to long.
- interactiveScript = null;
-
- //Pull out the name of the module and the context.
- var data = getScriptData(evt);
- context.completeLoad(data.id);
- }
- },
-
- /**
- * Callback for script errors.
- */
- onScriptError: function (evt) {
- var data = getScriptData(evt);
- if (!hasPathFallback(data.id)) {
- var parents = [];
- eachProp(registry, function(value, key) {
- if (key.indexOf('_@r') !== 0) {
- each(value.depMaps, function(depMap) {
- if (depMap.id === data.id) {
- parents.push(key);
- }
- return true;
- });
- }
- });
- return onError(makeError('scripterror', 'Script error for "' + data.id +
- (parents.length ?
- '", needed by: ' + parents.join(', ') :
- '"'), evt, [data.id]));
- }
- }
- };
-
- context.require = context.makeRequire();
- return context;
- }
-
- /**
- * Main entry point.
- *
- * If the only argument to require is a string, then the module that
- * is represented by that string is fetched for the appropriate context.
- *
- * If the first argument is an array, then it will be treated as an array
- * of dependency string names to fetch. An optional function callback can
- * be specified to execute when all of those dependencies are available.
- *
- * Make a local req variable to help Caja compliance (it assumes things
- * on a require that are not standardized), and to give a short
- * name for minification/local scope use.
- */
- req = requirejs = function (deps, callback, errback, optional) {
-
- //Find the right context, use default
- var context, config,
- contextName = defContextName;
-
- // Determine if have config object in the call.
- if (!isArray(deps) && typeof deps !== 'string') {
- // deps is a config object
- config = deps;
- if (isArray(callback)) {
- // Adjust args if there are dependencies
- deps = callback;
- callback = errback;
- errback = optional;
- } else {
- deps = [];
- }
- }
-
- if (config && config.context) {
- contextName = config.context;
- }
-
- context = getOwn(contexts, contextName);
- if (!context) {
- context = contexts[contextName] = req.s.newContext(contextName);
- }
-
- if (config) {
- context.configure(config);
- }
-
- return context.require(deps, callback, errback);
- };
-
- /**
- * Support require.config() to make it easier to cooperate with other
- * AMD loaders on globally agreed names.
- */
- req.config = function (config) {
- return req(config);
- };
-
- /**
- * Execute something after the current tick
- * of the event loop. Override for other envs
- * that have a better solution than setTimeout.
- * @param {Function} fn function to execute later.
- */
- req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
- setTimeout(fn, 4);
- } : function (fn) { fn(); };
-
- /**
- * Export require as a global, but only if it does not already exist.
- */
- if (!require) {
- require = req;
- }
-
- req.version = version;
-
- //Used to filter out dependencies that are already paths.
- req.jsExtRegExp = /^\/|:|\?|\.js$/;
- req.isBrowser = isBrowser;
- s = req.s = {
- contexts: contexts,
- newContext: newContext
- };
-
- //Create default context.
- req({});
-
- //Exports some context-sensitive methods on global require.
- each([
- 'toUrl',
- 'undef',
- 'defined',
- 'specified'
- ], function (prop) {
- //Reference from contexts instead of early binding to default context,
- //so that during builds, the latest instance of the default context
- //with its config gets used.
- req[prop] = function () {
- var ctx = contexts[defContextName];
- return ctx.require[prop].apply(ctx, arguments);
- };
- });
-
- if (isBrowser) {
- head = s.head = document.getElementsByTagName('head')[0];
- //If BASE tag is in play, using appendChild is a problem for IE6.
- //When that browser dies, this can be removed. Details in this jQuery bug:
- //http://dev.jquery.com/ticket/2709
- baseElement = document.getElementsByTagName('base')[0];
- if (baseElement) {
- head = s.head = baseElement.parentNode;
- }
- }
-
- /**
- * Any errors that require explicitly generates will be passed to this
- * function. Intercept/override it if you want custom error handling.
- * @param {Error} err the error object.
- */
- req.onError = defaultOnError;
-
- /**
- * Creates the node for the load command. Only used in browser envs.
- */
- req.createNode = function (config, moduleName, url) {
- var node = config.xhtml ?
- document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
- document.createElement('script');
- node.type = config.scriptType || 'text/javascript';
- node.charset = 'utf-8';
- node.async = true;
- return node;
- };
-
- /**
- * Does the request to load a module for the browser case.
- * Make this a separate function to allow other environments
- * to override it.
- *
- * @param {Object} context the require context to find state.
- * @param {String} moduleName the name of the module.
- * @param {Object} url the URL to the module.
- */
- req.load = function (context, moduleName, url) {
- var config = (context && context.config) || {},
- node;
- if (isBrowser) {
- //In the browser so use a script tag
- node = req.createNode(config, moduleName, url);
- if (config.onNodeCreated) {
- config.onNodeCreated(node, config, moduleName, url);
- }
-
- node.setAttribute('data-requirecontext', context.contextName);
- node.setAttribute('data-requiremodule', moduleName);
-
- //Set up load listener. Test attachEvent first because IE9 has
- //a subtle issue in its addEventListener and script onload firings
- //that do not match the behavior of all other browsers with
- //addEventListener support, which fire the onload event for a
- //script right after the script execution. See:
- //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
- //UNFORTUNATELY Opera implements attachEvent but does not follow the script
- //script execution mode.
- if (node.attachEvent &&
- //Check if node.attachEvent is artificially added by custom script or
- //natively supported by browser
- //read https://github.com/jrburke/requirejs/issues/187
- //if we can NOT find [native code] then it must NOT natively supported.
- //in IE8, node.attachEvent does not have toString()
- //Note the test for "[native code" with no closing brace, see:
- //https://github.com/jrburke/requirejs/issues/273
- !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
- !isOpera) {
- //Probably IE. IE (at least 6-8) do not fire
- //script onload right after executing the script, so
- //we cannot tie the anonymous define call to a name.
- //However, IE reports the script as being in 'interactive'
- //readyState at the time of the define call.
- useInteractive = true;
-
- node.attachEvent('onreadystatechange', context.onScriptLoad);
- //It would be great to add an error handler here to catch
- //404s in IE9+. However, onreadystatechange will fire before
- //the error handler, so that does not help. If addEventListener
- //is used, then IE will fire error before load, but we cannot
- //use that pathway given the connect.microsoft.com issue
- //mentioned above
<TRUNCATED>
[12/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
index 0ceb76b..8e14452 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
@@ -26,18 +26,25 @@ public class DocConstants {
public static final String STACK_BY_D = "The graph property for stacking the plot";
public static final String EXCLUDE_QUERY_D = "Exclude the values in query result e.g.: [{message:*timeout*}]";
public static final String INCLUDE_QUERY_D = "Include the values in query result e.g.: [{message:*exception*}]";
- public static final String MUST_BE_D = "Include the components, comman separated values";
- public static final String MUST_NOT_D = "Exclude the components, comman separated values";
+ public static final String MUST_BE_D = "Include the components, comma separated values";
+ public static final String MUST_NOT_D = "Exclude the components, comma separated values";
public static final String FROM_D = "Date range param, start date";
public static final String TO_D = "Date range param, end date";
+ public static final String START_TIME_D = "Date range param which is suportted from browser url";
+ public static final String END_TIME_D = "Date range param which is supported from browser url";
+ public static final String START_INDEX_D = "Start index of the queried result";
+ public static final String SORT_TYPE_D = "Type of sorting (osc, desc)";
+ public static final String SORT_BY_D = "Sorting the results based on this field";
+ public static final String PAGE_D = "Number of pages for the results";
+ public static final String PAGE_SIZE_D = "Page size of the results";
public static final String UNIT_D = "Aggregate the data with time gap as unit i.e 1MINUTE";
public static final String QUERY_D = "not required";
public static final String COLUMN_QUERY_D = "not required";
- public static final String I_MESSAGE_D = "Include query which will query againt message column";
+ public static final String I_MESSAGE_D = "Include query which will query against message column";
public static final String G_E_MESSAGE_D = "not required";
- public static final String E_MESSAGE_D = "Exclude query which will query againt message column";
- public static final String IS_LAST_PAGE_D = "";
- public static final String FIELD_D = "Get top ten values for particular field";
+ public static final String E_MESSAGE_D = "Exclude query which will query against message column";
+ public static final String IS_LAST_PAGE_D = "Show last page (true/false)";
+ public static final String FIELD_D = "Get values for particular field";
public static final String FORMAT_D = "File Export format, can be 'txt' or 'json'";
}
@@ -48,7 +55,6 @@ public class DocConstants {
public static final String GET_AUDIT_LINE_GRAPH_DATA_OD = "Get the data required for line graph";
public static final String GET_TOP_AUDIT_USERS_OD = "Get the top audit users having maximum access";
public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resources having maximum access";
- public static final String GET_TOP_AUDIT_COMPONENTS_OD = "not required";
public static final String GET_LIVE_LOGS_COUNT_OD = "not required";
public static final String GET_REQUEST_USER_LINE_GRAPH_OD = "not required";
public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
@@ -59,11 +65,11 @@ public class DocConstants {
public class ServiceDescriptions {
public static final String LEVEL_D = "filter for log level";
public static final String ADVANCED_SEARCH_D = "not required";
- public static final String TREE_PARAMS_D = "Host hierarchy shown on UI,filtering there is supported by this param";
- public static final String START_TIME_D = "Date range param which is suportted from browser url";
- public static final String END_TIME_D = "Date range param which is supported from browser url";
+ public static final String BUNDLE_ID = "filter for host";
+ public static final String TREE_PARAMS_D = "Host hierarchy shown on UI, filtering there is supported by this param";
public static final String FILE_NAME_D = "File name filter which is supported from browser url";
public static final String HOST_NAME_D = "Host name filter which is supported from browser url";
+ public static final String DATE_RANGE_LABEL_D = "Date range label (e.g.: Today)";
public static final String COMPONENT_NAME_D = "Component name filter which is supported from browser url";
public static final String FIND_D = "Finding particular text on subsequent pages in case of table view with pagination";
public static final String ID_D = "Log id value for traversing to that particular record with that log id";
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
index d84b7b9..bc377e5 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGenerator.java
@@ -26,14 +26,14 @@ import java.util.List;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.common.SearchCriteria;
+import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.NameValueData;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
import org.apache.ambari.logsearch.dao.SolrDaoBase;
import org.apache.ambari.logsearch.query.QueryGeneration;
import org.apache.ambari.logsearch.util.RESTErrorUtil;
import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VBarDataList;
-import org.apache.ambari.logsearch.view.VBarGraphData;
-import org.apache.ambari.logsearch.view.VNameValue;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
@@ -44,18 +44,19 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.RangeFacet;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import javax.inject.Inject;
+
@Component
public class GraphDataGenerator extends GraphDataGeneratorBase {
private static final Logger logger = Logger.getLogger(GraphDataGenerator.class);
- @Autowired
+ @Inject
private QueryGeneration queryGenerator;
- public VBarDataList getAnyGraphData(SearchCriteria searchCriteria, SolrDaoBase solrDaoBase, SolrQuery solrQuery) {
+ public BarGraphDataListResponse getAnyGraphData(SearchCriteria searchCriteria, SolrDaoBase solrDaoBase, SolrQuery solrQuery) {
// X axis credentials
String xAxisField = (String) searchCriteria.getParamValue("xAxis");
String stackField = (String) searchCriteria.getParamValue("stackBy");
@@ -119,12 +120,12 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
}
@SuppressWarnings("unchecked")
- private VBarDataList normalGraph(String xAxisField, String yAxisField, String from, String to, SolrDaoBase solrDaoBase,
+ private BarGraphDataListResponse normalGraph(String xAxisField, String yAxisField, String from, String to, SolrDaoBase solrDaoBase,
String typeXAxis, String fieldTime, SolrQuery solrQuery) {
- VBarDataList dataList = new VBarDataList();
- Collection<VBarGraphData> vBarGraphDatas = new ArrayList<VBarGraphData>();
- VBarGraphData vBarGraphData = new VBarGraphData();
- Collection<VNameValue> vNameValues = new ArrayList<VNameValue>();
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ Collection<BarGraphData> vBarGraphDatas = new ArrayList<BarGraphData>();
+ BarGraphData vBarGraphData = new BarGraphData();
+ Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
SolrUtil.setMainQuery(solrQuery, null);
queryGenerator.setSingleIncludeFilter(solrQuery, fieldTime, "[" + from + " TO " + to + "]");
if (typeXAxis.contains("string") || typeXAxis.contains("key_lower_case") || typeXAxis.contains("text")) {
@@ -140,7 +141,7 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
if (countValues != null) {
for (Count countValue : countValues) {
if (countValue != null) {
- VNameValue vNameValue = new VNameValue();
+ NameValueData vNameValue = new NameValueData();
vNameValue.setName(countValue.getName());
vNameValue.setValue("" + countValue.getCount());
vNameValues.add(vNameValue);
@@ -154,12 +155,12 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
}
}
if (xAxisField.equalsIgnoreCase(LogSearchConstants.SOLR_LEVEL)) {
- Collection<VNameValue> sortedVNameValues = new ArrayList<VNameValue>();
+ Collection<NameValueData> sortedVNameValues = new ArrayList<NameValueData>();
for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
- VNameValue value = new VNameValue();
+ NameValueData value = new NameValueData();
value.setName(level);
String val = "0";
- for (VNameValue valueLevel : vNameValues) {
+ for (NameValueData valueLevel : vNameValues) {
if (valueLevel.getName().equalsIgnoreCase(level)) {
val = valueLevel.getValue();
break;
@@ -168,9 +169,9 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
value.setValue(val);
sortedVNameValues.add(value);
}
- vBarGraphData.setDataCounts(sortedVNameValues);
+ vBarGraphData.setDataCount(sortedVNameValues);
} else {
- vBarGraphData.setDataCounts(vNameValues);
+ vBarGraphData.setDataCount(vNameValues);
}
return dataList;
} catch (SolrException | SolrServerException | IOException e) {
@@ -188,12 +189,12 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
if (jsonFacetResponse.toString().equals("{count=0}")) {
return dataList;
}
- VNameValue value = new VNameValue();
+ NameValueData value = new NameValueData();
String sum = (String) jsonFacetResponse.getVal(1);
value.setName(xAxisField);
value.setValue(sum != null ? sum.substring(0, sum.indexOf(".")) : "");
vNameValues.add(value);
- vBarGraphData.setDataCounts(vNameValues);
+ vBarGraphData.setDataCount(vNameValues);
vBarGraphData.setName(xAxisField);
vBarGraphDatas.add(vBarGraphData);
dataList.setGraphData(vBarGraphDatas);
@@ -207,10 +208,10 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
}
@SuppressWarnings("unchecked")
- private VBarDataList nonRangeStackGraph(String xAxisField, String yAxisField, String stackField, String from, String to,
+ private BarGraphDataListResponse nonRangeStackGraph(String xAxisField, String yAxisField, String stackField, String from, String to,
SolrDaoBase solrDaoBase, String typeXAxis, String fieldTime, SolrQuery solrQuery) {
- VBarDataList dataList = new VBarDataList();
- Collection<VBarGraphData> vGraphData = new ArrayList<VBarGraphData>();
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ Collection<BarGraphData> vGraphData = new ArrayList<BarGraphData>();
String mainQuery = queryGenerator.buildInclusiveRangeFilterQuery(fieldTime, from, to);
SolrUtil.setMainQuery(solrQuery, mainQuery);
SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
@@ -238,24 +239,24 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
}
extractNonRangeStackValuesFromBucket(jsonFacetResponse, stackField, vGraphData, typeXAxis);
if (LogSearchConstants.SOLR_LEVEL.equalsIgnoreCase(stackField) && LogSearchConstants.SOLR_LEVEL.equalsIgnoreCase(xAxisField)) {
- Collection<VBarGraphData> levelVGraphData = dataList.getGraphData();
- for (VBarGraphData garphData : levelVGraphData) {
- Collection<VNameValue> valueList = garphData.getDataCount();
- Collection<VNameValue> valueListSorted = new ArrayList<VNameValue>();
+ Collection<BarGraphData> levelVGraphData = dataList.getGraphData();
+ for (BarGraphData graphData : levelVGraphData) {
+ Collection<NameValueData> valueList = graphData.getDataCount();
+ Collection<NameValueData> valueListSorted = new ArrayList<NameValueData>();
for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
String val = "0";
- for (VNameValue value : valueList) {
+ for (NameValueData value : valueList) {
if (value.getName().equalsIgnoreCase(level)) {
val = value.getValue();
break;
}
}
- VNameValue v1 = new VNameValue();
+ NameValueData v1 = new NameValueData();
v1.setName(level.toUpperCase());
v1.setValue(val);
valueListSorted.add(v1);
}
- garphData.setDataCounts(valueListSorted);
+ graphData.setDataCount(valueListSorted);
}
}
return dataList;
@@ -267,12 +268,12 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
}
@SuppressWarnings("unchecked")
- private VBarDataList rangeNonStackGraph(String xAxisField, String yAxisField, String from, String to, String unit,
+ private BarGraphDataListResponse rangeNonStackGraph(String xAxisField, String yAxisField, String from, String to, String unit,
SolrDaoBase solrDaoBase, String typeXAxis, String fieldTime, SolrQuery solrQuery) {
- VBarDataList dataList = new VBarDataList();
- Collection<VBarGraphData> vBarGraphDatas = new ArrayList<VBarGraphData>();
- VBarGraphData vBarGraphData = new VBarGraphData();
- Collection<VNameValue> vNameValues = new ArrayList<VNameValue>();
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ Collection<BarGraphData> vBarGraphDatas = new ArrayList<BarGraphData>();
+ BarGraphData vBarGraphData = new BarGraphData();
+ Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
SolrUtil.setMainQuery(solrQuery, null);
if (SolrUtil.isSolrFieldNumber(typeXAxis,solrDaoBase)) {
queryGenerator.setSingleRangeFilter(solrQuery, fieldTime, from, to);
@@ -290,12 +291,12 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
List<RangeFacet.Count> listCount = rangeFacet.get(0).getCounts();
if (listCount != null) {
for (RangeFacet.Count cnt : listCount) {
- VNameValue vNameValue = new VNameValue();
+ NameValueData vNameValue = new NameValueData();
vNameValue.setName(cnt.getValue());
vNameValue.setValue("" + cnt.getCount());
vNameValues.add(vNameValue);
}
- vBarGraphData.setDataCounts(vNameValues);
+ vBarGraphData.setDataCount(vNameValues);
vBarGraphDatas.add(vBarGraphData);
vBarGraphData.setName(xAxisField);
dataList.setGraphData(vBarGraphDatas);
@@ -312,10 +313,10 @@ public class GraphDataGenerator extends GraphDataGeneratorBase {
}
@SuppressWarnings("unchecked")
- private VBarDataList rangeStackGraph(String xAxisField, String stackField, String from, String to, String unit,
+ private BarGraphDataListResponse rangeStackGraph(String xAxisField, String stackField, String from, String to, String unit,
SolrDaoBase solrDaoBase, SolrQuery solrQuery) {
- VBarDataList dataList = new VBarDataList();
- List<VBarGraphData> histogramData = new ArrayList<VBarGraphData>();
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
SolrUtil.setMainQuery(solrQuery, null);
SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
String jsonHistogramQuery =
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
index e7fab9a..c57e0e9 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/graph/GraphDataGeneratorBase.java
@@ -23,15 +23,15 @@ import java.util.Collection;
import java.util.Date;
import java.util.List;
-import org.apache.ambari.logsearch.manager.MgrBase;
+import org.apache.ambari.logsearch.manager.ManagerBase;
+import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.response.NameValueData;
import org.apache.ambari.logsearch.util.DateUtil;
-import org.apache.ambari.logsearch.view.VBarGraphData;
-import org.apache.ambari.logsearch.view.VNameValue;
import org.apache.commons.lang.StringUtils;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
-class GraphDataGeneratorBase extends MgrBase {
+class GraphDataGeneratorBase {
private static final String BUCKETS = "buckets";
@@ -62,19 +62,19 @@ class GraphDataGeneratorBase extends MgrBase {
@SuppressWarnings("unchecked")
protected void extractRangeStackValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String outerField,
- String innerField, List<VBarGraphData> histogramData) {
+ String innerField, List<BarGraphData> histogramData) {
if (jsonFacetResponse != null) {
NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
if (stack != null) {
ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get(BUCKETS);
if (stackBuckets != null) {
for (Object stackBucket : stackBuckets) {
- VBarGraphData vBarGraphData = new VBarGraphData();
+ BarGraphData vBarGraphData = new BarGraphData();
SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) stackBucket;
if (level != null) {
String name = level.getVal(0) != null ? level.getVal(0).toString().toUpperCase() : "";
vBarGraphData.setName(name);
- Collection<VNameValue> vNameValues = new ArrayList<VNameValue>();
+ Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
NamedList<Object> innerFiledValue = (NamedList<Object>) level.get(innerField);
if (innerFiledValue != null) {
ArrayList<Object> levelBuckets = (ArrayList<Object>) innerFiledValue.get(BUCKETS);
@@ -84,13 +84,15 @@ class GraphDataGeneratorBase extends MgrBase {
if (countValue != null) {
String innerName = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
String innerValue = countValue.getVal(1) != null ? countValue.getVal(1).toString() : "";
- VNameValue vNameValue = new VNameValue(innerName, innerValue);
+ NameValueData vNameValue = new NameValueData();
+ vNameValue.setName(innerName);
+ vNameValue.setValue(innerValue);
vNameValues.add(vNameValue);
}
}
}
}
- vBarGraphData.setDataCounts(vNameValues);
+ vBarGraphData.setDataCount(vNameValues);
}
histogramData.add(vBarGraphData);
}
@@ -101,7 +103,7 @@ class GraphDataGeneratorBase extends MgrBase {
@SuppressWarnings("unchecked")
protected boolean extractNonRangeStackValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String level,
- Collection<VBarGraphData> vGraphDatas, String typeXAxis) {
+ Collection<BarGraphData> vGraphDatas, String typeXAxis) {
boolean zeroFlag = true;
if (jsonFacetResponse == null || jsonFacetResponse.get(level) == null
|| jsonFacetResponse.get(level).toString().equals("{count=0}")) {
@@ -114,11 +116,11 @@ class GraphDataGeneratorBase extends MgrBase {
for (int index = 0; index < bucketList.size(); index++) {
SimpleOrderedMap<Object> valueCount = (SimpleOrderedMap<Object>) bucketList.get(index);
if (valueCount != null && valueCount.size() > 2) {
- VBarGraphData vGraphData = new VBarGraphData();
- Collection<VNameValue> levelCounts = new ArrayList<VNameValue>();
+ BarGraphData vGraphData = new BarGraphData();
+ Collection<NameValueData> levelCounts = new ArrayList<NameValueData>();
String name = valueCount.getVal(0) != null ? valueCount.getVal(0).toString().trim() : "";
if (isTypeNumber(typeXAxis)) {
- VNameValue nameValue = new VNameValue();
+ NameValueData nameValue = new NameValueData();
Double sumValue = (Double) valueCount.getVal(2);
String value = "0";// default is zero
if (sumValue != null) {
@@ -137,7 +139,9 @@ class GraphDataGeneratorBase extends MgrBase {
if (innerValueCount != null) {
String innerName = innerValueCount.getVal(0) != null ? innerValueCount.getVal(0).toString().trim() : "";
String innerValue = innerValueCount.getVal(1) != null ? innerValueCount.getVal(1).toString().trim() : "";
- VNameValue nameValue = new VNameValue(innerName, innerValue);
+ NameValueData nameValue = new NameValueData();
+ nameValue.setValue(innerValue);
+ nameValue.setName(innerName);
levelCounts.add(nameValue);
}
}
@@ -145,7 +149,7 @@ class GraphDataGeneratorBase extends MgrBase {
}
}
vGraphData.setName(name);
- vGraphData.setDataCounts(levelCounts);
+ vGraphData.setDataCount(levelCounts);
vGraphDatas.add(vGraphData);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
new file mode 100644
index 0000000..7affc5a
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
@@ -0,0 +1,597 @@
+/*
+ * 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.manager;
+
+import javax.inject.Inject;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.ambari.logsearch.common.ConfigHelper;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.ManageStartEndTime;
+import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
+import org.apache.ambari.logsearch.dao.AuditSolrDao;
+import org.apache.ambari.logsearch.graph.GraphDataGenerator;
+import org.apache.ambari.logsearch.model.response.AuditLogResponse;
+import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.GroupListResponse;
+import org.apache.ambari.logsearch.model.response.LogData;
+import org.apache.ambari.logsearch.model.response.LogSearchResponse;
+import org.apache.ambari.logsearch.model.response.NameValueData;
+import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
+import org.apache.ambari.logsearch.solr.model.SolrAuditLogData;
+import org.apache.ambari.logsearch.solr.model.SolrComponentTypeLogData;
+import org.apache.ambari.logsearch.util.BizUtil;
+import org.apache.ambari.logsearch.util.DateUtil;
+import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.ambari.logsearch.view.VResponse;
+import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.FacetField;
+import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.RangeFacet;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AuditLogsManager extends ManagerBase<SolrAuditLogData, AuditLogResponse> {
+ private static final Logger logger = Logger.getLogger(AuditLogsManager.class);
+
+ @Inject
+ private AuditSolrDao auditSolrDao;
+ @Inject
+ private GraphDataGenerator graphDataGenerator;
+ @Inject
+ private SolrAuditLogConfig solrAuditLogConfig;
+
+ public AuditLogResponse getLogs(AuditLogSearchCriteria searchCriteria) {
+ Boolean isLastPage = (Boolean) searchCriteria.getParamValue("isLastPage");
+ if (isLastPage) {
+ SolrQuery lastPageQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+ LogSearchResponse logResponse = getLastPage(searchCriteria, LogSearchConstants.AUDIT_EVTTIME, auditSolrDao, lastPageQuery);
+ if (logResponse == null) {
+ logResponse = new AuditLogResponse();
+ }
+ return (AuditLogResponse) logResponse;
+ }
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+ return getLogAsPaginationProvided(solrQuery, auditSolrDao);
+ }
+
+ private List<LogData> getComponents(SearchCriteria searchCriteria) {
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+ List<LogData> docList = new ArrayList<>();
+ try {
+ SolrUtil.setFacetField(solrQuery, LogSearchConstants.AUDIT_COMPONENT);
+ SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
+ List<FacetField> facetFields = null;
+ List<Count> componentsCount = new ArrayList<Count>();
+ FacetField facetField = null;
+
+ QueryResponse queryResponse = auditSolrDao.process(solrQuery);
+ if (queryResponse == null) {
+ return docList;
+ }
+
+ facetFields = queryResponse.getFacetFields();
+ if (facetFields == null) {
+ return docList;
+ }
+ if (!facetFields.isEmpty()) {
+ facetField = facetFields.get(0);
+ }
+ if (facetField != null) {
+ componentsCount = facetField.getValues();
+ }
+
+ for (Count component : componentsCount) {
+ SolrComponentTypeLogData logData = new SolrComponentTypeLogData();
+ logData.setType(component.getName());
+ docList.add(logData);
+ }
+ return docList;
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ public GroupListResponse getAuditComponents(SearchCriteria searchCriteria) {
+ GroupListResponse componentResponse = new GroupListResponse();
+ List<LogData> docList = getComponents(searchCriteria);
+ componentResponse.setGroupList(docList);
+ return componentResponse;
+ }
+
+ @SuppressWarnings("unchecked")
+ public BarGraphDataListResponse getAuditBarGraphData(SearchCriteria searchCriteria) {
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+
+ String from = getFrom((String) searchCriteria.getParamValue("startTime"));
+ String to = getTo((String) searchCriteria.getParamValue("endTime"));
+ String unit = getUnit((String) searchCriteria.getParamValue("unit"));
+
+ List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
+ String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_COMPONENT,
+ LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
+
+ try {
+ SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
+ SolrUtil.setRowCount(solrQuery, 0);
+ QueryResponse response = auditSolrDao.process(solrQuery);
+ if (response == null) {
+ return dataList;
+ }
+ SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
+
+ if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
+ return dataList;
+ }
+
+ extractValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
+
+ dataList.setGraphData(histogramData);
+ return dataList;
+
+ } catch (SolrServerException | SolrException | IOException e) {
+ logger.error(e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+
+ }
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public NameValueDataListResponse getLiveLogCounts() {
+ NameValueDataListResponse nameValueList = new NameValueDataListResponse();
+ SolrQuery solrQuery = new SolrQuery();
+ solrQuery.setParam("event", "/audit/logs/live/count");
+ try {
+ Date[] timeRange = ManageStartEndTime.getStartEndTime();
+ String startDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[0]);
+ String endDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[1]);
+
+ SolrUtil.setMainQuery(solrQuery, null);
+ SolrUtil.setFacetRange(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startDate, endDate, "+2MINUTE");
+ List<RangeFacet.Count> listCount;
+
+ QueryResponse response = auditSolrDao.process(solrQuery);
+
+ List<RangeFacet> rangeFacet = response.getFacetRanges();
+ if (rangeFacet == null) {
+ return nameValueList;
+ }
+ RangeFacet range = rangeFacet.get(0);
+
+ if (range == null) {
+ return nameValueList;
+ }
+
+ listCount = range.getCounts();
+
+ List<NameValueData> nameValues = new ArrayList<>();
+ int count = 0;
+ for (RangeFacet.Count cnt : listCount) {
+ NameValueData nameValue = new NameValueData();
+ nameValue.setName("" + count);
+ nameValue.setValue("" + cnt.getCount());
+ nameValues.add(nameValue);
+ count++;
+ }
+ nameValueList.setvNameValues(nameValues);
+ return nameValueList;
+
+ } catch (SolrException | SolrServerException | ParseException
+ | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ public BarGraphDataListResponse topTenUsers(SearchCriteria searchCriteria) {
+
+ String jsonUserQuery =
+ "{Users:{type:terms, field:reqUser, facet:{ Repo:{ type:terms, field:repo, facet:{eventCount:\"sum(event_count)\"}}}}}";
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+ SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
+ SolrUtil.setRowCount(solrQuery, 0);
+ try {
+ BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
+ QueryResponse queryResponse = auditSolrDao.process(solrQuery);
+ if (queryResponse == null) {
+ return barGraphDataListResponse;
+ }
+
+ NamedList<Object> namedList = queryResponse.getResponse();
+
+ if (namedList == null) {
+ return barGraphDataListResponse;
+ }
+
+ @SuppressWarnings("unchecked")
+ SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
+ if (jsonFacetResponse == null) {
+ return barGraphDataListResponse;
+ }
+ if (jsonFacetResponse.toString().equals("{count=0}")) {
+ return barGraphDataListResponse;
+ }
+ barGraphDataListResponse = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
+ return barGraphDataListResponse;
+
+ } catch (SolrServerException | SolrException | IOException e) {
+ logger.error("Error during solrQuery=" + e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ public BarGraphDataListResponse topTenResources(SearchCriteria searchCriteria) {
+
+ String jsonUserQuery =
+ "{Users:{type:terms,field:resource,facet:{Repo:{type:terms,field:repo,facet:{eventCount:\"sum(event_count)\"}}}}}";
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+ SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
+ SolrUtil.setRowCount(solrQuery, 0);
+ try {
+ BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
+ QueryResponse queryResponse = auditSolrDao.process(solrQuery);
+ if (queryResponse == null) {
+ return barGraphDataListResponse;
+ }
+
+ NamedList<Object> namedList = queryResponse.getResponse();
+ if (namedList == null) {
+ return barGraphDataListResponse;
+ }
+
+ @SuppressWarnings("unchecked")
+ SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
+
+ barGraphDataListResponse = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
+ return barGraphDataListResponse;
+
+ } catch (SolrServerException | SolrException | IOException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public BarGraphDataListResponse getRequestUserLineGraph(SearchCriteria searchCriteria) {
+
+ String from = getFrom((String) searchCriteria.getParamValue("startTime"));
+ String to = getTo((String) searchCriteria.getParamValue("endTime"));
+ String unit = getUnit((String) searchCriteria.getParamValue("unit"));
+
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ List<BarGraphData> histogramData = new ArrayList<BarGraphData>();
+
+ SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
+
+ String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_REQUEST_USER,
+ LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
+
+ try {
+ SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
+ SolrUtil.setRowCount(solrQuery, 0);
+ QueryResponse response = auditSolrDao.process(solrQuery);
+ if (response == null) {
+ return dataList;
+ }
+ SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
+
+ if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
+ return dataList;
+ }
+ extractValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
+
+ dataList.setGraphData(histogramData);
+ return dataList;
+
+ } catch (SolrException | IOException | SolrServerException e) {
+ logger.error("Error during solrQuery=" + solrQuery, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ }
+
+ public String getAuditLogsSchemaFieldsName() {
+ String excludeArray[] = Arrays.copyOf(solrAuditLogConfig.getExcludeColumnList().toArray(),
+ solrAuditLogConfig.getExcludeColumnList().size(), String[].class);
+ List<String> fieldNames = new ArrayList<String>();
+ HashMap<String, String> uiFieldColumnMapping = new HashMap<String, String>();
+ ConfigHelper.getSchemaFieldsName(excludeArray, fieldNames, auditSolrDao);
+
+ for (String fieldName : fieldNames) {
+ String uiField = solrAuditLogConfig.getSolrAndUiColumns().get(fieldName + LogSearchConstants.SOLR_SUFFIX);
+ if (uiField == null) {
+ uiFieldColumnMapping.put(fieldName, fieldName);
+ } else {
+ uiFieldColumnMapping.put(fieldName, uiField);
+ }
+ }
+
+ uiFieldColumnMapping = BizUtil.sortHashMapByValues(uiFieldColumnMapping);
+ return convertObjToString(uiFieldColumnMapping);
+
+ }
+
+ public BarGraphDataListResponse getAnyGraphData(SearchCriteria searchCriteria) {
+ searchCriteria.addParam("fieldTime", LogSearchConstants.AUDIT_EVTTIME);
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+ BarGraphDataListResponse result = graphDataGenerator.getAnyGraphData(searchCriteria, auditSolrDao, solrQuery);
+ if (result == null) {
+ result = new BarGraphDataListResponse();
+ }
+ return result;
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private void extractValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String outerField, String innerField,
+ List<BarGraphData> histogramData) {
+ NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
+ ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get("buckets");
+ for (Object temp : stackBuckets) {
+ BarGraphData vBarGraphData = new BarGraphData();
+
+ SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
+ String name = ((String) level.getVal(0)).toUpperCase();
+ vBarGraphData.setName(name);
+
+ Collection<NameValueData> vNameValues = new ArrayList<NameValueData>();
+ vBarGraphData.setDataCount(vNameValues);
+ ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level.get(innerField)).get("buckets");
+ for (Object temp1 : levelBuckets) {
+ SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
+ String value = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
+
+ String count = "" + countValue.getVal(1);
+ NameValueData vNameValue = new NameValueData();
+ vNameValue.setName(value);
+ vNameValue.setValue(count);
+ vNameValues.add(vNameValue);
+ }
+ histogramData.add(vBarGraphData);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public Response exportUserTableToTextFile(SearchCriteria searchCriteria) {
+ String jsonUserQuery =
+ "{ Users: { type: terms, field: reqUser, facet: {Repo: { type: terms, field: repo, facet: { eventCount: \"sum(event_count)\"}}}},x:{ type: terms,field: resource, facet: {y: { type: terms, field: repo,facet: { eventCount: \"sum(event_count)\"}}}}}";
+
+ SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+ String startTime = (String) searchCriteria.getParamValue("startTime");
+ String endTime = (String) searchCriteria.getParamValue("endTime");
+
+ startTime = startTime == null ? "" : startTime;
+ endTime = endTime == null ? "" : "_" + endTime;
+
+ SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
+ SolrUtil.setRowCount(solrQuery, 0);
+
+ String dataFormat = (String) searchCriteria.getParamValue("format");
+ FileOutputStream fis = null;
+ try {
+ QueryResponse queryResponse = auditSolrDao.process(solrQuery);
+ if (queryResponse == null) {
+ VResponse response = new VResponse();
+ response.setMsgDesc("Query was not able to execute " + solrQuery);
+ throw RESTErrorUtil.createRESTException(response);
+ }
+
+ NamedList<Object> namedList = queryResponse.getResponse();
+ if (namedList == null) {
+ VResponse response = new VResponse();
+ response.setMsgDesc("Query was not able to execute " + solrQuery);
+ throw RESTErrorUtil.createRESTException(response);
+ }
+ BarGraphDataListResponse vBarUserDataList = new BarGraphDataListResponse();
+ BarGraphDataListResponse vBarResourceDataList = new BarGraphDataListResponse();
+
+ SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
+ vBarUserDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "Repo", "Users");
+ vBarResourceDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse, "y", "x");
+ String data = "";
+ String summary = "";
+ if ("text".equals(dataFormat)) {
+ int users = 0;
+ int resources = 0;
+ summary += "\n\n\n\n";
+ data += addBlank("Users") + "Components/Access" + "\n";
+ data += "--------------------------------------------------------------------------\n";
+ Collection<BarGraphData> tableUserData = vBarUserDataList.getGraphData();
+ for (BarGraphData graphData : tableUserData) {
+ String userName = graphData.getName();
+ String largeUserName = "";
+
+ if (userName.length() > 45) {
+ largeUserName = userName.substring(0, 45);
+ data += addBlank(largeUserName);
+ } else
+ data += addBlank(userName);
+
+ Collection<NameValueData> vnameValueList = graphData.getDataCount();
+ int count = 0;
+ String blank = "";
+ for (NameValueData vNameValue : vnameValueList) {
+ data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
+ if (count == 0)
+ blank = addBlank(blank);
+ count++;
+
+ }
+ while (largeUserName.length() > 0) {
+ data += largeUserName.substring(0, 45) + "\n";
+ }
+
+ users += 1;
+ }
+ data += "\n\n\n\n\n\n";
+ data += addBlank("Resources") + "Components/Access" + "\n";
+ data += "--------------------------------------------------------------------------\n";
+ Collection<BarGraphData> tableResourceData = vBarResourceDataList.getGraphData();
+ for (BarGraphData graphData : tableResourceData) {
+ String resourceName = graphData.getName();
+ String largeResourceName = resourceName;
+ if (largeResourceName.length() > 45) {
+ resourceName = largeResourceName.substring(0, 45);
+ largeResourceName = largeResourceName.substring(45, largeResourceName.length());
+ } else {
+ largeResourceName = "";
+ }
+
+ //resourceName = resourceName.replaceAll("(.{45})", resourceName.substring(0, 45)+"\n");
+ data += addBlank(resourceName);
+ Collection<NameValueData> vnameValueList = graphData.getDataCount();
+ int count = 0;
+ String blank = "";
+ for (NameValueData vNameValue : vnameValueList) {
+ data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
+ if (count == 0)
+ blank = addBlank(blank);
+ count++;
+ }
+ String tempLargeResourceName = largeResourceName;
+ while (largeResourceName.length() > 45) {
+ largeResourceName = tempLargeResourceName.substring(0, 45);
+ tempLargeResourceName = tempLargeResourceName.substring(45, tempLargeResourceName.length());
+ data += largeResourceName + "\n";
+ }
+ if (largeResourceName.length() < 45 && !largeResourceName.isEmpty()) {
+ data += largeResourceName + "\n";
+ }
+ resources += 1;
+ }
+ String header = "--------------------------------SUMMARY-----------------------------------\n";
+ summary = header + "Users = " + users + "\nResources = " + resources + "\n" + summary;
+ data = summary + data;
+ } else {
+ data = "{" + convertObjToString(vBarUserDataList) + "," + convertObjToString(vBarResourceDataList) + "}";
+ dataFormat = "json";
+ }
+ String fileName = "Users_Resource" + startTime + endTime + ".";
+ File file = File.createTempFile(fileName, dataFormat);
+
+ fis = new FileOutputStream(file);
+ fis.write(data.getBytes());
+ return Response
+ .ok(file, MediaType.APPLICATION_OCTET_STREAM)
+ .header("Content-Disposition", "attachment;filename=" + fileName + dataFormat)
+ .build();
+
+ } catch (SolrServerException | SolrException | IOException e) {
+ logger.error("Error during solrQuery=" + e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ private String addBlank(String field) {
+ int blanks = 50;
+ int strSize = field.length();
+ String fieldWithBlank = field;
+ for (int i = 0; i < blanks - strSize; i++) {
+ fieldWithBlank += " ";
+ }
+ return fieldWithBlank;
+ }
+
+ public BarGraphDataListResponse getServiceLoad(SearchCriteria searchCriteria) {
+ BarGraphDataListResponse dataList = new BarGraphDataListResponse();
+ Collection<BarGraphData> vaDatas = new ArrayList<BarGraphData>();
+ dataList.setGraphData(vaDatas);
+
+ SolrQuery serivceLoadQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
+
+ try {
+ SolrUtil.setFacetField(serivceLoadQuery, LogSearchConstants.AUDIT_COMPONENT);
+ QueryResponse serviceLoadResponse = auditSolrDao.process(serivceLoadQuery);
+ if (serviceLoadResponse == null) {
+ return dataList;
+ }
+ FacetField serviceFacetField = serviceLoadResponse.getFacetField(LogSearchConstants.AUDIT_COMPONENT);
+ if (serviceFacetField == null) {
+ return dataList;
+ }
+
+ List<Count> serviceLoadFacets = serviceFacetField.getValues();
+ if (serviceLoadFacets == null) {
+ return dataList;
+ }
+ for (Count cnt : serviceLoadFacets) {
+ List<NameValueData> valueList = new ArrayList<NameValueData>();
+ BarGraphData vBarGraphData = new BarGraphData();
+ vaDatas.add(vBarGraphData);
+ NameValueData vNameValue = new NameValueData();
+ vNameValue.setName(cnt.getName());
+ vBarGraphData.setName(cnt.getName().toUpperCase());
+ vNameValue.setValue("" + cnt.getCount());
+ valueList.add(vNameValue);
+ vBarGraphData.setDataCount(valueList);
+ }
+
+ return dataList;
+
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error during solrQuery=" + e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ @Override
+ protected List<SolrAuditLogData> convertToSolrBeans(QueryResponse response) {
+ return response.getBeans(SolrAuditLogData.class);
+ }
+
+ @Override
+ protected AuditLogResponse createLogSearchResponse() {
+ return new AuditLogResponse();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditMgr.java
deleted file mode 100644
index 172ec81..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/AuditMgr.java
+++ /dev/null
@@ -1,630 +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.manager;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.ambari.logsearch.common.ConfigHelper;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.ManageStartEndTime;
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.dao.AuditSolrDao;
-import org.apache.ambari.logsearch.graph.GraphDataGenerator;
-import org.apache.ambari.logsearch.util.BizUtil;
-import org.apache.ambari.logsearch.util.DateUtil;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VBarDataList;
-import org.apache.ambari.logsearch.view.VBarGraphData;
-import org.apache.ambari.logsearch.view.VGroupList;
-import org.apache.ambari.logsearch.view.VNameValue;
-import org.apache.ambari.logsearch.view.VNameValueList;
-import org.apache.ambari.logsearch.view.VResponse;
-import org.apache.ambari.logsearch.view.VSolrLogList;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField;
-import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.RangeFacet;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class AuditMgr extends MgrBase {
- private static final Logger logger = Logger.getLogger(AuditMgr.class);
-
- @Autowired
- private AuditSolrDao auditSolrDao;
- @Autowired
- private GraphDataGenerator graphDataGenerator;
-
- public String getLogs(SearchCriteria searchCriteria) {
- String lastPage = (String) searchCriteria.getParamValue("isLastPage");
- Boolean isLastPage = Boolean.parseBoolean(lastPage);
- if (isLastPage) {
- SolrQuery lastPageQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- VSolrLogList collection = getLastPage(searchCriteria, LogSearchConstants.AUDIT_EVTTIME, auditSolrDao, lastPageQuery);
- if(collection == null){
- collection = new VSolrLogList();
- }
- return convertObjToString(collection);
- }
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- VSolrLogList collection = getLogAsPaginationProvided(solrQuery, auditSolrDao);
- return convertObjToString(collection);
-
- }
-
- private SolrDocumentList getComponents(SearchCriteria searchCriteria) {
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- SolrDocumentList docList = new SolrDocumentList();
- try {
- SolrUtil.setFacetField(solrQuery, LogSearchConstants.AUDIT_COMPONENT);
- SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
- List<FacetField> facetFields = null;
- List<Count> componentsCount = new ArrayList<Count>();
- FacetField facetField = null;
-
- QueryResponse queryResponse = auditSolrDao.process(solrQuery);
- if (queryResponse == null) {
- return docList;
- }
-
- facetFields = queryResponse.getFacetFields();
- if (facetFields == null) {
- return docList;
- }
- if (!facetFields.isEmpty()) {
- facetField = facetFields.get(0);
- }
- if (facetField != null) {
- componentsCount = facetField.getValues();
- }
-
- for (Count compnonet : componentsCount) {
- SolrDocument solrDocument = new SolrDocument();
- solrDocument.addField("type", compnonet.getName());
- docList.add(solrDocument);
- }
- return docList;
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- public String getAuditComponents(SearchCriteria searchCriteria) {
- VGroupList vGroupList = new VGroupList();
- SolrDocumentList docList = getComponents(searchCriteria);
-
- vGroupList.setGroupDocuments(docList);
- return convertObjToString(vGroupList);
- }
-
- @SuppressWarnings("unchecked")
- public String getAuditLineGraphData(SearchCriteria searchCriteria) {
- VBarDataList dataList = new VBarDataList();
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
- String from = getFrom((String) searchCriteria.getParamValue("startTime"));
- String to = getTo((String) searchCriteria.getParamValue("endTime"));
- String unit = getUnit((String) searchCriteria.getParamValue("unit"));
-
- List<VBarGraphData> histogramData = new ArrayList<VBarGraphData>();
- String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_COMPONENT,
- LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
-
- try {
- SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
- SolrUtil.setRowCount(solrQuery, 0);
- QueryResponse response = auditSolrDao.process(solrQuery);
- if (response == null){
- return convertObjToString(dataList);
- }
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-
- if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
- return convertObjToString(dataList);
- }
-
- extractValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
-
- dataList.setGraphData(histogramData);
- return convertObjToString(dataList);
-
- } catch (SolrServerException | SolrException | IOException e) {
- logger.error(e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-
- }
- }
-
- public String getTopAuditFieldCount(SearchCriteria searchCriteria) {
- int topCounts = 10;
- Integer top = (Integer) searchCriteria.getParamValue("top");
- String facetField = (String) searchCriteria.getParamValue("field");
- if (top == null){
- top = new Integer(topCounts);
- }
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- try {
-
- List<VNameValue> nameValues = new ArrayList<VNameValue>();
-
- VNameValueList nameValueList = new VNameValueList(nameValues);
-
- SolrUtil.setFacetField(solrQuery, facetField);
- SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_COUNT);
- SolrUtil.setFacetLimit(solrQuery, top.intValue());
-
- List<Count> countList = new ArrayList<FacetField.Count>();
- QueryResponse queryResponse = auditSolrDao.process(solrQuery);
- if (queryResponse == null) {
- return convertObjToString(nameValueList);
- }
-
- if (queryResponse.getFacetField(facetField) != null) {
- FacetField queryFacetField = queryResponse.getFacetField(facetField);
- if (queryFacetField != null) {
- countList = queryFacetField.getValues();
- }
- }
-
- for (Count cnt : countList) {
- VNameValue nameValue = new VNameValue();
- nameValue.setName(cnt.getName());
-
- nameValue.setValue("" + cnt.getCount());
- nameValues.add(nameValue);
- }
- return convertObjToString(nameValueList);
-
- } catch (SolrException | IOException | SolrServerException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public String getLiveLogCounts() {
- VNameValueList nameValueList = new VNameValueList();
- SolrQuery solrQuery = new SolrQuery();
- solrQuery.setParam("event", "/audit/logs/live/count");
- try {
- Date[] timeRange = ManageStartEndTime.getStartEndTime();
- String startDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[0]);
- String endDate = DateUtil.convertGivenDateFormatToSolrDateFormat(timeRange[1]);
-
- SolrUtil.setMainQuery(solrQuery, null);
- SolrUtil.setFacetRange(solrQuery, LogSearchConstants.AUDIT_EVTTIME, startDate, endDate, "+2MINUTE");
- List<RangeFacet.Count> listCount;
-
- QueryResponse response = auditSolrDao.process(solrQuery);
-
- List<RangeFacet> rangeFacet = response.getFacetRanges();
- if (rangeFacet == null){
- return convertObjToString(nameValueList);
- }
- RangeFacet range=rangeFacet.get(0);
-
- if(range == null){
- return convertObjToString(nameValueList);
- }
-
- listCount = range.getCounts();
-
- List<VNameValue> nameValues = new ArrayList<VNameValue>();
- int count = 0;
- for (RangeFacet.Count cnt : listCount) {
- VNameValue nameValue = new VNameValue();
- nameValue.setName("" + count);
- nameValue.setValue("" + cnt.getCount());
- nameValues.add(nameValue);
- count++;
- }
- nameValueList.setVNameValues(nameValues);
- return convertObjToString(nameValueList);
-
- } catch (SolrException | SolrServerException | ParseException
- | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- public String topTenUsers(SearchCriteria searchCriteria) {
-
- String jsonUserQuery =
- "{Users:{type:terms, field:reqUser, facet:{ Repo:{ type:terms, field:repo, facet:{eventCount:\"sum(event_count)\"}}}}}";
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
- SolrUtil.setRowCount(solrQuery, 0);
- try {
- VBarDataList vBarDataList = new VBarDataList();
- QueryResponse queryResponse = auditSolrDao.process(solrQuery);
- if (queryResponse == null) {
- return convertObjToString(vBarDataList);
- }
-
- NamedList<Object> namedList = queryResponse.getResponse();
-
- if (namedList == null) {
- return convertObjToString(vBarDataList);
- }
-
- @SuppressWarnings("unchecked")
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
- if (jsonFacetResponse == null) {
- return convertObjToString(vBarDataList);
- }
- if (jsonFacetResponse.toString().equals("{count=0}")) {
- return convertObjToString(vBarDataList);
- }
- vBarDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse,"Repo","Users");
- return convertObjToString(vBarDataList);
-
- } catch (SolrServerException | SolrException | IOException e) {
- logger.error("Error during solrQuery=" + e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- public String topTenResources(SearchCriteria searchCriteria) {
-
- String jsonUserQuery =
- "{Users:{type:terms,field:resource,facet:{Repo:{type:terms,field:repo,facet:{eventCount:\"sum(event_count)\"}}}}}";
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
- SolrUtil.setRowCount(solrQuery, 0);
- try {
- VBarDataList vBarDataList = new VBarDataList();
- QueryResponse queryResponse = auditSolrDao.process(solrQuery);
- if(queryResponse == null){
- return convertObjToString(vBarDataList);
- }
-
- NamedList<Object> namedList = queryResponse.getResponse();
- if (namedList == null) {
- return convertObjToString(vBarDataList);
- }
-
- @SuppressWarnings("unchecked")
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
-
- vBarDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse,"Repo","Users");
- return convertObjToString(vBarDataList);
-
- } catch (SolrServerException | SolrException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- @SuppressWarnings("unchecked")
- public String getRequestUserLineGraph(SearchCriteria searchCriteria) {
-
- String from = getFrom((String) searchCriteria.getParamValue("startTime"));
- String to = getTo((String) searchCriteria.getParamValue("endTime"));
- String unit = getUnit((String) searchCriteria.getParamValue("unit"));
-
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
- VBarDataList dataList = new VBarDataList();
- List<VBarGraphData> histogramData = new ArrayList<VBarGraphData>();
-
- SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
-
- String jsonHistogramQuery = queryGenerator.buildJSONFacetTermTimeRangeQuery(LogSearchConstants.AUDIT_REQUEST_USER,
- LogSearchConstants.AUDIT_EVTTIME, from, to, unit).replace("\\", "");
-
- try {
- SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
- SolrUtil.setRowCount(solrQuery, 0);
- QueryResponse response = auditSolrDao.process(solrQuery);
- if (response == null){
- return convertObjToString(dataList);
- }
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response.getResponse().get("facets");
-
- if (jsonFacetResponse == null || jsonFacetResponse.toString().equals("{count=0}")) {
- return convertObjToString(dataList);
- }
- extractValuesFromBucket(jsonFacetResponse, "x", "y", histogramData);
-
- dataList.setGraphData(histogramData);
- return convertObjToString(dataList);
-
- } catch (SolrException | IOException | SolrServerException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- }
-
- public String getAuditLogsSchemaFieldsName() {
- String excludeArray[] = PropertiesHelper.getPropertyStringList("logsearch.solr.audit.logs.exclude.columnlist");
- List<String> fieldNames = new ArrayList<String>();
- HashMap<String, String> uiFieldColumnMapping = new HashMap<String, String>();
- ConfigHelper.getSchemaFieldsName(excludeArray, fieldNames,auditSolrDao);
-
- for (String fieldName : fieldNames) {
- String uiField = ConfigHelper.auditLogsColumnMapping.get(fieldName + LogSearchConstants.SOLR_SUFFIX);
- if (uiField == null) {
- uiFieldColumnMapping.put(fieldName, fieldName);
- } else {
- uiFieldColumnMapping.put(fieldName, uiField);
- }
- }
-
- uiFieldColumnMapping = BizUtil.sortHashMapByValues(uiFieldColumnMapping);
- return convertObjToString(uiFieldColumnMapping);
-
- }
-
- public String getAnyGraphData(SearchCriteria searchCriteria) {
- searchCriteria.addParam("fieldTime", LogSearchConstants.AUDIT_EVTTIME);
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- VBarDataList result = graphDataGenerator.getAnyGraphData(searchCriteria, auditSolrDao, solrQuery);
- if (result == null) {
- result = new VBarDataList();
- }
- return convertObjToString(result);
-
- }
-
- @SuppressWarnings("unchecked")
- private void extractValuesFromBucket(SimpleOrderedMap<Object> jsonFacetResponse, String outerField, String innerField,
- List<VBarGraphData> histogramData) {
- NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
- ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get("buckets");
- for (Object temp : stackBuckets) {
- VBarGraphData vBarGraphData = new VBarGraphData();
-
- SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
- String name = ((String) level.getVal(0)).toUpperCase();
- vBarGraphData.setName(name);
-
- Collection<VNameValue> vNameValues = new ArrayList<VNameValue>();
- vBarGraphData.setDataCounts(vNameValues);
- ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level.get(innerField)).get("buckets");
- for (Object temp1 : levelBuckets) {
- SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
- String value = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
-
- String count = "" + countValue.getVal(1);
- VNameValue vNameValue = new VNameValue();
- vNameValue.setName(value);
- vNameValue.setValue(count);
- vNameValues.add(vNameValue);
- }
- histogramData.add(vBarGraphData);
- }
- }
-
- @SuppressWarnings({"unchecked"})
- public Response exportUserTableToTextFile(SearchCriteria searchCriteria) {
- String jsonUserQuery =
- "{ Users: { type: terms, field: reqUser, facet: {Repo: { type: terms, field: repo, facet: { eventCount: \"sum(event_count)\"}}}},x:{ type: terms,field: resource, facet: {y: { type: terms, field: repo,facet: { eventCount: \"sum(event_count)\"}}}}}";
-
- SolrQuery solrQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
- String startTime = (String) searchCriteria.getParamValue("startTime");
- String endTime = (String) searchCriteria.getParamValue("endTime");
-
- startTime = startTime == null ? "" : startTime;
- endTime = endTime == null ? "" : "_" + endTime;
-
- SolrUtil.setJSONFacet(solrQuery, jsonUserQuery);
- SolrUtil.setRowCount(solrQuery, 0);
-
- String dataFormat = (String) searchCriteria.getParamValue("format");
- FileOutputStream fis = null;
- try {
- QueryResponse queryResponse = auditSolrDao.process(solrQuery);
- if(queryResponse == null){
- VResponse response = new VResponse();
- response.setMsgDesc("Query was not able to execute "+solrQuery);
- throw RESTErrorUtil.createRESTException(response);
- }
-
- NamedList<Object> namedList = queryResponse.getResponse();
- if (namedList == null) {
- VResponse response = new VResponse();
- response.setMsgDesc("Query was not able to execute "+solrQuery);
- throw RESTErrorUtil.createRESTException(response);
- }
- VBarDataList vBarUserDataList = new VBarDataList();
- VBarDataList vBarResourceDataList = new VBarDataList();
-
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) namedList.get("facets");
- vBarUserDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse,"Repo","Users");
- vBarResourceDataList = BizUtil.buildSummaryForTopCounts(jsonFacetResponse,"y","x");
- String data = "";
- String summary = "";
- if ("text".equals(dataFormat)) {
- int users = 0;
- int resources = 0;
- summary += "\n\n\n\n";
- data += addBlank("Users") + "Components/Access" + "\n";
- data += "--------------------------------------------------------------------------\n";
- Collection<VBarGraphData> tableUserData = vBarUserDataList.getGraphData();
- for (VBarGraphData graphData : tableUserData) {
- String userName = graphData.getName();
- String largeUserName = "";
-
- if (userName.length() > 45) {
- largeUserName = userName.substring(0, 45);
- data += addBlank(largeUserName);
- } else
- data += addBlank(userName);
-
- Collection<VNameValue> vnameValueList = graphData.getDataCount();
- int count = 0;
- String blank = "";
- for (VNameValue vNameValue : vnameValueList) {
- data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
- if (count == 0)
- blank = addBlank(blank);
- count++;
-
- }
- while (largeUserName.length() > 0) {
- data += largeUserName.substring(0, 45) + "\n";
- }
-
- users += 1;
- }
- data += "\n\n\n\n\n\n";
- data += addBlank("Resources") + "Components/Access" + "\n";
- data += "--------------------------------------------------------------------------\n";
- Collection<VBarGraphData> tableResourceData = vBarResourceDataList.getGraphData();
- for (VBarGraphData graphData : tableResourceData) {
- String resourceName = graphData.getName();
- String largeResourceName = resourceName;
- if (largeResourceName.length() > 45) {
- resourceName = largeResourceName.substring(0, 45);
- largeResourceName = largeResourceName.substring(45, largeResourceName.length());
- } else {
- largeResourceName = "";
- }
-
- //resourceName = resourceName.replaceAll("(.{45})", resourceName.substring(0, 45)+"\n");
- data += addBlank(resourceName);
- Collection<VNameValue> vnameValueList = graphData.getDataCount();
- int count = 0;
- String blank = "";
- for (VNameValue vNameValue : vnameValueList) {
- data += blank + vNameValue.getName() + " " + vNameValue.getValue() + "\n";
- if (count == 0)
- blank = addBlank(blank);
- count++;
- }
- String tempLargeResourceName = largeResourceName;
- while (largeResourceName.length() > 45) {
- largeResourceName = tempLargeResourceName.substring(0, 45);
- tempLargeResourceName = tempLargeResourceName.substring(45, tempLargeResourceName.length());
- data += largeResourceName + "\n";
- }
- if (largeResourceName.length() < 45 && !largeResourceName.isEmpty()) {
- data += largeResourceName + "\n";
- }
- resources += 1;
- }
- String header = "--------------------------------SUMMARY-----------------------------------\n";
- summary = header + "Users = " + users + "\nResources = " + resources + "\n" + summary;
- data = summary + data;
- } else {
- data = "{" + convertObjToString(vBarUserDataList) + "," + convertObjToString(vBarResourceDataList) + "}";
- dataFormat = "json";
- }
- String fileName = "Users_Resource" + startTime + endTime + ".";
- File file = File.createTempFile(fileName, dataFormat);
-
- fis = new FileOutputStream(file);
- fis.write(data.getBytes());
- return Response
- .ok(file, MediaType.APPLICATION_OCTET_STREAM)
- .header("Content-Disposition", "attachment;filename=" + fileName + dataFormat)
- .build();
-
- } catch (SolrServerException | SolrException | IOException e) {
- logger.error("Error during solrQuery=" + e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException e) {
- }
- }
- }
- }
-
- private String addBlank(String field) {
- int blanks = 50;
- int strSize = field.length();
- String fieldWithBlank = field;
- for (int i = 0; i < blanks - strSize; i++) {
- fieldWithBlank += " ";
- }
- return fieldWithBlank;
- }
-
- public String getServiceLoad(SearchCriteria searchCriteria) {
- VBarDataList dataList = new VBarDataList();
- Collection<VBarGraphData> vaDatas = new ArrayList<VBarGraphData>();
- dataList.setGraphData(vaDatas);
-
- SolrQuery serivceLoadQuery = queryGenerator.commonAuditFilterQuery(searchCriteria);
-
- try {
- SolrUtil.setFacetField(serivceLoadQuery, LogSearchConstants.AUDIT_COMPONENT);
- QueryResponse serviceLoadResponse = auditSolrDao.process(serivceLoadQuery);
- if (serviceLoadResponse == null){
- return convertObjToString(dataList);
- }
- FacetField serviceFacetField =serviceLoadResponse.getFacetField(LogSearchConstants.AUDIT_COMPONENT);
- if (serviceFacetField == null) {
- return convertObjToString(dataList);
- }
-
- List<Count> serviceLoadFacets = serviceFacetField.getValues();
- if (serviceLoadFacets == null) {
- return convertObjToString(dataList);
- }
- for (Count cnt : serviceLoadFacets) {
- List<VNameValue> valueList = new ArrayList<VNameValue>();
- VBarGraphData vBarGraphData = new VBarGraphData();
- vaDatas.add(vBarGraphData);
- VNameValue vNameValue = new VNameValue();
- vNameValue.setName(cnt.getName());
- vBarGraphData.setName(cnt.getName().toUpperCase());
- vNameValue.setValue("" + cnt.getCount());
- valueList.add(vNameValue);
- vBarGraphData.setDataCounts(valueList);
- }
-
- return convertObjToString(dataList);
-
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/JsonManagerBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/JsonManagerBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/JsonManagerBase.java
new file mode 100644
index 0000000..94191e0
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/JsonManagerBase.java
@@ -0,0 +1,69 @@
+/*
+ * 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.manager;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+import java.util.Date;
+
+public class JsonManagerBase {
+
+ private JsonSerializer<Date> jsonDateSerialiazer = null;
+ private JsonDeserializer<Date> jsonDateDeserialiazer = null;
+
+ public JsonManagerBase() {
+ jsonDateSerialiazer = new JsonSerializer<Date>() {
+
+ @Override
+ public JsonElement serialize(Date paramT, java.lang.reflect.Type paramType, JsonSerializationContext paramJsonSerializationContext) {
+ return paramT == null ? null : new JsonPrimitive(paramT.getTime());
+ }
+ };
+
+ jsonDateDeserialiazer = new JsonDeserializer<Date>() {
+
+ @Override
+ public Date deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ return json == null ? null : new Date(json.getAsLong());
+ }
+
+ };
+ }
+
+ protected String convertObjToString(Object obj) {
+ if (obj == null) {
+ return "";
+ }
+
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(Date.class, jsonDateSerialiazer)
+ .registerTypeAdapter(Date.class, jsonDateDeserialiazer).create();
+
+ return gson.toJson(obj);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java
new file mode 100644
index 0000000..405eaef
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileManager.java
@@ -0,0 +1,155 @@
+/*
+ * 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.manager;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.ambari.logsearch.model.response.LogFileData;
+import org.apache.ambari.logsearch.model.response.LogFileDataListResponse;
+import org.apache.ambari.logsearch.model.response.LogListResponse;
+import org.apache.ambari.logsearch.model.response.ServiceLogData;
+import org.apache.ambari.logsearch.model.response.ServiceLogResponse;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.ambari.logsearch.dao.AuditSolrDao;
+import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
+import org.apache.ambari.logsearch.dao.SolrDaoBase;
+import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.FacetField;
+import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrException;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+
+
+@Component
+public class LogFileManager extends ManagerBase<ServiceLogData, ServiceLogResponse> {
+
+ private static final Logger logger = Logger.getLogger(LogFileManager.class);
+
+ @Inject
+ private ServiceLogsSolrDao serviceLogsSolrDao;
+ @Inject
+ private AuditSolrDao auditSolrDao;
+
+ public LogFileDataListResponse searchLogFiles(SearchCriteria searchCriteria) {
+ LogFileDataListResponse logFileList = new LogFileDataListResponse();
+ List<LogFileData> logFiles = new ArrayList<LogFileData>();
+ String componentName = (String) searchCriteria.getParamValue("component");
+ String host = (String) searchCriteria.getParamValue("host");
+ int minCount = 1;// to remove zero count facet
+ SolrQuery solrQuery = new SolrQuery();
+ SolrUtil.setMainQuery(solrQuery, null);
+ SolrUtil.setFacetFieldWithMincount(solrQuery, LogSearchConstants.SOLR_PATH, minCount);
+ // adding filter
+ queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_COMPONENT, componentName);
+ queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_HOST, host);
+ try {
+ String logType = (String) searchCriteria.getParamValue("logType");
+ if (StringUtils.isBlank(logType)) {
+ logType = LogType.SERVICE.name();// default is service Log
+ }
+ SolrDaoBase daoMgr = null;
+ if (logType.equalsIgnoreCase(LogType.SERVICE.name())) {
+ daoMgr = serviceLogsSolrDao;
+ } else if (logType.equalsIgnoreCase(LogType.AUDIT.name())) {
+ daoMgr = auditSolrDao;
+ } else {
+ throw RESTErrorUtil.createRESTException(logType + " is not a valid logType", MessageEnums.INVALID_INPUT_DATA);
+ }
+ QueryResponse queryResponse = daoMgr.process(solrQuery);
+ if (queryResponse.getFacetField(LogSearchConstants.SOLR_PATH) != null) {
+ FacetField queryFacetField = queryResponse.getFacetField(LogSearchConstants.SOLR_PATH);
+ if (queryFacetField != null) {
+ List<Count> countList = queryFacetField.getValues();
+ for (Count count : countList) {
+ LogFileData vLogFile = new LogFileData();
+ String filePath = count.getName();
+ String fileName = FilenameUtils.getName(filePath);
+ vLogFile.setPath(filePath);
+ vLogFile.setName(fileName);
+ logFiles.add(vLogFile);
+ }
+ }
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error in solr query :" + e.getLocalizedMessage() + "\n Query :" + solrQuery.toQueryString(), e.getCause());
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ logFileList.setLogFiles(logFiles);
+
+ return logFileList;
+ }
+
+ public LogListResponse getLogFileTail(SearchCriteria searchCriteria) {
+ String host = (String) searchCriteria.getParamValue("host");
+ String logFile = (String) searchCriteria.getParamValue("name");
+ String component = (String) searchCriteria.getParamValue("component");
+ String tailSize = (String) searchCriteria.getParamValue("tailSize");
+ if (StringUtils.isBlank(host)) {
+ throw RESTErrorUtil.createRESTException("missing Host Name", MessageEnums.ERROR_SYSTEM);
+ }
+ tailSize = (StringUtils.isBlank(tailSize)) ? "10" : tailSize;
+ SolrQuery logFileTailQuery = new SolrQuery();
+ try {
+ int tail = Integer.parseInt(tailSize);
+ tail = tail > 100 ? 100 : tail;
+ SolrUtil.setMainQuery(logFileTailQuery, null);
+ queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_HOST, host);
+ if (!StringUtils.isBlank(logFile)) {
+ queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_PATH, SolrUtil.makeSolrSearchString(logFile));
+ } else if (!StringUtils.isBlank(component)) {
+ queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_COMPONENT, component);
+ } else {
+ throw RESTErrorUtil.createRESTException("component or logfile parameter must be present", MessageEnums.ERROR_SYSTEM);
+ }
+
+ SolrUtil.setRowCount(logFileTailQuery, tail);
+ queryGenerator.setSortOrderDefaultServiceLog(logFileTailQuery, new SearchCriteria());
+ return getLogAsPaginationProvided(logFileTailQuery, serviceLogsSolrDao);
+
+ } catch (NumberFormatException ne) {
+
+ throw RESTErrorUtil.createRESTException(ne.getMessage(),
+ MessageEnums.ERROR_SYSTEM);
+
+ }
+ }
+
+ @Override
+ protected List<ServiceLogData> convertToSolrBeans(QueryResponse response) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected ServiceLogResponse createLogSearchResponse() {
+ throw new UnsupportedOperationException();
+ }
+}
[15/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
AMBARI-18310. Refactor logsearch portal side code (oleewere)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1d76f8fe
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1d76f8fe
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1d76f8fe
Branch: refs/heads/branch-dev-logsearch
Commit: 1d76f8fec98552ae1f66473c54b072951c43b17d
Parents: 0a10cbe
Author: oleewere <ol...@gmail.com>
Authored: Mon Sep 5 18:27:20 2016 +0200
Committer: oleewere <ol...@gmail.com>
Committed: Mon Sep 5 18:27:20 2016 +0200
----------------------------------------------------------------------
.../ambari-logsearch-portal/pom.xml | 2 +-
.../ambari-logsearch-portal/production/build.js | 28 -
.../ambari-logsearch-portal/production/r.js | 32140 -----------------
.../configsets/audit_logs/conf/managed-schema | 1 -
.../configsets/hadoop_logs/conf/managed-schema | 24 -
.../src/main/dev/solrcloud/README.md | 35 -
.../src/main/dev/solrcloud/reset_collections.sh | 28 -
.../src/main/dev/solrcloud/restart_solr.sh | 37 -
.../src/main/dev/solrcloud/update_config.sh | 49 -
.../org/apache/ambari/logsearch/LogSearch.java | 1 -
.../ambari/logsearch/common/ConfigHelper.java | 34 +-
.../logsearch/common/ExternalServerClient.java | 17 +-
.../logsearch/common/LogSearchConstants.java | 58 +-
.../apache/ambari/logsearch/common/Marker.java | 29 +
.../ambari/logsearch/common/PropertyMapper.java | 59 +
.../ambari/logsearch/common/SearchCriteria.java | 304 -
.../ambari/logsearch/conf/ApiDocConfig.java | 59 +
.../logsearch/conf/ApplicationConfig.java | 84 +
.../ambari/logsearch/conf/AuthConfig.java | 87 +
.../logsearch/conf/SolrAuditLogConfig.java | 181 +
.../ambari/logsearch/conf/SolrColumnConfig.java | 36 +
.../ambari/logsearch/conf/SolrConfig.java | 50 +
.../logsearch/conf/SolrConnectionConfig.java | 49 +
.../logsearch/conf/SolrKerberosConfig.java | 48 +
.../logsearch/conf/SolrServiceLogConfig.java | 144 +
.../ambari/logsearch/conf/SolrUserConfig.java | 104 +
.../ambari/logsearch/dao/AuditSolrDao.java | 29 +-
.../logsearch/dao/ServiceLogsSolrDao.java | 21 +-
.../ambari/logsearch/dao/SolrDaoBase.java | 19 +-
.../ambari/logsearch/dao/UserConfigSolrDao.java | 32 +-
.../apache/ambari/logsearch/dao/UserDao.java | 10 +-
.../ambari/logsearch/doc/DocConstants.java | 26 +-
.../logsearch/graph/GraphDataGenerator.java | 81 +-
.../logsearch/graph/GraphDataGeneratorBase.java | 34 +-
.../logsearch/manager/AuditLogsManager.java | 597 +
.../ambari/logsearch/manager/AuditMgr.java | 630 -
.../logsearch/manager/JsonManagerBase.java | 69 +
.../logsearch/manager/LogFileManager.java | 155 +
.../ambari/logsearch/manager/LogFileMgr.java | 145 -
.../ambari/logsearch/manager/LogsMgr.java | 1896 -
.../ambari/logsearch/manager/ManagerBase.java | 221 +
.../ambari/logsearch/manager/MgrBase.java | 256 -
.../ambari/logsearch/manager/PublicManager.java | 48 +
.../ambari/logsearch/manager/PublicMgr.java | 46 -
.../logsearch/manager/ServiceLogsManager.java | 1917 +
.../logsearch/manager/SessionManager.java | 76 +
.../ambari/logsearch/manager/SessionMgr.java | 76 -
.../logsearch/manager/UserConfigManager.java | 276 +
.../ambari/logsearch/manager/UserConfigMgr.java | 276 -
.../model/request/AnyGraphParamDefinition.java | 44 +
.../model/request/BundleIdParamDefinition.java | 32 +
.../request/CommonSearchParamDefinition.java | 69 +
.../model/request/DateRangeParamDefinition.java | 38 +
.../model/request/FieldParamDefinition.java | 32 +
.../model/request/FormatParamDefinition.java | 32 +
.../model/request/LastPageParamDefinition.java | 31 +
.../model/request/LogFileParamDefinition.java | 45 +
.../request/LogFileTailParamDefinition.java | 32 +
.../model/request/LogParamDefinition.java | 68 +
.../request/LogTruncatedParamDefinition.java | 44 +
.../model/request/QueryParamDefinition.java | 32 +
.../logsearch/model/request/SearchRequest.java | 25 +
.../request/ServiceLogFileParamDefinition.java | 38 +
.../request/ServiceLogParamDefinition.java | 80 +
.../ServiceLogSearchParamDefinition.java | 50 +
.../model/request/UnitParamDefinition.java | 33 +
.../request/UserConfigParamDefinition.java | 44 +
.../model/request/UtcOffsetParamDefinition.java | 32 +
.../model/request/impl/AnyGraphRequest.java | 109 +
.../request/impl/AuditBarGraphRequest.java | 40 +
.../model/request/impl/AuditLogRequest.java | 40 +
.../model/request/impl/BaseAuditLogRequest.java | 53 +
.../model/request/impl/BaseLogRequest.java | 118 +
.../request/impl/BaseServiceLogRequest.java | 186 +
.../model/request/impl/CommonSearchRequest.java | 119 +
.../request/impl/FieldAuditBarGraphRequest.java | 40 +
.../request/impl/FieldAuditLogRequest.java | 41 +
.../model/request/impl/LogFileRequest.java | 67 +
.../model/request/impl/LogFileTailRequest.java | 40 +
.../model/request/impl/QueryRequest.java | 40 +
.../request/impl/ServiceAnyGraphRequest.java | 109 +
.../impl/ServiceExtremeDatesRequest.java | 41 +
.../model/request/impl/ServiceGraphRequest.java | 40 +
.../request/impl/ServiceLogExportRequest.java | 54 +
.../request/impl/ServiceLogFileRequest.java | 54 +
.../model/request/impl/ServiceLogRequest.java | 93 +
.../impl/ServiceLogTruncatedRequest.java | 66 +
.../model/request/impl/SimpleQueryRequest.java | 42 +
.../model/request/impl/UserConfigRequest.java | 66 +
.../model/request/impl/UserExportRequest.java | 40 +
.../logsearch/model/response/AuditLogData.java | 149 +
.../model/response/AuditLogResponse.java | 48 +
.../logsearch/model/response/BarGraphData.java | 53 +
.../response/BarGraphDataListResponse.java | 42 +
.../logsearch/model/response/CommonLogData.java | 113 +
.../model/response/ComponentTypeLogData.java | 32 +
.../logsearch/model/response/CountData.java | 50 +
.../model/response/CountDataListResponse.java | 48 +
.../logsearch/model/response/GraphData.java | 64 +
.../model/response/GraphDataListResponse.java | 39 +
.../model/response/GroupListResponse.java | 48 +
.../logsearch/model/response/HostLogData.java | 30 +
.../logsearch/model/response/LogData.java | 25 +
.../logsearch/model/response/LogFileData.java | 48 +
.../model/response/LogFileDataListResponse.java | 48 +
.../model/response/LogListResponse.java | 27 +
.../model/response/LogSearchResponse.java | 22 +
.../logsearch/model/response/NameValueData.java | 62 +
.../response/NameValueDataListResponse.java | 49 +
.../logsearch/model/response/NodeData.java | 111 +
.../model/response/NodeListResponse.java | 50 +
.../model/response/SearchResponse.java | 110 +
.../model/response/ServiceLogData.java | 63 +
.../model/response/ServiceLogResponse.java | 48 +
.../ambari/logsearch/query/QueryGeneration.java | 18 +-
.../logsearch/query/QueryGenerationBase.java | 12 +-
.../AbstractCommonAuditLogRequestConverter.java | 48 +
.../AbstractCommonSearchRequestConverter.java | 53 +
...bstractCommonServiceLogRequestConverter.java | 56 +
.../converter/AnyGraphRequestConverter.java | 39 +
.../AuditBarGraphRequestConverter.java | 34 +
.../converter/AuditLogRequestConverter.java | 34 +
.../converter/BaseAuditLogRequestConverter.java | 33 +
.../BaseServiceLogRequestConverter.java | 32 +
.../FieldAuditLogRequestConverter.java | 34 +
.../FieldBarGraphRequestConverter.java | 35 +
.../converter/LogFileRequestConverter.java | 37 +
.../converter/LogFileTailRequestConverter.java | 38 +
.../ServiceAnyGraphRequestConverter.java | 39 +
.../ServiceExtremeDatesRequestConverter.java | 35 +
.../converter/ServiceGraphRequestConverter.java | 36 +
.../ServiceLogExportRequestConverter.java | 38 +
.../ServiceLogFileRequestConverter.java | 36 +
.../converter/ServiceLogRequestConverter.java | 41 +
.../ServiceLogTruncatedRequestConverter.java | 38 +
.../converter/SimpleQueryRequestConverter.java | 34 +
.../converter/UserConfigRequestConverter.java | 38 +
.../converter/UserExportRequestConverter.java | 35 +
.../query/model/AnyGraphSearchCriteria.java | 25 +
.../model/AuditBarGraphSearchCriteria.java | 25 +
.../query/model/AuditLogSearchCriteria.java | 25 +
.../query/model/CommonSearchCriteria.java | 100 +
.../model/FieldAuditBarGraphSearchCriteria.java | 25 +
.../model/FieldAuditLogSearchCriteria.java | 25 +
.../query/model/LogFileSearchCriteria.java | 25 +
.../query/model/LogFileTailSearchCriteria.java | 25 +
.../logsearch/query/model/SearchCriteria.java | 136 +
.../model/ServiceAnyGraphSearchCriteria.java | 25 +
.../model/ServiceExtremeDatesCriteria.java | 25 +
.../query/model/ServiceGraphSearchCriteria.java | 25 +
.../model/ServiceLogExportSearchCriteria.java | 25 +
.../model/ServiceLogFileSearchCriteria.java | 25 +
.../query/model/ServiceLogSearchCriteria.java | 25 +
.../ServiceLogTruncatedSearchCriteria.java | 25 +
.../query/model/UserConfigSearchCriteria.java | 25 +
.../query/model/UserExportSearchCriteria.java | 25 +
.../ambari/logsearch/rest/AuditLogsREST.java | 283 -
.../logsearch/rest/AuditLogsResource.java | 157 +
.../ambari/logsearch/rest/LogFileREST.java | 84 -
.../ambari/logsearch/rest/LogFileResource.java | 69 +
.../ambari/logsearch/rest/PublicREST.java | 48 -
.../ambari/logsearch/rest/PublicResource.java | 48 +
.../ambari/logsearch/rest/ServiceLogsREST.java | 574 -
.../logsearch/rest/ServiceLogsResource.java | 238 +
.../ambari/logsearch/rest/UserConfigREST.java | 128 -
.../logsearch/rest/UserConfigResource.java | 116 +
.../ambari/logsearch/service/UserService.java | 5 +-
.../logsearch/solr/model/SolrAuditLogData.java | 339 +
.../logsearch/solr/model/SolrCommonLogData.java | 248 +
.../solr/model/SolrComponentTypeLogData.java | 38 +
.../logsearch/solr/model/SolrHostLogData.java | 38 +
.../solr/model/SolrServiceLogData.java | 118 +
.../apache/ambari/logsearch/util/BizUtil.java | 40 +-
.../ambari/logsearch/view/VBarDataList.java | 46 -
.../ambari/logsearch/view/VBarGraphData.java | 50 -
.../apache/ambari/logsearch/view/VCount.java | 62 -
.../ambari/logsearch/view/VCountList.java | 68 -
.../ambari/logsearch/view/VGraphData.java | 79 -
.../ambari/logsearch/view/VGraphInfo.java | 62 -
.../ambari/logsearch/view/VGroupList.java | 66 -
.../apache/ambari/logsearch/view/VLogFile.java | 56 -
.../ambari/logsearch/view/VLogFileList.java | 70 -
.../ambari/logsearch/view/VNameValue.java | 123 -
.../ambari/logsearch/view/VNameValueList.java | 78 -
.../org/apache/ambari/logsearch/view/VNode.java | 122 -
.../apache/ambari/logsearch/view/VNodeList.java | 55 -
.../ambari/logsearch/view/VSolrLogList.java | 67 -
.../apache/ambari/logsearch/view/VString.java | 52 -
.../ambari/logsearch/view/VSummaryCount.java | 66 -
.../logsearch/view/VSummaryCountList.java | 37 -
...LogsearchSecurityContextFormationFilter.java | 10 +-
.../LogsearchAuthenticationProvider.java | 15 +-
...rchExternalServerAuthenticationProvider.java | 18 +-
.../LogsearchFileAuthenticationProvider.java | 5 +-
.../src/main/scripts/add_config_set.sh | 43 -
.../src/main/scripts/create_collections.sh | 37 -
.../main/webapp/META-INF/applicationContext.xml | 69 -
.../META-INF/security-applicationContext.xml | 1 +
.../src/main/webapp/WEB-INF/web.xml | 27 +-
.../scripts/model_bases/VUserFilterBase.js | 2 +-
.../views/dashboard/ComponentListView.js | 2 +-
.../scripts/views/graphs/GraphLayoutView.js | 2 +-
.../src/main/webapp/templates/graphs/backup.js | 2 +-
.../ambari/logsearch/dao/AuditSolrDaoTest.java | 37 +-
.../logsearch/dao/ServiceLogsSolrDaoTest.java | 37 +-
.../ambari/logsearch/dao/SolrDaoBaseTest.java | 73 +-
.../logsearch/dao/UserConfigSolrDaoTest.java | 56 +-
.../ambari/logsearch/dao/UserDaoTest.java | 58 -
.../src/test/resources/applicationContext.xml | 53 -
209 files changed, 11313 insertions(+), 38775 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/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 b36c9bb..ebba82c 100755
--- a/ambari-logsearch/ambari-logsearch-portal/pom.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/pom.xml
@@ -548,7 +548,7 @@
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
- <artifactId>jersey-media-moxy</artifactId>
+ <artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/production/build.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/production/build.js b/ambari-logsearch/ambari-logsearch-portal/production/build.js
deleted file mode 100644
index afeea67..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/production/build.js
+++ /dev/null
@@ -1,28 +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.
-*/
-
-{
- appDir: "../src/main/webapp",
- baseUrl: "scripts",
- dir: "../target/webapp-build",
- modules: [
- {
- name: "Init"
- }
- ]
-}
[03/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java
deleted file mode 100644
index 7832fcc..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java
+++ /dev/null
@@ -1,62 +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.view;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class VCount implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
-
- protected String name;
-
- protected Long count;
-
- /**
- * Default constructor. This will set all the attributes to default value.
- */
- public VCount() {
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Long getCount() {
- return count;
- }
-
- public void setCount(Long count) {
- this.count = count;
- }
-
- public String toString() {
- String str = "VLogLevel={";
- str += super.toString();
- str += "name={" + name + "} ";
- str += "count={" + count + "} ";
- str += "}";
- return str;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java
deleted file mode 100644
index f105478..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java
+++ /dev/null
@@ -1,68 +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.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VCountList extends VList {
- private static final long serialVersionUID = 1L;
-
- protected List<VCount> vCounts;
-
- public VCountList() {
- super();
- vCounts = new ArrayList<VCount>();
- }
-
- public VCountList(List<VCount> logList) {
- super(logList);
- this.vCounts = logList;
- }
-
- public void setCounts(List<VCount> list) {
- this.vCounts = list;
- }
-
- @Override
- public int getListSize() {
- if (vCounts != null)
- return vCounts.size();
- return 0;
- }
-
- @Override
- public List<VCount> getList() {
- return vCounts;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java
deleted file mode 100644
index 1eebfac..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java
+++ /dev/null
@@ -1,79 +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.view;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VGraphData implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected String name;
-
- protected Long count;
-
- protected List<VGraphData> dataList;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Long getCount() {
- return count;
- }
-
- public void setCount(Long info) {
- this.count = info;
- }
-
- public List<VGraphData> getDataList() {
- return dataList;
- }
-
- public void setDataList(List<VGraphData> dataList) {
- this.dataList = dataList;
- }
-
- @Override
- public String toString() {
- String str = "VGraphData={";
- str += super.toString();
- str += "info={ " + count + " } ";
- str += "dataList={ " + dataList + " } ";
- return str;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java
deleted file mode 100644
index 2bf75b5..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java
+++ /dev/null
@@ -1,62 +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.view;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VGraphInfo implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- protected List<VGraphData> graphData;
-
- public List<VGraphData> getGraphData() {
- return graphData;
- }
-
- public void setGraphData(List<VGraphData> graphData) {
- this.graphData = graphData;
- }
-
- @Override
- public String toString() {
- String str = "VGraphInfo={";
- str += super.toString();
- str += "graphData={ " + graphData + " }";
- return str;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java
deleted file mode 100644
index 5e6c3fa..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java
+++ /dev/null
@@ -1,66 +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.view;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.solr.common.SolrDocumentList;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VGroupList extends VList {
- private static final long serialVersionUID = 1L;
-
- protected SolrDocumentList groupList;
-
- public VGroupList() {
- super();
- groupList = new SolrDocumentList();
- }
-
- public VGroupList(SolrDocumentList logList) {
- super(logList);
- this.groupList = logList;
- }
-
- public void setGroupDocuments(SolrDocumentList list) {
- this.groupList = list;
- }
-
- @Override
- public int getListSize() {
- if (groupList != null)
- return groupList.size();
- return 0;
- }
-
- @Override
- public SolrDocumentList getList() {
- return groupList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java
deleted file mode 100644
index 57e32d2..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java
+++ /dev/null
@@ -1,56 +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.view;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VLogFile {
-
- private String name;
-
- private String path;
-
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java
deleted file mode 100644
index a79dae7..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java
+++ /dev/null
@@ -1,70 +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.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VLogFileList extends VList {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private List<VLogFile> logFiles;
-
- public VLogFileList() {
- logFiles = new ArrayList<VLogFile>();
- }
-
- @Override
- public int getListSize() {
- if (logFiles == null) {
- return 0;
- }
- return logFiles.size();
- }
-
- @Override
- public List<?> getList() {
- return logFiles;
- }
-
- public List<VLogFile> getLogFiles() {
- return logFiles;
- }
-
- public void setLogFiles(List<VLogFile> logFiles) {
- this.logFiles = logFiles;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java
deleted file mode 100644
index adbd6e0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java
+++ /dev/null
@@ -1,123 +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.view;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class VNameValue implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Name
- */
- protected String name;
- /**
- * Value
- */
- protected String value;
-
- /**
- * Default constructor. This will set all the attributes to default value.
- */
- public VNameValue() {
- }
-
- /**
- * @param name
- * the key
- * @param value
- * the value
- */
- public VNameValue(String name, String value) {
-
- this.name = name;
- this.value = value;
- }
-
- /**
- * 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>value</b>. You
- * cannot set null to the attribute.
- *
- * @param value
- * Value to set member attribute <b>value</b>
- */
- public void setValue(String value) {
- if(value.contains(".") && (value.contains("e") || value.contains("E"))){
- this.value=getExponentialValueReplaced(value);
- }else{
- this.value = value;
- }
- }
-
- /**
- * Returns the value for the member attribute <b>value</b>
- *
- * @return String - value of member attribute <b>value</b>.
- */
- public String getValue() {
- return this.value;
- }
-
- /**
- * This return the bean content in string format
- *
- * @return formatedStr
- */
- public String toString() {
- String str = "VNameValue={";
- str += super.toString();
- str += "name={" + name + "} ";
- str += "value={" + value + "} ";
- str += "}";
- return str;
- }
-
- private String getExponentialValueReplaced(String value) {
- try{
- Double number = Double.parseDouble(value);
- String newValue = String.format("%.0f", number);
- return newValue;
-
- }catch(Exception e){
- return value;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java
deleted file mode 100644
index e95249d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java
+++ /dev/null
@@ -1,78 +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.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VNameValueList extends VList {
- private static final long serialVersionUID = 1L;
- protected List<VNameValue> vNameValues = new ArrayList<VNameValue>();
-
- public VNameValueList() {
- super();
- }
-
- public VNameValueList(List<VNameValue> objList) {
- super(objList);
- this.vNameValues = objList;
- }
-
- /**
- * @return the vNameValues
- */
- public List<VNameValue> getVNameValues() {
- return vNameValues;
- }
-
- /**
- * @param vNameValues
- * the vNameValues to set
- */
- public void setVNameValues(List<VNameValue> vNameValues) {
- this.vNameValues = vNameValues;
- }
-
- @Override
- public int getListSize() {
- if (vNameValues != null) {
- return vNameValues.size();
- }
- return 0;
- }
-
- @Override
- public List<?> getList() {
- // TODO Auto-generated method stub
- return null;
- }
-
-// @Override
-// public List<VNameValue> getList() {
-// return vNameValues;
-// }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java
deleted file mode 100644
index a16ded8..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java
+++ /dev/null
@@ -1,122 +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.view;
-
-import java.util.Collection;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VNode {
-
- private String name;
-
- private String type;
-
- private String value;
-
- private boolean isRoot;
-
- private Collection<VNode> childs;
-
- private Collection<VNameValue> logLevelCount;
-
- private boolean isParent;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public boolean isRoot() {
- return isRoot;
- }
-
- public void setRoot(boolean isRoot) {
- this.isRoot = isRoot;
- }
-
- public Collection<VNode> getChilds() {
- return childs;
- }
-
- public void setChilds(Collection<VNode> childs) {
- this.childs = childs;
- }
-
- public boolean isParent() {
- return isParent;
- }
-
- public void setParent(boolean isParent) {
- this.isParent = isParent;
- }
-
- public Collection<VNameValue> getLogLevelCount() {
- return logLevelCount;
- }
-
- public void setLogLevelCount(Collection<VNameValue> logLevelCount) {
- this.logLevelCount = logLevelCount;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- String str = "VNode={";
- str += "name={" + name + "} ";
- str += "value={" + value + "} ";
- str += "type={" + type + "} ";
- str += "isRoot={" + isRoot + "} ";
- str += "isParent={" + isParent + "} ";
- str += "logLevelCount={" + logLevelCount + "} ";
- str += "childs={" + childs + "} ";
- str += "}";
- return str;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.java
deleted file mode 100644
index 78f32ce..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.java
+++ /dev/null
@@ -1,55 +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.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VNodeList extends VList {
- private static final long serialVersionUID = 1L;
- protected List<VNode> vNodeList = new ArrayList<VNode>();
-
- public List<VNode> getvNodeList() {
- return vNodeList;
- }
-
- public void setvNodeList(List<VNode> vNodeList) {
- this.vNodeList = vNodeList;
- }
-
- @Override
- public int getListSize() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public List<VNode> getList() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.java
deleted file mode 100644
index 55cc089..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.java
+++ /dev/null
@@ -1,67 +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.view;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.solr.common.SolrDocumentList;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VSolrLogList extends VList {
- private static final long serialVersionUID = 1L;
-
- protected SolrDocumentList logList;
-
- public VSolrLogList() {
- super();
- logList = new SolrDocumentList();
- }
-
- public VSolrLogList(SolrDocumentList logList) {
- super(logList);
- this.logList = logList;
- }
-
- public void setSolrDocuments(SolrDocumentList list) {
- this.logList = list;
- }
-
- @Override
- public int getListSize() {
- if (logList != null){
- return logList.size();
- }
- return 0;
- }
-
- @Override
- public SolrDocumentList getList() {
- return logList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java
deleted file mode 100644
index bda7565..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java
+++ /dev/null
@@ -1,52 +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.view;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class VString {
-
- /**
- * Value
- */
- protected String value;
-
- /**
- * Default constructor. This will set all the attributes to default value.
- */
- public VString() {
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String toString() {
- String str = "VString={";
- str += super.toString();
- str += "value={" + value + "} ";
- str += "}";
- return str;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java
deleted file mode 100644
index b8606d0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java
+++ /dev/null
@@ -1,66 +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.view;
-
-import java.util.List;
-
-public class VSummaryCount {
-
- protected String level;
-
- protected List<String> cricticalMsg;
-
- protected List<String> compName;
-
- protected List<Long> countMsg;
-
- public String getLevel() {
- return level;
- }
-
- public void setLevel(String level) {
- this.level = level;
- }
-
- public List<String> getCricticalMsg() {
- return cricticalMsg;
- }
-
- public void setCricticalMsg(List<String> cricticalMsg) {
- this.cricticalMsg = cricticalMsg;
- }
-
- public List<String> getCompName() {
- return compName;
- }
-
- public void setCompName(List<String> compName) {
- this.compName = compName;
- }
-
- public List<Long> getCountMsg() {
- return countMsg;
- }
-
- public void setCountMsg(List<Long> countMsg) {
- this.countMsg = countMsg;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java
deleted file mode 100644
index fcab0b7..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java
+++ /dev/null
@@ -1,37 +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.view;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class VSummaryCountList {
-
- protected Collection<VSummaryCount> countList = new ArrayList<VSummaryCount>();
-
- public Collection<VSummaryCount> getCountList() {
- return countList;
- }
-
- public void setCountList(Collection<VSummaryCount> countList) {
- this.countList = countList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
index 9fb285e..a34fbd0 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
@@ -20,6 +20,7 @@ package org.apache.ambari.logsearch.web.filters;
import java.io.IOException;
+import javax.inject.Inject;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
@@ -30,11 +31,10 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.ambari.logsearch.common.LogSearchContext;
-import org.apache.ambari.logsearch.manager.SessionMgr;
+import org.apache.ambari.logsearch.manager.SessionManager;
import org.apache.ambari.logsearch.util.CommonUtil;
import org.apache.ambari.logsearch.web.model.User;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
@@ -47,8 +47,8 @@ public class LogsearchSecurityContextFormationFilter extends GenericFilterBean {
public static final String LOGSEARCH_SC_SESSION_KEY = "LOGSEARCH_SECURITY_CONTEXT";
public static final String USER_AGENT = "User-Agent";
- @Autowired
- SessionMgr sessionMgr;
+ @Inject
+ SessionManager sessionManager;
public LogsearchSecurityContextFormationFilter() {
}
@@ -94,7 +94,7 @@ public class LogsearchSecurityContextFormationFilter extends GenericFilterBean {
httpSession.setAttribute(LOGSEARCH_SC_SESSION_KEY, context);
}
LogSearchContext.setContext(context);
- User user = sessionMgr.processSuccessLogin();
+ User user = sessionManager.processSuccessLogin();
context.setUser(user);
}
chain.doFilter(request, response);
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
index 0f7377d..3534818 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
@@ -23,7 +23,6 @@ import java.util.HashMap;
import org.apache.ambari.logsearch.dao.UserDao;
import org.apache.ambari.logsearch.util.JSONUtil;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
@@ -31,6 +30,8 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.stereotype.Component;
+import javax.inject.Inject;
+
@Component
public class LogsearchAuthenticationProvider extends
LogsearchAbstractAuthenticationProvider {
@@ -39,19 +40,19 @@ public class LogsearchAuthenticationProvider extends
private static Logger auditLogger = Logger
.getLogger("org.apache.ambari.logsearch.audit");
- @Autowired
+ @Inject
UserDao userDao;
- @Autowired
+ @Inject
LogsearchLdapAuthenticationProvider ldapAuthenticationProvider;
- @Autowired
+ @Inject
LogsearchFileAuthenticationProvider fileAuthenticationProvider;
- @Autowired
+ @Inject
LogsearchSimpleAuthenticationProvider simpleAuthenticationProvider;
-
- @Autowired
+
+ @Inject
LogsearchExternalServerAuthenticationProvider externalServerAuthenticationProvider;
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
index 4eea3e1..a06a381 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
@@ -22,14 +22,15 @@ import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
+import javax.inject.Inject;
import org.apache.ambari.logsearch.common.ExternalServerClient;
import org.apache.ambari.logsearch.common.PropertiesHelper;
+import org.apache.ambari.logsearch.conf.AuthConfig;
import org.apache.ambari.logsearch.util.JSONUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -95,16 +96,11 @@ public class LogsearchExternalServerAuthenticationProvider extends
};
}
- @Autowired
- ExternalServerClient externalServerClient;
+ @Inject
+ private ExternalServerClient externalServerClient;
- private String loginAPIURL = "/api/v1/users/$USERNAME/privileges?fields=*";// default
-
- @PostConstruct
- public void initialization() {
- loginAPIURL = PropertiesHelper.getProperty(AUTH_METHOD_PROP_START_WITH
- + "external_auth.login_url", loginAPIURL);
- }
+ @Inject
+ private AuthConfig authConfig;
/**
* Authenticating user from external-server using REST call
@@ -134,7 +130,7 @@ public class LogsearchExternalServerAuthenticationProvider extends
password = StringEscapeUtils.unescapeHtml(password);
username = StringEscapeUtils.unescapeHtml(username);
try {
- String finalLoginUrl = loginAPIURL.replace("$USERNAME", username);
+ String finalLoginUrl = authConfig.getExternalAuthLoginUrl().replace("$USERNAME", username);
String responseObj = (String) externalServerClient.sendGETRequest(
finalLoginUrl, String.class, null, username, password);
if (!isAllowedRole(responseObj)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
index 44c31c5..180de31 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
@@ -24,7 +24,6 @@ import org.apache.ambari.logsearch.util.CommonUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -34,12 +33,14 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Component;
+import javax.inject.Inject;
+
@Component
public class LogsearchFileAuthenticationProvider extends LogsearchAbstractAuthenticationProvider {
private static Logger logger = Logger.getLogger(LogsearchFileAuthenticationProvider.class);
- @Autowired
+ @Inject
private UserDetailsService userDetailsService;
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh
deleted file mode 100755
index e9d3106..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh
+++ /dev/null
@@ -1,43 +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.
-
-if [ $# -ne 4 ]; then
- echo "Usage: $0 <solr_home> <zk_host_with_path> <config_name> <config_folder>"
- echo "Example: $0 /opt/solr MY_ZKHOST/solr hadoop_logs `dirname $0`/configsets/hadoop_logs"
- exit 1
-fi
-
-curr_dir=`pwd`
-cd `dirname $0`; script_dir=`pwd`; cd $curr_dir
-
-
-solr_home=$1
-zk_host=$2
-config_name=$3
-config_folder=$4
-
-tmp_folder=/tmp/solr_config_${config_name}_$USER
-rm -rf $tmp_folder
-
-$solr_home/server/scripts/cloud-scripts/zkcli.sh -zkhost $zk_host -cmd downconfig -confdir $tmp_folder -confname $config_name > /dev/null 2>&1
-
-if [ -d $tmp_folder ]; then
- echo "Config $config_name already existing. Will not add to zookeeper"
-else
- echo "Adding config to $config_name to $zk_host"
- $solr_home/server/scripts/cloud-scripts/zkcli.sh -zkhost $zk_host -cmd upconfig -confdir $config_folder -confname $config_name
- echo "Added config to $config_name to $zk_host"
-fi
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.sh
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.sh
deleted file mode 100755
index be728aa..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.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.
-
-if [ $# -ne 4 ]; then
- echo "Usage: $0 <solr_home> <number of shards> <number of replications> [configset folder]"
- exit 1
-fi
-
-curr_dir=`pwd`
-cd `dirname $0`; script_dir=`pwd`; cd $curr_dir
-
-
-solr_home=$1
-shards=$2
-replications=$3
-
-configsets_folder=$4
-if [ "$configsets_folder" = "" ]; then
- configsets_folder=${script_dir}/solr_configsets
-fi
-
-${solr_home}/bin/solr create -c hadoop_logs -d ${configsets_folder}/hadoop_logs/conf -s ${shards} -rf ${replications}
-${solr_home}/bin/solr create -c history -d ${configsets_folder}/history/conf -s 1 -rf ${shards}
-${solr_home}/bin/solr create -c audit_logs -d ${configsets_folder}/audit_logs/conf -s ${shards} -rf ${replications}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
deleted file mode 100644
index b457a1d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
-xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
-xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns:util="http://www.springframework.org/schema/util"
-xsi:schemaLocation="http://www.springframework.org/schema/aop
-http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
-http://www.springframework.org/schema/beans
-http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
-http://www.springframework.org/schema/context
-http://www.springframework.org/schema/context/spring-context-4.2.xsd
-http://www.springframework.org/schema/jee
-http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
-http://www.springframework.org/schema/tx
-http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
-http://www.springframework.org/schema/task
-http://www.springframework.org/schema/task/spring-task-4.2.xsd
-http://www.springframework.org/schema/util
-http://www.springframework.org/schema/util/spring-util.xsd">
-
- <context:component-scan base-package="org.apache.ambari.logsearch" />
- <task:annotation-driven />
- <bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.common.XMLPropertiesHelper" />
-
- <bean id="propertyConfigurer" class="org.apache.ambari.logsearch.common.PropertiesHelper">
- <property name="locations">
- <list>
- <value>classpath:default.properties</value>
- <value>classpath:logsearch.properties</value>
- <value>classpath:logsearch-admin-site.xml</value>
- </list>
- </property>
- <property name="propertiesPersister" ref="xmlPropertyConfigurer" />
- </bean>
-
- <bean id="host" class="java.net.InetAddress" factory-method="getLocalHost"/>
- <bean id="apiListingResource" class="io.swagger.jaxrs.listing.ApiListingResource"/>
- <bean id="swaggerSerializers" class="io.swagger.jaxrs.listing.SwaggerSerializers" scope="singleton"/>
- <bean id="beanConfig" class="io.swagger.jaxrs.config.BeanConfig">
- <property name="schemes" value="http" /> <!-- TODO: set this from property -->
- <property name="resourcePackage" value="org.apache.ambari.logsearch.rest"/>
- <property name="version" value="1.0.0"/>
- <property name="host" value="#{host.hostAddress}:61888"/> <!-- TODO: set port from property -->
- <property name="basePath" value="/api/v1"/>
- <property name="title" value="Log Search REST API"/>
- <property name="description" value="Log aggregation, analysis, and visualization."/>
- <property name="license" value="Apache 2.0"/>
- <property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
- <property name="scan" value="true"/>
- </bean>
-
-</beans>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
index 233fad4..9961cd0 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
@@ -34,6 +34,7 @@ http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<security:http pattern="/favicon.ico" security="none" />
<security:http pattern="/api/v1/public/**" security="none" />
<security:http pattern="/api/v1/swagger.json" security="none"/>
+ <security:http pattern="/api/v1/swagger.yaml" security="none"/>
<security:http disable-url-rewriting="true" use-expressions="true" create-session="always" entry-point-ref="authenticationProcessingFilterEntryPoint">
<csrf disabled="true"/>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
index dbe5210..0f1beec 100755
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
@@ -16,21 +16,20 @@
limitations under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
-
-
- <display-name>LogSearch</display-name>
-
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>META-INF/applicationContext.xml
- META-INF/security-applicationContext.xml
- </param-value>
- </context-param>
-
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <context-param>
+ <param-name>contextClass</param-name>
+ <param-value>
+ org.springframework.web.context.support.AnnotationConfigWebApplicationContext
+ </param-value>
+ </context-param>
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>org.apache.ambari.logsearch.conf.ApplicationConfig</param-value>
+ </context-param>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
index da299a0..cd469de 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
@@ -27,7 +27,7 @@ define(['require',
var VUserFilterBase = BaseModel.extend(
/** @lends VUserFilterBase.prototype */
{
- urlRoot: Globals.baseURL + 'userconfig/users/filter',
+ urlRoot: Globals.baseURL + 'userconfig/filters',
defaults: {},
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
index b8c43bb..2afb4e1 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
@@ -68,7 +68,7 @@ define(['require',
pageSize: 99999
}
});
- this.componentsList.url = Globals.baseURL + "service/logs/components/level/counts";
+ this.componentsList.url = Globals.baseURL + "service/logs/components/levels/counts";
this.hostList = new VNodeList([],{
state: {
firstPage: 0,
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
index 35d0c9a..728d721 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
@@ -84,7 +84,7 @@ define(['require',
this.collection.url = Globals.baseURL + "service/logs/histogram";
this.collection.modelAttrName = "graphData";
} else {
- this.collection.url = Globals.baseURL + "audit/logs/linegraph";
+ this.collection.url = Globals.baseURL + "audit/logs/bargraph";
this.collection.modelAttrName = "graphData";
this.lineView = true;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
index 8999e01..e250b02 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
@@ -81,7 +81,7 @@ define(['require',
this.collection.url = Globals.baseURL + "service/logs/histogram";
this.collection.modelAttrName = "graphData";
} else {
- this.collection.url = Globals.baseURL + "audit/logs/linegraph";
+ this.collection.url = Globals.baseURL + "audit/logs/bargraph";
this.collection.modelAttrName = "graphData";
this.lineView = true;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
index 0b94b60..017d7a8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
@@ -21,18 +21,38 @@ package org.apache.ambari.logsearch.dao;
import java.util.ArrayList;
+import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.util.NamedList;
import org.easymock.Capture;
import org.easymock.CaptureType;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
public class AuditSolrDaoTest {
+ @TestSubject
+ private AuditSolrDao dao = new AuditSolrDao();
+
+ @Mock
+ private SolrAuditLogConfig configMock;
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
+
@Test
public void testAuditSolrDaoPostConstructor() throws Exception {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
@@ -42,6 +62,18 @@ public class AuditSolrDaoTest {
header.add("status", 0);
response.add("responseHeader", header);
response.add("collections", new ArrayList<String>());
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_audit_logs_config_name");
+ EasyMock.expect(configMock.getCollection()).andReturn("test_audit_logs_collection");
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(123);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(456);
+ EasyMock.expect(configMock.getAliasNameIn()).andReturn("alias");
+ EasyMock.expect(configMock.getRangerCollection()).andReturn("ranger_audit");
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
@@ -50,9 +82,8 @@ public class AuditSolrDaoTest {
mockSolrClient.request(EasyMock.capture(captureCreateRequest), EasyMock.anyString());
EasyMock.expectLastCall().andReturn(response);
- EasyMock.replay(mockSolrClient);
-
- AuditSolrDao dao = new AuditSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
index 2985a62..bdee8a8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
@@ -21,18 +21,38 @@ package org.apache.ambari.logsearch.dao;
import java.util.ArrayList;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
+import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.util.NamedList;
import org.easymock.Capture;
import org.easymock.CaptureType;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
public class ServiceLogsSolrDaoTest {
+ @TestSubject
+ private ServiceLogsSolrDao dao = new ServiceLogsSolrDao();
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Mock
+ private SolrServiceLogConfig configMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
+
@Test
public void testServiceLogsSolrDaoPostConstructor() throws Exception {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
@@ -42,20 +62,29 @@ public class ServiceLogsSolrDaoTest {
header.add("status", 0);
response.add("responseHeader", header);
response.add("collections", new ArrayList<String>());
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_service_logs_config_name");
+ EasyMock.expect(configMock.getCollection()).andReturn("test_service_logs_collection");
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(789);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(987);
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
mockSolrClient.request(EasyMock.capture(captureCreateRequest), EasyMock.anyString()); EasyMock.expectLastCall().andReturn(response);
- EasyMock.replay(mockSolrClient);
-
- ServiceLogsSolrDao dao = new ServiceLogsSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
dao.postConstructor();
- EasyMock.verify(mockSolrClient);
+ EasyMock.verify(mockSolrClient, configMock, kerbConfigMock);
CollectionAdminRequest.Create createRequest = captureCreateRequest.getValue();
Assert.assertEquals(createRequest.getConfigName(), "test_service_logs_config_name");
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
index ba5b074..22b10c3 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
@@ -24,11 +24,10 @@ import java.util.Arrays;
import javax.ws.rs.WebApplicationException;
-import org.apache.ambari.logsearch.manager.MgrBase.LogType;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
+import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
@@ -38,6 +37,10 @@ import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.NamedList;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -45,14 +48,30 @@ import org.junit.rules.ExpectedException;
import junit.framework.Assert;
public class SolrDaoBaseTest {
+
+ @TestSubject
+ private SolrDaoBase dao = new SolrDaoBase(LogType.SERVICE) {};
+
@Rule
public ExpectedException expectedException = ExpectedException.none();
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
// ----------------------------------------------------------- connectToSolr -----------------------------------------------------------
@Test
public void testConnectToSolrWithConnectString() throws Exception {
- SolrDaoBase dao = new SolrDaoBase(null) {};
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
SolrClient solrClient = dao.connectToSolr(null, "zk_connect_string", "collection");
Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
@@ -60,7 +79,11 @@ public class SolrDaoBaseTest {
@Test
public void testConnectToSolrWithUrl() throws Exception {
- SolrDaoBase dao = new SolrDaoBase(null) {};
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
SolrClient solrClient = dao.connectToSolr("url", null, "collection");
Assert.assertEquals(solrClient.getClass(), HttpSolrClient.class);
@@ -68,7 +91,11 @@ public class SolrDaoBaseTest {
@Test
public void testConnectToSolrWithBoth() throws Exception {
- SolrDaoBase dao = new SolrDaoBase(null) {};
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
SolrClient solrClient = dao.connectToSolr("url", "zk_connect_string", "collection");
Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
@@ -76,10 +103,14 @@ public class SolrDaoBaseTest {
@Test
public void testConnectToSolrWithNeither() throws Exception {
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
expectedException.expect(Exception.class);
expectedException.expectMessage("Both zkConnectString and URL are empty. zkConnectString=null, collection=collection, url=null");
- SolrDaoBase dao = new SolrDaoBase(null) {};
dao.connectToSolr(null, null, "collection");
}
@@ -88,7 +119,6 @@ public class SolrDaoBaseTest {
expectedException.expect(Exception.class);
expectedException.expectMessage("For solr, collection name is mandatory. zkConnectString=zk_connect_string, collection=null, url=url");
- SolrDaoBase dao = new SolrDaoBase(null) {};
dao.connectToSolr("url", "zk_connect_string", null);
}
@@ -106,8 +136,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
boolean status = dao.checkSolrStatus(10000);
@@ -120,8 +149,7 @@ public class SolrDaoBaseTest {
public void testCheckSolrStatusNotSuccessful() throws Exception {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
boolean status = dao.checkSolrStatus(10000);
@@ -148,8 +176,7 @@ public class SolrDaoBaseTest {
mockSolrClouldClient.setDefaultCollection("alias_name"); EasyMock.expectLastCall();
EasyMock.replay(mockSolrClient, mockSolrClouldClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.isZkConnectString = true;
dao.solrClient = mockSolrClient;
dao.solrClouldClient = mockSolrClouldClient;
@@ -177,8 +204,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class), EasyMock.anyString())).andReturn(response);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.isZkConnectString = true;
dao.solrClient = mockSolrClient;
dao.collectionName = "test_collection";
@@ -201,8 +227,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class), EasyMock.anyString())).andReturn(response);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.isZkConnectString = true;
dao.solrClient = mockSolrClient;
@@ -218,8 +243,7 @@ public class SolrDaoBaseTest {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
EasyMock.expect(mockSolrClient.query(EasyMock.anyObject(SolrQuery.class), EasyMock.eq(METHOD.POST))).andReturn(new QueryResponse());
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
dao.process(new SolrQuery());
@@ -230,8 +254,7 @@ public class SolrDaoBaseTest {
@Test
public void testProcessNoConnection() throws Exception {
expectedException.expect(WebApplicationException.class);
-
- SolrDaoBase dao = new SolrDaoBase(LogType.SERVICE) {};
+
dao.process(new SolrQuery());
}
@@ -251,8 +274,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.add(EasyMock.anyObject(SolrInputDocument.class))).andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
dao.addDocs(new SolrInputDocument());
@@ -274,8 +296,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.deleteByQuery(EasyMock.anyString())).andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
dao.removeDoc("query");
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
index dddbf31..3b01a19 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
@@ -20,7 +20,10 @@
package org.apache.ambari.logsearch.dao;
import java.util.ArrayList;
+import java.util.Arrays;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
+import org.apache.ambari.logsearch.conf.SolrUserConfig;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@@ -32,11 +35,29 @@ import org.apache.solr.common.util.NamedList;
import org.easymock.Capture;
import org.easymock.CaptureType;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
public class UserConfigSolrDaoTest {
+
+ @TestSubject
+ private UserConfigSolrDao dao = new UserConfigSolrDao();
+
+ @Mock
+ private SolrUserConfig configMock;
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
@Test
public void testUserConfigDaoPostConstructor() throws Exception {
@@ -56,6 +77,17 @@ public class UserConfigSolrDaoTest {
updateResponseHeader.add("QTime", 1);
updateResponseContent.add("responseHeader", updateResponseHeader);
updateResponse.setResponse(updateResponseContent);
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null).times(2);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181").times(2);
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_history_logs_config_name").times(2);
+ EasyMock.expect(configMock.getCollection()).andReturn("test_history_logs_collection").times(2);
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none").times(2);
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(123).times(2);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(234).times(2);
+ EasyMock.expect(configMock.getLogLevels()).andReturn(Arrays.asList("TRACE")).times(2);
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false).times(2);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file").times(2);
Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
Capture<SolrParams> captureSolrParams = EasyMock.newCapture(CaptureType.LAST);
@@ -67,9 +99,8 @@ public class UserConfigSolrDaoTest {
mockSolrClient.query(EasyMock.capture(captureSolrParams), EasyMock.capture(captureMethod)); EasyMock.expectLastCall().andReturn(queryResponse);
mockSolrClient.add(EasyMock.capture(captureSolrInputDocument)); EasyMock.expectLastCall().andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient);
-
- UserConfigSolrDao dao = new UserConfigSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.postConstructor();
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
@@ -92,7 +123,7 @@ public class UserConfigSolrDaoTest {
SolrInputDocument solrInputDocument = captureSolrInputDocument.getValue();
Assert.assertNotNull(solrInputDocument.getFieldValue("id"));
Assert.assertEquals(solrInputDocument.getFieldValue("rowtype"), "log_feeder_config");
- Assert.assertEquals(solrInputDocument.getFieldValue("jsons"), "{\"filter\":{\"test_component2\":{\"label\":\"test_component2\",\"hosts\":[],\"defaultLevels\":[\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],\"overrideLevels\":[]},\"test_component1\":{\"label\":\"test_component1\",\"hosts\":[],\"defaultLevels\":[\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],\"overrideLevels\":[]}},\"id\":\"" + solrInputDocument.getFieldValue("id") + "\"}");
+ Assert.assertEquals(solrInputDocument.getFieldValue("jsons"), "{\"filter\":{\"test_component2\":{\"label\":\"test_component2\",\"hosts\":[],\"defaultLevels\":[\"TRACE\"],\"overrideLevels\":[]},\"test_component1\":{\"label\":\"test_component1\",\"hosts\":[],\"defaultLevels\":[\"TRACE\"],\"overrideLevels\":[]}},\"id\":\"" + solrInputDocument.getFieldValue("id") + "\"}");
Assert.assertEquals(solrInputDocument.getFieldValue("username"), "log_feeder_config");
Assert.assertEquals(solrInputDocument.getFieldValue("filtername"), "log_feeder_config");
}
@@ -107,18 +138,27 @@ public class UserConfigSolrDaoTest {
header.add("QTime", 1);
response.add("responseHeader", header);
updateResponse.setResponse(response);
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_history_logs_config_name");
+ EasyMock.expect(configMock.getCollection()).andReturn("test_history_logs_collection");
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(123);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(234);
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
EasyMock.expect(mockSolrClient.deleteByQuery("id:test_id")).andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient);
-
- UserConfigSolrDao dao = new UserConfigSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.postConstructor();
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
dao.deleteUserConfig("test_id");
- EasyMock.verify(mockSolrClient);
+ EasyMock.verify(mockSolrClient, configMock, kerbConfigMock);
}
}
[13/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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/1d76f8fe/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()) {
[08/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
new file mode 100644
index 0000000..7430770
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
@@ -0,0 +1,276 @@
+/*
+ * 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.manager;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
+import org.apache.ambari.logsearch.query.QueryGeneration;
+import org.apache.ambari.logsearch.util.JSONUtil;
+import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
+import org.apache.ambari.logsearch.view.VUserConfig;
+import org.apache.ambari.logsearch.view.VUserConfigList;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+
+@Component
+public class UserConfigManager extends JsonManagerBase {
+
+ private static final Logger logger = Logger.getLogger(UserConfigManager.class);
+
+ @Inject
+ private UserConfigSolrDao userConfigSolrDao;
+ @Inject
+ private QueryGeneration queryGenerator;
+
+ public String saveUserConfig(VUserConfig vHistory) {
+
+ SolrInputDocument solrInputDoc = new SolrInputDocument();
+ if (!isValid(vHistory)) {
+ throw RESTErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA);
+ }
+
+ if (isNotUnique(vHistory) && !vHistory.isOverwrite()) {
+ throw RESTErrorUtil.createRESTException( "Name '" + vHistory.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
+ }
+ String loggedInUserName = vHistory.getUserName();
+ String filterName = vHistory.getFiltername();
+
+ solrInputDoc.addField(LogSearchConstants.ID, vHistory.getId());
+ solrInputDoc.addField(LogSearchConstants.USER_NAME, loggedInUserName);
+ solrInputDoc.addField(LogSearchConstants.VALUES, vHistory.getValues());
+ solrInputDoc.addField(LogSearchConstants.FILTER_NAME, filterName);
+ solrInputDoc.addField(LogSearchConstants.ROW_TYPE, vHistory.getRowType());
+ List<String> shareNameList = vHistory.getShareNameList();
+ if (shareNameList != null && !shareNameList.isEmpty()) {
+ solrInputDoc.addField(LogSearchConstants.SHARE_NAME_LIST, shareNameList);
+ }
+ // Check whether the Filter Name exists in solr
+ SolrQuery solrQuery = new SolrQuery();
+ SolrUtil.setMainQuery(solrQuery, null);
+ queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
+ queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.USER_NAME, loggedInUserName);
+ try {
+ QueryResponse queryResponse = userConfigSolrDao.process(solrQuery);
+ if (queryResponse != null) {
+ SolrDocumentList documentList = queryResponse.getResults();
+ if (documentList != null && !documentList.isEmpty() && !vHistory.isOverwrite()) {
+ logger.error("Filtername is already present");
+ throw RESTErrorUtil.createRESTException("Filtername is already present", MessageEnums.INVALID_INPUT_DATA);
+ }
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error in checking same filtername config", e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ try {
+ userConfigSolrDao.addDocs(solrInputDoc);
+ return convertObjToString(solrInputDoc);
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error saving user config. solrDoc=" + solrInputDoc, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ private boolean isNotUnique(VUserConfig vHistory) {
+ String filterName = vHistory.getFiltername();
+ String rowType = vHistory.getRowType();
+
+ if (filterName != null && rowType != null) {
+ SolrQuery solrQuery = new SolrQuery();
+ filterName = SolrUtil.makeSearcableString(filterName);
+ solrQuery.setQuery(LogSearchConstants.COMPOSITE_KEY + ":" + filterName + "-" + rowType);
+ SolrUtil.setRowCount(solrQuery, 0);
+ try {
+ Long numFound = userConfigSolrDao.process(solrQuery).getResults().getNumFound();
+ if (numFound > 0) {
+ return true;
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error while checking if userConfig is unique.", e);
+ }
+ }
+ return false;
+ }
+
+ private boolean isValid(VUserConfig vHistory) {
+ return !StringUtils.isBlank(vHistory.getFiltername())
+ && !StringUtils.isBlank(vHistory.getRowType())
+ && !StringUtils.isBlank(vHistory.getUserName())
+ && !StringUtils.isBlank(vHistory.getValues());
+ }
+
+ public void deleteUserConfig(String id) {
+ try {
+ userConfigSolrDao.deleteUserConfig(id);
+ } catch (SolrException | SolrServerException | IOException e) {
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getUserConfig(SearchCriteria searchCriteria) {
+
+ SolrDocumentList solrList = new SolrDocumentList();
+ VUserConfigList userConfigList = new VUserConfigList();
+
+ String rowType = (String) searchCriteria.getParamValue(LogSearchConstants.ROW_TYPE);
+ if (StringUtils.isBlank(rowType)) {
+ throw RESTErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA);
+ }
+
+ String userName = (String) searchCriteria.getParamValue(LogSearchConstants.USER_NAME);
+ if (StringUtils.isBlank(userName)) {
+ throw RESTErrorUtil.createRESTException("user name was not specified", MessageEnums.INVALID_INPUT_DATA);
+ }
+ String filterName = (String) searchCriteria.getParamValue(LogSearchConstants.FILTER_NAME);
+ filterName = StringUtils.isBlank(filterName) ? "*" : "*" + filterName + "*";
+
+ try {
+
+ SolrQuery userConfigQuery = new SolrQuery();
+ SolrUtil.setMainQuery(userConfigQuery, null);
+ queryGenerator.setPagination(userConfigQuery, searchCriteria);
+ queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.ROW_TYPE, rowType);
+ queryGenerator.setSingleORFilter(userConfigQuery, LogSearchConstants.USER_NAME, userName, LogSearchConstants.SHARE_NAME_LIST, userName);
+ queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
+
+ if (StringUtils.isBlank(searchCriteria.getSortBy())) {
+ searchCriteria.setSortBy(LogSearchConstants.FILTER_NAME);
+ }
+ if (StringUtils.isBlank(searchCriteria.getSortType())) {
+ searchCriteria.setSortType("" + SolrQuery.ORDER.asc);
+ }
+
+ queryGenerator.setSingleSortOrder(userConfigQuery, searchCriteria);
+ solrList = userConfigSolrDao.process(userConfigQuery).getResults();
+
+ Collection<VUserConfig> configList = new ArrayList<VUserConfig>();
+
+ for (SolrDocument solrDoc : solrList) {
+ VUserConfig userConfig = new VUserConfig();
+ userConfig.setFiltername("" + solrDoc.get(LogSearchConstants.FILTER_NAME));
+ userConfig.setId("" + solrDoc.get(LogSearchConstants.ID));
+ userConfig.setValues("" + solrDoc.get(LogSearchConstants.VALUES));
+ userConfig.setRowType("" + solrDoc.get(LogSearchConstants.ROW_TYPE));
+ try {
+ List<String> shareNameList = (List<String>) solrDoc.get(LogSearchConstants.SHARE_NAME_LIST);
+ userConfig.setShareNameList(shareNameList);
+ } catch (Exception e) {
+ // do nothing
+ }
+
+ userConfig.setUserName("" + solrDoc.get(LogSearchConstants.USER_NAME));
+
+ configList.add(userConfig);
+ }
+
+ userConfigList.setName("historyList");
+ userConfigList.setUserConfigList(configList);
+
+ userConfigList.setStartIndex(searchCriteria.getStartIndex());
+ userConfigList.setPageSize((int) searchCriteria.getMaxRows());
+
+ userConfigList.setTotalCount((long) solrList.getNumFound());
+ } catch (SolrException | SolrServerException | IOException e) {
+ // do nothing
+ logger.error(e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+
+ return convertObjToString(userConfigList);
+
+ }
+
+ public String updateUserConfig(VUserConfig vuserConfig) {
+ return saveUserConfig(vuserConfig);
+ }
+
+ // ////////////////////////////LEVEL FILTER/////////////////////////////////////
+
+ public String getUserFilter() {
+ VLogfeederFilterWrapper userFilter;
+ try {
+ userFilter = userConfigSolrDao.getUserFilter();
+ } catch (SolrServerException | IOException e) {
+ logger.error(e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ return convertObjToString(userFilter);
+ }
+
+ public String saveUserFiter(String json) {
+ if (!StringUtils.isBlank(json)) {
+ VLogfeederFilterWrapper logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(json, VLogfeederFilterWrapper.class);
+ try {
+ if (logfeederFilterWrapper == null) {
+ logger.error(json + " is a invalid json");
+ }
+ userConfigSolrDao.saveUserFilter(logfeederFilterWrapper);
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("user config not able to save", e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+ return getUserFilter();
+ }
+
+ public String getAllUserName() {
+ List<String> userList = new ArrayList<String>();
+ try {
+ SolrQuery userListQuery = new SolrQuery();
+ SolrUtil.setMainQuery(userListQuery, null);
+ SolrUtil.setFacetField(userListQuery, LogSearchConstants.USER_NAME);
+ QueryResponse queryResponse = userConfigSolrDao.process(userListQuery);
+ if (queryResponse == null) {
+ return convertObjToString(userList);
+ }
+ List<Count> counList = queryResponse.getFacetField(LogSearchConstants.USER_NAME).getValues();
+ for (Count cnt : counList) {
+ String userName = cnt.getName();
+ userList.add(userName);
+ }
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.warn("Error getting all users.", e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ return convertObjToString(userList);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java
deleted file mode 100644
index 59c1bbd..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/UserConfigMgr.java
+++ /dev/null
@@ -1,276 +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.manager;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
-import org.apache.ambari.logsearch.query.QueryGeneration;
-import org.apache.ambari.logsearch.util.JSONUtil;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
-import org.apache.ambari.logsearch.view.VUserConfig;
-import org.apache.ambari.logsearch.view.VUserConfigList;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrInputDocument;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class UserConfigMgr extends MgrBase {
-
- private static final Logger logger = Logger.getLogger(UserConfigMgr.class);
-
- @Autowired
- private UserConfigSolrDao userConfigSolrDao;
- @Autowired
- private QueryGeneration queryGenerator;
-
- public String saveUserConfig(VUserConfig vHistory) {
-
- SolrInputDocument solrInputDoc = new SolrInputDocument();
- if (!isValid(vHistory)) {
- throw RESTErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA);
- }
-
- if (isNotUnique(vHistory) && !vHistory.isOverwrite()) {
- throw RESTErrorUtil.createRESTException( "Name '" + vHistory.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
- }
- String loggedInUserName = vHistory.getUserName();
- String filterName = vHistory.getFiltername();
-
- solrInputDoc.addField(LogSearchConstants.ID, vHistory.getId());
- solrInputDoc.addField(LogSearchConstants.USER_NAME, loggedInUserName);
- solrInputDoc.addField(LogSearchConstants.VALUES, vHistory.getValues());
- solrInputDoc.addField(LogSearchConstants.FILTER_NAME, filterName);
- solrInputDoc.addField(LogSearchConstants.ROW_TYPE, vHistory.getRowType());
- List<String> shareNameList = vHistory.getShareNameList();
- if (shareNameList != null && !shareNameList.isEmpty()) {
- solrInputDoc.addField(LogSearchConstants.SHARE_NAME_LIST, shareNameList);
- }
- // Check whether the Filter Name exists in solr
- SolrQuery solrQuery = new SolrQuery();
- SolrUtil.setMainQuery(solrQuery, null);
- queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
- queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.USER_NAME, loggedInUserName);
- try {
- QueryResponse queryResponse = userConfigSolrDao.process(solrQuery);
- if (queryResponse != null) {
- SolrDocumentList documentList = queryResponse.getResults();
- if (documentList != null && !documentList.isEmpty() && !vHistory.isOverwrite()) {
- logger.error("Filtername is already present");
- throw RESTErrorUtil.createRESTException("Filtername is already present", MessageEnums.INVALID_INPUT_DATA);
- }
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error in checking same filtername config", e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- try {
- userConfigSolrDao.addDocs(solrInputDoc);
- return convertObjToString(solrInputDoc);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error saving user config. solrDoc=" + solrInputDoc, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- private boolean isNotUnique(VUserConfig vHistory) {
- String filterName = vHistory.getFiltername();
- String rowType = vHistory.getRowType();
-
- if (filterName != null && rowType != null) {
- SolrQuery solrQuery = new SolrQuery();
- filterName = SolrUtil.makeSearcableString(filterName);
- solrQuery.setQuery(LogSearchConstants.COMPOSITE_KEY + ":" + filterName + "-" + rowType);
- SolrUtil.setRowCount(solrQuery, 0);
- try {
- Long numFound = userConfigSolrDao.process(solrQuery).getResults().getNumFound();
- if (numFound > 0) {
- return true;
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error while checking if userConfig is unique.", e);
- }
- }
- return false;
- }
-
- private boolean isValid(VUserConfig vHistory) {
- return !StringUtils.isBlank(vHistory.getFiltername())
- && !StringUtils.isBlank(vHistory.getRowType())
- && !StringUtils.isBlank(vHistory.getUserName())
- && !StringUtils.isBlank(vHistory.getValues());
- }
-
- public void deleteUserConfig(String id) {
- try {
- userConfigSolrDao.deleteUserConfig(id);
- } catch (SolrException | SolrServerException | IOException e) {
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- @SuppressWarnings("unchecked")
- public String getUserConfig(SearchCriteria searchCriteria) {
-
- SolrDocumentList solrList = new SolrDocumentList();
- VUserConfigList userConfigList = new VUserConfigList();
-
- String rowType = (String) searchCriteria.getParamValue(LogSearchConstants.ROW_TYPE);
- if (StringUtils.isBlank(rowType)) {
- throw RESTErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA);
- }
-
- String userName = (String) searchCriteria.getParamValue(LogSearchConstants.USER_NAME);
- if (StringUtils.isBlank(userName)) {
- throw RESTErrorUtil.createRESTException("user name was not specified", MessageEnums.INVALID_INPUT_DATA);
- }
- String filterName = (String) searchCriteria.getParamValue(LogSearchConstants.FILTER_NAME);
- filterName = StringUtils.isBlank(filterName) ? "*" : "*" + filterName + "*";
-
- try {
-
- SolrQuery userConfigQuery = new SolrQuery();
- SolrUtil.setMainQuery(userConfigQuery, null);
- queryGenerator.setPagination(userConfigQuery, searchCriteria);
- queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.ROW_TYPE, rowType);
- queryGenerator.setSingleORFilter(userConfigQuery, LogSearchConstants.USER_NAME, userName, LogSearchConstants.SHARE_NAME_LIST, userName);
- queryGenerator.setSingleIncludeFilter(userConfigQuery, LogSearchConstants.FILTER_NAME, SolrUtil.makeSearcableString(filterName));
-
- if (StringUtils.isBlank(searchCriteria.getSortBy())) {
- searchCriteria.setSortBy(LogSearchConstants.FILTER_NAME);
- }
- if (StringUtils.isBlank(searchCriteria.getSortType())) {
- searchCriteria.setSortType("" + SolrQuery.ORDER.asc);
- }
-
- queryGenerator.setSingleSortOrder(userConfigQuery, searchCriteria);
- solrList = userConfigSolrDao.process(userConfigQuery).getResults();
-
- Collection<VUserConfig> configList = new ArrayList<VUserConfig>();
-
- for (SolrDocument solrDoc : solrList) {
- VUserConfig userConfig = new VUserConfig();
- userConfig.setFiltername("" + solrDoc.get(LogSearchConstants.FILTER_NAME));
- userConfig.setId("" + solrDoc.get(LogSearchConstants.ID));
- userConfig.setValues("" + solrDoc.get(LogSearchConstants.VALUES));
- userConfig.setRowType("" + solrDoc.get(LogSearchConstants.ROW_TYPE));
- try {
- List<String> shareNameList = (List<String>) solrDoc.get(LogSearchConstants.SHARE_NAME_LIST);
- userConfig.setShareNameList(shareNameList);
- } catch (Exception e) {
- // do nothing
- }
-
- userConfig.setUserName("" + solrDoc.get(LogSearchConstants.USER_NAME));
-
- configList.add(userConfig);
- }
-
- userConfigList.setName("historyList");
- userConfigList.setUserConfigList(configList);
-
- userConfigList.setStartIndex(searchCriteria.getStartIndex());
- userConfigList.setPageSize((int) searchCriteria.getMaxRows());
-
- userConfigList.setTotalCount((long) solrList.getNumFound());
- } catch (SolrException | SolrServerException | IOException e) {
- // do nothing
- logger.error(e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- return convertObjToString(userConfigList);
-
- }
-
- public String updateUserConfig(VUserConfig vuserConfig) {
- return saveUserConfig(vuserConfig);
- }
-
- // ////////////////////////////LEVEL FILTER/////////////////////////////////////
-
- public String getUserFilter() {
- VLogfeederFilterWrapper userFilter;
- try {
- userFilter = userConfigSolrDao.getUserFilter();
- } catch (SolrServerException | IOException e) {
- logger.error(e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- return convertObjToString(userFilter);
- }
-
- public String saveUserFiter(String json) {
- if (!StringUtils.isBlank(json)) {
- VLogfeederFilterWrapper logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(json, VLogfeederFilterWrapper.class);
- try {
- if (logfeederFilterWrapper == null) {
- logger.error(json + " is a invalid json");
- }
- userConfigSolrDao.saveUserFilter(logfeederFilterWrapper);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("user config not able to save", e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
- return getUserFilter();
- }
-
- public String getAllUserName() {
- List<String> userList = new ArrayList<String>();
- try {
- SolrQuery userListQuery = new SolrQuery();
- SolrUtil.setMainQuery(userListQuery, null);
- SolrUtil.setFacetField(userListQuery, LogSearchConstants.USER_NAME);
- QueryResponse queryResponse = userConfigSolrDao.process(userListQuery);
- if (queryResponse == null) {
- return convertObjToString(userList);
- }
- List<Count> counList = queryResponse.getFacetField(LogSearchConstants.USER_NAME).getValues();
- for (Count cnt : counList) {
- String userName = cnt.getName();
- userList.add(userName);
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.warn("Error getting all users.", e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- return convertObjToString(userList);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/AnyGraphParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/AnyGraphParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/AnyGraphParamDefinition.java
new file mode 100644
index 0000000..e92d7bf
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/AnyGraphParamDefinition.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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.X_AXIS_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.Y_AXIS_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.STACK_BY_D;
+
+public interface AnyGraphParamDefinition {
+
+ String getxAxis();
+
+ @ApiParam(value = X_AXIS_D, name = LogSearchConstants.REQUEST_PARAM_XAXIS)
+ void setxAxis(String xAxis);
+
+ String getyAxis();
+
+ @ApiParam(value = Y_AXIS_D, name = LogSearchConstants.REQUEST_PARAM_YAXIS)
+ void setyAxis(String yAxis);
+
+ String getStackBy();
+
+ @ApiParam(value = STACK_BY_D, name = LogSearchConstants.REQUEST_PARAM_STACK_BY)
+ void setStackBy(String stackBy);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/BundleIdParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/BundleIdParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/BundleIdParamDefinition.java
new file mode 100644
index 0000000..aa1a393
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/BundleIdParamDefinition.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.BUNDLE_ID;
+
+public interface BundleIdParamDefinition {
+
+ String getBundleId();
+
+ @ApiParam(value = BUNDLE_ID, name = LogSearchConstants.REQUEST_PARAM_BUNDLE_ID)
+ void setBundleId(String bundleId);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/CommonSearchParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/CommonSearchParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/CommonSearchParamDefinition.java
new file mode 100644
index 0000000..ef334d1
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/CommonSearchParamDefinition.java
@@ -0,0 +1,69 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.START_TIME_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.END_TIME_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.START_INDEX_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.PAGE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.PAGE_SIZE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.SORT_BY_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.SORT_TYPE_D;
+
+
+public interface CommonSearchParamDefinition {
+
+ String getStartIndex();
+
+ @ApiParam(value = START_INDEX_D, name = LogSearchConstants.REQUEST_PARAM_START_INDEX)
+ void setStartIndex(String startIndex);
+
+ String getPage();
+
+ @ApiParam(value = PAGE_D, name = LogSearchConstants.REQUEST_PARAM_PAGE)
+ void setPage(String page);
+
+ String getPageSize();
+
+ @ApiParam(value = PAGE_SIZE_D, name = LogSearchConstants.REQUEST_PARAM_PAGE_SIZE)
+ void setPageSize(String pageSize);
+
+ String getSortBy();
+
+ @ApiParam(value = SORT_BY_D, name = LogSearchConstants.REQUEST_PARAM_SORT_BY)
+ void setSortBy(String sortBy);
+
+ String getSortType();
+
+ @ApiParam(value = SORT_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_SORT_TYPE)
+ void setSortType(String sortType);
+
+ String getStartTime();
+
+ @ApiParam(value = START_TIME_D, name = LogSearchConstants.REQUEST_PARAM_START_TIME)
+ void setStartTime(String startTime);
+
+ String getEndTime();
+
+ @ApiParam(value = END_TIME_D, name = LogSearchConstants.REQUEST_PARAM_END_TIME)
+ void setEndTime(String endTime);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/DateRangeParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/DateRangeParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/DateRangeParamDefinition.java
new file mode 100644
index 0000000..e6edf7c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/DateRangeParamDefinition.java
@@ -0,0 +1,38 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.FROM_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.TO_D;
+
+public interface DateRangeParamDefinition {
+
+ String getFrom();
+
+ @ApiParam(value = FROM_D, name = LogSearchConstants.REQUEST_PARAM_FROM)
+ void setFrom(String from);
+
+ String getTo();
+
+ @ApiParam(value = TO_D, name = LogSearchConstants.REQUEST_PARAM_TO)
+ void setTo(String to);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java
new file mode 100644
index 0000000..396fa93
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.FIELD_D;
+
+public interface FieldParamDefinition {
+
+ String getField();
+
+ @ApiParam(value = FIELD_D, name = LogSearchConstants.REQUEST_PARAM_FIELD)
+ void setField(String field);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FormatParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FormatParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FormatParamDefinition.java
new file mode 100644
index 0000000..47f0620
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/FormatParamDefinition.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.FORMAT_D;
+
+public interface FormatParamDefinition {
+
+ String getFormat();
+
+ @ApiParam(value = FORMAT_D, name = LogSearchConstants.REQUEST_PARAM_FORMAT)
+ void setFormat(String format);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LastPageParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LastPageParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LastPageParamDefinition.java
new file mode 100644
index 0000000..c8531db
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LastPageParamDefinition.java
@@ -0,0 +1,31 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.IS_LAST_PAGE_D;
+
+public interface LastPageParamDefinition {
+ boolean isLastPage();
+
+ @ApiParam(value = IS_LAST_PAGE_D, name = LogSearchConstants.REQUEST_PARAM_LAST_PAGE)
+ void setLastPage(boolean lastPage);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java
new file mode 100644
index 0000000..c355989
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileParamDefinition.java
@@ -0,0 +1,45 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.COMPONENT_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.HOST_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.LOG_TYPE_D;
+
+
+public interface LogFileParamDefinition {
+
+ String getComponent();
+
+ @ApiParam(value = COMPONENT_D, name = LogSearchConstants.REQUEST_PARAM_COMPONENT)
+ void setComponent(String component);
+
+ String getHost();
+
+ @ApiParam(value = HOST_D, name = LogSearchConstants.REQUEST_PARAM_HOST)
+ void setHost(String host);
+
+ String getLogType();
+
+ @ApiParam(value = LOG_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_LOG_TYPE)
+ void setLogType(String logType);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java
new file mode 100644
index 0000000..a527c48
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogFileTailParamDefinition.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.TAIL_SIZE_D;
+
+public interface LogFileTailParamDefinition {
+
+ String getTailSize();
+
+ @ApiParam(value = TAIL_SIZE_D, name = LogSearchConstants.REQUEST_PARAM_TAIL_SIZE)
+ void setTailSize(String tailSize);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
new file mode 100644
index 0000000..e503ff5
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java
@@ -0,0 +1,68 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.COLUMN_QUERY_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.I_MESSAGE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.G_E_MESSAGE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_BE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.MUST_NOT_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.INCLUDE_QUERY_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.EXCLUDE_QUERY_D;
+
+public interface LogParamDefinition {
+
+ String getColumnQuery();
+
+ @ApiParam(value = COLUMN_QUERY_D, name = LogSearchConstants.REQUEST_PARAM_COLUMN_QUERY)
+ void setColumnQuery(String columnQuery);
+
+ String getiMessage();
+
+ @ApiParam(value = I_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
+ void setiMessage(String iMessage);
+
+ String getgEMessage();
+
+ @ApiParam(value = G_E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_G_E_MESSAGE)
+ void setgEMessage(String gEMessage);
+
+ String getMustBe();
+
+ @ApiParam(value = MUST_BE_D, name = LogSearchConstants.REQUEST_PARAM_MUST_BE)
+ void setMustBe(String mustBe);
+
+ String getMustNot();
+
+ @ApiParam(value = MUST_NOT_D, name = LogSearchConstants.REQUEST_PARAM_MUST_NOT)
+ void setMustNot(String mustNot);
+
+ String getIncludeQuery();
+
+ @ApiParam(value = INCLUDE_QUERY_D, name = LogSearchConstants.REQUEST_PARAM_INCLUDE_QUERY)
+ void setIncludeQuery(String includeQuery);
+
+ String getExcludeQuery();
+
+ @ApiParam(value = EXCLUDE_QUERY_D, name = LogSearchConstants.REQUEST_PARAM_EXCLUDE_QUERY)
+ void setExcludeQuery(String excludeQuery);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java
new file mode 100644
index 0000000..c3e2998
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.ID_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.SCROLL_TYPE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.NUMBER_ROWS_D;
+
+public interface LogTruncatedParamDefinition {
+
+ String getId();
+
+ @ApiParam(value = ID_D, name = LogSearchConstants.REQUEST_PARAM_ID)
+ void setId(String id);
+
+ String getScrollType();
+
+ @ApiParam(value = SCROLL_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_SCROLL_TYPE)
+ void setScrollType(String scrollType);
+
+ String getNumberRows();
+
+ @ApiParam(value = NUMBER_ROWS_D, name = LogSearchConstants.REQUEST_PARAM_NUMBER_ROWS)
+ void setNumberRows(String numberRows);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java
new file mode 100644
index 0000000..3fcdbc0
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/QueryParamDefinition.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.QUERY_D;
+
+public interface QueryParamDefinition {
+
+ String getQuery();
+
+ @ApiParam(value = QUERY_D, name = LogSearchConstants.REQUEST_PARAM_QUERY)
+ void setQuery(String query);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.java
new file mode 100644
index 0000000..0015c09
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.java
@@ -0,0 +1,25 @@
+/*
+ * 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.model.request;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public interface SearchRequest {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java
new file mode 100644
index 0000000..a266b3e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogFileParamDefinition.java
@@ -0,0 +1,38 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.HOST_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.COMPONENT_D;
+
+public interface ServiceLogFileParamDefinition {
+
+ String getHostLogFile();
+
+ @ApiParam(value = HOST_D, name = LogSearchConstants.REQUEST_PARAM_HOST_LOG_FILE)
+ void setHostLogFile(String hostLogFile);
+
+ String getComponentLogFile();
+
+ @ApiParam(value = COMPONENT_D, name = LogSearchConstants.REQUEST_PARAM_COMPONENT_LOG_FILE)
+ void setComponentLogFile(String componentLogFile);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
new file mode 100644
index 0000000..f280ac2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java
@@ -0,0 +1,80 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.LEVEL_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.ADVANCED_SEARCH_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.TREE_PARAMS_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.E_MESSAGE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.G_MUST_NOT_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.HOST_NAME_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.COMPONENT_NAME_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.FILE_NAME_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.DATE_RANGE_LABEL_D;
+
+public interface ServiceLogParamDefinition {
+
+ String getLevel();
+
+ @ApiParam(value = LEVEL_D, name = LogSearchConstants.REQUEST_PARAM_LEVEL)
+ void setLevel(String level);
+
+ String getAdvancedSearch();
+
+ @ApiParam(value = ADVANCED_SEARCH_D, name = LogSearchConstants.REQUEST_PARAM_ADVANCED_SEARCH)
+ void setAdvancedSearch(String advancedSearch);
+
+ String getTreeParams();
+
+ @ApiParam(value = TREE_PARAMS_D, name = LogSearchConstants.REQUEST_PARAM_TREE_PARAMS)
+ void setTreeParams(String treeParams);
+
+ String geteMessage();
+
+ @ApiParam(value = E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
+ void seteMessage(String eMessage);
+
+ String getgMustNot();
+
+ @ApiParam(value = G_MUST_NOT_D, name = LogSearchConstants.REQUEST_PARAM_G_MUST_NOT)
+ void setgMustNot(String gMustNot);
+
+ String getHostName();
+
+ @ApiParam(value = HOST_NAME_D, name = LogSearchConstants.REQUEST_PARAM_HOST_NAME)
+ void setHostName(String hostName);
+
+ String getComponentName();
+
+ @ApiParam(value = COMPONENT_NAME_D, name = LogSearchConstants.REQUEST_PARAM_COMPONENT_NAME)
+ void setComponentName(String componentName);
+
+ String getFileName();
+
+ @ApiParam(value = FILE_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILE_NAME)
+ void setFileName(String fileName);
+
+ String getDateRangeLabel();
+
+ @ApiParam(value = DATE_RANGE_LABEL_D, name = LogSearchConstants.REQUEST_PARAM_DATE_RANGE_LABEL)
+ void setDateRangeLabel(String dateRangeLabel);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogSearchParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogSearchParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogSearchParamDefinition.java
new file mode 100644
index 0000000..9d8f1a6
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogSearchParamDefinition.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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.FIND_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.KEYWORD_TYPE_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.SOURCE_LOG_ID_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.TOKEN_D;
+
+public interface ServiceLogSearchParamDefinition {
+
+ String getKeyWord();
+
+ @ApiParam(value = FIND_D, name = LogSearchConstants.REQUEST_PARAM_KEYWORD)
+ void setKeyWord(String keyWord);
+
+ String getSourceLogId();
+
+ @ApiParam(value = SOURCE_LOG_ID_D, name = LogSearchConstants.REQUEST_PARAM_SOURCE_LOG_ID)
+ void setSourceLogId(String sourceLogId);
+
+ String getKeywordType();
+
+ @ApiParam(value = KEYWORD_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_KEYWORD_TYPE)
+ void setKeywordType(String keywordType);
+
+ String getToken();
+
+ @ApiParam(value = TOKEN_D, name = LogSearchConstants.REQUEST_PARAM_TOKEN)
+ void setToken(String token);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UnitParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UnitParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UnitParamDefinition.java
new file mode 100644
index 0000000..3f493da
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UnitParamDefinition.java
@@ -0,0 +1,33 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.UNIT_D;
+
+public interface UnitParamDefinition {
+
+ String getUnit();
+
+ @ApiParam(value = UNIT_D, name = LogSearchConstants.REQUEST_PARAM_UNIT)
+ void setUnit(String unit);
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
new file mode 100644
index 0000000..23b350a
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.USER_ID_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.FILTER_NAME_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.ROW_TYPE_D;
+
+public interface UserConfigParamDefinition {
+
+ String getUserId();
+
+ @ApiParam(value = USER_ID_D, name = LogSearchConstants.REQUEST_PARAM_USER_ID)
+ void setUserId(String userId);
+
+ String getFilterName();
+
+ @ApiParam(value = FILTER_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
+ void setFilterName(String filterName);
+
+ String getRowType();
+
+ @ApiParam(value = ROW_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_ROW_TYPE)
+ void setRowType(String rowType);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UtcOffsetParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UtcOffsetParamDefinition.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UtcOffsetParamDefinition.java
new file mode 100644
index 0000000..aa2be71
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/UtcOffsetParamDefinition.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.UTC_OFFSET_D;
+
+public interface UtcOffsetParamDefinition {
+
+ String getUtcOffset();
+
+ @ApiParam(value = UTC_OFFSET_D, name = LogSearchConstants.REQUEST_PARAM_UTC_OFFSET)
+ void setUtcOffset(String utcOffset);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java
new file mode 100644
index 0000000..41da712
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AnyGraphRequest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.AnyGraphParamDefinition;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class AnyGraphRequest extends CommonSearchRequest
+ implements AnyGraphParamDefinition, DateRangeParamDefinition, UnitParamDefinition{
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_XAXIS)
+ private String xAxis;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_YAXIS)
+ private String yAxis;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_STACK_BY)
+ private String stackBy;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
+ private String from;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
+ private String to;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
+ private String unit;
+
+ @Override
+ public String getxAxis() {
+ return xAxis;
+ }
+
+ @Override
+ public void setxAxis(String xAxis) {
+ this.xAxis = xAxis;
+ }
+
+ @Override
+ public String getyAxis() {
+ return yAxis;
+ }
+
+ @Override
+ public void setyAxis(String yAxis) {
+ this.yAxis = yAxis;
+ }
+
+ @Override
+ public String getStackBy() {
+ return stackBy;
+ }
+
+ @Override
+ public void setStackBy(String stackBy) {
+ this.stackBy = stackBy;
+ }
+
+ @Override
+ public String getFrom() {
+ return from;
+ }
+
+ @Override
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ @Override
+ public String getTo() {
+ return to;
+ }
+
+ @Override
+ public void setTo(String to) {
+ this.to = to;
+ }
+
+ @Override
+ public String getUnit() {
+ return unit;
+ }
+
+ @Override
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
new file mode 100644
index 0000000..91e7d1e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditBarGraphRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class AuditBarGraphRequest extends BaseAuditLogRequest implements UnitParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
+ private String unit;
+
+ @Override
+ public String getUnit() {
+ return unit;
+ }
+
+ @Override
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
new file mode 100644
index 0000000..8dd13dc
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/AuditLogRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.LastPageParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class AuditLogRequest extends BaseAuditLogRequest implements LastPageParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_LAST_PAGE)
+ private boolean isLastPage;
+
+ @Override
+ public boolean isLastPage() {
+ return isLastPage;
+ }
+
+ @Override
+ public void setLastPage(boolean lastPage) {
+ isLastPage = lastPage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.java
new file mode 100644
index 0000000..74b4ab7
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseAuditLogRequest.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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class BaseAuditLogRequest extends BaseLogRequest implements DateRangeParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
+ private String from;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
+ private String to;
+
+ @Override
+ public String getFrom() {
+ return from;
+ }
+
+ @Override
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ @Override
+ public String getTo() {
+ return to;
+ }
+
+ @Override
+ public void setTo(String to) {
+ this.to = to;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
new file mode 100644
index 0000000..5a96991
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseLogRequest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.LogParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class BaseLogRequest extends QueryRequest implements LogParamDefinition {
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_COLUMN_QUERY)
+ private String columnQuery;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_I_MESSAGE)
+ private String iMessage;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_G_E_MESSAGE)
+ private String gEMessage;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_MUST_BE)
+ private String mustBe;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_MUST_NOT)
+ private String mustNot;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_EXCLUDE_QUERY)
+ private String excludeQuery;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_INCLUDE_QUERY)
+ private String includeQuery;
+
+ @Override
+ public String getColumnQuery() {
+ return columnQuery;
+ }
+
+ @Override
+ public void setColumnQuery(String columnQuery) {
+ this.columnQuery = columnQuery;
+ }
+
+ @Override
+ public String getiMessage() {
+ return iMessage;
+ }
+
+ @Override
+ public void setiMessage(String iMessage) {
+ this.iMessage = iMessage;
+ }
+
+ @Override
+ public String getgEMessage() {
+ return gEMessage;
+ }
+
+ @Override
+ public void setgEMessage(String gEMessage) {
+ this.gEMessage = gEMessage;
+ }
+
+ @Override
+ public String getMustBe() {
+ return mustBe;
+ }
+
+ @Override
+ public void setMustBe(String mustBe) {
+ this.mustBe = mustBe;
+ }
+
+ @Override
+ public String getMustNot() {
+ return mustNot;
+ }
+
+ @Override
+ public void setMustNot(String mustNot) {
+ this.mustNot = mustNot;
+ }
+
+ @Override
+ public String getIncludeQuery() {
+ return includeQuery;
+ }
+
+ @Override
+ public void setIncludeQuery(String includeQuery) {
+ this.includeQuery = includeQuery;
+ }
+
+ @Override
+ public String getExcludeQuery() {
+ return excludeQuery;
+ }
+
+ @Override
+ public void setExcludeQuery(String excludeQuery) {
+ this.excludeQuery = excludeQuery;
+ }
+}
[04/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java
deleted file mode 100644
index 7a27e1c..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsREST.java
+++ /dev/null
@@ -1,574 +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.rest;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.manager.LogsMgr;
-import org.apache.ambari.logsearch.view.VCountList;
-import org.apache.ambari.logsearch.view.VNameValueList;
-import org.apache.ambari.logsearch.view.VNodeList;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.*;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.*;
-import static org.apache.ambari.logsearch.doc.DocConstants.ServiceOperationDescriptions.*;
-
-@Api(value = "service/logs", description = "Service log operations")
-@Path("service/logs")
-@Component
-@Scope("request")
-public class ServiceLogsREST {
-
- @Autowired
- LogsMgr logMgr;
-
- @GET
- @Produces({"application/json"})
- @ApiOperation(SEARCH_LOGS_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FIND_D, name = "find", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = SOURCE_LOG_ID_D, name = "sourceLogId", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = KEYWORD_TYPE_D, name = "keywordType", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TOKEN_D, name = "token", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = IS_LAST_PAGE_D, name = "isLastPage", dataType = "boolean", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public String searchSolrData(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- searchCriteria.addParam("keyword", StringEscapeUtils.unescapeXml(request.getParameter("find")));
- searchCriteria.addParam("sourceLogId", request.getParameter("sourceLogId"));
- searchCriteria.addParam("keywordType",
- request.getParameter("keywordType"));
- searchCriteria.addParam("token",
- request.getParameter("token"));
- searchCriteria.addParam("isLastPage",request.getParameter("isLastPage"));
- return logMgr.searchLogs(searchCriteria);
- }
-
- @GET
- @Path("/hosts")
- @Produces({"application/json"})
- @ApiOperation(GET_HOSTS_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query")
- })
- public String getHosts(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addParam("q", request.getParameter("q"));
- return logMgr.getHosts();
- }
-
- @GET
- @Path("/components")
- @Produces({"application/json"})
- @ApiOperation(GET_COMPONENTS_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query")
- })
- public String getComponents(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addParam("q", request.getParameter("q"));
- return logMgr.getComponents();
- }
-
- @GET
- @Path("/aggregated")
- @Produces({"application/json"})
- @ApiOperation(GET_AGGREGATED_INFO_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public String getAggregatedInfo(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria();
- searchCriteria.addRequiredServiceLogsParams(request);
- return logMgr.getAggregatedInfo(searchCriteria);
- }
-
- @GET
- @Path("/levels/count")
- @Produces({"application/json"})
- @ApiOperation(GET_LOG_LEVELS_COUNT_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public VCountList getLogLevelsCount(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria();
- searchCriteria.addParam("q", request.getParameter("q"));
- searchCriteria
- .addParam("startDate", request.getParameter("start_time"));
- searchCriteria.addParam("endDate", request.getParameter("end_time"));
- return logMgr.getLogLevelCount();
- }
-
- @GET
- @Path("/components/count")
- @Produces({"application/json"})
- @ApiOperation(GET_COMPONENTS_COUNT_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public VCountList getComponentsCount(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria();
- searchCriteria.addParam("q", request.getParameter("q"));
- searchCriteria
- .addParam("startDate", request.getParameter("start_time"));
- searchCriteria.addParam("endDate", request.getParameter("end_time"));
- return logMgr.getComponentsCount();
- }
-
- @GET
- @Path("/hosts/count")
- @Produces({"application/json"})
- @ApiOperation(GET_HOSTS_COUNT_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query")
- })
- public VCountList getHostsCount(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria();
- searchCriteria.addParam("q", request.getParameter("q"));
- searchCriteria
- .addParam("startDate", request.getParameter("start_time"));
- searchCriteria.addParam("endDate", request.getParameter("end_time"));
- searchCriteria.addParam("excludeQuery", StringEscapeUtils
- .unescapeXml(request.getParameter("excludeQuery")));
- searchCriteria.addParam("includeQuery", StringEscapeUtils
- .unescapeXml(request.getParameter("includeQuery")));
- return logMgr.getHostsCount();
- }
-
- @GET
- @Path("/tree")
- @Produces({"application/json"})
- @ApiOperation(GET_TREE_EXTENSION_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public VNodeList getTreeExtension(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- searchCriteria.addParam("hostName", request.getParameter("hostName"));
- return logMgr.getTreeExtension(searchCriteria);
- }
-
- @GET
- @Path("/levels/counts/namevalues")
- @Produces({"application/json"})
- @ApiOperation(GET_LOG_LEVELS_COUNT_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public VNameValueList getLogsLevelCount(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- return logMgr.getLogsLevelCount(searchCriteria);
- }
-
- @GET
- @Path("/histogram")
- @Produces({"application/json"})
- @ApiOperation(GET_HISTOGRAM_DATA_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public String getHistogramData(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- searchCriteria.addParam("unit", request.getParameter("unit"));
- return logMgr.getHistogramData(searchCriteria);
- }
-
- @GET
- @Path("/request/cancel")
- @Produces({"application/json"})
- @ApiOperation(CANCEL_FIND_REQUEST_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = TOKEN_D, name = "token", dataType = "string", paramType = "query"),
- })
- public String cancelFindRequest(@Context HttpServletRequest request) {
- String uniqueId = request.getParameter("token");
- return logMgr.cancelFindRequestByDate(uniqueId);
- }
-
- @GET
- @Path("/export")
- @Produces({"application/json"})
- @ApiOperation(EXPORT_TO_TEXT_FILE_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FORMAT_D, name = "format", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = UTC_OFFSET_D, name = "utcOffset", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public Response exportToTextFile(@Context HttpServletRequest request) {
-
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- searchCriteria.addParam("format", request.getParameter("format"));
- searchCriteria.addParam("utcOffset", request.getParameter("utcOffset"));
- return logMgr.exportToTextFile(searchCriteria);
-
- }
-
- @GET
- @Path("/hosts/components")
- @Produces({"application/json"})
- @ApiOperation(GET_HOST_LIST_BY_COMPONENT_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public String getHostListByComponent(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- searchCriteria.addParam("componentName",
- request.getParameter("componentName"));
- return logMgr.getHostListByComponent(searchCriteria);
- }
-
- @GET
- @Path("/components/level/counts")
- @Produces({"application/json"})
- @ApiOperation(GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public String getComponentListWithLevelCounts(
- @Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- return logMgr.getComponentListWithLevelCounts(searchCriteria);
- }
-
- @GET
- @Path("/solr/boundarydates")
- @Produces({"application/json"})
- @ApiOperation(GET_EXTREME_DATES_FOR_BUNDLE_ID_OD)
- public String getExtremeDatesForBundelId(@Context HttpServletRequest request) {
-
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addParam(LogSearchConstants.BUNDLE_ID,
- request.getParameter("bundle_id"));
-
- return logMgr.getExtremeDatesForBundelId(searchCriteria);
-
- }
-
- @GET
- @Path("/fields")
- @Produces({"application/json"})
- @ApiOperation(GET_SERVICE_LOGS_FIELD_NAME_OD)
- public String getServiceLogsFieldsName() {
- return logMgr.getServiceLogsFieldsName();
- }
-
- @GET
- @Path("/schema/fields")
- @Produces({"application/json"})
- @ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD)
- public String getServiceLogsSchemaFieldsName() {
- return logMgr.getServiceLogsSchemaFieldsName();
- }
-
- @GET
- @Path("/anygraph")
- @Produces({"application/json"})
- @ApiOperation(GET_ANY_GRAPH_DATA_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = X_AXIS_D, name = "xAxis", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = Y_AXIS_D, name = "yAxis", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = STACK_BY_D, name = "stackBy", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public String getAnyGraphData(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("xAxis", request.getParameter("xAxis"));
- searchCriteria.addParam("yAxis", request.getParameter("yAxis"));
- searchCriteria.addParam("stackBy", request.getParameter("stackBy"));
- searchCriteria.addParam("from", request.getParameter("from"));
- searchCriteria.addParam("to", request.getParameter("to"));
- searchCriteria.addParam("unit", request.getParameter("unit"));
- return logMgr.getAnyGraphData(searchCriteria);
- }
-
- @GET
- @Path("/truncated")
- @Produces({"application/json"})
- @ApiOperation(GET_AFTER_BEFORE_LOGS_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_D,name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ID_D, name = "id", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = SCROLL_TYPE_D, name = "scrollType", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = NUMBER_ROWS_D, name = "numberRows", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query")
- })
- public String getAfterBeforeLogs(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredServiceLogsParams(request);
- searchCriteria.addParam("hostLogFile", request.getParameter("host"));
- searchCriteria.addParam("compLogFile",
- request.getParameter("component"));
- searchCriteria.addParam("id", request.getParameter("id"));
- searchCriteria.addParam("scrollType",
- request.getParameter("scrollType"));
- searchCriteria.addParam("numberRows",
- request.getParameter("numberRows"));
- return logMgr.getAfterBeforeLogs(searchCriteria);
- }
-
- @GET
- @Path("/serviceconfig")
- @Produces({"application/json"})
- @ApiOperation(GET_HADOOP_SERVICE_CONFIG_JSON_OD)
- public String getHadoopServiceConfigJSON() {
- return logMgr.getHadoopServiceConfigJSON();
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
new file mode 100644
index 0000000..5400825
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
@@ -0,0 +1,238 @@
+/*
+ * 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.rest;
+
+import javax.inject.Inject;
+import javax.ws.rs.BeanParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceExtremeDatesRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogFileRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
+import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.CountDataListResponse;
+import org.apache.ambari.logsearch.model.response.GraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.GroupListResponse;
+import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
+import org.apache.ambari.logsearch.model.response.NodeListResponse;
+import org.apache.ambari.logsearch.model.response.ServiceLogResponse;
+import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.ambari.logsearch.manager.ServiceLogsManager;
+import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
+import org.apache.ambari.logsearch.query.model.ServiceExtremeDatesCriteria;
+import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
+import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
+import org.apache.ambari.logsearch.query.model.ServiceLogFileSearchCriteria;
+import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
+import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
+import org.springframework.context.annotation.Scope;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.stereotype.Component;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.ServiceOperationDescriptions.*;
+
+@Api(value = "service/logs", description = "Service log operations")
+@Path("service/logs")
+@Component
+@Scope("request")
+public class ServiceLogsResource {
+
+ @Inject
+ private ServiceLogsManager serviceLogsManager;
+
+ @Inject
+ private ConversionService conversionService;
+
+ @GET
+ @Produces({"application/json"})
+ @ApiOperation(SEARCH_LOGS_OD)
+ public ServiceLogResponse searchSolrData(@BeanParam ServiceLogRequest request) {
+ return serviceLogsManager.searchLogs(conversionService.convert(request, ServiceLogSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/hosts")
+ @Produces({"application/json"})
+ @ApiOperation(GET_HOSTS_OD)
+ public GroupListResponse getHosts() {
+ return serviceLogsManager.getHosts();
+ }
+
+ @GET
+ @Path("/components")
+ @Produces({"application/json"})
+ @ApiOperation(GET_COMPONENTS_OD)
+ public GroupListResponse getComponents() {
+ return serviceLogsManager.getComponents();
+ }
+
+ @GET
+ @Path("/aggregated")
+ @Produces({"application/json"})
+ @ApiOperation(GET_AGGREGATED_INFO_OD)
+ public GraphDataListResponse getAggregatedInfo(@BeanParam BaseServiceLogRequest request) {
+ return serviceLogsManager.getAggregatedInfo(conversionService.convert(request, CommonSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/levels/count")
+ @Produces({"application/json"})
+ @ApiOperation(GET_LOG_LEVELS_COUNT_OD)
+ public CountDataListResponse getLogLevelsCount() {
+ return serviceLogsManager.getLogLevelCount();
+ }
+
+ @GET
+ @Path("/components/count")
+ @Produces({"application/json"})
+ @ApiOperation(GET_COMPONENTS_COUNT_OD)
+ public CountDataListResponse getComponentsCount() {
+ return serviceLogsManager.getComponentsCount();
+ }
+
+ @GET
+ @Path("/hosts/count")
+ @Produces({"application/json"})
+ @ApiOperation(GET_HOSTS_COUNT_OD)
+ public CountDataListResponse getHostsCount() {
+ return serviceLogsManager.getHostsCount();
+ }
+
+ @GET
+ @Path("/tree")
+ @Produces({"application/json"})
+ @ApiOperation(GET_TREE_EXTENSION_OD)
+ public NodeListResponse getTreeExtension(@QueryParam("hostName") @ApiParam String hostName, @BeanParam ServiceLogFileRequest request) {
+ SearchCriteria searchCriteria = conversionService.convert(request, ServiceLogFileSearchCriteria.class);
+ searchCriteria.addParam("hostName", hostName); // TODO: use host_name instead - needs UI change
+ return serviceLogsManager.getTreeExtension(searchCriteria);
+ }
+
+ @GET
+ @Path("/levels/counts/namevalues")
+ @Produces({"application/json"})
+ @ApiOperation(GET_LOG_LEVELS_COUNT_OD)
+ public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogFileRequest request) {
+ return serviceLogsManager.getLogsLevelCount(conversionService.convert(request, ServiceLogFileSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/histogram")
+ @Produces({"application/json"})
+ @ApiOperation(GET_HISTOGRAM_DATA_OD)
+ public BarGraphDataListResponse getHistogramData(@BeanParam ServiceGraphRequest request) {
+ return serviceLogsManager.getHistogramData(conversionService.convert(request, ServiceGraphSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/request/cancel")
+ @Produces({"application/json"})
+ @ApiOperation(CANCEL_FIND_REQUEST_OD)
+ public String cancelFindRequest(@QueryParam("token") @ApiParam String token) {
+ return serviceLogsManager.cancelFindRequestByDate(token);
+ }
+
+ @GET
+ @Path("/export")
+ @Produces({"application/json"})
+ @ApiOperation(EXPORT_TO_TEXT_FILE_OD)
+ public Response exportToTextFile(@BeanParam ServiceLogExportRequest request) {
+ return serviceLogsManager.exportToTextFile(conversionService.convert(request, ServiceLogExportSearchCriteria.class));
+
+ }
+
+ @GET
+ @Path("/hosts/components")
+ @Produces({"application/json"})
+ @ApiOperation(GET_HOST_LIST_BY_COMPONENT_OD)
+ public NodeListResponse getHostListByComponent(@BeanParam ServiceLogFileRequest request, @QueryParam("componentName") @ApiParam String componentName) {
+ SearchCriteria searchCriteria = conversionService.convert(request, ServiceLogFileSearchCriteria.class);
+ searchCriteria.addParam("componentName", componentName); // TODO: use component_name instead - needs UI change
+ return serviceLogsManager.getHostListByComponent(searchCriteria);
+ }
+
+ @GET
+ @Path("/components/levels/counts")
+ @Produces({"application/json"})
+ @ApiOperation(GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD)
+ public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogFileRequest request) {
+ return serviceLogsManager.getComponentListWithLevelCounts(conversionService.convert(request, ServiceLogFileSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/solr/boundarydates")
+ @Produces({"application/json"})
+ @ApiOperation(GET_EXTREME_DATES_FOR_BUNDLE_ID_OD)
+ public NameValueDataListResponse getExtremeDatesForBundelId(@BeanParam ServiceExtremeDatesRequest request) {
+ return serviceLogsManager.getExtremeDatesForBundelId(conversionService.convert(request, ServiceExtremeDatesCriteria.class));
+ }
+
+ @GET
+ @Path("/fields")
+ @Produces({"application/json"})
+ @ApiOperation(GET_SERVICE_LOGS_FIELD_NAME_OD)
+ public String getServiceLogsFieldsName() {
+ return serviceLogsManager.getServiceLogsFieldsName();
+ }
+
+ @GET
+ @Path("/schema/fields")
+ @Produces({"application/json"})
+ @ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD)
+ public String getServiceLogsSchemaFieldsName() {
+ return serviceLogsManager.getServiceLogsSchemaFieldsName();
+ }
+
+ @GET
+ @Path("/anygraph")
+ @Produces({"application/json"})
+ @ApiOperation(GET_ANY_GRAPH_DATA_OD)
+ public BarGraphDataListResponse getAnyGraphData(@BeanParam ServiceAnyGraphRequest request) {
+ return serviceLogsManager.getAnyGraphData(conversionService.convert(request, ServiceAnyGraphSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/truncated")
+ @Produces({"application/json"})
+ @ApiOperation(GET_AFTER_BEFORE_LOGS_OD)
+ public ServiceLogResponse getAfterBeforeLogs(@BeanParam ServiceLogTruncatedRequest request) {
+ return serviceLogsManager.getAfterBeforeLogs(conversionService.convert(request, ServiceLogTruncatedSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/serviceconfig")
+ @Produces({"application/json"})
+ @ApiOperation(GET_HADOOP_SERVICE_CONFIG_JSON_OD)
+ public String getHadoopServiceConfigJSON() {
+ return serviceLogsManager.getHadoopServiceConfigJSON();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java
deleted file mode 100644
index 699dc17..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java
+++ /dev/null
@@ -1,128 +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.rest;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.manager.UserConfigMgr;
-import org.apache.ambari.logsearch.view.VUserConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.*;
-import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigOperationDescriptions.*;
-
-@Api(value = "userconfig", description = "User config operations")
-@Path("userconfig")
-@Component
-@Scope("request")
-public class UserConfigREST {
-
- @Autowired
- UserConfigMgr userConfigMgr;
-
- @POST
- @Produces({"application/json"})
- @ApiOperation(SAVE_USER_CONFIG_OD)
- public String saveUserConfig(VUserConfig vhist) {
- return userConfigMgr.saveUserConfig(vhist);
- }
-
- @PUT
- @Produces({"application/json"})
- @ApiOperation(UPDATE_USER_CONFIG_OD)
- public String updateUserConfig(VUserConfig vhist) {
- return userConfigMgr.updateUserConfig(vhist);
- }
-
- @DELETE
- @Path("/{id}")
- @ApiOperation(DELETE_USER_CONFIG_OD)
- public void deleteUserConfig(@PathParam("id") String id) {
- userConfigMgr.deleteUserConfig(id);
- }
-
- @GET
- @Produces({"application/json"})
- @ApiOperation(GET_USER_CONFIG_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = USER_ID_D, name = "userId", paramType = "query", dataType = "string"),
- @ApiImplicitParam(value = FILTER_NAME_D, name = "filterName", paramType = "query", dataType = "string"),
- @ApiImplicitParam(value = ROW_TYPE_D, name = "rowType", paramType = "query", dataType = "string")
- })
- public String getUserConfig(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addParam(LogSearchConstants.USER_NAME,
- request.getParameter("userId"));
- searchCriteria.addParam(LogSearchConstants.FILTER_NAME,
- request.getParameter("filterName"));
- searchCriteria.addParam(LogSearchConstants.ROW_TYPE,
- request.getParameter("rowType"));
- return userConfigMgr.getUserConfig(searchCriteria);
- }
-
- @GET
- @Path("/users/filter")
- @Produces({"application/json"})
- @ApiOperation(GET_USER_FILTER_OD)
- public String getUserFilter(@Context HttpServletRequest request) {
- return userConfigMgr.getUserFilter();
- }
-
- @POST
- @Path("/users/filter")
- @Produces({"application/json"})
- @ApiOperation(UPDATE_USER_FILTER_OD)
- public String createUserFilter(String json) {
- return userConfigMgr.saveUserFiter(json);
- }
-
- @PUT
- @Path("/users/filter/{id}")
- @Produces({"application/json"})
- @ApiOperation(GET_USER_FILTER_BY_ID_OD)
- public String updateUserFilter(String json) {
- return userConfigMgr.saveUserFiter(json);
- }
-
- @GET
- @Path("/users/names")
- @Produces({"application/json"})
- @ApiOperation(GET_ALL_USER_NAMES_OD)
- public String getAllUserName() {
- return userConfigMgr.getAllUserName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
new file mode 100644
index 0000000..fd36978
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
@@ -0,0 +1,116 @@
+/*
+ * 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.rest;
+
+import javax.inject.Inject;
+import javax.ws.rs.BeanParam;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.ambari.logsearch.manager.UserConfigManager;
+import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest;
+import org.apache.ambari.logsearch.query.model.UserConfigSearchCriteria;
+import org.apache.ambari.logsearch.view.VUserConfig;
+import org.springframework.context.annotation.Scope;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.stereotype.Component;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigOperationDescriptions.*;
+
+@Api(value = "userconfig", description = "User config operations")
+@Path("userconfig")
+@Component
+@Scope("request")
+public class UserConfigResource {
+
+ @Inject
+ private UserConfigManager userConfigManager;
+
+ @Inject
+ private ConversionService conversionService;
+
+ @POST
+ @Produces({"application/json"})
+ @ApiOperation(SAVE_USER_CONFIG_OD)
+ public String saveUserConfig(VUserConfig vhist) {
+ return userConfigManager.saveUserConfig(vhist);
+ }
+
+ @PUT
+ @Produces({"application/json"})
+ @ApiOperation(UPDATE_USER_CONFIG_OD)
+ public String updateUserConfig(VUserConfig vhist) {
+ return userConfigManager.updateUserConfig(vhist);
+ }
+
+ @DELETE
+ @Path("/{id}")
+ @ApiOperation(DELETE_USER_CONFIG_OD)
+ public void deleteUserConfig(@PathParam("id") String id) {
+ userConfigManager.deleteUserConfig(id);
+ }
+
+ @GET
+ @Produces({"application/json"})
+ @ApiOperation(GET_USER_CONFIG_OD)
+ public String getUserConfig(@BeanParam UserConfigRequest request) {
+ return userConfigManager.getUserConfig(conversionService.convert(request, UserConfigSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/filters")
+ @Produces({"application/json"})
+ @ApiOperation(GET_USER_FILTER_OD)
+ public String getUserFilter() {
+ return userConfigManager.getUserFilter();
+ }
+
+ @POST
+ @Path("/filters")
+ @Produces({"application/json"})
+ @ApiOperation(UPDATE_USER_FILTER_OD)
+ public String createUserFilter(String json) {
+ return userConfigManager.saveUserFiter(json);
+ }
+
+ @PUT
+ @Path("/filters/{id}")
+ @Produces({"application/json"})
+ @ApiOperation(GET_USER_FILTER_BY_ID_OD)
+ public String updateUserFilter(String json) {
+ return userConfigManager.saveUserFiter(json);
+ }
+
+ @GET
+ @Path("/names")
+ @Produces({"application/json"})
+ @ApiOperation(GET_ALL_USER_NAMES_OD)
+ public String getAllUserName() {
+ return userConfigManager.getAllUserName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/service/UserService.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/service/UserService.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/service/UserService.java
index 4b2b918..ba4431d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/service/UserService.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/service/UserService.java
@@ -18,7 +18,6 @@
*/
package org.apache.ambari.logsearch.service;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
@@ -26,12 +25,14 @@ import org.apache.ambari.logsearch.dao.UserDao;
import org.apache.ambari.logsearch.web.model.User;
import org.apache.log4j.Logger;
+import javax.inject.Inject;
+
@Service
public class UserService implements UserDetailsService {
private static final Logger logger = Logger.getLogger(UserService.class);
- @Autowired
+ @Inject
private UserDao userDao;
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrAuditLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrAuditLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrAuditLogData.java
new file mode 100644
index 0000000..a3f59f7
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrAuditLogData.java
@@ -0,0 +1,339 @@
+/*
+ * 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.solr.model;
+
+import org.apache.ambari.logsearch.model.response.AuditLogData;
+import org.apache.solr.client.solrj.beans.Field;
+
+import java.util.Date;
+import java.util.List;
+
+public class SolrAuditLogData extends SolrCommonLogData implements AuditLogData {
+
+ @Field("logType")
+ private String logType;
+
+ @Field("policy")
+ private String policy;
+
+ @Field("access")
+ private String access;
+
+ @Field("action")
+ private String action;
+
+ @Field("agent")
+ private String agent;
+
+ @Field("agentHost")
+ private String agentHost;
+
+ @Field("cliIP")
+ private String clientIp;
+
+ @Field("cliType")
+ private String clientType;
+
+ @Field("reqContext")
+ private String requestContext;
+
+ @Field("enforcer")
+ private String enforcer;
+
+ @Field("evtTime")
+ private Date eventTime;
+
+ @Field("reason")
+ private String reason;
+
+ @Field("proxyUsers")
+ private List<String> proxyUsers;
+
+ @Field("repo")
+ private String repo;
+
+ @Field("repoType")
+ private String repoType;
+
+ @Field("reqData")
+ private String requestData;
+
+ @Field("reqUser")
+ private String requestUser;
+
+ @Field("resType")
+ private String responseType;
+
+ @Field("resource")
+ private String resource;
+
+ @Field("result")
+ private Integer result;
+
+ @Field("sess")
+ private String session;
+
+ @Field("tags")
+ private List<String> tags;
+
+ @Field("tags_str")
+ private String tagsStr;
+
+ @Field("text")
+ private String text;
+
+ @Override
+ public String getText() {
+ return text;
+ }
+
+ @Override
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ @Override
+ public String getTagsStr() {
+ return tagsStr;
+ }
+
+ @Override
+ public void setTagsStr(String tagsStr) {
+ this.tagsStr = tagsStr;
+ }
+
+ @Override
+ public List<String> getTags() {
+ return tags;
+ }
+
+ @Override
+ public void setTags(List<String> tags) {
+ this.tags = tags;
+ }
+
+ @Override
+ public String getSession() {
+ return session;
+ }
+
+ @Override
+ public void setSession(String session) {
+ this.session = session;
+ }
+
+ @Override
+ public Integer getResult() {
+ return result;
+ }
+
+ @Override
+ public void setResult(Integer result) {
+ this.result = result;
+ }
+
+ @Override
+ public String getResource() {
+ return resource;
+ }
+
+ @Override
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+ @Override
+ public String getResponseType() {
+ return responseType;
+ }
+
+ public void setResponseType(String responseType) {
+ this.responseType = responseType;
+ }
+
+ @Override
+ public String getRequestUser() {
+ return requestUser;
+ }
+
+ @Override
+ public void setRequestUser(String requestUser) {
+ this.requestUser = requestUser;
+ }
+
+ @Override
+ public String getRequestData() {
+ return requestData;
+ }
+
+ @Override
+ public void setRequestData(String requestData) {
+ this.requestData = requestData;
+ }
+
+ @Override
+ public String getRepoType() {
+ return repoType;
+ }
+
+ @Override
+ public void setRepoType(String repoType) {
+ this.repoType = repoType;
+ }
+
+ @Override
+ public String getRepo() {
+ return repo;
+ }
+
+ @Override
+ public void setRepo(String repo) {
+ this.repo = repo;
+ }
+
+ @Override
+ public List<String> getProxyUsers() {
+ return proxyUsers;
+ }
+
+ @Override
+ public void setProxyUsers(List<String> proxyUsers) {
+ this.proxyUsers = proxyUsers;
+ }
+
+ @Override
+ public String getReason() {
+ return reason;
+ }
+
+ @Override
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ @Override
+ public Date getEventTime() {
+ return eventTime;
+ }
+
+ @Override
+ public void setEventTime(Date eventTime) {
+ this.eventTime = eventTime;
+ }
+
+ @Override
+ public String getEnforcer() {
+ return enforcer;
+ }
+
+ @Override
+ public void setEnforcer(String enforcer) {
+ this.enforcer = enforcer;
+ }
+
+ @Override
+ public String getRequestContext() {
+ return requestContext;
+ }
+
+ @Override
+ public void setRequestContext(String requestContext) {
+ this.requestContext = requestContext;
+ }
+
+ @Override
+ public String getClientType() {
+ return clientType;
+ }
+
+ @Override
+ public void setClientType(String clientType) {
+ this.clientType = clientType;
+ }
+
+ @Override
+ public String getClientIp() {
+ return clientIp;
+ }
+
+ @Override
+ public void setClientIp(String clientIp) {
+ this.clientIp = clientIp;
+ }
+
+ @Override
+ public String getAgent() {
+ return agent;
+ }
+
+ @Override
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ @Override
+ public String getAgentHost() {
+ return agentHost;
+ }
+
+ @Override
+ public void setAgentHost(String agentHost) {
+ this.agentHost = agentHost;
+ }
+
+ @Override
+ public String getAction() {
+ return action;
+ }
+
+ @Override
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ @Override
+ public String getAccess() {
+ return access;
+ }
+
+ @Override
+ public void setAccess(String access) {
+ this.access = access;
+ }
+
+ @Override
+ public String getPolicy() {
+ return policy;
+ }
+
+ @Override
+ public void setPolicy(String policy) {
+ this.policy = policy;
+ }
+
+ @Override
+ public String getLogType() {
+ return logType;
+ }
+
+ @Override
+ public void setLogType(String logType) {
+ this.logType = logType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrCommonLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrCommonLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrCommonLogData.java
new file mode 100644
index 0000000..d68279d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrCommonLogData.java
@@ -0,0 +1,248 @@
+/*
+ * 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.solr.model;
+
+import org.apache.ambari.logsearch.model.response.CommonLogData;
+import org.apache.solr.client.solrj.beans.Field;
+
+import java.util.Date;
+
+public class SolrCommonLogData implements CommonLogData {
+
+ @Field("id")
+ private String id;
+
+ @Field("bundle_id")
+ private String bundleId;
+
+ @Field("case_id")
+ private String caseId;
+
+ @Field("cluster")
+ private String cluster;
+
+ @Field("seq_num")
+ private Long seqNum;
+
+ @Field("log_message")
+ private String logMessage;
+
+ @Field("logfile_line_number")
+ private Integer logFileLineNumber;
+
+ @Field("event_dur_m5")
+ private Long eventDurationMs;
+
+ @Field("file")
+ private String file;
+
+ @Field("type")
+ private String type;
+
+ @Field("event_count")
+ private Long eventCount;
+
+ @Field("event_md5")
+ private String eventMd5;
+
+ @Field("message_md5")
+ private String messageMd5;
+
+ @Field("_ttl_")
+ private String ttl;
+
+ @Field("_expire_at_")
+ private Date expire;
+
+ @Field("_version_")
+ private Long version;
+
+ @Field("_router_field_")
+ private Integer routerField;
+
+ @Override
+ public String getId() {
+ return this.id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getCaseId() {
+ return this.caseId;
+ }
+
+ @Override
+ public void setCaseId(String caseId) {
+ this.caseId = caseId;
+ }
+
+ @Override
+ public String getLogMessage() {
+ return this.logMessage;
+ }
+
+ @Override
+ public String getBundleId() {
+ return bundleId;
+ }
+
+ @Override
+ public void setBundleId(String bundleId) {
+ this.bundleId = bundleId;
+ }
+
+ @Override
+ public Integer getLogFileLineNumber() {
+ return logFileLineNumber;
+ }
+
+ @Override
+ public void setLogFileLineNumber(Integer logFileLineNumber) {
+ this.logFileLineNumber = logFileLineNumber;
+ }
+
+ @Override
+ public void setLogMessage(String logMessage) {
+ this.logMessage = logMessage;
+ }
+
+ @Override
+ public Long getEventDurationMs() {
+ return eventDurationMs;
+ }
+
+ @Override
+ public void setEventDurationMs(Long eventDurationMs) {
+ this.eventDurationMs = eventDurationMs;
+ }
+
+ @Override
+ public String getFile() {
+ return file;
+ }
+
+ @Override
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ @Override
+ public Long getSeqNum() {
+ return seqNum;
+ }
+
+ @Override
+ public void setSeqNum(Long seqNum) {
+ this.seqNum = seqNum;
+ }
+
+ @Override
+ public String getMessageMd5() {
+ return messageMd5;
+ }
+
+ @Override
+ public void setMessageMd5(String messageMd5) {
+ this.messageMd5 = messageMd5;
+ }
+
+ @Override
+ public String getEventMd5() {
+ return eventMd5;
+ }
+
+ @Override
+ public void setEventMd5(String eventMd5) {
+ this.eventMd5 = eventMd5;
+ }
+
+ @Override
+ public String getCluster() {
+ return cluster;
+ }
+
+ @Override
+ public void setCluster(String cluster) {
+ this.cluster = cluster;
+ }
+
+ @Override
+ public Long getEventCount() {
+ return eventCount;
+ }
+
+ @Override
+ public void setEventCount(Long eventCount) {
+ this.eventCount = eventCount;
+ }
+
+ @Override
+ public String getTtl() {
+ return this.ttl;
+ }
+
+ @Override
+ public void setTtl(String ttl) {
+ this.ttl = ttl;
+ }
+
+ @Override
+ public Date getExpire() {
+ return expire;
+ }
+
+ @Override
+ public void setExpire(Date expire) {
+ this.expire = expire;
+ }
+
+ @Override
+ public Long getVersion() {
+ return version;
+ }
+
+ @Override
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+
+ @Override
+ public Integer getRouterField() {
+ return this.routerField;
+ }
+
+ @Override
+ public void setRouterField(Integer routerField) {
+ this.routerField = routerField;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public void setType(String type) {
+ this.type = type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrComponentTypeLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrComponentTypeLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrComponentTypeLogData.java
new file mode 100644
index 0000000..988c878
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrComponentTypeLogData.java
@@ -0,0 +1,38 @@
+/*
+ * 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.solr.model;
+
+import org.apache.ambari.logsearch.model.response.ComponentTypeLogData;
+import org.apache.solr.client.solrj.beans.Field;
+
+public class SolrComponentTypeLogData implements ComponentTypeLogData {
+
+ @Field("type")
+ private String type;
+
+ @Override
+ public String getType() {
+ return this.type;
+ }
+
+ @Override
+ public void setType(String type) {
+ this.type = type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrHostLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrHostLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrHostLogData.java
new file mode 100644
index 0000000..215b22c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrHostLogData.java
@@ -0,0 +1,38 @@
+/*
+ * 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.solr.model;
+
+import org.apache.ambari.logsearch.model.response.HostLogData;
+import org.apache.solr.client.solrj.beans.Field;
+
+public class SolrHostLogData implements HostLogData {
+
+ @Field("host")
+ private String host;
+
+ @Override
+ public String getHost() {
+ return host;
+ }
+
+ @Override
+ public void setHost(String host) {
+ this.host = host;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrServiceLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrServiceLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrServiceLogData.java
new file mode 100644
index 0000000..890dc7d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/solr/model/SolrServiceLogData.java
@@ -0,0 +1,118 @@
+/*
+ * 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.solr.model;
+
+import org.apache.ambari.logsearch.model.response.ServiceLogData;
+import org.apache.solr.client.solrj.beans.Field;
+
+import java.util.Date;
+
+public class SolrServiceLogData extends SolrCommonLogData implements ServiceLogData {
+
+ @Field("level")
+ private String level;
+
+ @Field("line_number")
+ private Integer lineNumber;
+
+ @Field("logtime")
+ private Date logTime;
+
+ @Field("type")
+ private String type;
+
+ @Field("ip")
+ private String ip;
+
+ @Field("path")
+ private String path;
+
+ @Field("host")
+ private String host;
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public String getIp() {
+ return ip;
+ }
+
+ @Override
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String getHost() {
+ return host;
+ }
+
+ @Override
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ @Override
+ public Date getLogTime() {
+ return logTime;
+ }
+
+ @Override
+ public void setLogTime(Date logTime) {
+ this.logTime = logTime;
+ }
+
+ @Override
+ public Integer getLineNumber() {
+ return lineNumber;
+ }
+
+ @Override
+ public void setLineNumber(Integer lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ @Override
+ public String getLevel() {
+ return level;
+ }
+
+ @Override
+ public void setLevel(String level) {
+ this.level = level;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
index bd6cfbb..637a4d7 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/util/BizUtil.java
@@ -32,10 +32,10 @@ import java.util.Map.Entry;
import java.util.Set;
import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.view.VBarDataList;
-import org.apache.ambari.logsearch.view.VBarGraphData;
+import org.apache.ambari.logsearch.model.response.BarGraphData;
+import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.NameValueData;
import org.apache.ambari.logsearch.view.VHost;
-import org.apache.ambari.logsearch.view.VNameValue;
import org.apache.ambari.logsearch.view.VSummary;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
@@ -173,41 +173,41 @@ public class BizUtil {
}
@SuppressWarnings({"unchecked", "rawtypes"})
- public static VBarDataList buildSummaryForTopCounts(SimpleOrderedMap<Object> jsonFacetResponse,String innerJsonKey,String outerJsonKey) {
+ public static BarGraphDataListResponse buildSummaryForTopCounts(SimpleOrderedMap<Object> jsonFacetResponse, String innerJsonKey, String outerJsonKey) {
- VBarDataList vBarDataList = new VBarDataList();
+ BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse();
- Collection<VBarGraphData> dataList = new ArrayList<VBarGraphData>();
+ Collection<BarGraphData> dataList = new ArrayList<>();
if (jsonFacetResponse == null) {
logger.info("Solr document list in null");
- return vBarDataList;
+ return barGraphDataListResponse;
}
List<Object> userList = jsonFacetResponse.getAll(outerJsonKey);
if (userList.isEmpty()) {
- return vBarDataList;
+ return barGraphDataListResponse;
}
SimpleOrderedMap<Map<String, Object>> userMap = (SimpleOrderedMap<Map<String, Object>>) userList.get(0);
if (userMap == null) {
logger.info("No top user details found");
- return vBarDataList;
+ return barGraphDataListResponse;
}
List<SimpleOrderedMap> userUsageList = (List<SimpleOrderedMap>) userMap.get("buckets");
if(userUsageList == null){
- return vBarDataList;
+ return barGraphDataListResponse;
}
for (SimpleOrderedMap usageMap : userUsageList) {
if (usageMap != null) {
- VBarGraphData vBarGraphData = new VBarGraphData();
+ BarGraphData barGraphData = new BarGraphData();
String userName = (String) usageMap.get("val");
if (!StringUtils.isBlank(userName)) {
- vBarGraphData.setName(userName);
+ barGraphData.setName(userName);
}
SimpleOrderedMap repoMap = (SimpleOrderedMap) usageMap.get(innerJsonKey);
- List<VNameValue> componetCountList = new ArrayList<VNameValue>();
- List<SimpleOrderedMap> repoUsageList = (List<SimpleOrderedMap>) repoMap.get("buckets");
+ List<NameValueData> componetCountList = new ArrayList<NameValueData>();
if (repoMap != null) {
+ List<SimpleOrderedMap> repoUsageList = (List<SimpleOrderedMap>) repoMap.get("buckets");
for (SimpleOrderedMap repoUsageMap : repoUsageList) {
- VNameValue componetCount = new VNameValue();
+ NameValueData componetCount = new NameValueData();
if (repoUsageMap.get("val") != null) {
componetCount.setName(repoUsageMap.get("val").toString());
}
@@ -221,19 +221,19 @@ public class BizUtil {
componetCount.setValue(eventCount);
componetCountList.add(componetCount);
}
- vBarGraphData.setDataCounts(componetCountList);
- dataList.add(vBarGraphData);
+ barGraphData.setDataCount(componetCountList);
+ dataList.add(barGraphData);
}
}}
- vBarDataList.setGraphData(dataList);
+ barGraphDataListResponse.setGraphData(dataList);
logger.info("getting graph data");
- return vBarDataList;
+ return barGraphDataListResponse;
}
public static HashMap<String, String> sortHashMapByValues(HashMap<String, String> passedMap) {
if (passedMap == null ) {
- return passedMap;
+ return null;
}
HashMap<String, String> sortedMap = new LinkedHashMap<String, String>();
List<String> mapValues = new ArrayList<String>(passedMap.values());
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarDataList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarDataList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarDataList.java
deleted file mode 100644
index b13946c..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarDataList.java
+++ /dev/null
@@ -1,46 +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.view;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VBarDataList {
- protected Collection<VBarGraphData> graphData;
-
- public VBarDataList() {
- graphData = new ArrayList<VBarGraphData>();
- }
-
- public Collection<VBarGraphData> getGraphData() {
- return graphData;
- }
-
- public void setGraphData(Collection<VBarGraphData> histogramData) {
- this.graphData = histogramData;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarGraphData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarGraphData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarGraphData.java
deleted file mode 100644
index 50fe47e..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VBarGraphData.java
+++ /dev/null
@@ -1,50 +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.view;
-
-import java.util.Collection;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VBarGraphData {
- protected Collection<VNameValue> dataCount = null;
- protected String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String level) {
- this.name = level;
- }
-
- public Collection<VNameValue> getDataCount() {
- return dataCount;
- }
-
- public void setDataCounts(Collection<VNameValue> dateValueCounts) {
- this.dataCount = dateValueCounts;
- }
-
-}
[11/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileMgr.java
deleted file mode 100644
index e227c6c..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogFileMgr.java
+++ /dev/null
@@ -1,145 +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.manager;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.dao.AuditSolrDao;
-import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VLogFile;
-import org.apache.ambari.logsearch.view.VLogFileList;
-import org.apache.ambari.logsearch.view.VSolrLogList;
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField;
-import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-
-@Component
-public class LogFileMgr extends MgrBase {
-
- private static final Logger logger = Logger.getLogger(LogFileMgr.class);
-
- @Autowired
- private ServiceLogsSolrDao serviceLogsSolrDao;
- @Autowired
- private AuditSolrDao auditSolrDao;
-
- public String searchLogFiles(SearchCriteria searchCriteria) {
- VLogFileList logFileList = new VLogFileList();
- List<VLogFile> logFiles = new ArrayList<VLogFile>();
- String componentName = (String) searchCriteria.getParamValue("component");
- String host = (String) searchCriteria.getParamValue("host");
- int minCount = 1;// to remove zero count facet
- SolrQuery solrQuery = new SolrQuery();
- SolrUtil.setMainQuery(solrQuery, null);
- SolrUtil.setFacetFieldWithMincount(solrQuery, LogSearchConstants.SOLR_PATH, minCount);
- // adding filter
- queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_COMPONENT, componentName);
- queryGenerator.setSingleIncludeFilter(solrQuery, LogSearchConstants.SOLR_HOST, host);
- try {
- String logType = (String) searchCriteria.getParamValue("logType");
- if (StringUtils.isBlank(logType)) {
- logType = LogType.SERVICE.name();// default is service Log
- }
- SolrDaoBase daoMgr = null;
- if (logType.equalsIgnoreCase(LogType.SERVICE.name())) {
- daoMgr = serviceLogsSolrDao;
- } else if (logType.equalsIgnoreCase(LogType.AUDIT.name())) {
- daoMgr = auditSolrDao;
- } else {
- throw RESTErrorUtil.createRESTException(logType + " is not a valid logType", MessageEnums.INVALID_INPUT_DATA);
- }
- QueryResponse queryResponse = daoMgr.process(solrQuery);
- if (queryResponse.getFacetField(LogSearchConstants.SOLR_PATH) != null) {
- FacetField queryFacetField = queryResponse.getFacetField(LogSearchConstants.SOLR_PATH);
- if (queryFacetField != null) {
- List<Count> countList = queryFacetField.getValues();
- for (Count count : countList) {
- VLogFile vLogFile = new VLogFile();
- String filePath = count.getName();
- String fileName = FilenameUtils.getName(filePath);
- vLogFile.setPath(filePath);
- vLogFile.setName(fileName);
- logFiles.add(vLogFile);
- }
- }
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error in solr query :" + e.getLocalizedMessage() + "\n Query :" + solrQuery.toQueryString(), e.getCause());
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- logFileList.setLogFiles(logFiles);
- String jsonStr = "";
- jsonStr = convertObjToString(logFileList);
-
- return jsonStr;
- }
-
- public String getLogFileTail(SearchCriteria searchCriteria) {
- String host = (String) searchCriteria.getParamValue("host");
- String logFile = (String) searchCriteria.getParamValue("name");
- String component = (String) searchCriteria.getParamValue("component");
- String tailSize = (String) searchCriteria.getParamValue("tailSize");
- if (StringUtils.isBlank(host)) {
- throw RESTErrorUtil.createRESTException("missing Host Name", MessageEnums.ERROR_SYSTEM);
- }
- tailSize = (StringUtils.isBlank(tailSize)) ? "10" : tailSize;
- SolrQuery logFileTailQuery = new SolrQuery();
- try {
- int tail = Integer.parseInt(tailSize);
- tail = tail > 100 ? 100 : tail;
- SolrUtil.setMainQuery(logFileTailQuery, null);
- queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_HOST, host);
- if (!StringUtils.isBlank(logFile)) {
- queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_PATH, SolrUtil.makeSolrSearchString(logFile));
- } else if (!StringUtils.isBlank(component)) {
- queryGenerator.setSingleIncludeFilter(logFileTailQuery, LogSearchConstants.SOLR_COMPONENT, component);
- } else {
- throw RESTErrorUtil.createRESTException("component or logfile parameter must be present", MessageEnums.ERROR_SYSTEM);
- }
-
- SolrUtil.setRowCount(logFileTailQuery, tail);
- queryGenerator.setSortOrderDefaultServiceLog(logFileTailQuery, new SearchCriteria());
- VSolrLogList solrLogList = getLogAsPaginationProvided(logFileTailQuery, serviceLogsSolrDao);
- return convertObjToString(solrLogList);
-
- } catch (NumberFormatException ne) {
-
- throw RESTErrorUtil.createRESTException(ne.getMessage(),
- MessageEnums.ERROR_SYSTEM);
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java
deleted file mode 100644
index 53e0aab..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/manager/LogsMgr.java
+++ /dev/null
@@ -1,1896 +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.manager;
-
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TimeZone;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.ambari.logsearch.common.ConfigHelper;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
-import org.apache.ambari.logsearch.graph.GraphDataGenerator;
-import org.apache.ambari.logsearch.query.QueryGenerationBase;
-import org.apache.ambari.logsearch.util.BizUtil;
-import org.apache.ambari.logsearch.util.DateUtil;
-import org.apache.ambari.logsearch.util.FileUtil;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.ambari.logsearch.view.VBarDataList;
-import org.apache.ambari.logsearch.view.VBarGraphData;
-import org.apache.ambari.logsearch.view.VCount;
-import org.apache.ambari.logsearch.view.VCountList;
-import org.apache.ambari.logsearch.view.VGraphData;
-import org.apache.ambari.logsearch.view.VGraphInfo;
-import org.apache.ambari.logsearch.view.VGroupList;
-import org.apache.ambari.logsearch.view.VNameValue;
-import org.apache.ambari.logsearch.view.VNameValueList;
-import org.apache.ambari.logsearch.view.VNode;
-import org.apache.ambari.logsearch.view.VNodeList;
-import org.apache.ambari.logsearch.view.VSolrLogList;
-import org.apache.ambari.logsearch.view.VSummary;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField;
-import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.PivotField;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.RangeFacet;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import com.google.common.collect.Lists;
-
-@Component
-public class LogsMgr extends MgrBase {
- private static final Logger logger = Logger.getLogger(LogsMgr.class);
-
- private static List<String> cancelByDate = new CopyOnWriteArrayList<String>();
-
- private static Map<String, String> mapUniqueId = new ConcurrentHashMap<String, String>();
-
- private static enum CONDITION {
- OR, AND
- }
-
- @Autowired
- private ServiceLogsSolrDao serviceLogsSolrDao;
- @Autowired
- private GraphDataGenerator graphDataGenerator;
-
- public String searchLogs(SearchCriteria searchCriteria) {
- String keyword = (String) searchCriteria.getParamValue("keyword");
- String logId = (String) searchCriteria.getParamValue("sourceLogId");
- String lastPage = (String) searchCriteria.getParamValue("isLastPage");
- Boolean isLastPage = Boolean.parseBoolean(lastPage);
-
- if (!StringUtils.isBlank(keyword)) {
- try {
- return getPageByKeyword(searchCriteria);
- } catch (SolrException | SolrServerException e) {
- logger.error("Error while getting keyword=" + keyword, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- } else if (!StringUtils.isBlank(logId)) {
- try {
- return getPageByLogId(searchCriteria);
- } catch (SolrException e) {
- logger.error("Error while getting keyword=" + keyword, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- } else if (isLastPage) {
- SolrQuery lastPageQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- VSolrLogList collection = getLastPage(searchCriteria,LogSearchConstants.LOGTIME,serviceLogsSolrDao,lastPageQuery);
- if(collection == null){
- collection = new VSolrLogList();
- }
- return convertObjToString(collection);
- } else {
- SolrQuery solrQuery = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
-
- solrQuery.setParam("event", "/service/logs");
-
- VSolrLogList collection = getLogAsPaginationProvided(solrQuery,
- serviceLogsSolrDao);
- return convertObjToString(collection);
- }
- }
-
- public String getHosts() {
- return getFields(LogSearchConstants.SOLR_HOST);
- }
-
- private String getFields(String field){
-
- SolrQuery solrQuery = new SolrQuery();
- VGroupList collection = new VGroupList();
- SolrUtil.setMainQuery(solrQuery, null);
- SolrUtil.setFacetField(solrQuery,
- field);
- SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX);
- try {
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if(response == null){
- return convertObjToString(collection);
- }
- FacetField facetField = response
- .getFacetField(field);
- if (facetField == null){
- return convertObjToString(collection);
- }
- List<Count> fieldList = facetField.getValues();
- if (fieldList == null){
- return convertObjToString(collection);
- }
- SolrDocumentList docList = response.getResults();
- if(docList == null){
- return convertObjToString(collection);
- }
- String temp = "";
- for (Count cnt : fieldList) {
- SolrDocument solrDoc = new SolrDocument();
- temp = cnt.getName();
- solrDoc.put(field, temp);
- docList.add(solrDoc);
- }
-
- collection.setGroupDocuments(docList);
- if(!docList.isEmpty()){
- collection.setStartIndex((int) docList.getStart());
- collection.setTotalCount(docList.getNumFound());
- }
- return convertObjToString(collection);
- } catch (IOException | SolrServerException | SolrException e) {
- logger.error(e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- }
-
- public String getComponents() {
- return getFields(LogSearchConstants.SOLR_COMPONENT);
- }
-
- public String getAggregatedInfo(SearchCriteria searchCriteria) {
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- String hierarchy = "host,type,level";
- VGraphInfo graphInfo = new VGraphInfo();
- try {
- SolrUtil.setMainQuery(solrQuery, null);
- SolrUtil.setFacetPivot(solrQuery, 1, hierarchy);
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if (response == null) {
- return convertObjToString(graphInfo);
- }
-
- List<List<PivotField>> hirarchicalPivotField = new ArrayList<List<PivotField>>();
- List<VGraphData> dataList = new ArrayList<VGraphData>();
- NamedList<List<PivotField>> namedList = response.getFacetPivot();
- if (namedList != null) {
- hirarchicalPivotField = namedList.getAll(hierarchy);
- }
- if (!hirarchicalPivotField.isEmpty()) {
- dataList = buidGraphData(hirarchicalPivotField.get(0));
- }
- if (!dataList.isEmpty()) {
- graphInfo.setGraphData(dataList);
- }
-
- return convertObjToString(graphInfo);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- public List<VGraphData> buidGraphData(List<PivotField> pivotFields) {
- List<VGraphData> logList = new ArrayList<VGraphData>();
- if (pivotFields != null) {
- for (PivotField pivotField : pivotFields) {
- if (pivotField != null) {
- VGraphData logLevel = new VGraphData();
- logLevel.setName("" + pivotField.getValue());
- logLevel.setCount(Long.valueOf(pivotField.getCount()));
- if (pivotField.getPivot() != null) {
- logLevel.setDataList(buidGraphData(pivotField.getPivot()));
- }
- logList.add(logLevel);
- }
- }
- }
- return logList;
- }
-
- public VCountList getFieldCount(String field){
- VCountList collection = new VCountList();
- List<VCount> vCounts = new ArrayList<VCount>();
- SolrQuery solrQuery = new SolrQuery();
- SolrUtil.setMainQuery(solrQuery, null);
- if(field == null){
- return collection;
- }
- SolrUtil.setFacetField(solrQuery, field);
- try {
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if (response == null){
- return collection;
- }
- FacetField facetFields = response.getFacetField(field);
- if (facetFields == null){
- return collection;
- }
- List<Count> fieldList = facetFields.getValues();
-
- if(fieldList == null){
- return collection;
- }
-
- for (Count cnt : fieldList) {
- if (cnt != null) {
- VCount vCount = new VCount();
- vCount.setName(cnt.getName());
- vCount.setCount(cnt.getCount());
- vCounts.add(vCount);
- }
- }
-
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- collection.setCounts(vCounts);
- return collection;
- }
-
- public VCountList getLogLevelCount() {
- return getFieldCount(LogSearchConstants.SOLR_LEVEL);
- }
-
- public VCountList getComponentsCount() {
- return getFieldCount(LogSearchConstants.SOLR_COMPONENT);
- }
-
- public VCountList getHostsCount() {
- return getFieldCount(LogSearchConstants.SOLR_HOST);
- }
-
- public List<VNode> buidTreeData(List<PivotField> pivotFields,
- List<PivotField> pivotFieldHost, SolrQuery query,
- String firstPriority, String secondPriority) {
- List<VNode> extensionTree = new ArrayList<VNode>();
- String hostQuery = null;
- if (pivotFields != null) {
- // For Host
- for (PivotField pivotHost : pivotFields) {
- if (pivotHost != null) {
- VNode hostNode = new VNode();
- String name = (pivotHost.getValue() == null ? "" : ""+ pivotHost.getValue());
- String value = "" + pivotHost.getCount();
- if(!StringUtils.isBlank(name)){
- hostNode.setName(name);
- }
- if(!StringUtils.isBlank(value)){
- hostNode.setValue(value);
- }
- if(!StringUtils.isBlank(firstPriority)){
- hostNode.setType(firstPriority);
- }
-
- hostNode.setParent(true);
- hostNode.setRoot(true);
- PivotField hostPivot = null;
- for (PivotField searchHost : pivotFieldHost) {
- if (!StringUtils.isBlank(hostNode.getName())
- && hostNode.getName().equals(searchHost.getValue())) {
- hostPivot = searchHost;
- break;
- }
- }
- List<PivotField> pivotLevelHost = hostPivot.getPivot();
- if (pivotLevelHost != null) {
- Collection<VNameValue> logLevelCount = new ArrayList<VNameValue>();
- for (PivotField pivotLevel : pivotLevelHost) {
- if (pivotLevel != null) {
- VNameValue vnameValue = new VNameValue();
- String levelName = (pivotLevel.getValue() == null ? "" : ""
- + pivotLevel.getValue());
- vnameValue.setName(levelName.toUpperCase());
- vnameValue.setValue("" + pivotLevel.getCount());
- logLevelCount.add(vnameValue);
- }
- }
- hostNode.setLogLevelCount(logLevelCount);
- }
-
- query.addFilterQuery(hostQuery);
- List<PivotField> pivotComponents = pivotHost.getPivot();
- // For Components
- if (pivotComponents != null) {
- Collection<VNode> componentNodes = new ArrayList<VNode>();
- for (PivotField pivotComp : pivotComponents) {
- if (pivotComp != null) {
- VNode compNode = new VNode();
- String compName = (pivotComp.getValue() == null ? "" : ""
- + pivotComp.getValue());
- compNode.setName(compName);
- if (!StringUtils.isBlank(secondPriority)) {
- compNode.setType(secondPriority);
- }
- compNode.setValue("" + pivotComp.getCount());
- compNode.setParent(false);
- compNode.setRoot(false);
- List<PivotField> pivotLevels = pivotComp.getPivot();
- if (pivotLevels != null) {
- Collection<VNameValue> logLevelCount = new ArrayList<VNameValue>();
- for (PivotField pivotLevel : pivotLevels) {
- if (pivotLevel != null) {
- VNameValue vnameValue = new VNameValue();
- String compLevel = pivotLevel.getValue() == null ? ""
- : "" + pivotLevel.getValue();
- vnameValue.setName((compLevel).toUpperCase());
-
- vnameValue.setValue("" + pivotLevel.getCount());
- logLevelCount.add(vnameValue);
- }
- }
- compNode.setLogLevelCount(logLevelCount);
- }
- componentNodes.add(compNode);
- }}
- hostNode.setChilds(componentNodes);
- }
- extensionTree.add(hostNode);
- }}
- }
-
- return extensionTree;
- }
-
- public VNodeList getTreeExtension(SearchCriteria searchCriteria) {
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- solrQuery.setParam("event", "/getTreeExtension");
-
- if (searchCriteria.getSortBy() == null) {
- searchCriteria.setSortBy(LogSearchConstants.SOLR_HOST);
- searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
- }
- queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
- String hostName = ""
- + ((searchCriteria.getParamValue("hostName") == null) ? ""
- : searchCriteria.getParamValue("hostName"));
- if (!StringUtils.isBlank(hostName)){
- solrQuery.addFilterQuery(LogSearchConstants.SOLR_HOST + ":*"
- + hostName + "*");
- }
- String firstHirarchy = "host,type,level";
- String secondHirarchy = "host,level";
- VNodeList list = new VNodeList();
- try {
-
- SolrUtil.setFacetPivot(solrQuery, 1, firstHirarchy,
- secondHirarchy);
-
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- List<List<PivotField>> listFirstHirarchicalPivotFields = new ArrayList<List<PivotField>>();
- NamedList<List<PivotField>> firstNamedList = response
- .getFacetPivot();
- if (firstNamedList != null) {
- listFirstHirarchicalPivotFields = firstNamedList
- .getAll(firstHirarchy);
- }
- List<List<PivotField>> listSecondHirarchicalPivotFields = new ArrayList<List<PivotField>>();
- NamedList<List<PivotField>> secondNamedList = response
- .getFacetPivot();
- if (secondNamedList != null) {
- listSecondHirarchicalPivotFields = secondNamedList
- .getAll(secondHirarchy);
- }
- List<PivotField> firstHirarchicalPivotFields = new ArrayList<PivotField>();
- List<PivotField> secondHirarchicalPivotFields = new ArrayList<PivotField>();
- if (!listFirstHirarchicalPivotFields.isEmpty()) {
- firstHirarchicalPivotFields = listFirstHirarchicalPivotFields
- .get(0);
- }
- if (!listSecondHirarchicalPivotFields.isEmpty()) {
- secondHirarchicalPivotFields = listSecondHirarchicalPivotFields
- .get(0);
- }
- List<VNode> dataList = buidTreeData(firstHirarchicalPivotFields,
- secondHirarchicalPivotFields, solrQuery,
- LogSearchConstants.HOST, LogSearchConstants.COMPONENT);
-
- list.setvNodeList(dataList);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- return list;
- }
-
- public String getHostListByComponent(SearchCriteria searchCriteria) {
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- solrQuery.setParam("event", "/service/hosts/component");
-
- VNodeList list = new VNodeList();
- if (searchCriteria.getSortBy() == null) {
- searchCriteria.setSortBy(LogSearchConstants.SOLR_HOST);
- searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
- }
- queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
- String componentName = ""
- + ((searchCriteria.getParamValue("componentName") == null) ? ""
- : searchCriteria.getParamValue("componentName"));
- if (!StringUtils.isBlank(componentName)){
- solrQuery.addFilterQuery(LogSearchConstants.SOLR_COMPONENT + ":"
- + componentName);
- } else {
- return convertObjToString(list);
- }
-
- String firstHirarchy = "type,host,level";
- String secondHirarchy = "type,level";
-
- try {
- SolrUtil.setFacetPivot(solrQuery, 1, firstHirarchy,
- secondHirarchy);
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- List<List<PivotField>> firstHirarchicalPivotFields = null;
- List<List<PivotField>> secondHirarchicalPivotFields = null;
- NamedList<List<PivotField>> firstNamedList = response
- .getFacetPivot();
- if (firstNamedList != null) {
- firstHirarchicalPivotFields = firstNamedList
- .getAll(firstHirarchy);
- secondHirarchicalPivotFields = firstNamedList
- .getAll(secondHirarchy);
- }
-
- if (firstHirarchicalPivotFields == null
- || secondHirarchicalPivotFields == null) {
- return convertObjToString(list);
- }
-
- List<VNode> dataList = buidTreeData(
- firstHirarchicalPivotFields.get(0),
- secondHirarchicalPivotFields.get(0), solrQuery,
- LogSearchConstants.COMPONENT, LogSearchConstants.HOST);
- if(dataList == null){
- return convertObjToString(list);
- }
-
- list.setvNodeList(dataList);
- return convertObjToString(list);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- public VNameValueList getLogsLevelCount(SearchCriteria sc) {
- VNameValueList nameValueList = new VNameValueList();
- SolrQuery query = queryGenerator.commonServiceFilterQuery(sc);
- query.setParam("event", "/service/logs/levels/counts/namevalues");
- List<VNameValue> logsCounts = getLogLevelFacets(query);
- nameValueList.setVNameValues(logsCounts);
-
- return nameValueList;
- }
-
- public List<VNameValue> getLogLevelFacets(SolrQuery query) {
- String defalutValue = "0";
- HashMap<String, String> map = new HashMap<String, String>();
- List<VNameValue> logsCounts = new ArrayList<VNameValue>();
- try {
- SolrUtil.setFacetField(query, LogSearchConstants.SOLR_LEVEL);
- List<Count> logLevelCounts = getFacetCounts(query,
- LogSearchConstants.SOLR_LEVEL);
- if (logLevelCounts == null) {
- return logsCounts;
- }
- for (Count count : logLevelCounts) {
- map.put(count.getName().toUpperCase(), "" + count.getCount());
- }
- for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
- VNameValue nameValue = new VNameValue();
- String value = map.get(level);
- if (StringUtils.isBlank(value)) {
- value = defalutValue;
- }
- nameValue.setName(level);
- nameValue.setValue(value);
- logsCounts.add(nameValue);
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + query, e);
- }
- return logsCounts;
- }
-
- // Get Facet Count According to FacetFeild
- public List<Count> getFacetCounts(SolrQuery solrQuery, String facetField)
- throws SolrServerException, IOException, SolrException {
- List<Count> list = new ArrayList<FacetField.Count>();
-
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if(response == null){
- return list;
- }
-
- FacetField field = response.getFacetField(facetField);
- if (field == null) {
- return list;
- }
- list = field.getValues();
-
-
- return list;
- }
-
- public String getPageByKeyword(SearchCriteria searchCriteria)
- throws SolrServerException {
- String defaultChoice = "0";
-
- String key = (String) searchCriteria.getParamValue("keyword");
- if(StringUtils.isBlank(key)){
- throw RESTErrorUtil.createRESTException("Keyword was not given",
- MessageEnums.DATA_NOT_FOUND);
- }
-
- String keyword = SolrUtil.escapeForStandardTokenizer(key);
-
- if(keyword.startsWith("\"") && keyword.endsWith("\"")){
- keyword = keyword.substring(1);
- keyword = keyword.substring(0, keyword.length()-1);
- }
- keyword = "*" + keyword + "*";
-
-
- String keyType = (String) searchCriteria.getParamValue("keywordType");
- QueryResponse queryResponse = null;
-
- if (!defaultChoice.equals(keyType)) {
- try {
- int currentPageNumber = searchCriteria.getPage();
- int maxRows = searchCriteria.getMaxRows();
- String nextPageLogID = "";
-
- int lastLogIndexNumber = ((currentPageNumber + 1)
- * maxRows);
- String nextPageLogTime = "";
-
-
- // Next Page Start Time Calculation
- SolrQuery nextPageLogTimeQuery = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- nextPageLogTimeQuery.remove("start");
- nextPageLogTimeQuery.remove("rows");
- nextPageLogTimeQuery.setStart(lastLogIndexNumber);
- nextPageLogTimeQuery.setRows(1);
-
- queryResponse = serviceLogsSolrDao.process(
- nextPageLogTimeQuery);
- if(queryResponse == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocumentList docList = queryResponse.getResults();
- if(docList ==null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocument solrDoc = docList.get(0);
-
- Date logDate = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
- if(logDate == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
- nextPageLogTime = DateUtil
- .convertDateWithMillisecondsToSolrDate(logDate);
- nextPageLogID = ""
- + solrDoc.get(LogSearchConstants.ID);
-
- if (StringUtils.isBlank(nextPageLogID)){
- nextPageLogID = "0";
- }
-
- String filterQueryListIds = "";
- // Remove the same Time Ids
- SolrQuery listRemoveIds = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- listRemoveIds.remove("start");
- listRemoveIds.remove("rows");
- queryGenerator.setSingleIncludeFilter(listRemoveIds,
- LogSearchConstants.LOGTIME, "\"" + nextPageLogTime + "\"");
- queryGenerator.setSingleExcludeFilter(listRemoveIds,
- LogSearchConstants.ID, nextPageLogID);
- SolrUtil.setFl(listRemoveIds, LogSearchConstants.ID);
- queryResponse = serviceLogsSolrDao.process(
- listRemoveIds);
- if(queryResponse == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocumentList docListIds = queryResponse.getResults();
- if(docListIds ==null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
- boolean isFirst = true;
- for (SolrDocument solrDocId : docListIds ) {
- String id = "" + solrDocId.get(LogSearchConstants.ID);
- if (isFirst) {
- filterQueryListIds += LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
- isFirst = false;
- } else {
- filterQueryListIds += " "+CONDITION.AND+" " + LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
- }
- }
-
- // Keyword Sequence Number Calculation
- String endTime = (String) searchCriteria.getParamValue("to");
- String startTime = (String) searchCriteria
- .getParamValue("from");
- SolrQuery logTimeThroughRangeQuery = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- logTimeThroughRangeQuery.remove("start");
- logTimeThroughRangeQuery.remove("rows");
- logTimeThroughRangeQuery.setRows(1);
- if (!StringUtils.isBlank(filterQueryListIds)){
- logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
- }
-
- String sortByType = searchCriteria.getSortType();
-
- if (!StringUtils.isBlank(sortByType) && sortByType
- .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
-
- queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
- LogSearchConstants.LOGTIME, nextPageLogTime,
- endTime);
- logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
- LogSearchConstants.LOGTIME + " "
- + LogSearchConstants.ASCENDING_ORDER);
-
- } else {
-
- queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
- LogSearchConstants.LOGTIME, startTime,
- nextPageLogTime);
- logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
- LogSearchConstants.LOGTIME + " "
- + LogSearchConstants.DESCENDING_ORDER);
- }
- queryGenerator.setSingleIncludeFilter(logTimeThroughRangeQuery,
- LogSearchConstants.SOLR_KEY_LOG_MESSAGE, keyword);
-
-
- queryResponse = serviceLogsSolrDao.process(
- logTimeThroughRangeQuery);
- if(queryResponse == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocumentList documentList = queryResponse.getResults();
- if(documentList ==null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocument solrDocument = new SolrDocument();
- if (!documentList.isEmpty()){
- solrDocument = documentList.get(0);
- }
-
- Date keywordLogDate = (Date) solrDocument.get(LogSearchConstants.LOGTIME);
- if(keywordLogDate == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
- String originalKeywordDate = DateUtil
- .convertDateWithMillisecondsToSolrDate(keywordLogDate);
- String keywordId = "" + solrDocument.get(LogSearchConstants.ID);
-
- // Getting Range Count from StartTime To Keyword Log Time
- SolrQuery rangeLogQuery = nextPageLogTimeQuery.getCopy();
- rangeLogQuery.remove("start");
- rangeLogQuery.remove("rows");
-
- if (!StringUtils.isBlank(sortByType) && sortByType
- .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
- keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, 1);
- String keywordDateTime = DateUtil
- .convertDateWithMillisecondsToSolrDate(keywordLogDate);
- queryGenerator.setSingleRangeFilter(rangeLogQuery,
- LogSearchConstants.LOGTIME, startTime,
- keywordDateTime);
- } else {
- keywordLogDate = DateUtils.addMilliseconds(keywordLogDate, -1);
- String keywordDateTime = DateUtil
- .convertDateWithMillisecondsToSolrDate(keywordLogDate);
- queryGenerator.setSingleRangeFilter(rangeLogQuery,
- LogSearchConstants.LOGTIME, keywordDateTime,
- endTime);
- }
-
-
- long countNumberLogs = countQuery(rangeLogQuery,serviceLogsSolrDao) - 1;
-
-
- //Adding numbers on
-
-
- try {
- SolrQuery sameIdQuery = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- queryGenerator.setSingleIncludeFilter(sameIdQuery,
- LogSearchConstants.LOGTIME, "\"" + originalKeywordDate + "\"");
- SolrUtil.setFl(sameIdQuery, LogSearchConstants.ID);
- SolrDocumentList sameQueryDocList = serviceLogsSolrDao.process(sameIdQuery)
- .getResults();
- for (SolrDocument solrDocumenent : sameQueryDocList) {
- String id = (String) solrDocumenent
- .getFieldValue(LogSearchConstants.ID);
- countNumberLogs++;
-
- if (StringUtils.isBlank(id) && id.equals(keywordId)){
- break;
- }
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error(e);
- }
-
- int start = (int) ((countNumberLogs / maxRows) * maxRows);
- SolrQuery logIdQuery = nextPageLogTimeQuery.getCopy();
- rangeLogQuery.remove("start");
- rangeLogQuery.remove("rows");
- logIdQuery.setStart(start);
- logIdQuery.setRows(searchCriteria.getMaxRows());
- VSolrLogList vSolrLogList = getLogAsPaginationProvided(logIdQuery, serviceLogsSolrDao);
- return convertObjToString(vSolrLogList);
-
- } catch (Exception e) {
- //do nothing
- }
-
- } else {
- try {
- int currentPageNumber = searchCriteria.getPage();
- int maxRows = searchCriteria.getMaxRows();
-
- if (currentPageNumber == 0) {
- throw RESTErrorUtil.createRESTException("This is first Page Not",
- MessageEnums.DATA_NOT_FOUND);
- }
-
- int firstLogCurrentPage = (currentPageNumber * maxRows);
- String lastLogsLogTime = "";
-
- // Next Page Start Time Calculation
- SolrQuery lastLogTime = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- lastLogTime.remove("start");
- lastLogTime.remove("rows");
-
- lastLogTime.setStart(firstLogCurrentPage);
- lastLogTime.setRows(1);
-
- queryResponse = serviceLogsSolrDao.process(
- lastLogTime);
- if(queryResponse == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocumentList docList = queryResponse.getResults();
- if(docList ==null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
- SolrDocument solrDoc = docList.get(0);
-
- Date logDate = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
- String sortByType = searchCriteria.getSortType();
- lastLogsLogTime = DateUtil
- .convertDateWithMillisecondsToSolrDate(logDate);
- String lastLogsLogId = ""
- + solrDoc.get(LogSearchConstants.ID);
-
-
- String filterQueryListIds = "";
- // Remove the same Time Ids
- SolrQuery listRemoveIds = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- listRemoveIds.remove("start");
- listRemoveIds.remove("rows");
- queryGenerator.setSingleIncludeFilter(listRemoveIds,
- LogSearchConstants.LOGTIME, "\"" + lastLogsLogTime + "\"");
- queryGenerator.setSingleExcludeFilter(listRemoveIds,
- LogSearchConstants.ID, lastLogsLogId);
- SolrUtil.setFl(listRemoveIds, LogSearchConstants.ID);
- queryResponse = serviceLogsSolrDao.process(
- lastLogTime);
- if(queryResponse == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocumentList docListIds = queryResponse.getResults();
- if(docListIds == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
- boolean isFirst = true;
- for (SolrDocument solrDocId : docListIds) {
- if (solrDocId != null) {
- String id = "" + solrDocId.get(LogSearchConstants.ID);
- if (isFirst) {
- filterQueryListIds += LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":" + id;
- isFirst = false;
- } else {
- filterQueryListIds += " "+CONDITION.AND+" " + LogSearchConstants.MINUS_OPERATOR + LogSearchConstants.ID + ":"
- + id;
- }
- }
- }
-
-
- // Keyword LogTime Calculation
- String endTime = (String) searchCriteria.getParamValue("to");
- String startTime = (String) searchCriteria
- .getParamValue("from");
- SolrQuery logTimeThroughRangeQuery = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- logTimeThroughRangeQuery.remove("start");
- logTimeThroughRangeQuery.remove("rows");
- logTimeThroughRangeQuery.setRows(1);
- queryGenerator.setSingleExcludeFilter(logTimeThroughRangeQuery,
- LogSearchConstants.ID, lastLogsLogId);
- if (!StringUtils.isBlank(filterQueryListIds)){
- logTimeThroughRangeQuery.setFilterQueries(filterQueryListIds);
- }
-
- if (!StringUtils.isBlank(sortByType) && sortByType
- .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
-
- logTimeThroughRangeQuery.remove(LogSearchConstants.SORT);
- logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
- LogSearchConstants.LOGTIME + " "
- + LogSearchConstants.DESCENDING_ORDER);
-
-
- queryGenerator.setSingleRangeFilter(
- logTimeThroughRangeQuery,
- LogSearchConstants.LOGTIME, startTime,
- lastLogsLogTime);
-
- } else {
-
- logTimeThroughRangeQuery.remove(LogSearchConstants.SORT);
- logTimeThroughRangeQuery.set(LogSearchConstants.SORT,
- LogSearchConstants.LOGTIME + " "
- + LogSearchConstants.ASCENDING_ORDER);
-
-
- queryGenerator.setSingleRangeFilter(logTimeThroughRangeQuery,
- LogSearchConstants.LOGTIME, lastLogsLogTime, endTime);
- }
- queryGenerator.setSingleIncludeFilter(logTimeThroughRangeQuery,
- LogSearchConstants.SOLR_KEY_LOG_MESSAGE, keyword);
-
-
- queryResponse = serviceLogsSolrDao.process(
- logTimeThroughRangeQuery);
- if(queryResponse == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- SolrDocumentList documentList = queryResponse.getResults();
- if(documentList == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
- SolrDocument solrDocument = new SolrDocument();
- if (!documentList.isEmpty()){
- solrDocument = documentList.get(0);
- }
-
- Date keywordLogDate = (Date) solrDocument.get(LogSearchConstants.LOGTIME);
- if(keywordLogDate == null){
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
- String originalKeywordDate = DateUtil
- .convertDateWithMillisecondsToSolrDate(keywordLogDate);
- String keywordId = "" + solrDocument.get(LogSearchConstants.ID);
-
- // Getting Range Count from StartTime To Keyword Log Time
- SolrQuery rangeLogQuery = lastLogTime.getCopy();
- rangeLogQuery.remove("start");
- rangeLogQuery.remove("rows");
-
- if (!StringUtils.isBlank(sortByType) && sortByType
- .equalsIgnoreCase(LogSearchConstants.ASCENDING_ORDER)) {
- // keywordLogDate = DateUtil.addMilliSecondsToDate(keywordLogDate, 1);
- String keywordDateTime = DateUtil
- .convertDateWithMillisecondsToSolrDate(keywordLogDate);
- queryGenerator.setSingleRangeFilter(rangeLogQuery,
- LogSearchConstants.LOGTIME, startTime,
- keywordDateTime);
-
-
- } else {
- // keywordLogDate = DateUtil.addMilliSecondsToDate(keywordLogDate, -1);
- String keywordDateTime = DateUtil
- .convertDateWithMillisecondsToSolrDate(keywordLogDate);
- queryGenerator.setSingleRangeFilter(rangeLogQuery,
- LogSearchConstants.LOGTIME, keywordDateTime,
- endTime);
- }
-
-
- long countNumberLogs = countQuery(rangeLogQuery,serviceLogsSolrDao) - 1;
-
- //Adding numbers on
- try {
- SolrQuery sameIdQuery = queryGenerator
- .commonServiceFilterQuery(searchCriteria);
- queryGenerator.setSingleIncludeFilter(sameIdQuery,
- LogSearchConstants.LOGTIME, "\"" + originalKeywordDate + "\"");
- SolrUtil.setFl(sameIdQuery, LogSearchConstants.ID);
- SolrDocumentList sameQueryDocList = serviceLogsSolrDao.process(sameIdQuery)
- .getResults();
- for (SolrDocument solrDocumenent : sameQueryDocList) {
- if (solrDocumenent != null) {
- String id = (String) solrDocumenent
- .getFieldValue(LogSearchConstants.ID);
- countNumberLogs++;
- if ( StringUtils.isBlank(id) && id.equals(keywordId)) {
- break;
- }
- }
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error(e);
- }
- int start = (int) ((countNumberLogs / maxRows) * maxRows);
-
- SolrQuery logIdQuery = lastLogTime.getCopy();
- rangeLogQuery.remove("start");
- rangeLogQuery.remove("rows");
- logIdQuery.setStart(start);
- logIdQuery.setRows(searchCriteria.getMaxRows());
- VSolrLogList vSolrLogList = getLogAsPaginationProvided(logIdQuery, serviceLogsSolrDao);
- return convertObjToString(vSolrLogList);
- } catch (Exception e) {
- //do nothing
- }
-
- }
- throw RESTErrorUtil.createRESTException("The keyword "+"\""+key+"\""+" was not found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- private String getPageByLogId(SearchCriteria searchCriteria) {
- VSolrLogList vSolrLogList = new VSolrLogList();
- String endLogTime = (String) searchCriteria.getParamValue("to");
- if(StringUtils.isBlank(endLogTime)){
- return convertObjToString(vSolrLogList);
- }
- long startIndex = 0l;
-
- String logId = (String) searchCriteria.getParamValue("sourceLogId");
- if(StringUtils.isBlank(logId)){
- return convertObjToString(vSolrLogList);
- }
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
-
- String endTimeMinusOneMilli = "";
- String logTime = "";
- try {
-
- SolrQuery logTimeByIdQuery = new SolrQuery();
- SolrUtil.setMainQuery(logTimeByIdQuery, null);
- queryGenerator.setSingleIncludeFilter(logTimeByIdQuery,
- LogSearchConstants.ID, logId);
- SolrUtil.setRowCount(solrQuery, 1);
-
- QueryResponse queryResponse = serviceLogsSolrDao
- .process(logTimeByIdQuery);
-
- if(queryResponse == null){
- return convertObjToString(new VSolrLogList());
- }
-
- SolrDocumentList docList = queryResponse.getResults();
- Date dateOfLogId = null;
- if (docList != null && !docList.isEmpty()) {
- SolrDocument dateLogIdDoc = docList.get(0);
- if(dateLogIdDoc != null){
- dateOfLogId = (Date) dateLogIdDoc.get(LogSearchConstants.LOGTIME);
- }
- }
-
- if (dateOfLogId != null) {
- logTime = DateUtil.convertDateWithMillisecondsToSolrDate(dateOfLogId);
- Date endDate = DateUtils.addMilliseconds(dateOfLogId, 1);
- endTimeMinusOneMilli = (String) DateUtil
- .convertDateWithMillisecondsToSolrDate(endDate);
- }
-
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error(e);
- }
-
- try {
- solrQuery.remove(LogSearchConstants.ID);
- solrQuery.remove(LogSearchConstants.LOGTIME);
- queryGenerator.setSingleRangeFilter(solrQuery,
- LogSearchConstants.LOGTIME, endTimeMinusOneMilli, endLogTime);
- SolrUtil.setRowCount(solrQuery, 0);
- startIndex = countQuery(solrQuery,serviceLogsSolrDao);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error(e);
- }
-
- try {
- SolrQuery sameIdQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- queryGenerator.setSingleIncludeFilter(sameIdQuery,
- LogSearchConstants.LOGTIME, "\"" + logTime + "\"");
- sameIdQuery.set("fl", LogSearchConstants.ID);
-
- QueryResponse sameIdResponse = serviceLogsSolrDao.process(sameIdQuery);
- SolrDocumentList docList = sameIdResponse.getResults();
-
- for (SolrDocument solrDocumenent : docList) {
- String id = (String) solrDocumenent
- .getFieldValue(LogSearchConstants.ID);
- startIndex++;
- if (!StringUtils.isBlank(id)) {
- if (id.equals(logId)) {
- break;
- }
- }
- }
-
- SolrQuery logIdQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- logIdQuery.remove("rows");
- logIdQuery.remove("start");
- int start = (int) ((startIndex / searchCriteria.getMaxRows()) * searchCriteria
- .getMaxRows());
- logIdQuery.setStart(start);
- logIdQuery.setRows(searchCriteria.getMaxRows());
- vSolrLogList = getLogAsPaginationProvided(logIdQuery,
- serviceLogsSolrDao);
- return convertObjToString(vSolrLogList);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error(e);
- }
-
- throw RESTErrorUtil.createRESTException("LogId not Found",
- MessageEnums.ERROR_SYSTEM);
- }
-
- @SuppressWarnings("unchecked")
- public List<VNameValue> getHistogramCounts(SolrQuery solrQuery,
- String from, String to, String unit) {
- List<VNameValue> logsCounts = new ArrayList<VNameValue>();
- try {
-
- SolrUtil.setFacetRange(solrQuery, LogSearchConstants.LOGTIME,
- from, to, unit);
-
- List<RangeFacet.Count> logLevelCounts = null;
-
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if(response == null){
- return logsCounts;
- }
- @SuppressWarnings("rawtypes")
- List<RangeFacet> rangeFacetList = response.getFacetRanges();
- if (rangeFacetList == null) {
- return logsCounts;
-
- }
-
- @SuppressWarnings("rawtypes")
- RangeFacet rangeFacet=rangeFacetList.get(0);
- if (rangeFacet == null) {
- return logsCounts;
- }
- logLevelCounts = rangeFacet.getCounts();
-
- if(logLevelCounts == null){
- return logsCounts;
- }
- for (RangeFacet.Count logCount : logLevelCounts) {
- VNameValue nameValue = new VNameValue();
- nameValue.setName(logCount.getValue());
- nameValue.setValue("" + logCount.getCount());
- logsCounts.add(nameValue);
- }
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- }
- return logsCounts;
- }
-
- public List<Count> getFacetCountsByDate(SolrQuery solrQuery,
- String facetField) throws SolrServerException, IOException,
- SolrException {
-
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-
- FacetField field = response.getFacetDate(facetField);
- return field.getValues();
- }
-
- @SuppressWarnings("unchecked")
- public String getHistogramData(SearchCriteria searchCriteria) {
- String deafalutValue = "0";
- VBarDataList dataList = new VBarDataList();
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- solrQuery.set("event", "/audit/logs/histogram");
- String from = getFrom((String) searchCriteria.getParamValue("from"));
- String to = getTo((String) searchCriteria.getParamValue("to"));
- String unit = getUnit((String) searchCriteria.getParamValue("unit"));
-
- List<VBarGraphData> histogramData = new ArrayList<VBarGraphData>();
-
- String jsonHistogramQuery = queryGenerator
- .buildJSONFacetTermTimeRangeQuery(
- LogSearchConstants.SOLR_LEVEL,
- LogSearchConstants.LOGTIME, from, to, unit).replace(
- "\\", "");
-
- try {
- SolrUtil.setJSONFacet(solrQuery, jsonHistogramQuery);
- SolrUtil.setRowCount(solrQuery,Integer.parseInt(deafalutValue));
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if (response == null){
- return convertObjToString(dataList);
- }
- SimpleOrderedMap<Object> jsonFacetResponse = (SimpleOrderedMap<Object>) response
- .getResponse().get("facets");
-
- if (jsonFacetResponse == null
- || jsonFacetResponse.toString().equals("{count=0}")){
- return convertObjToString(dataList);
- }
-
- extractValuesFromBuckets(jsonFacetResponse, "x", "y", histogramData);
-
- Collection<VNameValue> vNameValues = new ArrayList<VNameValue>();
- List<VBarGraphData> graphDatas = new ArrayList<VBarGraphData>();
- for (String level : LogSearchConstants.SUPPORTED_LOG_LEVEL) {
- boolean isLevelPresent = false;
- VBarGraphData vData1 = null;
- for (VBarGraphData vData2 : histogramData) {
- String name = vData2.getName();
- if (level.contains(name)) {
- isLevelPresent = true;
- vData1 = vData2;
- break;
- }
- if (vNameValues.isEmpty()) {
- Collection<VNameValue> vNameValues2 = vData2
- .getDataCount();
- for (VNameValue value : vNameValues2) {
- VNameValue value2 = new VNameValue();
- value2.setValue(deafalutValue);
- value2.setName(value.getName());
- vNameValues.add(value2);
- }
- }
- }
- if (!isLevelPresent) {
- VBarGraphData vBarGraphData = new VBarGraphData();
- vBarGraphData.setName(level);
- vBarGraphData.setDataCounts(vNameValues);
- graphDatas.add(vBarGraphData);
- } else {
- graphDatas.add(vData1);
- }
- }
-
- dataList.setGraphData(graphDatas);
- return convertObjToString(dataList);
-
- } catch (SolrServerException | SolrException | IOException e) {
- logger.error(e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
-
- }
- }
-
- public void arrangeLevel(String level,
- List<VBarGraphData> histogramDataLocal,
- List<VBarGraphData> histogramData) {
- for (VBarGraphData histData : histogramData) {
- if (histData != null && level.equals(histData.getName())) {
- histogramDataLocal.add(histData);
- }
- }
- }
-
- public String cancelFindRequestByDate(String uniqueId) {
- if (StringUtils.isEmpty(uniqueId)) {
- logger.error("Unique id is Empty");
- throw RESTErrorUtil.createRESTException("Unique id is Empty",
- MessageEnums.DATA_NOT_FOUND);
- }
-
- if (cancelByDate.remove(uniqueId)) {
- mapUniqueId.remove(uniqueId);
- return "Cancel Request Successfully Procssed ";
- }
- return "Cancel Request Unable to Process";
- }
-
- public boolean cancelRequest(String uniqueId) {
- if (StringUtils.isBlank(uniqueId)) {
- logger.error("Unique id is Empty");
- throw RESTErrorUtil.createRESTException("Unique id is Empty",
- MessageEnums.DATA_NOT_FOUND);
- }
- for (String date : cancelByDate) {
- if (uniqueId.equalsIgnoreCase(date)){
- return false;
- }
- }
- return true;
- }
-
- public Response exportToTextFile(SearchCriteria searchCriteria) {
- String defaultFormat = "text";
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- String from = (String) searchCriteria.getParamValue("from");
- String to = (String) searchCriteria.getParamValue("to");
- String utcOffset = (String) searchCriteria.getParamValue("utcOffset");
- String format = (String) searchCriteria.getParamValue("format");
-
- format = defaultFormat.equalsIgnoreCase(format) && format != null ? ".txt"
- : ".json";
-
- if(StringUtils.isBlank(utcOffset)){
- utcOffset = "0";
- }
-
- if (!DateUtil.isDateValid(from) || !DateUtil.isDateValid(to)) {
- logger.error("Not valid date format. Valid format should be"
- + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z);
- throw RESTErrorUtil.createRESTException("Not valid date format. Valid format should be"
- + LogSearchConstants.SOLR_DATE_FORMAT_PREFIX_Z,
- MessageEnums.INVALID_INPUT_DATA);
-
- } else {
- from = from.replace("T", " ");
- from = from.replace(".", ",");
-
- to = to.replace("T", " ");
- to = to.replace(".", ",");
-
- to = DateUtil.addOffsetToDate(to, Long.parseLong(utcOffset),
- "yyyy-MM-dd HH:mm:ss,SSS");
- from = DateUtil.addOffsetToDate(from, Long.parseLong(utcOffset),
- "yyyy-MM-dd HH:mm:ss,SSS");
- }
-
- String fileName = DateUtil.getCurrentDateInString();
- if (searchCriteria.getParamValue("hostLogFile") != null
- && searchCriteria.getParamValue("compLogFile") != null) {
- fileName = searchCriteria.getParamValue("hostLogFile") + "_"
- + searchCriteria.getParamValue("compLogFile");
- }
-
- String textToSave = "";
- try {
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if (response == null) {
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- SolrDocumentList docList = response.getResults();
- if (docList == null) {
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
-
- VSummary vsummary = BizUtil.buildSummaryForLogFile(docList);
- vsummary.setFormat(format);
- vsummary.setFrom(from);
- vsummary.setTo(to);
-
- String includeString = (String) searchCriteria.getParamValue("iMessage");
- if (StringUtils.isBlank(includeString)) {
- includeString = "";
- }
-
- String include[] = includeString.split(LogSearchConstants.I_E_SEPRATOR);
-
- for (String inc : include) {
- includeString = includeString + ",\"" + inc + "\"";
- }
- includeString = includeString.replaceFirst(",", "");
- if (!StringUtils.isBlank(includeString)) {
- vsummary.setIncludeString(includeString);
- }
-
- String excludeString = null;
- boolean isNormalExcluded = false;
-
- excludeString = (String) searchCriteria.getParamValue("eMessage");
- if (StringUtils.isBlank(excludeString)) {
- excludeString = "";
- }
-
- String exclude[] = excludeString.split(LogSearchConstants.I_E_SEPRATOR);
- for (String exc : exclude) {
- excludeString = excludeString + ",\"" + exc + "\"";
- }
-
- excludeString = excludeString.replaceFirst(",", "");
- if (!StringUtils.isBlank(excludeString)) {
- vsummary.setExcludeString(excludeString);
- isNormalExcluded = true;
- }
-
- String globalExcludeString = (String) searchCriteria
- .getParamValue("gEMessage");
- if (StringUtils.isBlank(globalExcludeString)) {
- globalExcludeString = "";
- }
-
- String globalExclude[] = globalExcludeString
- .split(LogSearchConstants.I_E_SEPRATOR);
-
- for (String exc : globalExclude) {
- excludeString = excludeString + ",\"" + exc + "\"";
- }
-
- if (!StringUtils.isBlank(excludeString)) {
- if (!isNormalExcluded) {
- excludeString = excludeString.replaceFirst(",", "");
- }
- vsummary.setExcludeString(excludeString);
- }
-
- for (SolrDocument solrDoc : docList) {
-
- Date logTimeDateObj = (Date) solrDoc.get(LogSearchConstants.LOGTIME);
- if(logTimeDateObj != null){
- String logTime = DateUtil.convertSolrDateToNormalDateFormat(
- logTimeDateObj.getTime(), Long.parseLong(utcOffset));
- solrDoc.remove(LogSearchConstants.LOGTIME);
- solrDoc.addField(LogSearchConstants.LOGTIME, logTime);
- }
- }
-
- if (format.toLowerCase(Locale.ENGLISH).equals(".txt")) {
- textToSave = BizUtil.convertObjectToNormalText(docList);
- } else if (format.toLowerCase(Locale.ENGLISH).equals(".json")) {
- textToSave = convertObjToString(docList);
- } else {
- throw RESTErrorUtil.createRESTException(
- "unsoported format either should be json or text",
- MessageEnums.ERROR_SYSTEM);
- }
- return FileUtil.saveToFile(textToSave, fileName, vsummary);
-
- } catch (SolrException | SolrServerException | IOException
- | ParseException e) {
- logger.error("Error during solrQuery=" + solrQuery, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- public String getComponentListWithLevelCounts(SearchCriteria searchCriteria) {
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- solrQuery.setParam("event", "/service/logs/components/level/counts");
-
- if (searchCriteria.getSortBy() == null) {
- searchCriteria.setSortBy(LogSearchConstants.SOLR_COMPONENT);
- searchCriteria.setSortType(SolrQuery.ORDER.asc.toString());
- }
- queryGenerator.setFilterFacetSort(solrQuery, searchCriteria);
- String componentLevelHirachy = "type,level";
- VNodeList list = new VNodeList();
- try {
-
- SolrUtil.setFacetPivot(solrQuery, 1, componentLevelHirachy);
-
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-
- List<List<PivotField>> listPivotField = new ArrayList<List<PivotField>>();
- NamedList<List<PivotField>> namedList = response.getFacetPivot();
- if (namedList != null) {
- listPivotField = namedList.getAll(componentLevelHirachy);
- }
- List<PivotField> secondHirarchicalPivotFields = null;
- if (listPivotField == null || listPivotField.isEmpty()) {
- return convertObjToString(list);
- } else {
- secondHirarchicalPivotFields = listPivotField.get(0);
- }
- List<VNode> datatList = new ArrayList<VNode>();
- for (PivotField singlePivotField : secondHirarchicalPivotFields) {
- if (singlePivotField != null) {
- VNode comp = new VNode();
- comp.setName("" + singlePivotField.getValue());
- List<PivotField> levelList = singlePivotField.getPivot();
- List<VNameValue> levelCountList = new ArrayList<VNameValue>();
- comp.setLogLevelCount(levelCountList);
- if(levelList != null){
- for (PivotField levelPivot : levelList) {
- VNameValue level = new VNameValue();
- level.setName(("" + levelPivot.getValue()).toUpperCase());
- level.setValue("" + levelPivot.getCount());
- levelCountList.add(level);
- }
- }
- datatList.add(comp);
- }
- }
- list.setvNodeList(datatList);
- return convertObjToString(list);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error(e.getMessage() + "SolrQuery"+solrQuery);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- public String getExtremeDatesForBundelId(SearchCriteria searchCriteria) {
- SolrQuery solrQuery = new SolrQuery();
- VNameValueList nameValueList = new VNameValueList();
- try {
- String bundelId = (String) searchCriteria
- .getParamValue(LogSearchConstants.BUNDLE_ID);
- if(StringUtils.isBlank(bundelId)){
- bundelId = "";
- }
-
- queryGenerator.setSingleIncludeFilter(solrQuery,
- LogSearchConstants.BUNDLE_ID, bundelId);
-
- SolrUtil.setMainQuery(solrQuery, null);
- solrQuery.setSort(LogSearchConstants.LOGTIME, SolrQuery.ORDER.asc);
- SolrUtil.setRowCount(solrQuery, 1);
-
- List<VNameValue> vNameValues = new ArrayList<VNameValue>();
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
-
- if(response == null){
- return convertObjToString(nameValueList);
- }
-
- SolrDocumentList solrDocList = response.getResults();
- if(solrDocList == null){
- return convertObjToString(nameValueList);
- }
- for (SolrDocument solrDoc : solrDocList) {
-
- Date logTimeAsc = (Date) solrDoc
- .getFieldValue(LogSearchConstants.LOGTIME);
- if (logTimeAsc != null) {
- VNameValue nameValue = new VNameValue();
- nameValue.setName("From");
- nameValue.setValue("" + logTimeAsc.getTime());
- vNameValues.add(nameValue);
- }
- }
-
- solrQuery.clear();
- SolrUtil.setMainQuery(solrQuery, null);
- queryGenerator.setSingleIncludeFilter(solrQuery,
- LogSearchConstants.BUNDLE_ID, bundelId);
- solrQuery.setSort(LogSearchConstants.LOGTIME, SolrQuery.ORDER.desc);
- SolrUtil.setRowCount(solrQuery, 1);
-
- solrDocList.clear();
- response = serviceLogsSolrDao.process(solrQuery);
-
- solrDocList = response.getResults();
- for (SolrDocument solrDoc : solrDocList) {
- if (solrDoc != null) {
- Date logTimeDesc = (Date) solrDoc
- .getFieldValue(LogSearchConstants.LOGTIME);
-
- if (logTimeDesc != null) {
- VNameValue nameValue = new VNameValue();
- nameValue.setName("To");
- nameValue.setValue("" + logTimeDesc.getTime());
- vNameValues.add(nameValue);
- }
- }
- }
- nameValueList.setVNameValues(vNameValues);
-
-
- } catch (SolrServerException | SolrException | IOException e) {
- logger.error(e.getMessage() + "SolrQuery"+solrQuery);
- nameValueList=new VNameValueList();
- }
- return convertObjToString(nameValueList);
- }
-
- protected VGroupList getSolrGroupList(SolrQuery query)
- throws SolrServerException, IOException, SolrException {
- VGroupList collection = new VGroupList();
- QueryResponse response = serviceLogsSolrDao.process(query);
- if (response == null) {
- return collection;
- }
- SolrDocumentList docList = response.getResults();
- if (docList != null) {
- collection.setGroupDocuments(docList);
- collection.setStartIndex((int) docList.getStart());
- collection.setTotalCount(docList.getNumFound());
- }
-
- return collection;
- }
-
- public String getServiceLogsFieldsName() {
- String fieldsNameStrArry[] = PropertiesHelper
- .getPropertyStringList("logsearch.service.logs.fields");
- if (fieldsNameStrArry.length > 0) {
-
- List<String> uiFieldNames = new ArrayList<String>();
- String temp = null;
- for (String field : fieldsNameStrArry) {
- temp = ConfigHelper.serviceLogsColumnMapping.get(field
- + LogSearchConstants.SOLR_SUFFIX);
- if (temp == null){
- uiFieldNames.add(field);
- }else{
- uiFieldNames.add(temp);
- }
- }
- return convertObjToString(uiFieldNames);
-
- }
- throw RESTErrorUtil.createRESTException(
- "No field name found in property file",
- MessageEnums.DATA_NOT_FOUND);
-
- }
-
- public String getServiceLogsSchemaFieldsName() {
-
- List<String> fieldNames = new ArrayList<String>();
- String excludeArray[] = PropertiesHelper
- .getPropertyStringList("logsearch.solr.service.logs.exclude.columnlist");
-
- HashMap<String, String> uiFieldColumnMapping = new LinkedHashMap<String, String>();
- ConfigHelper.getSchemaFieldsName(excludeArray, fieldNames,serviceLogsSolrDao);
-
- for (String fieldName : fieldNames) {
- String uiField = ConfigHelper.serviceLogsColumnMapping.get(fieldName
- + LogSearchConstants.SOLR_SUFFIX);
- if (uiField != null) {
- uiFieldColumnMapping.put(fieldName, uiField);
- } else {
- uiFieldColumnMapping.put(fieldName, fieldName);
- }
- }
-
- HashMap<String, String> uiFieldColumnMappingSorted = new LinkedHashMap<String, String>();
- uiFieldColumnMappingSorted.put(LogSearchConstants.SOLR_LOG_MESSAGE, LogSearchConstants.SOLR_LOG_MESSAGE);
-
- Iterator<Entry<String, String>> it = BizUtil
- .sortHashMapByValues(uiFieldColumnMapping).entrySet().iterator();
- while (it.hasNext()) {
- @SuppressWarnings("rawtypes")
- Map.Entry pair = (Map.Entry) it.next();
- uiFieldColumnMappingSorted.put("" + pair.getKey(), "" + pair.getValue());
- }
-
- return convertObjToString(uiFieldColumnMappingSorted);
-
- }
-
- @SuppressWarnings("unchecked")
- public void extractValuesFromBuckets(
- SimpleOrderedMap<Object> jsonFacetResponse, String outerField,
- String innerField, List<VBarGraphData> histogramData) {
- NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse
- .get(outerField);
- ArrayList<Object> stackBuckets = (ArrayList<Object>) stack
- .get("buckets");
- for (Object temp : stackBuckets) {
- VBarGraphData vBarGraphData = new VBarGraphData();
-
- SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
- String name = ((String) level.getVal(0)).toUpperCase();
- vBarGraphData.setName(name);
-
- Collection<VNameValue> vNameValues = new ArrayList<VNameValue>();
- vBarGraphData.setDataCounts(vNameValues);
- ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level
- .get(innerField)).get("buckets");
- for (Object temp1 : levelBuckets) {
- SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
- String value = DateUtil
- .convertDateWithMillisecondsToSolrDate((Date) countValue
- .getVal(0));
-
- String count = "" + countValue.getVal(1);
- VNameValue vNameValue = new VNameValue();
- vNameValue.setName(value);
- vNameValue.setValue(count);
- vNameValues.add(vNameValue);
- }
- histogramData.add(vBarGraphData);
- }
- }
-
- public String getAnyGraphData(SearchCriteria searchCriteria) {
- searchCriteria.addParam("fieldTime", LogSearchConstants.LOGTIME);
- SolrQuery solrQuery = queryGenerator.commonServiceFilterQuery(searchCriteria);
- VBarDataList result = graphDataGenerator.getAnyGraphData(searchCriteria,
- serviceLogsSolrDao, solrQuery);
- if (result == null) {
- result = new VBarDataList();
- }
- return convertObjToString(result);
-
- }
-
- public String getAfterBeforeLogs(SearchCriteria searchCriteria) {
- VSolrLogList vSolrLogList = new VSolrLogList();
- SolrDocumentList docList = null;
- String id = (String) searchCriteria
- .getParamValue(LogSearchConstants.ID);
- if (StringUtils.isBlank(id)) {
- return convertObjToString(vSolrLogList);
-
- }
- String maxRows = "";
-
- maxRows = (String) searchCriteria.getParamValue("numberRows");
- if (StringUtils.isBlank(maxRows)){
- maxRows = ""+maxRows;
- }
- String scrollType = (String) searchCriteria.getParamValue("scrollType");
- if(StringUtils.isBlank(scrollType)){
- scrollType = "";
- }
-
- String logTime = null;
- String sequenceId = null;
- try {
- SolrQuery solrQuery = new SolrQuery();
- SolrUtil.setMainQuery(solrQuery,
- queryGenerator.buildFilterQuery(LogSearchConstants.ID, id));
- SolrUtil.setRowCount(solrQuery, 1);
- QueryResponse response = serviceLogsSolrDao.process(solrQuery);
- if(response == null){
- return convertObjToString(vSolrLogList);
- }
- docList = response.getResults();
- if (docList != null && !docList.isEmpty()) {
- Date date = (Date) docList.get(0).getFieldValue(
- LogSearchConstants.LOGTIME);
- logTime = DateUtil.convertDateWithMillisecondsToSolrDate(date);
- sequenceId = ""
- + docList.get(0).getFieldValue(
- LogSearchConstants.SEQUNCE_ID);
- }
- if (StringUtils.isBlank(logTime)) {
- return convertObjToString(vSolrLogList);
- }
- } catch (SolrServerException | SolrException | IOException e) {
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR
- .getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType)) {
- vSolrLogList = whenScrollUp(searchCriteria, logTime,
- sequenceId, maxRows);
-
- SolrDocumentList solrDocList = new SolrDocumentList();
- for (SolrDocument solrDoc : vSolrLogList.getList()) {
- solrDocList.add(solrDoc);
- }
- vSolrLogList.setSolrDocuments(solrDocList);
- return convertObjToString(vSolrLogList);
-
- } else if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
- SolrDocumentList solrDocList = new SolrDocumentList();
- vSolrLogList = new VSolrLogList();
- for (SolrDocument solrDoc : whenScrollDown(searchCriteria, logTime,
- sequenceId, maxRows).getList()) {
- solrDocList.add(solrDoc);
- }
- vSolrLogList.setSolrDocuments(solrDocList);
- return convertObjToString(vSolrLogList);
-
- } else {
- vSolrLogList = new VSolrLogList();
- SolrDocumentList initial = new SolrDocumentList();
- SolrDocumentList before = whenScrollUp(searchCriteria, logTime,
- sequenceId, maxRows).getList();
- SolrDocumentList after = whenScrollDown(searchCriteria, logTime,
- sequenceId, maxRows).getList();
- if (before != null && !before.isEmpty()) {
- for (SolrDocument solrDoc : Lists.reverse(before)) {
- initial.add(solrDoc);
- }
- }
-
- initial.add(docList.get(0));
- if (after != null && !after.isEmpty()){
- for (SolrDocument solrDoc : after) {
- initial.add(solrDoc);
- }
- }
-
- vSolrLogList.setSolrDocuments(initial);
-
- return convertObjToString(vSolrLogList);
-
- }
- }
-
- private VSolrLogList whenScrollUp(SearchCriteria searchCriteria,
- String logTime, String sequenceId, String maxRows) {
- SolrQuery solrQuery = new SolrQuery();
- SolrUtil.setMainQuery(solrQuery, null);
- /*queryGenerator.setSingleExcludeFilter(solrQuery,
- LogSearchConstants.SEQUNCE_ID, sequenceId);*/
- try {
- int seq_num = Integer.parseInt(sequenceId) - 1;
- sequenceId = "" + seq_num;
- } catch (Exception e) {
-
- }
- queryGenerator.setSingleRangeFilter(
- solrQuery,
- LogSearchConstants.SEQUNCE_ID, "*", sequenceId);
-
- queryGenerator.applyLogFileFilter(solrQuery, searchCriteria);
-
- queryGenerator.setSingleRangeFilter(solrQuery,
- LogSearchConstants.LOGTIME, "*", logTime);
- SolrUtil.setRowCount(solrQuery, Integer.parseInt(maxRows));
- String order1 = LogSearchConstants.LOGTIME + " "
- + LogSearchConstants.DESCENDING_ORDER;
- String order2 = LogSearchConstants.SEQUNCE_ID + " "
- + LogSearchConstants.DESCENDING_ORDER;
- List<String> sortOrder = new ArrayList<String>();
- sortOrder.add(order1);
- sortOrder.add(order2);
- searchCriteria.addParam(LogSearchConstants.SORT, sortOrder);
- queryGenerator.setMultipleSortOrder(solrQuery, searchCriteria);
-
- return getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao);
- }
-
- private VSolrLogList whenScrollDown(SearchCriteria searchCriteria,
- String logTime, String sequenceId, String maxRows) {
- SolrQuery solrQuery = new SolrQuery();
- SolrUtil.setMainQuery(solrQuery, null);
- queryGenerator.applyLogFileFilter(solrQuery, searchCriteria);
-
- /*queryGenerator.setSingleExcludeFilter(solrQuery,
- LogSearchConstants.SEQUNCE_ID, sequenceId);*/
- try {
- int seq_num = Integer.parseInt(sequenceId) + 1;
- sequenceId = "" + seq_num;
- } catch (Exception e) {
-
- }
- queryGenerator.setSingleRangeFilter(
- solrQuery,
- LogSearchConstants.SEQUNCE_ID, sequenceId, "*");
- queryGenerator.setSingleRangeFilter(solrQuery,
- LogSearchConstants.LOGTIME, logTime, "*");
- SolrUtil.setRowCount(solrQuery, Integer.parseInt(maxRows));
-
- String order1 = LogSearchConstants.LOGTIME + " "
- + LogSearchConstants.ASCENDING_ORDER;
- String order2 = LogSearchConstants.SEQUNCE_ID + " "
- + LogSearchConstants.ASCENDING_ORDER;
- List<String> sortOrder = new ArrayList<String>();
- sortOrder.add(order1);
- sortOrder.add(order2);
- searchCriteria.addParam(LogSearchConstants.SORT, sortOrder);
- queryGenerator.setMultipleSortOrder(solrQuery, searchCriteria);
-
- return getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao);
- }
-
- @Scheduled(cron = "${logsearch.solr.warming.cron}")
- public void warmingSolrServer(){
- logger.info("solr warming triggered.");
- SolrQuery solrQuery = new SolrQuery();
- TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
- GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
- utc.setTimeInMillis(new Date().getTime());
- utc.set(Calendar.HOUR, 0);
- utc.set(Calendar.MINUTE, 0);
- utc.set(Calendar.MILLISECOND, 001);
- utc.set(Calendar.SECOND, 0);
- DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
- String from = DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
- utc.set(Calendar.MILLISECOND, 999);
- utc.set(Calendar.SECOND, 59);
- utc.set(Calendar.MINUTE, 59);
- utc.set(Calendar.HOUR, 23);
- String to = DateUtil.convertDateWithMillisecondsToSolrDate(utc.getTime());
- queryGenerator.setSingleRangeFilter(solrQuery,
- LogSearchConstants.LOGTIME, from,to);
- String level = LogSearchConstants.FATAL+","+LogSearchConstants.ERROR+","+LogSearchConstants.WARN;
- queryGenerator.setFilterClauseWithFieldName(solrQuery, level,
- LogSearchConstants.SOLR_LEVEL, "", QueryGenerationBase.Condition.OR);
- try {
- serviceLogsSolrDao.process(solrQuery);
- } catch (SolrServerException | IOException e) {
- logger.error("Error while warming solr server",e);
- }
- }
-
-
-}
[05/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java
new file mode 100644
index 0000000..091194e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/SearchCriteria.java
@@ -0,0 +1,136 @@
+/*
+ * 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.query.model;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.ambari.logsearch.common.PropertiesHelper;
+
+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 HashMap<String, Object> paramList = new HashMap<String, Object>();
+
+ private Map<String, Object> urlParamMap = new HashMap<String, Object>();
+
+ public SearchCriteria() {
+ // Auto-generated constructor stub
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public int getMaxRows() {
+ return maxRows;
+ }
+
+ public void setMaxRows(int maxRows) {
+ this.maxRows = maxRows;
+ }
+
+ public String getSortType() {
+ return sortType;
+ }
+
+
+ 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 Object getParamValue(String name) {
+ return paramList.get(name);
+ }
+
+ public String getSortBy() {
+ return sortBy;
+ }
+
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ public void setSortType(String sortType) {
+ this.sortType = sortType;
+ }
+
+ 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/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
new file mode 100644
index 0000000..0ef5bdf
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceAnyGraphSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceAnyGraphSearchCriteria extends ServiceLogFileSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java
new file mode 100644
index 0000000..3fc6ff8
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceExtremeDatesCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceExtremeDatesCriteria extends CommonSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
new file mode 100644
index 0000000..31a57a4
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceGraphSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceGraphSearchCriteria extends ServiceLogFileSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
new file mode 100644
index 0000000..8bab7f0
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogExportSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogExportSearchCriteria extends ServiceLogFileSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java
new file mode 100644
index 0000000..a9f5926
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogFileSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogFileSearchCriteria extends CommonSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
new file mode 100644
index 0000000..d41c589
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogSearchCriteria extends ServiceLogFileSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
new file mode 100644
index 0000000..24dc9a8
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/ServiceLogTruncatedSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class ServiceLogTruncatedSearchCriteria extends ServiceLogFileSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.java
new file mode 100644
index 0000000..8798cd6
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserConfigSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class UserConfigSearchCriteria extends CommonSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java
new file mode 100644
index 0000000..755c673
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/UserExportSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class UserExportSearchCriteria extends FieldAuditLogSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java
deleted file mode 100644
index 3d99dc0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsREST.java
+++ /dev/null
@@ -1,283 +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.rest;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.manager.AuditMgr;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.*;
-import static org.apache.ambari.logsearch.doc.DocConstants.AuditOperationDescriptions.*;
-
-@Api(value = "audit/logs", description = "Audit log operations")
-@Path("audit/logs")
-@Component
-@Scope("request")
-public class AuditLogsREST {
-
- @Autowired
- AuditMgr auditMgr;
-
- @GET
- @Path("/schema/fields")
- @Produces({"application/json"})
- @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD)
- public String getSolrFieldList(@Context HttpServletRequest request) {
- return auditMgr.getAuditLogsSchemaFieldsName();
- }
-
- @GET
- @Produces({"application/json"})
- @ApiOperation(GET_AUDIT_LOGS_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = IS_LAST_PAGE_D, name = "isLastPage", dataType = "boolean", paramType = "query")
- })
- public String getAuditLogs(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredAuditLogsParams(request);
- searchCriteria.addParam("isLastPage", request.getParameter("isLastPage"));
- return auditMgr.getLogs(searchCriteria);
- }
-
- @GET
- @Path("/components")
- @Produces({"application/json"})
- @ApiOperation(GET_AUDIT_COMPONENTS_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- })
- public String getAuditComponents(@Context HttpServletRequest request) {
-
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addParam("q", request.getParameter("q"));
- return auditMgr.getAuditComponents(searchCriteria);
- }
-
- @GET
- @Path("/linegraph")
- @Produces({"application/json"})
- @ApiOperation(GET_AUDIT_LINE_GRAPH_DATA_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query")
- })
- public String getAuditLineGraphData(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredAuditLogsParams(request);
- searchCriteria.addParam("unit", request.getParameter("unit"));
- return auditMgr.getAuditLineGraphData(searchCriteria);
- }
-
- @GET
- @Path("/users")
- @Produces({"application/json"})
- @ApiOperation(GET_TOP_AUDIT_USERS_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query")
- })
- public String getTopAuditUsers(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredAuditLogsParams(request);
- searchCriteria.addParam("field", request.getParameter("field"));
- return auditMgr.topTenUsers(searchCriteria);
- }
-
- @GET
- @Path("/resources")
- @Produces({"application/json"})
- @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query")
- })
- public String getTopAuditResources(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredAuditLogsParams(request);
- searchCriteria.addParam("field", request.getParameter("field"));
- //return auditMgr.getTopAuditFieldCount(searchCriteria);
- return auditMgr.topTenResources(searchCriteria);
-
- }
-
- @GET
- @Path("/live/count")
- @Produces({"application/json"})
- @ApiOperation(GET_LIVE_LOGS_COUNT_OD)
- public String getLiveLogsCount() {
- return auditMgr.getLiveLogCounts();
- }
-
- @GET
- @Path("/request/user/linegraph")
- @Produces({"application/json"})
- @ApiOperation(GET_REQUEST_USER_LINE_GRAPH_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query")
- })
- public String getRequestUserLineGraph(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredAuditLogsParams(request);
- searchCriteria.addParam("field", request.getParameter("field"));
- searchCriteria.addParam("unit", request.getParameter("unit"));
- return auditMgr.getRequestUserLineGraph(searchCriteria);
- }
-
- @GET
- @Path("/anygraph")
- @Produces({"application/json"})
- @ApiOperation(GET_ANY_GRAPH_DATA_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = X_AXIS_D, name = "xAxis", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = Y_AXIS_D, name = "yAxis", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = STACK_BY_D, name = "stackBy", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query")
- })
- public String getAnyGraphData(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addParam("xAxis", request.getParameter("xAxis"));
- searchCriteria.addParam("yAxis", request.getParameter("yAxis"));
- searchCriteria.addParam("stackBy", request.getParameter("stackBy"));
- searchCriteria.addParam("from", request.getParameter("from"));
- searchCriteria.addParam("to", request.getParameter("to"));
- searchCriteria.addParam("unit", request.getParameter("unit"));
- return auditMgr.getAnyGraphData(searchCriteria);
- }
-
- @GET
- @Path("/users/export")
- @Produces({"application/json"})
- @ApiOperation(EXPORT_USER_TALBE_TO_TEXT_FILE_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FORMAT_D, name = "format", dataType = "string", paramType = "query")
- })
- public Response exportUserTableToTextFile(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredAuditLogsParams(request);
- searchCriteria.addParam("field", request.getParameter("field"));
- searchCriteria.addParam("format", request.getParameter("format"));
- return auditMgr.exportUserTableToTextFile(searchCriteria);
- }
-
- @GET
- @Path("/serviceload")
- @Produces({"application/json"})
- @ApiOperation(GET_SERVICE_LOAD_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"),
- })
- public String getServiceLoad(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addRequiredAuditLogsParams(request);
- return auditMgr.getServiceLoad(searchCriteria);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
new file mode 100644
index 0000000..82e21e8
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
@@ -0,0 +1,157 @@
+/*
+ * 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.rest;
+
+import javax.inject.Inject;
+import javax.ws.rs.BeanParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.ambari.logsearch.model.request.impl.AnyGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditBarGraphRequest;
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.SimpleQueryRequest;
+import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
+import org.apache.ambari.logsearch.model.response.AuditLogResponse;
+import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
+import org.apache.ambari.logsearch.model.response.GroupListResponse;
+import org.apache.ambari.logsearch.model.response.NameValueDataListResponse;
+import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria;
+import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
+import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
+import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
+import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
+import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
+import org.apache.ambari.logsearch.manager.AuditLogsManager;
+import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
+import org.springframework.context.annotation.Scope;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.stereotype.Component;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.AuditOperationDescriptions.*;
+
+@Api(value = "audit/logs", description = "Audit log operations")
+@Path("audit/logs")
+@Component
+@Scope("request")
+public class AuditLogsResource {
+
+ @Inject
+ private AuditLogsManager auditLogsManager;
+
+ @Inject
+ private ConversionService conversionService;
+
+ @GET
+ @Path("/schema/fields")
+ @Produces({"application/json"})
+ @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD)
+ public String getSolrFieldList() {
+ return auditLogsManager.getAuditLogsSchemaFieldsName();
+ }
+
+ @GET
+ @Produces({"application/json"})
+ @ApiOperation(GET_AUDIT_LOGS_OD)
+ public AuditLogResponse getAuditLogs(@BeanParam AuditLogRequest auditLogRequest) {
+ return auditLogsManager.getLogs(conversionService.convert(auditLogRequest, AuditLogSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/components")
+ @Produces({"application/json"})
+ @ApiOperation(GET_AUDIT_COMPONENTS_OD)
+ public GroupListResponse getAuditComponents(@BeanParam SimpleQueryRequest request) {
+ return auditLogsManager.getAuditComponents(conversionService.convert(request, SearchCriteria.class));
+ }
+
+ @GET
+ @Path("/bargraph")
+ @Produces({"application/json"})
+ @ApiOperation(GET_AUDIT_LINE_GRAPH_DATA_OD)
+ public BarGraphDataListResponse getAuditBarGraphData(@BeanParam AuditBarGraphRequest request) {
+ return auditLogsManager.getAuditBarGraphData(conversionService.convert(request, AuditBarGraphSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/users")
+ @Produces({"application/json"})
+ @ApiOperation(GET_TOP_AUDIT_USERS_OD)
+ public BarGraphDataListResponse getTopAuditUsers(@BeanParam FieldAuditBarGraphRequest request) {
+ return auditLogsManager.topTenUsers(conversionService.convert(request, FieldAuditBarGraphSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/resources")
+ @Produces({"application/json"})
+ @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD)
+ public BarGraphDataListResponse getTopAuditResources(@BeanParam FieldAuditLogRequest request) {
+ return auditLogsManager.topTenResources(conversionService.convert(request, FieldAuditLogSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/live/count")
+ @Produces({"application/json"})
+ @ApiOperation(GET_LIVE_LOGS_COUNT_OD)
+ public NameValueDataListResponse getLiveLogsCount() {
+ return auditLogsManager.getLiveLogCounts();
+ }
+
+ @GET
+ @Path("/request/user/bargraph")
+ @Produces({"application/json"})
+ @ApiOperation(GET_REQUEST_USER_LINE_GRAPH_OD)
+ public BarGraphDataListResponse getRequestUserBarGraph(@BeanParam FieldAuditBarGraphRequest request) {
+ return auditLogsManager.getRequestUserLineGraph(conversionService.convert(request, FieldAuditBarGraphSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/anygraph")
+ @Produces({"application/json"})
+ @ApiOperation(GET_ANY_GRAPH_DATA_OD)
+ public BarGraphDataListResponse getAnyGraphData(@BeanParam AnyGraphRequest request) {
+ return auditLogsManager.getAnyGraphData(conversionService.convert(request, AnyGraphSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/users/export")
+ @Produces({"application/json"})
+ @ApiOperation(EXPORT_USER_TALBE_TO_TEXT_FILE_OD)
+ public Response exportUserTableToTextFile(@BeanParam UserExportRequest request) {
+ return auditLogsManager.exportUserTableToTextFile(conversionService.convert(request, UserExportSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/serviceload")
+ @Produces({"application/json"})
+ @ApiOperation(GET_SERVICE_LOAD_OD)
+ public BarGraphDataListResponse getServiceLoad(@BeanParam BaseAuditLogRequest request) {
+ return auditLogsManager.getServiceLoad(conversionService.convert(request, CommonSearchCriteria.class));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java
deleted file mode 100644
index 6099e0f..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java
+++ /dev/null
@@ -1,84 +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.rest;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.apache.ambari.logsearch.common.SearchCriteria;
-import org.apache.ambari.logsearch.manager.LogFileMgr;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.*;
-import static org.apache.ambari.logsearch.doc.DocConstants.LogFileOperationDescriptions.*;
-
-@Api(value = "logfile", description = "Logfile operations")
-@Path("logfile")
-@Component
-@Scope("request")
-public class LogFileREST {
-
- @Autowired
- LogFileMgr logFileMgr;
-
- @GET
- @Produces({"application/json"})
- @ApiOperation(SEARCH_LOG_FILES_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LOG_TYPE_D, name = "logType", dataType = "string", paramType = "query")
- })
- public String searchLogFiles(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria(request);
- searchCriteria.addParam("component", request.getParameter("component"));
- searchCriteria.addParam("host", request.getParameter("host"));
- searchCriteria.addParam("logType", request.getParameter("logType"));
- return logFileMgr.searchLogFiles(searchCriteria);
- }
-
- @GET
- @Path("/tail")
- @Produces({"application/json"})
- @ApiOperation(GET_LOG_FILE_TAIL_OD)
- @ApiImplicitParams(value = {
- @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = LOG_TYPE_D, name = "logType", dataType = "string", paramType = "query"),
- @ApiImplicitParam(value = TAIL_SIZE_D, name = "tailSize", dataType = "string", paramType = "query")
- })
- public String getLogFileTail(@Context HttpServletRequest request) {
- SearchCriteria searchCriteria = new SearchCriteria();
- searchCriteria.addParam("host", request.getParameter("host"));
- searchCriteria.addParam("component", request.getParameter("component"));
- searchCriteria.addParam("name", request.getParameter("name"));
- searchCriteria.addParam("tailSize", request.getParameter("tailSize"));
- return logFileMgr.getLogFileTail(searchCriteria);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java
new file mode 100644
index 0000000..c23f457
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileResource.java
@@ -0,0 +1,69 @@
+/*
+ * 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.rest;
+
+import javax.inject.Inject;
+import javax.ws.rs.BeanParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.ambari.logsearch.model.request.impl.LogFileRequest;
+import org.apache.ambari.logsearch.model.request.impl.LogFileTailRequest;
+import org.apache.ambari.logsearch.model.response.LogFileDataListResponse;
+import org.apache.ambari.logsearch.model.response.LogListResponse;
+import org.apache.ambari.logsearch.query.model.LogFileSearchCriteria;
+import org.apache.ambari.logsearch.query.model.LogFileTailSearchCriteria;
+import org.apache.ambari.logsearch.manager.LogFileManager;
+import org.springframework.context.annotation.Scope;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.stereotype.Component;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.LogFileOperationDescriptions.*;
+
+@Api(value = "logfile", description = "Logfile operations")
+@Path("logfile")
+@Component
+@Scope("request")
+public class LogFileResource {
+
+ @Inject
+ private LogFileManager logFileManager;
+
+ @Inject
+ private ConversionService conversionService;
+
+ @GET
+ @Produces({"application/json"})
+ @ApiOperation(SEARCH_LOG_FILES_OD)
+ public LogFileDataListResponse searchLogFiles(@BeanParam LogFileRequest request) {
+ return logFileManager.searchLogFiles(conversionService.convert(request, LogFileSearchCriteria.class));
+ }
+
+ @GET
+ @Path("/tail")
+ @Produces({"application/json"})
+ @ApiOperation(GET_LOG_FILE_TAIL_OD)
+ public LogListResponse getLogFileTail(@BeanParam LogFileTailRequest request) {
+ return logFileManager.getLogFileTail(conversionService.convert(request, LogFileTailSearchCriteria.class));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java
deleted file mode 100644
index 5218f5d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java
+++ /dev/null
@@ -1,48 +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.rest;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.ambari.logsearch.manager.PublicMgr;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.PublicOperationDescriptions.OBTAIN_GENERAL_CONFIG_OD;
-
-@Api(value = "public", description = "Public operations")
-@Path("public")
-@Component
-@Scope("request")
-public class PublicREST {
-
- @Autowired
- PublicMgr generalMgr;
-
- @GET
- @Path("/config")
- @ApiOperation(OBTAIN_GENERAL_CONFIG_OD)
- public String getGeneralConfig() {
- return generalMgr.getGeneralConfig();
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java
new file mode 100644
index 0000000..94bf059
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.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.rest;
+
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.ambari.logsearch.manager.PublicManager;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.PublicOperationDescriptions.OBTAIN_GENERAL_CONFIG_OD;
+
+@Api(value = "public", description = "Public operations")
+@Path("public")
+@Component
+@Scope("request")
+public class PublicResource {
+
+ @Inject
+ private PublicManager publicManager;
+
+ @GET
+ @Path("/config")
+ @ApiOperation(OBTAIN_GENERAL_CONFIG_OD)
+ public String getGeneralConfig() {
+ return publicManager.getGeneralConfig();
+ }
+}
[06/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java
new file mode 100644
index 0000000..41d8a31
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java
@@ -0,0 +1,111 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Collection;
+
+@ApiModel
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+public class NodeData {
+
+ @ApiModelProperty
+ private String name;
+
+ @ApiModelProperty
+ private String type;
+
+ @ApiModelProperty
+ private String value;
+
+ @ApiModelProperty
+ private Collection<NodeData> childs;
+
+ @ApiModelProperty
+ private Collection<NameValueData> logLevelCount;
+
+ @ApiModelProperty
+ @JsonProperty("isParent")
+ private boolean parent;
+
+ @ApiModelProperty
+ @JsonProperty("isRoot")
+ private boolean root;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public boolean isRoot() {
+ return root;
+ }
+
+ public void setRoot(boolean root) {
+ this.root = root;
+ }
+
+ public Collection<NodeData> getChilds() {
+ return childs;
+ }
+
+ public void setChilds(Collection<NodeData> childs) {
+ this.childs = childs;
+ }
+
+ public Collection<NameValueData> getLogLevelCount() {
+ return logLevelCount;
+ }
+
+ public void setLogLevelCount(Collection<NameValueData> logLevelCount) {
+ this.logLevelCount = logLevelCount;
+ }
+
+ public boolean isParent() {
+ return parent;
+ }
+
+ public void setParent(boolean parent) {
+ this.parent = parent;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.java
new file mode 100644
index 0000000..51044b3
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class NodeListResponse extends SearchResponse {
+
+ @ApiModelProperty
+ protected List<NodeData> vNodeList = new ArrayList<NodeData>();
+
+ public List<NodeData> getvNodeList() {
+ return vNodeList;
+ }
+
+ public void setvNodeList(List<NodeData> vNodeList) {
+ this.vNodeList = vNodeList;
+ }
+
+ @Override
+ public int getListSize() {
+ if (vNodeList == null) {
+ return 0;
+ }
+ return vNodeList.size();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java
new file mode 100644
index 0000000..dd88d29
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java
@@ -0,0 +1,110 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public abstract class SearchResponse {
+ /**
+ * Start index for the result
+ */
+ private int startIndex;
+ /**
+ * Page size used for the result
+ */
+ private int pageSize;
+ /**
+ * Total records in the database for the given search conditions
+ */
+ private long totalCount;
+ /**
+ * Number of rows returned for the search condition
+ */
+ private int resultSize;
+ /**
+ * Sort type. Either desc or asc
+ */
+ private String sortType;
+ /**
+ * Comma seperated list of the fields for sorting
+ */
+ private String sortBy;
+
+ private long queryTimeMS = System.currentTimeMillis();
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public long getTotalCount() {
+ return totalCount;
+ }
+
+ public int getResultSize() {
+ return resultSize;
+ }
+
+ public String getSortType() {
+ return sortType;
+ }
+
+ public String getSortBy() {
+ return sortBy;
+ }
+
+ public long getQueryTimeMS() {
+ return queryTimeMS;
+ }
+
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public void setTotalCount(long totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ public void setResultSize(int resultSize) {
+ this.resultSize = resultSize;
+ }
+
+ public void setSortType(String sortType) {
+ this.sortType = sortType;
+ }
+
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ public void setQueryTimeMS(long queryTimeMS) {
+ this.queryTimeMS = queryTimeMS;
+ }
+
+ public abstract int getListSize();
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java
new file mode 100644
index 0000000..16aed16
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java
@@ -0,0 +1,63 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Date;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public interface ServiceLogData extends CommonLogData, ComponentTypeLogData, HostLogData {
+
+ @JsonProperty("level")
+ String getLevel();
+
+ void setLevel(String level);
+
+ @JsonProperty("line_number")
+ Integer getLineNumber();
+
+ void setLineNumber(Integer lineNumber);
+
+ @JsonProperty("logtime")
+ Date getLogTime();
+
+ void setLogTime(Date logTime);
+
+ @JsonProperty("ip")
+ String getIp();
+
+ void setIp(String ip);
+
+ @JsonProperty("path")
+ String getPath();
+
+ void setPath(String path);
+
+ @JsonProperty("type")
+ String getType();
+
+ void setType(String type);
+
+ @JsonProperty("host")
+ String getHost();
+
+ void setHost(String host);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.java
new file mode 100644
index 0000000..2e689c1
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceLogResponse extends LogSearchResponse<ServiceLogData> {
+
+ @ApiModelProperty
+ private List<ServiceLogData> logList;
+
+ @Override
+ public List<ServiceLogData> getLogList() {
+ return logList;
+ }
+
+ @Override
+ public void setLogList(List<ServiceLogData> logList) {
+ this.logList = logList;
+ }
+
+ @Override
+ public int getListSize() {
+ return logList == null ? 0 : logList.size();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
index 16cf932..10224bc 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGeneration.java
@@ -28,9 +28,11 @@ import java.util.regex.Pattern;
import org.apache.ambari.logsearch.common.ConfigHelper;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import org.apache.ambari.logsearch.common.PropertiesHelper;
-import org.apache.ambari.logsearch.common.SearchCriteria;
+import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
+import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
import org.apache.ambari.logsearch.dao.SolrDaoBase;
-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.ambari.logsearch.util.SolrUtil;
import org.apache.commons.lang.StringUtils;
@@ -44,11 +46,19 @@ import org.apache.solr.schema.TrieFloatField;
import org.apache.solr.schema.TrieLongField;
import org.springframework.stereotype.Component;
+import javax.inject.Inject;
+
@Component
public class QueryGeneration extends QueryGenerationBase {
private static Logger logger = Logger.getLogger(QueryGeneration.class);
+ @Inject
+ private SolrServiceLogConfig solrServiceLogConfig;
+
+ @Inject
+ private SolrAuditLogConfig solrAuditLogConfig;
+
public SolrQuery commonServiceFilterQuery(SearchCriteria searchCriteria) {
LogType logType = LogType.SERVICE;
SolrQuery solrQuery = new SolrQuery();
@@ -349,10 +359,10 @@ public class QueryGeneration extends QueryGenerationBase {
String originalKey;
switch (logType) {
case AUDIT:
- originalKey = ConfigHelper.auditLogsColumnMapping.get(key + LogSearchConstants.UI_SUFFIX);
+ originalKey = solrAuditLogConfig.getSolrAndUiColumns().get(key + LogSearchConstants.UI_SUFFIX);
break;
case SERVICE:
- originalKey = ConfigHelper.serviceLogsColumnMapping.get(key + LogSearchConstants.UI_SUFFIX);
+ originalKey = solrServiceLogConfig.getSolrAndUiColumns().get(key + LogSearchConstants.UI_SUFFIX);
break;
default:
originalKey = null;
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
index 77d4969..d7d30d7 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/QueryGenerationBase.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.common.SearchCriteria;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
import org.apache.ambari.logsearch.dao.AuditSolrDao;
import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao;
import org.apache.ambari.logsearch.util.SolrUtil;
@@ -31,21 +31,22 @@ import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrQuery.ORDER;
-import org.springframework.beans.factory.annotation.Autowired;
import com.google.gson.Gson;
+import javax.inject.Inject;
+
public abstract class QueryGenerationBase {
private static final Logger logger = Logger.getLogger(QueryGenerationBase.class);
- @Autowired
+ @Inject
protected AuditSolrDao auditSolrDao;
- @Autowired
+ @Inject
protected ServiceLogsSolrDao serviceLogsSolrDao;
- public static enum Condition {
+ public enum Condition {
OR, AND
}
@@ -98,7 +99,6 @@ public abstract class QueryGenerationBase {
solrQuery.addFilterQuery(filterQuery);
logger.debug("Filter added :- " + filterQuery);
}
-
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.java
new file mode 100644
index 0000000..798bd47
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonAuditLogRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
+import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.springframework.stereotype.Component;
+
+@Component
+public abstract class AbstractCommonAuditLogRequestConverter<SOURCE extends BaseAuditLogRequest, RESULT extends CommonSearchCriteria>
+ extends AbstractCommonSearchRequestConverter<SOURCE, RESULT> {
+
+ @Override
+ public RESULT convertToSearchCriteria(SOURCE request) {
+ RESULT criteria = createCriteria(request);
+ criteria.addParam("q", request.getQuery());
+ criteria.addParam("columnQuery", StringEscapeUtils.unescapeXml(request.getColumnQuery()));
+ criteria.addParam("iMessage", StringEscapeUtils.unescapeXml(request.getiMessage()));
+ criteria.addParam("gEMessage", StringEscapeUtils.unescapeXml(request.getgEMessage()));
+ criteria.addParam("eMessage", StringEscapeUtils.unescapeXml(request.getgEMessage()));
+ criteria.addParam("includeString", request.getMustBe());
+ criteria.addParam("unselectComp", request.getMustNot());
+ criteria.addParam("excludeQuery", StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
+ criteria.addParam("includeQuery", StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
+ criteria.addParam("startTime", request.getFrom());
+ criteria.addParam("endTime", request.getTo());
+ return criteria;
+ }
+
+ public abstract RESULT createCriteria(SOURCE request);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.java
new file mode 100644
index 0000000..3fd07e2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonSearchRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest;
+import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.core.convert.converter.Converter;
+
+public abstract class AbstractCommonSearchRequestConverter<SOURCE extends CommonSearchRequest, RESULT extends CommonSearchCriteria>
+ implements Converter<SOURCE, RESULT> {
+
+ @Override
+ public RESULT convert(SOURCE source) {
+ RESULT criteria = convertToSearchCriteria(source);
+ addDefaultParams(source, criteria);
+ return criteria;
+ }
+
+ public abstract RESULT convertToSearchCriteria(SOURCE source);
+
+ private void addDefaultParams(SOURCE request, RESULT criteria) {
+ criteria.setStartIndex(StringUtils.isNumeric(request.getStartIndex()) ? new Integer(request.getStartIndex()) : 0);
+ criteria.setPage(StringUtils.isNumeric(request.getPage()) ? new Integer(request.getPage()) : 0);
+ criteria.setMaxRows(StringUtils.isNumeric(request.getPageSize()) ? new Integer(request.getPageSize()) : 50);
+ criteria.setSortBy(request.getSortBy());
+ criteria.setSortType(request.getSortType());
+ if (StringUtils.isNotEmpty(request.getStartTime())){
+ criteria.setGlobalStartTime(request.getStartTime());
+ criteria.getUrlParamMap().put("globalStartTime", request.getStartTime());
+ }
+ if (StringUtils.isNotEmpty(request.getEndTime())){
+ criteria.setGlobalEndTime(request.getEndTime());
+ criteria.getUrlParamMap().put("globalEndTime", request.getEndTime());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
new file mode 100644
index 0000000..a02d585
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AbstractCommonServiceLogRequestConverter.java
@@ -0,0 +1,56 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
+import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
+import org.apache.commons.lang.StringEscapeUtils;
+
+public abstract class AbstractCommonServiceLogRequestConverter<SOURCE extends BaseServiceLogRequest, RESULT extends CommonSearchCriteria>
+ extends AbstractCommonSearchRequestConverter<SOURCE, RESULT> {
+
+ @Override
+ public RESULT convertToSearchCriteria(SOURCE request) {
+ RESULT criteria = createCriteria(request);
+ criteria.addParam("advanceSearch", StringEscapeUtils.unescapeXml(request.getAdvancedSearch()));
+ criteria.addParam("q", request.getQuery());
+ criteria.addParam("treeParams", StringEscapeUtils.unescapeHtml(request.getTreeParams()));
+ criteria.addParam("level", request.getLevel());
+ criteria.addParam("gMustNot", request.getgMustNot());
+ criteria.addParam("from", request.getFrom());
+ criteria.addParam("to", request.getTo());
+ criteria.addParam("selectComp", request.getMustBe());
+ criteria.addParam("unselectComp", request.getMustNot());
+ criteria.addParam("iMessage", StringEscapeUtils.unescapeXml(request.getiMessage()));
+ criteria.addParam("gEMessage", StringEscapeUtils.unescapeXml(request.getgEMessage()));
+ criteria.addParam("eMessage", StringEscapeUtils.unescapeXml(request.getgEMessage()));
+ criteria.addParam(LogSearchConstants.BUNDLE_ID, request.getBundleId());
+ criteria.addParam("host_name", request.getHostName());
+ criteria.addParam("component_name", request.getComponentName());
+ criteria.addParam("file_name", request.getFileName());
+ criteria.addParam("startDate", request.getStartTime());
+ criteria.addParam("endDate", request.getEndTime());
+ criteria.addParam("excludeQuery", StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
+ criteria.addParam("includeQuery", StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
+ return criteria;
+ }
+
+ public abstract RESULT createCriteria(SOURCE request);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.java
new file mode 100644
index 0000000..0372168
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AnyGraphRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.AnyGraphRequest;
+import org.apache.ambari.logsearch.query.model.AnyGraphSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AnyGraphRequestConverter extends AbstractCommonSearchRequestConverter<AnyGraphRequest, AnyGraphSearchCriteria> {
+
+ @Override
+ public AnyGraphSearchCriteria convertToSearchCriteria(AnyGraphRequest anyGraphRequest) {
+ AnyGraphSearchCriteria criteria = new AnyGraphSearchCriteria();
+ criteria.addParam("xAxis", anyGraphRequest.getxAxis());
+ criteria.addParam("yAxis", anyGraphRequest.getyAxis());
+ criteria.addParam("stackBy", anyGraphRequest.getStackBy());
+ criteria.addParam("unit", anyGraphRequest.getUnit());
+ criteria.addParam("from", anyGraphRequest.getFrom());
+ criteria.addParam("to", anyGraphRequest.getTo());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.java
new file mode 100644
index 0000000..f72a673
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditBarGraphRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
+import org.apache.ambari.logsearch.query.model.AuditBarGraphSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AuditBarGraphRequestConverter extends AbstractCommonAuditLogRequestConverter<AuditBarGraphRequest, AuditBarGraphSearchCriteria>{
+
+ @Override
+ public AuditBarGraphSearchCriteria createCriteria(AuditBarGraphRequest request) {
+ AuditBarGraphSearchCriteria criteria = new AuditBarGraphSearchCriteria();
+ criteria.addParam("unit", request.getUnit());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.java
new file mode 100644
index 0000000..27d314d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/AuditLogRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
+import org.apache.ambari.logsearch.query.model.AuditLogSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<AuditLogRequest, AuditLogSearchCriteria> {
+
+ @Override
+ public AuditLogSearchCriteria createCriteria(AuditLogRequest request) {
+ AuditLogSearchCriteria criteria = new AuditLogSearchCriteria();
+ criteria.addParam("isLastPage", request.isLastPage());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java
new file mode 100644
index 0000000..35aceb2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseAuditLogRequestConverter.java
@@ -0,0 +1,33 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.BaseAuditLogRequest;
+import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BaseAuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<BaseAuditLogRequest, CommonSearchCriteria> {
+
+ @Override
+ public CommonSearchCriteria createCriteria(BaseAuditLogRequest request) {
+ return new CommonSearchCriteria();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java
new file mode 100644
index 0000000..cfd544c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/BaseServiceLogRequestConverter.java
@@ -0,0 +1,32 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.BaseServiceLogRequest;
+import org.apache.ambari.logsearch.query.model.CommonSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BaseServiceLogRequestConverter extends AbstractCommonServiceLogRequestConverter<BaseServiceLogRequest, CommonSearchCriteria> {
+
+ @Override
+ public CommonSearchCriteria createCriteria(BaseServiceLogRequest request) {
+ return new CommonSearchCriteria();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.java
new file mode 100644
index 0000000..089b593
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldAuditLogRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.apache.ambari.logsearch.query.model.FieldAuditLogSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class FieldAuditLogRequestConverter extends AbstractCommonAuditLogRequestConverter<FieldAuditLogRequest, FieldAuditLogSearchCriteria> {
+
+ @Override
+ public FieldAuditLogSearchCriteria createCriteria(FieldAuditLogRequest request) {
+ FieldAuditLogSearchCriteria criteria = new FieldAuditLogSearchCriteria();
+ criteria.addParam("field", request.getField());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java
new file mode 100644
index 0000000..dd518f8
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/FieldBarGraphRequestConverter.java
@@ -0,0 +1,35 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.FieldAuditBarGraphRequest;
+import org.apache.ambari.logsearch.query.model.FieldAuditBarGraphSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class FieldBarGraphRequestConverter extends AbstractCommonAuditLogRequestConverter<FieldAuditBarGraphRequest, FieldAuditBarGraphSearchCriteria> {
+
+ @Override
+ public FieldAuditBarGraphSearchCriteria createCriteria(FieldAuditBarGraphRequest request) {
+ FieldAuditBarGraphSearchCriteria criteria = new FieldAuditBarGraphSearchCriteria();
+ criteria.addParam("unit", request.getUnit());
+ criteria.addParam("field", request.getField());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java
new file mode 100644
index 0000000..7c3038e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileRequestConverter.java
@@ -0,0 +1,37 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.LogFileRequest;
+import org.apache.ambari.logsearch.query.model.LogFileSearchCriteria;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
+
+@Component
+public class LogFileRequestConverter implements Converter<LogFileRequest, LogFileSearchCriteria> {
+
+ @Override
+ public LogFileSearchCriteria convert(LogFileRequest request) {
+ LogFileSearchCriteria criteria = new LogFileSearchCriteria();
+ criteria.addParam("component", request.getComponent());
+ criteria.addParam("host", request.getHost());
+ criteria.addParam("logType", request.getLogType());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java
new file mode 100644
index 0000000..88b1a34
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/LogFileTailRequestConverter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.LogFileTailRequest;
+import org.apache.ambari.logsearch.query.model.LogFileTailSearchCriteria;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
+
+@Component
+public class LogFileTailRequestConverter implements Converter<LogFileTailRequest, LogFileTailSearchCriteria> {
+
+ @Override
+ public LogFileTailSearchCriteria convert(LogFileTailRequest request) {
+ LogFileTailSearchCriteria criteria = new LogFileTailSearchCriteria();
+ criteria.addParam("component", request.getComponent());
+ criteria.addParam("host", request.getHost());
+ criteria.addParam("logType", request.getLogType());
+ criteria.addParam("tailSize", request.getTailSize());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.java
new file mode 100644
index 0000000..7a559de
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceAnyGraphRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest;
+import org.apache.ambari.logsearch.query.model.ServiceAnyGraphSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceAnyGraphRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceAnyGraphRequest, ServiceAnyGraphSearchCriteria> {
+
+ @Override
+ public ServiceAnyGraphSearchCriteria createCriteria(ServiceAnyGraphRequest anyGraphRequest) {
+ ServiceAnyGraphSearchCriteria criteria = new ServiceAnyGraphSearchCriteria();
+ criteria.addParam("xAxis", anyGraphRequest.getxAxis());
+ criteria.addParam("yAxis", anyGraphRequest.getyAxis());
+ criteria.addParam("stackBy", anyGraphRequest.getStackBy());
+ criteria.addParam("unit", anyGraphRequest.getUnit());
+ criteria.addParam("from", anyGraphRequest.getFrom());
+ criteria.addParam("to", anyGraphRequest.getTo());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java
new file mode 100644
index 0000000..fe81468
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceExtremeDatesRequestConverter.java
@@ -0,0 +1,35 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.impl.ServiceExtremeDatesRequest;
+import org.apache.ambari.logsearch.query.model.ServiceExtremeDatesCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceExtremeDatesRequestConverter extends AbstractCommonSearchRequestConverter<ServiceExtremeDatesRequest, ServiceExtremeDatesCriteria> {
+
+ @Override
+ public ServiceExtremeDatesCriteria convertToSearchCriteria(ServiceExtremeDatesRequest request) {
+ ServiceExtremeDatesCriteria criteria = new ServiceExtremeDatesCriteria();
+ criteria.addParam(LogSearchConstants.BUNDLE_ID, request.getBundleId());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.java
new file mode 100644
index 0000000..19165c0
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceGraphRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
+import org.apache.ambari.logsearch.query.model.ServiceGraphSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceGraphRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceGraphRequest, ServiceGraphSearchCriteria> {
+
+ @Override
+ public ServiceGraphSearchCriteria createCriteria(ServiceGraphRequest request) {
+ ServiceGraphSearchCriteria criteria = new ServiceGraphSearchCriteria();
+ criteria.addParam("hostLogFile", request.getHostLogFile());
+ criteria.addParam("compLogFile", request.getComponentLogFile());
+ criteria.addParam("unit", request.getUnit());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
new file mode 100644
index 0000000..7d83e49
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogExportRequestConverter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest;
+import org.apache.ambari.logsearch.query.model.ServiceLogExportSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLogExportRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogExportRequest, ServiceLogExportSearchCriteria> {
+
+ @Override
+ public ServiceLogExportSearchCriteria createCriteria(ServiceLogExportRequest request) {
+ ServiceLogExportSearchCriteria criteria = new ServiceLogExportSearchCriteria();
+ criteria.addParam("hostLogFile", request.getHostLogFile());
+ criteria.addParam("compLogFile",
+ request.getComponentLogFile());
+ criteria.addParam("format", request.getFormat());
+ criteria.addParam("utcOffset", request.getUtcOffset());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.java
new file mode 100644
index 0000000..f5148f3
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogFileRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogFileRequest;
+import org.apache.ambari.logsearch.query.model.ServiceLogFileSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLogFileRequestConverter
+ extends AbstractCommonServiceLogRequestConverter<ServiceLogFileRequest, ServiceLogFileSearchCriteria> {
+
+ @Override
+ public ServiceLogFileSearchCriteria createCriteria(ServiceLogFileRequest request) {
+ ServiceLogFileSearchCriteria criteria = new ServiceLogFileSearchCriteria();
+ criteria.addParam("hostLogFile", request.getHostLogFile());
+ criteria.addParam("compLogFile", request.getComponentLogFile());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
new file mode 100644
index 0000000..6a70d55
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogRequestConverter.java
@@ -0,0 +1,41 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest;
+import org.apache.ambari.logsearch.query.model.ServiceLogSearchCriteria;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLogRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogRequest, ServiceLogSearchCriteria> {
+
+ @Override
+ public ServiceLogSearchCriteria createCriteria(ServiceLogRequest request) {
+ ServiceLogSearchCriteria criteria = new ServiceLogSearchCriteria();
+ criteria.addParam("hostLogFile", request.getHostLogFile());
+ criteria.addParam("compLogFile", request.getComponentLogFile());
+ criteria.addParam("keyword", StringEscapeUtils.unescapeXml(request.getKeyWord()));
+ criteria.addParam("sourceLogId", request.getSourceLogId());
+ criteria.addParam("keywordType", request.getKeywordType());
+ criteria.addParam("token", request.getToken());
+ criteria.addParam("isLastPage", request.isLastPage());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
new file mode 100644
index 0000000..676f049
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/ServiceLogTruncatedRequestConverter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
+import org.apache.ambari.logsearch.query.model.ServiceLogTruncatedSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLogTruncatedRequestConverter extends AbstractCommonServiceLogRequestConverter<ServiceLogTruncatedRequest, ServiceLogTruncatedSearchCriteria> {
+
+ @Override
+ public ServiceLogTruncatedSearchCriteria createCriteria(ServiceLogTruncatedRequest request) {
+ ServiceLogTruncatedSearchCriteria criteria = new ServiceLogTruncatedSearchCriteria();
+ criteria.addParam("hostLogFile", request.getHostLogFile());
+ criteria.addParam("compLogFile", request.getComponentLogFile());
+ criteria.addParam("id", request.getId());
+ criteria.addParam("scrollType", request.getScrollType());
+ criteria.addParam("numberRows", request.getNumberRows());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.java
new file mode 100644
index 0000000..8c50f66
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/SimpleQueryRequestConverter.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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.SimpleQueryRequest;
+import org.apache.ambari.logsearch.query.model.SearchCriteria;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SimpleQueryRequestConverter implements Converter<SimpleQueryRequest, SearchCriteria> {
+ @Override
+ public SearchCriteria convert(SimpleQueryRequest simpleQueryRequest) {
+ SearchCriteria searchCriteria = new SearchCriteria();
+ searchCriteria.addParam("q", simpleQueryRequest.getQuery());
+ return searchCriteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserConfigRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserConfigRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserConfigRequestConverter.java
new file mode 100644
index 0000000..50847c7
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserConfigRequestConverter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest;
+import org.apache.ambari.logsearch.query.model.UserConfigSearchCriteria;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserConfigRequestConverter implements Converter<UserConfigRequest, UserConfigSearchCriteria> {
+
+ @Override
+ public UserConfigSearchCriteria convert(UserConfigRequest request) {
+ UserConfigSearchCriteria criteria = new UserConfigSearchCriteria();
+ criteria.addParam(LogSearchConstants.USER_NAME, request.getUserId());
+ criteria.addParam(LogSearchConstants.FILTER_NAME, request.getFilterName());
+ criteria.addParam(LogSearchConstants.ROW_TYPE, request.getRowType());
+ return criteria;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java
new file mode 100644
index 0000000..a0b5f0f
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/converter/UserExportRequestConverter.java
@@ -0,0 +1,35 @@
+/*
+ * 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.query.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
+import org.apache.ambari.logsearch.query.model.UserExportSearchCriteria;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserExportRequestConverter extends AbstractCommonAuditLogRequestConverter<UserExportRequest, UserExportSearchCriteria> {
+
+ @Override
+ public UserExportSearchCriteria createCriteria(UserExportRequest request) {
+ UserExportSearchCriteria criteria = new UserExportSearchCriteria();
+ criteria.addParam("field", request.getField());
+ return criteria;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java
new file mode 100644
index 0000000..a11c056
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AnyGraphSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class AnyGraphSearchCriteria extends CommonSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java
new file mode 100644
index 0000000..c41ec15
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditBarGraphSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class AuditBarGraphSearchCriteria extends CommonSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java
new file mode 100644
index 0000000..f4fe207
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/AuditLogSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class AuditLogSearchCriteria extends CommonSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonSearchCriteria.java
new file mode 100644
index 0000000..47d12e5
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/CommonSearchCriteria.java
@@ -0,0 +1,100 @@
+/*
+ * 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.query.model;
+
+public class CommonSearchCriteria extends 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;
+
+ @Override
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ @Override
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ @Override
+ public int getMaxRows() {
+ return maxRows;
+ }
+
+ @Override
+ public void setMaxRows(int maxRows) {
+ this.maxRows = maxRows;
+ }
+
+ @Override
+ public String getSortType() {
+ return sortType;
+ }
+
+ @Override
+ public void setSortType(String sortType) {
+ this.sortType = sortType;
+ }
+
+ @Override
+ public String getSortBy() {
+ return sortBy;
+ }
+
+ @Override
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ @Override
+ public int getPage() {
+ return page;
+ }
+
+ @Override
+ public void setPage(int page) {
+ this.page = page;
+ }
+
+ @Override
+ public String getGlobalStartTime() {
+ return globalStartTime;
+ }
+
+ @Override
+ public void setGlobalStartTime(String globalStartTime) {
+ this.globalStartTime = globalStartTime;
+ }
+
+ @Override
+ public String getGlobalEndTime() {
+ return globalEndTime;
+ }
+
+ @Override
+ public void setGlobalEndTime(String globalEndTime) {
+ this.globalEndTime = globalEndTime;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java
new file mode 100644
index 0000000..f931f5d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditBarGraphSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class FieldAuditBarGraphSearchCriteria extends AuditBarGraphSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java
new file mode 100644
index 0000000..8dd5854
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/FieldAuditLogSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class FieldAuditLogSearchCriteria extends CommonSearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java
new file mode 100644
index 0000000..e4e2a14
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class LogFileSearchCriteria extends SearchCriteria {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java
new file mode 100644
index 0000000..fecb396
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/query/model/LogFileTailSearchCriteria.java
@@ -0,0 +1,25 @@
+/*
+ * 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.query.model;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public class LogFileTailSearchCriteria extends SearchCriteria {
+}
[07/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
new file mode 100644
index 0000000..ba4f4a8
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/BaseServiceLogRequest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.BundleIdParamDefinition;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+import org.apache.ambari.logsearch.model.request.ServiceLogParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class BaseServiceLogRequest extends BaseLogRequest
+ implements ServiceLogParamDefinition, BundleIdParamDefinition, DateRangeParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_LEVEL)
+ private String level;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_ADVANCED_SEARCH)
+ private String advancedSearch;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_TREE_PARAMS)
+ private String treeParams;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_E_MESSAGE)
+ private String eMessage;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_G_MUST_NOT)
+ private String gMustNot;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_HOST_NAME)
+ private String hostName;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_COMPONENT_NAME)
+ private String componentName;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FILE_NAME)
+ private String fileName;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_BUNDLE_ID)
+ private String bundleId;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
+ private String from;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
+ private String to;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_DATE_RANGE_LABEL)
+ private String dateRangeLabel;
+
+ @Override
+ public String getLevel() {
+ return level;
+ }
+
+ @Override
+ public void setLevel(String level) {
+ this.level = level;
+ }
+
+ @Override
+ public String getAdvancedSearch() {
+ return advancedSearch;
+ }
+
+ @Override
+ public void setAdvancedSearch(String advancedSearch) {
+ this.advancedSearch = advancedSearch;
+ }
+
+ @Override
+ public String getTreeParams() {
+ return treeParams;
+ }
+
+ @Override
+ public void setTreeParams(String treeParams) {
+ this.treeParams = treeParams;
+ }
+
+ @Override
+ public String geteMessage() {
+ return eMessage;
+ }
+
+ @Override
+ public void seteMessage(String eMessage) {
+ this.eMessage = eMessage;
+ }
+
+ @Override
+ public String getgMustNot() {
+ return gMustNot;
+ }
+
+ @Override
+ public void setgMustNot(String gMustNot) {
+ this.gMustNot = gMustNot;
+ }
+
+ @Override
+ public String getHostName() {
+ return hostName;
+ }
+
+ @Override
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ @Override
+ public String getComponentName() {
+ return componentName;
+ }
+
+ @Override
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ @Override
+ public String getFileName() {
+ return fileName;
+ }
+
+ @Override
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ public String getBundleId() {
+ return bundleId;
+ }
+
+ @Override
+ public void setBundleId(String bundleId) {
+ this.bundleId = bundleId;
+ }
+
+ @Override
+ public String getFrom() {
+ return from;
+ }
+
+ @Override
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ @Override
+ public String getTo() {
+ return to;
+ }
+
+ @Override
+ public void setTo(String to) {
+ this.to = to;
+ }
+
+ @Override
+ public String getDateRangeLabel() {
+ return dateRangeLabel;
+ }
+
+ @Override
+ public void setDateRangeLabel(String dateRangeLabel) {
+ this.dateRangeLabel = dateRangeLabel;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/CommonSearchRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/CommonSearchRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/CommonSearchRequest.java
new file mode 100644
index 0000000..7001cf3
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/CommonSearchRequest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.CommonSearchParamDefinition;
+import org.apache.ambari.logsearch.model.request.SearchRequest;
+
+import javax.ws.rs.QueryParam;
+
+public class CommonSearchRequest implements SearchRequest, CommonSearchParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_START_INDEX)
+ private String startIndex;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_PAGE)
+ private String page;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_PAGE_SIZE)
+ private String pageSize;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_SORT_BY)
+ private String sortBy;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_SORT_TYPE)
+ private String sortType;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_START_TIME)
+ private String startTime;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_END_TIME)
+ private String endTime;
+
+ @Override
+ public String getStartIndex() {
+ return startIndex;
+ }
+
+ @Override
+ public void setStartIndex(String startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ @Override
+ public String getPage() {
+ return page;
+ }
+
+ @Override
+ public void setPage(String page) {
+ this.page = page;
+ }
+
+ @Override
+ public String getPageSize() {
+ return pageSize;
+ }
+
+ @Override
+ public void setPageSize(String pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ @Override
+ public String getSortBy() {
+ return sortBy;
+ }
+
+ @Override
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ @Override
+ public String getSortType() {
+ return sortType;
+ }
+
+ @Override
+ public void setSortType(String sortType) {
+ this.sortType = sortType;
+ }
+
+ @Override
+ public String getStartTime() {
+ return startTime;
+ }
+
+ @Override
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+
+ @Override
+ public String getEndTime() {
+ return endTime;
+ }
+
+ @Override
+ public void setEndTime(String endTime) {
+ this.endTime = endTime;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditBarGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditBarGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditBarGraphRequest.java
new file mode 100644
index 0000000..aa08aaf
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditBarGraphRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.FieldParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class FieldAuditBarGraphRequest extends AuditBarGraphRequest implements FieldParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FIELD)
+ private String field;
+
+ @Override
+ public String getField() {
+ return field;
+ }
+
+ @Override
+ public void setField(String field) {
+ this.field = field;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
new file mode 100644
index 0000000..67502fa
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.FieldParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class FieldAuditLogRequest extends BaseAuditLogRequest implements FieldParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FIELD)
+ private String field;
+
+ @Override
+ public String getField() {
+ return field;
+ }
+
+ @Override
+ public void setField(String field) {
+ this.field = field;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java
new file mode 100644
index 0000000..78c5b33
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileRequest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.LogFileParamDefinition;
+import org.apache.ambari.logsearch.model.request.SearchRequest;
+
+import javax.ws.rs.QueryParam;
+
+public class LogFileRequest implements SearchRequest, LogFileParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_COMPONENT)
+ private String component;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_HOST)
+ private String host;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_LOG_TYPE)
+ private String logType;
+
+ @Override
+ public String getComponent() {
+ return component;
+ }
+
+ @Override
+ public void setComponent(String component) {
+ this.component = component;
+ }
+
+ @Override
+ public String getHost() {
+ return host;
+ }
+
+ @Override
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ @Override
+ public String getLogType() {
+ return logType;
+ }
+
+ @Override
+ public void setLogType(String logType) {
+ this.logType = logType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java
new file mode 100644
index 0000000..d5b91ab
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/LogFileTailRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.LogFileTailParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class LogFileTailRequest extends LogFileRequest implements LogFileTailParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_TAIL_SIZE)
+ private String tailSize;
+
+ @Override
+ public String getTailSize() {
+ return tailSize;
+ }
+
+ @Override
+ public void setTailSize(String tailSize) {
+ this.tailSize = tailSize;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java
new file mode 100644
index 0000000..0ce788c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/QueryRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.QueryParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class QueryRequest extends CommonSearchRequest implements QueryParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_QUERY)
+ private String query;
+
+ @Override
+ public String getQuery() {
+ return query;
+ }
+
+ @Override
+ public void setQuery(String query) {
+ this.query = query;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceAnyGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceAnyGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceAnyGraphRequest.java
new file mode 100644
index 0000000..a6aadbb
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceAnyGraphRequest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.AnyGraphParamDefinition;
+import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
+import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceAnyGraphRequest extends ServiceLogRequest
+ implements AnyGraphParamDefinition, DateRangeParamDefinition, UnitParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_XAXIS)
+ private String xAxis;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_YAXIS)
+ private String yAxis;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_STACK_BY)
+ private String stackBy;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
+ private String unit;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FROM)
+ private String from;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_TO)
+ private String to;
+
+ @Override
+ public String getxAxis() {
+ return xAxis;
+ }
+
+ @Override
+ public void setxAxis(String xAxis) {
+ this.xAxis = xAxis;
+ }
+
+ @Override
+ public String getyAxis() {
+ return yAxis;
+ }
+
+ @Override
+ public void setyAxis(String yAxis) {
+ this.yAxis = yAxis;
+ }
+
+ @Override
+ public String getStackBy() {
+ return stackBy;
+ }
+
+ @Override
+ public void setStackBy(String stackBy) {
+ this.stackBy = stackBy;
+ }
+
+ @Override
+ public String getUnit() {
+ return unit;
+ }
+
+ @Override
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+
+ @Override
+ public String getFrom() {
+ return from;
+ }
+
+ @Override
+ public void setFrom(String from) {
+ this.from = from;
+ }
+
+ @Override
+ public String getTo() {
+ return to;
+ }
+
+ @Override
+ public void setTo(String to) {
+ this.to = to;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java
new file mode 100644
index 0000000..8207c5d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceExtremeDatesRequest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.BundleIdParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceExtremeDatesRequest extends CommonSearchRequest implements BundleIdParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_BUNDLE_ID)
+ private String bundleId;
+
+ @Override
+ public String getBundleId() {
+ return bundleId;
+ }
+
+ @Override
+ public void setBundleId(String bundleId) {
+ this.bundleId = bundleId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java
new file mode 100644
index 0000000..1618aa1
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceGraphRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceGraphRequest extends ServiceLogFileRequest implements UnitParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_UNIT)
+ private String unit;
+
+ @Override
+ public String getUnit() {
+ return unit;
+ }
+
+ @Override
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.java
new file mode 100644
index 0000000..6ae0dc9
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogExportRequest.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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.FormatParamDefinition;
+import org.apache.ambari.logsearch.model.request.UtcOffsetParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceLogExportRequest extends ServiceLogFileRequest implements FormatParamDefinition, UtcOffsetParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FORMAT)
+ private String format;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_UTC_OFFSET)
+ private String utcOffset;
+
+ @Override
+ public String getFormat() {
+ return format;
+ }
+
+ @Override
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ @Override
+ public String getUtcOffset() {
+ return utcOffset;
+ }
+
+ @Override
+ public void setUtcOffset(String utcOffset) {
+ this.utcOffset = utcOffset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.java
new file mode 100644
index 0000000..6c7078a
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogFileRequest.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.model.request.impl;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.ServiceLogFileParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceLogFileRequest extends BaseServiceLogRequest implements ServiceLogFileParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_HOST_LOG_FILE)
+ private String hostLogFile;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_COMPONENT_LOG_FILE)
+ private String componentLogFile;
+
+ @Override
+ public String getHostLogFile() {
+ return hostLogFile;
+ }
+
+ @Override
+ public void setHostLogFile(String hostLogFile) {
+ this.hostLogFile = hostLogFile;
+ }
+
+ @Override
+ public String getComponentLogFile() {
+ return componentLogFile;
+ }
+
+ @Override
+ public void setComponentLogFile(String componentLogFile) {
+ this.componentLogFile = componentLogFile;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java
new file mode 100644
index 0000000..9a46de3
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogRequest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.LastPageParamDefinition;
+import org.apache.ambari.logsearch.model.request.ServiceLogSearchParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceLogRequest extends ServiceLogFileRequest implements ServiceLogSearchParamDefinition, LastPageParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_KEYWORD)
+ private String keyWord;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_SOURCE_LOG_ID)
+ private String sourceLogId;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_KEYWORD_TYPE)
+ private String keywordType;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_TOKEN)
+ private String token;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_LAST_PAGE)
+ private boolean isLastPage;
+
+ @Override
+ public String getKeyWord() {
+ return keyWord;
+ }
+
+ @Override
+ public void setKeyWord(String keyWord) {
+ this.keyWord = keyWord;
+ }
+
+ @Override
+ public String getSourceLogId() {
+ return sourceLogId;
+ }
+
+ @Override
+ public void setSourceLogId(String sourceLogId) {
+ this.sourceLogId = sourceLogId;
+ }
+
+ @Override
+ public String getKeywordType() {
+ return keywordType;
+ }
+
+ @Override
+ public void setKeywordType(String keywordType) {
+ this.keywordType = keywordType;
+ }
+
+ @Override
+ public String getToken() {
+ return token;
+ }
+
+ @Override
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ @Override
+ public boolean isLastPage() {
+ return isLastPage;
+ }
+
+ @Override
+ public void setLastPage(boolean lastPage) {
+ isLastPage = lastPage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
new file mode 100644
index 0000000..516c328
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/ServiceLogTruncatedRequest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.LogTruncatedParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class ServiceLogTruncatedRequest extends ServiceLogFileRequest implements LogTruncatedParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_ID)
+ private String id;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_SCROLL_TYPE)
+ private String scrollType;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_NUMBER_ROWS)
+ private String numberRows;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getScrollType() {
+ return scrollType;
+ }
+
+ @Override
+ public void setScrollType(String scrollType) {
+ this.scrollType = scrollType;
+ }
+
+ @Override
+ public String getNumberRows() {
+ return numberRows;
+ }
+
+ @Override
+ public void setNumberRows(String numberRows) {
+ this.numberRows = numberRows;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java
new file mode 100644
index 0000000..eec4379
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/SimpleQueryRequest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.QueryParamDefinition;
+import org.apache.ambari.logsearch.model.request.SearchRequest;
+
+import javax.ws.rs.QueryParam;
+
+
+public class SimpleQueryRequest implements SearchRequest, QueryParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_QUERY)
+ private String query;
+
+ @Override
+ public String getQuery() {
+ return query;
+ }
+
+ @Override
+ public void setQuery(String query) {
+ this.query = query;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
new file mode 100644
index 0000000..c99ea75
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.UserConfigParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class UserConfigRequest extends CommonSearchRequest implements UserConfigParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_USER_ID)
+ private String userId;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FILE_NAME)
+ private String filterName;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_ROW_TYPE)
+ private String rowType;
+
+ @Override
+ public String getUserId() {
+ return userId;
+ }
+
+ @Override
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public String getFilterName() {
+ return filterName;
+ }
+
+ @Override
+ public void setFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+ @Override
+ public String getRowType() {
+ return rowType;
+ }
+
+ @Override
+ public void setRowType(String rowType) {
+ this.rowType = rowType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserExportRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserExportRequest.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserExportRequest.java
new file mode 100644
index 0000000..1583f94
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserExportRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.FormatParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class UserExportRequest extends FieldAuditLogRequest implements FormatParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FORMAT)
+ private String format;
+
+ @Override
+ public String getFormat() {
+ return format;
+ }
+
+ @Override
+ public void setFormat(String format) {
+ this.format = format;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogData.java
new file mode 100644
index 0000000..6df56a1
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogData.java
@@ -0,0 +1,149 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Date;
+import java.util.List;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public interface AuditLogData extends CommonLogData {
+
+ @JsonProperty("logType")
+ String getLogType();
+
+ void setLogType(String logType);
+
+ @JsonProperty("policy")
+ String getPolicy();
+
+ void setPolicy(String policy);
+
+ @JsonProperty("access")
+ String getAccess();
+
+ void setAccess(String access);
+
+ @JsonProperty("action")
+ String getAction();
+
+ void setAction(String action);
+
+ @JsonProperty("agent")
+ String getAgent();
+
+ void setAgent(String agent);
+
+ @JsonProperty("agentHost")
+ String getAgentHost();
+
+ void setAgentHost(String agentHost);
+
+ @JsonProperty("cliIP")
+ String getClientIp();
+
+ void setClientIp(String clientIp);
+
+ @JsonProperty("cliType")
+ String getClientType();
+
+ public void setClientType(String clientType);
+
+ @JsonProperty("reqContext")
+ String getRequestContext();
+
+ void setRequestContext(String requestContext);
+
+ @JsonProperty("enforcer")
+ String getEnforcer();
+
+ void setEnforcer(String enforcer);
+
+ @JsonProperty("evtTime")
+ Date getEventTime();
+
+ void setEventTime(Date eventTime);
+
+ @JsonProperty("reason")
+ String getReason();
+
+ void setReason(String reason);
+
+ @JsonProperty("proxyUsers")
+ List<String> getProxyUsers();
+
+ void setProxyUsers(List<String> proxyUsers);
+
+ @JsonProperty("repo")
+ String getRepo();
+
+ void setRepo(String repo);
+
+ @JsonProperty("repoType")
+ String getRepoType();
+
+ void setRepoType(String repoType);
+
+ @JsonProperty("reqData")
+ String getRequestData();
+
+ void setRequestData(String requestData);
+
+ @JsonProperty("reqUser")
+ String getRequestUser();
+
+ void setRequestUser(String requestUser);
+
+ @JsonProperty("resType")
+ String getResponseType();
+
+ void setResponseType(String requestType);
+
+ @JsonProperty("resource")
+ String getResource();
+
+ void setResource(String resource);
+
+ @JsonProperty("result")
+ Integer getResult();
+
+ void setResult(Integer result);
+
+ @JsonProperty("sess")
+ String getSession();
+
+ void setSession(String session);
+
+ @JsonProperty("tags")
+ List<String> getTags();
+
+ void setTags(List<String> tags);
+
+ @JsonProperty("tags_str")
+ String getTagsStr();
+
+ void setTagsStr(String tagsStr);
+
+ @JsonProperty("text")
+ String getText();
+
+ void setText(String text);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogResponse.java
new file mode 100644
index 0000000..a886a96
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/AuditLogResponse.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AuditLogResponse extends LogSearchResponse<AuditLogData> {
+
+ @ApiModelProperty
+ private List<AuditLogData> logList;
+
+ @Override
+ public List<AuditLogData> getLogList() {
+ return logList;
+ }
+
+ @Override
+ public void setLogList(List<AuditLogData> logList) {
+ this.logList = logList;
+ }
+
+ @Override
+ public int getListSize() {
+ return logList == null ? 0 : logList.size();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphData.java
new file mode 100644
index 0000000..3f2bd6f
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphData.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class BarGraphData implements Serializable {
+
+ @ApiModelProperty
+ private Collection<NameValueData> dataCount = new ArrayList<>();
+ @ApiModelProperty
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Collection<NameValueData> getDataCount() {
+ return dataCount;
+ }
+
+ public void setDataCount(Collection<NameValueData> dateValueCounts) {
+ this.dataCount = dateValueCounts;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphDataListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphDataListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphDataListResponse.java
new file mode 100644
index 0000000..4d5d166
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/BarGraphDataListResponse.java
@@ -0,0 +1,42 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class BarGraphDataListResponse {
+
+ @ApiModelProperty
+ protected Collection<BarGraphData> graphData = new ArrayList<>();
+
+ public Collection<BarGraphData> getGraphData() {
+ return graphData;
+ }
+
+ public void setGraphData(Collection<BarGraphData> graphData) {
+ this.graphData = graphData;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CommonLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CommonLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CommonLogData.java
new file mode 100644
index 0000000..e2bba3f
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CommonLogData.java
@@ -0,0 +1,113 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.Date;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public interface CommonLogData extends LogData {
+
+ @JsonProperty("id")
+ String getId();
+
+ void setId(String id);
+
+ @JsonProperty("case_id")
+ String getCaseId();
+
+ void setCaseId(String caseId);
+
+ @JsonProperty("log_message")
+ String getLogMessage();
+
+ void setLogMessage(String logMessage);
+
+ @JsonProperty("bundle_id")
+ String getBundleId();
+
+ void setBundleId(String bundleId);
+
+ @JsonProperty("logfile_line_number")
+ Integer getLogFileLineNumber();
+
+ void setLogFileLineNumber(Integer logFileLineNumber);
+
+ @JsonProperty("file")
+ String getFile();
+
+ void setFile(String file);
+
+ @JsonProperty("type")
+ String getType();
+
+ void setType(String type);
+
+ @JsonProperty("seq_num")
+ Long getSeqNum();
+
+ void setSeqNum(Long seqNum);
+
+ @JsonProperty("message_md5")
+ String getMessageMd5();
+
+ void setMessageMd5(String messageMd5);
+
+ @JsonProperty("cluster")
+ String getCluster();
+
+ void setCluster(String cluster);
+
+ @JsonProperty("event_count")
+ Long getEventCount();
+
+ void setEventCount(Long eventCount);
+
+ @JsonProperty("event_md5")
+ public String getEventMd5();
+
+ public void setEventMd5(String eventMd5);
+
+ @JsonProperty("event_dur_ms")
+ public Long getEventDurationMs();
+
+ public void setEventDurationMs(Long eventDurationMs);
+
+ @JsonProperty("_ttl_")
+ String getTtl();
+
+ void setTtl(String ttl);
+
+ @JsonProperty("_expire_at_")
+ Date getExpire();
+
+ void setExpire(Date expire);
+
+ @JsonProperty("_version_")
+ Long getVersion();
+
+ void setVersion(Long version);
+
+ @JsonProperty("_router_field_")
+ Integer getRouterField();
+
+ void setRouterField(Integer routerField);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ComponentTypeLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ComponentTypeLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ComponentTypeLogData.java
new file mode 100644
index 0000000..6c15f9c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/ComponentTypeLogData.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.response;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public interface ComponentTypeLogData extends LogData {
+
+ @JsonProperty("type")
+ String getType();
+
+ void setType(String type);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountData.java
new file mode 100644
index 0000000..fabaad2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountData.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CountData {
+
+ @ApiModelProperty
+ private String name;
+
+ @ApiModelProperty
+ private Long count;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Long getCount() {
+ return count;
+ }
+
+ public void setCount(Long count) {
+ this.count = count;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountDataListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountDataListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountDataListResponse.java
new file mode 100644
index 0000000..2543dcc
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/CountDataListResponse.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CountDataListResponse extends SearchResponse {
+
+ @ApiModelProperty
+ private List<CountData> vCounts;
+
+ public List<CountData> getvCounts() {
+ return vCounts;
+ }
+
+ public void setvCounts(List<CountData> vCounts) {
+ this.vCounts = vCounts;
+ }
+
+ @Override
+ public int getListSize() {
+ if (vCounts != null)
+ return vCounts.size();
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphData.java
new file mode 100644
index 0000000..e39ec95
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphData.java
@@ -0,0 +1,64 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.List;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class GraphData implements Serializable {
+
+ @ApiModelProperty
+ private String name;
+
+ @ApiModelProperty
+ private Long count;
+
+ @ApiModelProperty
+ private List<GraphData> dataList;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Long getCount() {
+ return count;
+ }
+
+ public void setCount(Long count) {
+ this.count = count;
+ }
+
+ public List<GraphData> getDataList() {
+ return dataList;
+ }
+
+ public void setDataList(List<GraphData> dataList) {
+ this.dataList = dataList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphDataListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphDataListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphDataListResponse.java
new file mode 100644
index 0000000..4357c28
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GraphDataListResponse.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.model.response;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+@ApiModel
+public class GraphDataListResponse {
+
+ @ApiModelProperty
+ protected List<GraphData> graphData;
+
+ public List<GraphData> getGraphData() {
+ return graphData;
+ }
+
+ public void setGraphData(List<GraphData> graphData) {
+ this.graphData = graphData;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GroupListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GroupListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GroupListResponse.java
new file mode 100644
index 0000000..92c51f2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/GroupListResponse.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.model.response;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel
+public class GroupListResponse extends SearchResponse {
+
+ @ApiModelProperty
+ private List<LogData> groupList = new ArrayList<>();
+
+ public List<LogData> getGroupList() {
+ return groupList;
+ }
+
+ public void setGroupList(List<LogData> groupList) {
+ this.groupList = groupList;
+ }
+
+ @Override
+ public int getListSize() {
+ if (groupList != null){
+ return groupList.size();
+ }
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/HostLogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/HostLogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/HostLogData.java
new file mode 100644
index 0000000..8cab1ab
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/HostLogData.java
@@ -0,0 +1,30 @@
+/*
+ * 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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public interface HostLogData extends LogData {
+ @JsonProperty("host")
+ String getHost();
+
+ void setHost(String host);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogData.java
new file mode 100644
index 0000000..ec6c34c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogData.java
@@ -0,0 +1,25 @@
+/*
+ * 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.model.response;
+
+import org.apache.ambari.logsearch.common.Marker;
+
+@Marker
+public interface LogData {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.java
new file mode 100644
index 0000000..5a67606
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.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.model.response;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel
+public class LogFileData {
+
+ @ApiModelProperty
+ private String name;
+
+ @ApiModelProperty
+ private String path;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.java
new file mode 100644
index 0000000..57614c3
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.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.model.response;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel
+public class LogFileDataListResponse extends SearchResponse {
+
+ @ApiModelProperty
+ private List<LogFileData> logFiles = new ArrayList<LogFileData>();
+
+ @Override
+ public int getListSize() {
+ if (logFiles == null) {
+ return 0;
+ }
+ return logFiles.size();
+ }
+
+ public List<LogFileData> getLogFiles() {
+ return logFiles;
+ }
+
+ public void setLogFiles(List<LogFileData> logFiles) {
+ this.logFiles = logFiles;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java
new file mode 100644
index 0000000..c075fe2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java
@@ -0,0 +1,27 @@
+/*
+ * 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.model.response;
+
+import java.util.List;
+
+public interface LogListResponse<T extends LogData> {
+ List<T> getLogList();
+
+ void setLogList(List<T> logList);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java
new file mode 100644
index 0000000..a63415b
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java
@@ -0,0 +1,22 @@
+/*
+ * 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.model.response;
+
+abstract public class LogSearchResponse<T extends LogData> extends SearchResponse implements LogListResponse<T> {
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.java
new file mode 100644
index 0000000..3f320e7
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class NameValueData {
+
+ @ApiModelProperty
+ private String name;
+ @ApiModelProperty
+ private String value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ if (value.contains(".") && (value.contains("e") || value.contains("E"))) {
+ this.value = getExponentialValueReplaced(value);
+ } else {
+ this.value = value;
+ }
+ }
+
+ private String getExponentialValueReplaced(String value) {
+ try{
+ Double number = Double.parseDouble(value);
+ return String.format("%.0f", number);
+ } catch(Exception e){
+ return value;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.java
new file mode 100644
index 0000000..4cb983f
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.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.model.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@ApiModel
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class NameValueDataListResponse extends SearchResponse {
+ @ApiModelProperty
+ protected List<NameValueData> vNameValues = new ArrayList<>();
+
+ public List<NameValueData> getvNameValues() {
+ return vNameValues;
+ }
+
+ public void setvNameValues(List<NameValueData> vNameValues) {
+ this.vNameValues = vNameValues;
+ }
+
+ @Override
+ public int getListSize() {
+ if (vNameValues != null) {
+ return vNameValues.size();
+ }
+ return 0;
+ }
+}
[02/15] ambari git commit: AMBARI-18310. Refactor logsearch portal
side code (oleewere)
Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java
deleted file mode 100644
index 703d877..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserDaoTest.java
+++ /dev/null
@@ -1,58 +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.dao;
-
-import java.util.Collection;
-
-import org.apache.ambari.logsearch.web.model.Role;
-import org.apache.ambari.logsearch.web.model.User;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "/applicationContext.xml" })
-public class UserDaoTest {
-
- @Autowired
- private UserDao dao;
-
- @Test
- public void testUserDaoInitAndFindUser() throws Exception {
- User user = dao.loadUserByUsername("testUserName");
- assertEquals(user.getUsername(), "testUserName");
- assertEquals(user.getFirstName(), "Test User Name");
- assertEquals(user.getLastName(), "Test User Name");
-
- Collection<? extends GrantedAuthority> authorities = user.getAuthorities();
- assertTrue(authorities.size() == 1);
-
- Role authority = (Role)authorities.iterator().next();
- assertEquals(authority.getName(), "ROLE_USER");
- assertTrue(authority.getPrivileges().size() == 1);
- assertEquals(authority.getPrivileges().get(0).getName(), "READ_PRIVILEGE");
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1d76f8fe/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
deleted file mode 100644
index 38437a4..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/resources/applicationContext.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
-xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
-xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns:util="http://www.springframework.org/schema/util"
-xsi:schemaLocation="http://www.springframework.org/schema/aop
-http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
-http://www.springframework.org/schema/beans
-http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
-http://www.springframework.org/schema/context
-http://www.springframework.org/schema/context/spring-context-4.2.xsd
-http://www.springframework.org/schema/jee
-http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
-http://www.springframework.org/schema/tx
-http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
-http://www.springframework.org/schema/task
-http://www.springframework.org/schema/task/spring-task-4.2.xsd
-http://www.springframework.org/schema/util
-http://www.springframework.org/schema/util/spring-util.xsd">
-
- <context:component-scan base-package="org.apache.ambari.logsearch" />
- <task:annotation-driven />
- <bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.common.XMLPropertiesHelper" />
-
- <bean id="propertyConfigurer" class="org.apache.ambari.logsearch.common.PropertiesHelper">
- <property name="locations">
- <list>
- <value>classpath:default.properties</value>
- <value>classpath:logsearch.properties</value>
- <value>classpath:logsearch-admin-site.xml</value>
- </list>
- </property>
- <property name="propertiesPersister" ref="xmlPropertyConfigurer" />
- </bean>
-
-</beans>