Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0D3B8200C40 for ; Thu, 23 Mar 2017 13:43:27 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0BF73160B92; Thu, 23 Mar 2017 12:43:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AE224160B84 for ; Thu, 23 Mar 2017 13:43:24 +0100 (CET) Received: (qmail 56751 invoked by uid 500); 23 Mar 2017 12:43:21 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 52495 invoked by uid 99); 23 Mar 2017 12:43:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Mar 2017 12:43:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 74193E0ACF; Thu, 23 Mar 2017 12:43:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: oleewere@apache.org To: commits@ambari.apache.org Date: Thu, 23 Mar 2017 12:44:12 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [59/88] [abbrv] ambari git commit: AMBARI-20528. Rename Log Search Portal module to Log Search Server (oleewere) archived-at: Thu, 23 Mar 2017 12:43:27 -0000 http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java new file mode 100644 index 0000000..9ce209b --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/ServiceLogsManager.java @@ -0,0 +1,617 @@ +/* + * 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.FileOutputStream; +import java.io.IOException; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateException; + +import org.apache.ambari.logsearch.common.HadoopServiceConfigHelper; +import org.apache.ambari.logsearch.common.LogSearchConstants; +import org.apache.ambari.logsearch.common.LogType; +import org.apache.ambari.logsearch.common.MessageEnums; +import org.apache.ambari.logsearch.common.StatusMessage; +import org.apache.ambari.logsearch.dao.ServiceLogsSolrDao; +import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao; +import org.apache.ambari.logsearch.model.request.impl.HostLogFilesRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogAggregatedInfoRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogLevelCountRequest; +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.HostLogFilesResponse; +import org.apache.ambari.logsearch.model.response.LogData; +import org.apache.ambari.logsearch.model.response.LogListResponse; +import org.apache.ambari.logsearch.model.response.NameValueDataListResponse; +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.converter.BaseServiceLogRequestQueryConverter; +import org.apache.ambari.logsearch.converter.ServiceLogTruncatedRequestQueryConverter; +import org.apache.ambari.logsearch.solr.ResponseDataGenerator; +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.DownloadUtil; +import org.apache.ambari.logsearch.util.DateUtil; +import org.apache.ambari.logsearch.util.RESTErrorUtil; +import org.apache.ambari.logsearch.util.SolrUtil; +import org.apache.commons.collections.CollectionUtils; +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.client.solrj.response.UpdateResponse; +import org.apache.solr.common.SolrDocument; +import org.apache.solr.common.SolrDocumentList; +import org.apache.solr.common.SolrException; +import org.springframework.core.convert.ConversionService; +import org.springframework.data.solr.core.DefaultQueryParser; +import org.springframework.data.solr.core.query.Criteria; +import org.springframework.data.solr.core.query.SimpleFacetQuery; +import org.springframework.data.solr.core.query.SimpleFilterQuery; +import org.springframework.data.solr.core.query.SimpleQuery; +import org.springframework.data.solr.core.query.SimpleStringCriteria; + +import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.CLUSTER; +import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.ID; +import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.SEQUENCE_ID; +import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT; +import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.HOST; +import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.KEY_LOG_MESSAGE; +import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL; +import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME; + +@Named +public class ServiceLogsManager extends ManagerBase { + private static final Logger logger = Logger.getLogger(ServiceLogsManager.class); + + private static final String SERVICE_LOG_TEMPLATE = "service_log_txt.ftl"; + + @Inject + private ServiceLogsSolrDao serviceLogsSolrDao; + @Inject + private ResponseDataGenerator responseDataGenerator; + @Inject + private ConversionService conversionService; + @Inject + private Configuration freemarkerConfiguration; + @Inject + private SolrSchemaFieldDao solrSchemaFieldDao; + + public ServiceLogResponse searchLogs(ServiceLogRequest request) { + String event = "/service/logs"; + String keyword = request.getKeyWord(); + Boolean isLastPage = request.isLastPage(); + SimpleQuery solrQuery = conversionService.convert(request, SimpleQuery.class); + if (StringUtils.isNotBlank(keyword)) { + try { + return (ServiceLogResponse) getPageByKeyword(request, event); + } 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 (isLastPage) { + ServiceLogResponse logResponse = getLastPage(serviceLogsSolrDao, solrQuery, event); + if (logResponse == null){ + logResponse = new ServiceLogResponse(); + } + return logResponse; + } else { + ServiceLogResponse response = getLogAsPaginationProvided(solrQuery, serviceLogsSolrDao, event); + if (response.getTotalCount() > 0 && CollectionUtils.isEmpty(response.getLogList())) { + request.setLastPage(true); + solrQuery = conversionService.convert(request, SimpleQuery.class); + ServiceLogResponse lastResponse = getLastPage(serviceLogsSolrDao, solrQuery, event); + if (lastResponse != null){ + response = lastResponse; + } + } + return response; + } + } + + public GroupListResponse getHosts(String clusters) { + return getFields(HOST, clusters, SolrHostLogData.class); + } + + public GroupListResponse getComponents(String clusters) { + return getFields(COMPONENT, clusters, SolrComponentTypeLogData.class); + } + + public GraphDataListResponse getAggregatedInfo(ServiceLogAggregatedInfoRequest request) { + SimpleQuery solrDataQuery = new BaseServiceLogRequestQueryConverter().convert(request); + SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(solrDataQuery); + String hierarchy = String.format("%s,%s,%s", HOST, COMPONENT, LEVEL); + solrQuery.setQuery("*:*"); + SolrUtil.setFacetPivot(solrQuery, 1, hierarchy); + QueryResponse response = serviceLogsSolrDao.process(solrQuery); + return responseDataGenerator.generateSimpleGraphResponse(response, hierarchy); + } + + public CountDataListResponse getFieldCount(String field, String clusters) { + SimpleFacetQuery facetQuery = conversionService.convert(field, SimpleFacetQuery.class); + if (StringUtils.isEmpty(clusters)) { + List clusterFilterList = Splitter.on(",").splitToList(clusters); + facetQuery.addFilterQuery(new SimpleFilterQuery(new Criteria(CLUSTER).in(clusterFilterList))); + } + return responseDataGenerator.generateCountResponseByField(serviceLogsSolrDao.process(facetQuery), field); + } + + public CountDataListResponse getComponentsCount(String clusters) { + return getFieldCount(COMPONENT, clusters); + } + + public CountDataListResponse getHostsCount(String clusters) { + return getFieldCount(HOST, clusters); + } + + public NodeListResponse getTreeExtension(ServiceLogHostComponentRequest request) { + SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class); + SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(facetQuery); + String hostName = request.getHostName() == null ? "" : request.getHostName(); + if (StringUtils.isNotBlank(hostName)){ + solrQuery.addFilterQuery(String.format("%s:*%s*", HOST, hostName)); + } + QueryResponse response = serviceLogsSolrDao.process(solrQuery, "/service/logs/tree"); + String firstHierarchy = String.format("%s,%s,%s", HOST, COMPONENT, LEVEL); + String secondHierarchy = String.format("%s,%s", HOST, LEVEL); + return responseDataGenerator.generateServiceNodeTreeFromFacetResponse(response, firstHierarchy, secondHierarchy, + LogSearchConstants.HOST, LogSearchConstants.COMPONENT); + } + + public NodeListResponse getHostListByComponent(ServiceLogComponentHostRequest request) { + SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class); + SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(facetQuery); + solrQuery.setFacetSort(request.getSortBy() == null ? HOST: request.getSortBy()); + + NodeListResponse list = new NodeListResponse(); + String componentName = request.getComponentName() == null ? "" : request.getComponentName(); + if (StringUtils.isNotBlank(componentName)){ + solrQuery.addFilterQuery(COMPONENT + ":" + + componentName); + QueryResponse response = serviceLogsSolrDao.process(solrQuery, "/service/logs/hosts/components"); + String firstHierarchy = String.format("%s,%s,%s", COMPONENT, HOST, LEVEL); + String secondHierarchy = String.format("%s,%s", COMPONENT, LEVEL); + return responseDataGenerator.generateServiceNodeTreeFromFacetResponse(response, firstHierarchy, secondHierarchy, + LogSearchConstants.COMPONENT, LogSearchConstants.HOST); + } else { + return list; + } + } + + public NameValueDataListResponse getLogsLevelCount(ServiceLogLevelCountRequest request) { + SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class); + QueryResponse response = serviceLogsSolrDao.process(facetQuery, "/service/logs/levels/counts"); + return responseDataGenerator.getNameValueDataListResponseWithDefaults(response, LogSearchConstants.SUPPORTED_LOG_LEVELS, false); + } + + public BarGraphDataListResponse getHistogramData(ServiceGraphRequest request) { + SolrQuery solrQuery = conversionService.convert(request, SolrQuery.class); + QueryResponse response = serviceLogsSolrDao.process(solrQuery, "/service/logs/histogram"); + return responseDataGenerator.generateBarGraphDataResponseWithRanges(response, LEVEL, true); + } + + public LogListResponse getPageByKeyword(ServiceLogRequest request, String event) + throws SolrServerException { + String defaultChoice = "0"; + String keyword = request.getKeyWord(); + if (StringUtils.isBlank(keyword)) { + throw RESTErrorUtil.createRESTException("Keyword was not given", MessageEnums.DATA_NOT_FOUND); + } + + boolean isNext = !defaultChoice.equals(request.getKeywordType()); // 1 is next, 0 is previous + return getPageForKeywordByType(request, keyword, isNext, event); + } + + private LogListResponse getPageForKeywordByType(ServiceLogRequest request, String keyword, boolean isNext, String event) { + String fromDate = request.getFrom(); // store start & end dates + String toDate = request.getTo(); + boolean timeAscending = LogSearchConstants.ASCENDING_ORDER.equals(request.getSortType()); + + int currentPageNumber = Integer.parseInt(request.getPage()); + int maxRows = Integer.parseInt(request.getPageSize()); + Date logDate = getDocDateFromNextOrLastPage(request, keyword, isNext, currentPageNumber, maxRows); + if (logDate == null) { + throw RESTErrorUtil.createRESTException("The keyword " + "\"" + keyword + "\"" + " was not found", MessageEnums.ERROR_SYSTEM); + } + + String nextOrPreviousPageDate = DateUtil.convertDateWithMillisecondsToSolrDate(logDate); + SolrServiceLogData firstKeywordLog = getNextHitForKeyword(request, keyword, isNext, event, timeAscending, nextOrPreviousPageDate); + + long keywordSeqNum = firstKeywordLog.getSeqNum(); + String keywordLogtime = DateUtil.convertDateWithMillisecondsToSolrDate(firstKeywordLog.getLogTime()); + + long numberOfDateDuplicates = countNumberOfDuplicates(request, isNext, keywordSeqNum, keywordLogtime); + + long numberOfLogsUntilFound = getNumberOfLogsUntilFound(request, fromDate, toDate, timeAscending, keywordLogtime, numberOfDateDuplicates); + int start = (int) ((numberOfLogsUntilFound / maxRows)); + + request.setFrom(fromDate); + request.setTo(toDate); + request.setPage(String.valueOf(start)); + SolrQuery keywordNextPageQuery = new DefaultQueryParser().doConstructSolrQuery(conversionService.convert(request, SimpleQuery.class)); + return getLogAsPaginationProvided(keywordNextPageQuery, serviceLogsSolrDao, event); + } + + private Long getNumberOfLogsUntilFound(ServiceLogRequest request, String fromDate, String toDate, boolean timeAscending, + String keywordLogtime, long numberOfDateDuplicates) { + if (!timeAscending) { + request.setTo(toDate); + request.setFrom(keywordLogtime); + } else { + request.setTo(keywordLogtime); + request.setFrom(fromDate); + } + SimpleQuery rangeQuery = conversionService.convert(request, SimpleQuery.class); + return serviceLogsSolrDao.count(rangeQuery) - numberOfDateDuplicates; + } + + private long countNumberOfDuplicates(ServiceLogRequest request, boolean isNext, long keywordSeqNum, String keywordLogtime) { + request.setFrom(keywordLogtime); + request.setTo(keywordLogtime); + SimpleQuery duplicationsQuery = conversionService.convert(request, SimpleQuery.class); + if (isNext) { + duplicationsQuery.addFilterQuery(new SimpleFilterQuery(new SimpleStringCriteria(String.format("%s:[* TO %d]", SEQUENCE_ID, keywordSeqNum - 1)))); + } else { + duplicationsQuery.addFilterQuery(new SimpleFilterQuery(new SimpleStringCriteria(String.format("%s:[%d TO *]", SEQUENCE_ID, keywordSeqNum + 1)))); + } + return serviceLogsSolrDao.count(duplicationsQuery); + } + + private SolrServiceLogData getNextHitForKeyword(ServiceLogRequest request, String keyword, boolean isNext, String event, boolean timeAscending, String nextOrPreviousPageDate) { + if (hasNextOrAscOrder(isNext, timeAscending)) { + request.setTo(nextOrPreviousPageDate); + } else { + request.setFrom(nextOrPreviousPageDate); + } + SimpleQuery keywordNextQuery = conversionService.convert(request, SimpleQuery.class); + keywordNextQuery.addFilterQuery(new SimpleFilterQuery(new Criteria(KEY_LOG_MESSAGE).contains(keyword))); + keywordNextQuery.setRows(1); + SolrQuery kewordNextSolrQuery = new DefaultQueryParser().doConstructSolrQuery(keywordNextQuery); + kewordNextSolrQuery.setStart(0); + if (hasNextOrAscOrder(isNext, timeAscending)) { + kewordNextSolrQuery.setSort(LOGTIME, SolrQuery.ORDER.desc); + } else { + kewordNextSolrQuery.setSort(LOGTIME, SolrQuery.ORDER.asc); + } + kewordNextSolrQuery.addSort(SEQUENCE_ID, SolrQuery.ORDER.desc); + QueryResponse queryResponse = serviceLogsSolrDao.process(kewordNextSolrQuery, event); + if (queryResponse == null) { + throw RESTErrorUtil.createRESTException("The keyword " + "\"" + keyword + "\"" + " was not found", MessageEnums.ERROR_SYSTEM); + } + List solrServiceLogDataList = queryResponse.getBeans(SolrServiceLogData.class); + if (!CollectionUtils.isNotEmpty(solrServiceLogDataList)) { + throw RESTErrorUtil.createRESTException("The keyword " + "\"" + keyword + "\"" + " was not found", MessageEnums.ERROR_SYSTEM); + } + return solrServiceLogDataList.get(0); + } + + private Date getDocDateFromNextOrLastPage(ServiceLogRequest request, String keyword, boolean isNext, int currentPageNumber, int maxRows) { + int lastOrFirstLogIndex; + if (isNext) { + lastOrFirstLogIndex = ((currentPageNumber + 1) * maxRows); + } else { + if (currentPageNumber == 0) { + throw RESTErrorUtil.createRESTException("This is the first Page", MessageEnums.DATA_NOT_FOUND); + } + lastOrFirstLogIndex = (currentPageNumber * maxRows) - 1; + } + SimpleQuery sq = conversionService.convert(request, SimpleQuery.class); + SolrQuery nextPageLogTimeQuery = new DefaultQueryParser().doConstructSolrQuery(sq); + nextPageLogTimeQuery.remove("start"); + nextPageLogTimeQuery.remove("rows"); + nextPageLogTimeQuery.setStart(lastOrFirstLogIndex); + nextPageLogTimeQuery.setRows(1); + + QueryResponse queryResponse = serviceLogsSolrDao.process(nextPageLogTimeQuery); + if (queryResponse == null) { + throw RESTErrorUtil.createRESTException(String.format("Cannot process next page query for \"%s\" ", keyword), MessageEnums.ERROR_SYSTEM); + } + SolrDocumentList docList = queryResponse.getResults(); + if (docList == null || docList.isEmpty()) { + throw RESTErrorUtil.createRESTException(String.format("Next page element for \"%s\" is not found", keyword), MessageEnums.ERROR_SYSTEM); + } + + SolrDocument solrDoc = docList.get(0); + return (Date) solrDoc.get(LOGTIME); + } + + private boolean hasNextOrAscOrder(boolean isNext, boolean timeAscending) { + return isNext && !timeAscending || !isNext && timeAscending; + } + + public Response export(ServiceLogExportRequest request) { + String defaultFormat = "text"; + SimpleQuery solrQuery = conversionService.convert(request, SimpleQuery.class); + String from = request.getFrom(); + String to = request.getTo(); + String utcOffset = StringUtils.isBlank(request.getUtcOffset()) ? "0" : request.getUtcOffset(); + String format = request.getFormat() != null && defaultFormat.equalsIgnoreCase(request.getFormat()) ? ".txt" : ".json"; + String fileName = "Component_Logs_" + DateUtil.getCurrentDateInString(); + + 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 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); + } + + if (format.toLowerCase(Locale.ENGLISH).equals(".txt")) { + Template template = freemarkerConfiguration.getTemplate(SERVICE_LOG_TEMPLATE); + Map models = new HashMap<>(); + DownloadUtil.fillModelsForLogFile(docList, models, request, format, from, to); + StringWriter stringWriter = new StringWriter(); + template.process(models, stringWriter); + textToSave = stringWriter.toString(); + } 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); + } + File file = File.createTempFile(fileName, format); + FileOutputStream fis = new FileOutputStream(file); + fis.write(textToSave.getBytes()); + return Response + .ok(file, MediaType.APPLICATION_OCTET_STREAM) + .header("Content-Disposition", "attachment;filename=" + fileName + format) + .build(); + } catch (SolrException | TemplateException | IOException e) { + logger.error("Error during solrQuery=" + solrQuery, e); + throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM); + } + } + + public NodeListResponse getComponentListWithLevelCounts(ServiceLogComponentLevelRequest request) { + SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class); + SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(facetQuery); + solrQuery.setFacetSort(StringUtils.isEmpty(request.getSortBy()) ? COMPONENT: request.getSortBy()); + QueryResponse response = serviceLogsSolrDao.process(facetQuery, "/service/logs/components/levels/counts"); + return responseDataGenerator.generateOneLevelServiceNodeTree(response, String.format("%s,%s", COMPONENT, LEVEL)); + } + + public String getServiceLogsSchemaFieldsName() { + return convertObjToString(solrSchemaFieldDao.getSchemaFieldNameMap(LogType.SERVICE)); + } + + public BarGraphDataListResponse getAnyGraphCountData(ServiceAnyGraphRequest request) { + SimpleFacetQuery solrDataQuery = conversionService.convert(request, SimpleFacetQuery.class); + QueryResponse queryResponse = serviceLogsSolrDao.process(solrDataQuery); + return responseDataGenerator.getGraphDataWithDefaults(queryResponse, LEVEL, LogSearchConstants.SUPPORTED_LOG_LEVELS); + } + + public ServiceLogResponse getAfterBeforeLogs(ServiceLogTruncatedRequest request) { + ServiceLogResponse logResponse = new ServiceLogResponse(); + List docList = null; + String scrollType = request.getScrollType() != null ? request.getScrollType() : ""; + + String logTime = null; + String sequenceId = null; + SolrQuery solrQuery = new SolrQuery(); + solrQuery.setQuery("*:*"); + solrQuery.setRows(1); + solrQuery.addFilterQuery(String.format("%s:%s", ID, request.getId())); + 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().toString(); + } + if (StringUtils.isBlank(logTime)) { + return logResponse; + } + if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType) || LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) { + List solrDocList = new ArrayList<>(); + ServiceLogResponse beforeAfterResponse = whenScroll(request, logTime, sequenceId, scrollType); + if (beforeAfterResponse.getLogList() == null) { + return logResponse; + } + for (ServiceLogData solrDoc : beforeAfterResponse.getLogList()) { + solrDocList.add(solrDoc); + } + logResponse.setLogList(solrDocList); + return logResponse; + + } else { + logResponse = new ServiceLogResponse(); + List initial = new ArrayList<>(); + List before = whenScroll(request, logTime, sequenceId, LogSearchConstants.SCROLL_TYPE_BEFORE).getLogList(); + List after = whenScroll(request, logTime, sequenceId, LogSearchConstants.SCROLL_TYPE_AFTER).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 whenScroll(ServiceLogTruncatedRequest request, String logTime, String sequenceId, String afterOrBefore) { + request.setScrollType(afterOrBefore); + ServiceLogTruncatedRequestQueryConverter converter = new ServiceLogTruncatedRequestQueryConverter(); + converter.setLogTime(logTime); + converter.setSequenceId(sequenceId); + return getLogAsPaginationProvided(converter.convert(request), serviceLogsSolrDao, "service/logs/truncated"); + } + + @Override + protected List convertToSolrBeans(QueryResponse response) { + return response.getBeans(SolrServiceLogData.class); + } + + @Override + protected ServiceLogResponse createLogSearchResponse() { + return new ServiceLogResponse(); + } + + private List getLogDataListByFieldType(Class clazz, QueryResponse response, List fieldList) { + List groupList = getComponentBeans(clazz, response); + String temp = ""; + for (Count cnt : fieldList) { + LogData logData = createNewFieldByType(clazz, cnt, temp); + groupList.add(logData); + } + return groupList; + } + + private List getComponentBeans(Class clazz, QueryResponse response) { + if (clazz.isAssignableFrom(SolrHostLogData.class) || clazz.isAssignableFrom(SolrComponentTypeLogData.class)) { + return (List) response.getBeans(clazz); + } else { + throw new UnsupportedOperationException(); + } + } + + private GroupListResponse getFields(String field, String clusters, Class clazz) { + SolrQuery solrQuery = new SolrQuery(); + solrQuery.setQuery("*:*"); + SolrUtil.addListFilterToSolrQuery(solrQuery, CLUSTER, clusters); + GroupListResponse collection = new GroupListResponse(); + SolrUtil.setFacetField(solrQuery, + field); + SolrUtil.setFacetSort(solrQuery, LogSearchConstants.FACET_INDEX); + QueryResponse response = serviceLogsSolrDao.process(solrQuery); + if (response == null) { + return collection; + } + FacetField facetField = response + .getFacetField(field); + if (facetField == null) { + return collection; + } + List fieldList = facetField.getValues(); + if (fieldList == null) { + return collection; + } + SolrDocumentList docList = response.getResults(); + if (docList == null) { + return collection; + } + List groupList = getLogDataListByFieldType(clazz, response, fieldList); + + collection.setGroupList(groupList); + if (!docList.isEmpty()) { + collection.setStartIndex((int) docList.getStart()); + collection.setTotalCount(docList.getNumFound()); + } + return collection; + } + + private LogData createNewFieldByType(Class 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(); + } + + + public String getHadoopServiceConfigJSON() { + String hadoopServiceConfigJSON = HadoopServiceConfigHelper.getHadoopServiceConfigJSON(); + if (hadoopServiceConfigJSON == null) { + throw RESTErrorUtil.createRESTException("Could not load HadoopServiceConfig.json", MessageEnums.ERROR_SYSTEM); + } + return hadoopServiceConfigJSON; + } + + public HostLogFilesResponse getHostLogFileData(HostLogFilesRequest request) { + SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class); + QueryResponse queryResponse = serviceLogsSolrDao.process(facetQuery, "/service/logs/hostlogfiles"); + return responseDataGenerator.generateHostLogFilesResponse(queryResponse); + } + + public StatusMessage deleteLogs(ServiceLogRequest request) { + SimpleQuery solrQuery = conversionService.convert(request, SimpleQuery.class); + UpdateResponse updateResponse = serviceLogsSolrDao.deleteByQuery(solrQuery, "/service/logs"); + return new StatusMessage(updateResponse.getStatus()); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java new file mode 100644 index 0000000..e8b699e --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/SessionManager.java @@ -0,0 +1,77 @@ +/* + * 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 javax.inject.Named; + +@Named +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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java new file mode 100644 index 0000000..a60fc5c --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java @@ -0,0 +1,223 @@ +/* + * 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.LogSearchContext; +import org.apache.ambari.logsearch.common.MessageEnums; +import org.apache.ambari.logsearch.dao.UserConfigSolrDao; +import org.apache.ambari.logsearch.model.common.LogFeederDataMap; +import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest; +import org.apache.ambari.logsearch.model.response.UserConfigData; +import org.apache.ambari.logsearch.model.response.UserConfigDataListResponse; +import org.apache.ambari.logsearch.util.RESTErrorUtil; +import org.apache.ambari.logsearch.util.SolrUtil; +import org.apache.commons.collections.CollectionUtils; +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.core.convert.ConversionService; + +import javax.inject.Inject; +import javax.inject.Named; + +import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ID; +import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.USER_NAME; +import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.VALUES; +import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.FILTER_NAME; +import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.ROW_TYPE; +import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.SHARE_NAME_LIST; + +@Named +public class UserConfigManager extends JsonManagerBase { + + private static final Logger logger = Logger.getLogger(UserConfigManager.class); + + @Inject + private UserConfigSolrDao userConfigSolrDao; + @Inject + private ConversionService conversionService; + + public String saveUserConfig(UserConfigData userConfig) { + String filterName = userConfig.getFiltername(); + + SolrInputDocument solrInputDoc = new SolrInputDocument(); + if (!isValid(userConfig)) { + throw RESTErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA); + } + + if (isNotUnique(filterName)) { + throw RESTErrorUtil.createRESTException( "Name '" + userConfig.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA); + } + solrInputDoc.addField(ID, userConfig.getId()); + solrInputDoc.addField(USER_NAME, LogSearchContext.getCurrentUsername()); + solrInputDoc.addField(VALUES, userConfig.getValues()); + solrInputDoc.addField(FILTER_NAME, filterName); + solrInputDoc.addField(ROW_TYPE, userConfig.getRowType()); + List shareNameList = userConfig.getShareNameList(); + if (CollectionUtils.isNotEmpty(shareNameList)) { + solrInputDoc.addField(SHARE_NAME_LIST, shareNameList); + } + + 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(String filterName) { + + if (filterName != null) { + SolrQuery solrQuery = new SolrQuery(); + filterName = SolrUtil.makeSearcableString(filterName); + solrQuery.setQuery("*:*"); + solrQuery.addFilterQuery(FILTER_NAME + ":" + filterName); + solrQuery.addFilterQuery(USER_NAME + ":" + LogSearchContext.getCurrentUsername()); + SolrUtil.setRowCount(solrQuery, 0); + try { + Long numFound = userConfigSolrDao.process(solrQuery).getResults().getNumFound(); + if (numFound > 0) { + return true; + } + } catch (SolrException e) { + logger.error("Error while checking if userConfig is unique.", e); + } + } + return false; + } + + private boolean isValid(UserConfigData vHistory) { + return StringUtils.isNotBlank(vHistory.getFiltername()) + && StringUtils.isNotBlank(vHistory.getRowType()) + && StringUtils.isNotBlank(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 UserConfigDataListResponse getUserConfig(UserConfigRequest request) { + UserConfigDataListResponse response = new UserConfigDataListResponse(); + String rowType = request.getRowType(); + if (StringUtils.isBlank(rowType)) { + throw RESTErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA); + } + + SolrQuery userConfigQuery = conversionService.convert(request, SolrQuery.class); + userConfigQuery.addFilterQuery(String.format("%s:%s OR %s:%s", USER_NAME, LogSearchContext.getCurrentUsername(), + SHARE_NAME_LIST, LogSearchContext.getCurrentUsername())); + SolrDocumentList solrList = userConfigSolrDao.process(userConfigQuery).getResults(); + + Collection configList = new ArrayList<>(); + + for (SolrDocument solrDoc : solrList) { + UserConfigData userConfig = new UserConfigData(); + userConfig.setFiltername("" + solrDoc.get(FILTER_NAME)); + userConfig.setId("" + solrDoc.get(ID)); + userConfig.setValues("" + solrDoc.get(VALUES)); + userConfig.setRowType("" + solrDoc.get(ROW_TYPE)); + try { + List shareNameList = (List) solrDoc.get(SHARE_NAME_LIST); + userConfig.setShareNameList(shareNameList); + } catch (Exception e) { + // do nothing + } + + userConfig.setUserName("" + solrDoc.get(USER_NAME)); + + configList.add(userConfig); + } + + response.setName("historyList"); + response.setUserConfigList(configList); + + response.setStartIndex(Integer.parseInt(request.getStartIndex())); + response.setPageSize(Integer.parseInt(request.getPageSize())); + + response.setTotalCount((long) solrList.getNumFound()); + + return response; + + } + + // ////////////////////////////LEVEL FILTER///////////////////////////////////// + + public LogFeederDataMap getUserFilter() { + LogFeederDataMap userFilter; + try { + userFilter = userConfigSolrDao.getUserFilter(); + } catch (SolrServerException | IOException e) { + logger.error(e); + throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM); + } + return userFilter; + } + + public LogFeederDataMap saveUserFiter(LogFeederDataMap logfeederFilters) { + try { + userConfigSolrDao.saveUserFilter(logfeederFilters); + } 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 List getAllUserName() { + List userList = new ArrayList(); + try { + SolrQuery userListQuery = new SolrQuery(); + userListQuery.setQuery("*:*"); + SolrUtil.setFacetField(userListQuery, USER_NAME); + QueryResponse queryResponse = userConfigSolrDao.process(userListQuery); + if (queryResponse == null) { + return userList; + } + List counList = queryResponse.getFacetField(USER_NAME).getValues(); + for (Count cnt : counList) { + String userName = cnt.getName(); + userList.add(userName); + } + } catch (SolrException e) { + logger.warn("Error getting all users.", e); + throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM); + } + return userList; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogFeederDataMap.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogFeederDataMap.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogFeederDataMap.java new file mode 100644 index 0000000..cc7d53d --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogFeederDataMap.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.common; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.TreeMap; + +@ApiModel +public class LogFeederDataMap { + + @ApiModelProperty + private String id; + + @ApiModelProperty + private TreeMap filter; + + public TreeMap getFilter() { + return filter; + } + + public void setFilter(TreeMap filter) { + this.filter = filter; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogfeederFilterData.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogfeederFilterData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogfeederFilterData.java new file mode 100644 index 0000000..e0f8013 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/common/LogfeederFilterData.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.model.common; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; + +@ApiModel +public class LogfeederFilterData { + + @ApiModelProperty + private String label; + + @ApiModelProperty + private List hosts = new ArrayList<>(); + + @ApiModelProperty + private List defaultLevels = new ArrayList<>(); + + @ApiModelProperty + private List overrideLevels = new ArrayList<>(); + + @ApiModelProperty + private String expiryTime; + + public LogfeederFilterData() { + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List getHosts() { + return hosts; + } + + public void setHosts(List hosts) { + this.hosts = hosts; + } + + public List getDefaultLevels() { + return defaultLevels; + } + + public void setDefaultLevels(List defaultLevels) { + this.defaultLevels = defaultLevels; + } + + public List getOverrideLevels() { + return overrideLevels; + } + + public void setOverrideLevels(List overrideLevels) { + this.overrideLevels = overrideLevels; + } + + public String getExpiryTime() { + return expiryTime; + } + + public void setExpiryTime(String expiryTime) { + this.expiryTime = expiryTime; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/AnyGraphParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/AnyGraphParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/BundleIdParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/BundleIdParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ClustersParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ClustersParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ClustersParamDefinition.java new file mode 100644 index 0000000..cb15b0a --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ClustersParamDefinition.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.CLUSTER_D; + +public interface ClustersParamDefinition { + + String getClusters(); + + @ApiParam(value = CLUSTER_D, name = LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) + void setClusters(String cluster); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/CommonSearchParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/CommonSearchParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/DateRangeParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/DateRangeParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/FieldParamDefinition.java new file mode 100644 index 0000000..66b3eeb --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/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, required = true) + void setField(String field); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/FormatParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/FormatParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/HostComponentParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/HostComponentParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/HostComponentParamDefinition.java new file mode 100644 index 0000000..914b5f0 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/HostComponentParamDefinition.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_NAME_D; +import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.COMPONENT_NAME_D; + +public interface HostComponentParamDefinition { + + 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); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LastPageParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LastPageParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.java new file mode 100644 index 0000000..4840eaa --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LogParamDefinition.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.request; + +import io.swagger.annotations.ApiParam; +import org.apache.ambari.logsearch.common.LogSearchConstants; + +import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.E_MESSAGE_D; +import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.I_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 getiMessage(); + + @ApiParam(value = I_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_I_MESSAGE) + void setiMessage(String iMessage); + + String geteMessage(); + + @ApiParam(value = E_MESSAGE_D, name = LogSearchConstants.REQUEST_PARAM_E_MESSAGE) + void seteMessage(String eMessage); + + 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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/LogTruncatedParamDefinition.java new file mode 100644 index 0000000..d3832c1 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/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); + + Integer getNumberRows(); + + @ApiParam(value = NUMBER_ROWS_D, name = LogSearchConstants.REQUEST_PARAM_NUMBER_ROWS) + void setNumberRows(Integer numberRows); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.java new file mode 100644 index 0000000..8b275b6 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/SearchRequest.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.request; + +public interface SearchRequest extends ClustersParamDefinition { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.java new file mode 100644 index 0000000..9306bb5 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogParamDefinition.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.HOST_PARAMS_D; +import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.LEVEL_D; +import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.FILE_NAME_D; + +public interface ServiceLogParamDefinition extends HostComponentParamDefinition { + + String getLevel(); + + @ApiParam(value = LEVEL_D, name = LogSearchConstants.REQUEST_PARAM_LEVEL) + void setLevel(String level); + + String getFileName(); + + @ApiParam(value = FILE_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILE_NAME) + void setFileName(String fileName); + + String getHostList(); + + @ApiParam(value = HOST_PARAMS_D, name = LogSearchConstants.REQUEST_PARAM_HOSTS) + void setHostList(String hostList); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogSearchParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/ServiceLogSearchParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.java new file mode 100644 index 0000000..97d9543 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/TopParamDefinition.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.TOP; + +public interface TopParamDefinition { + Integer getTop(); + + @ApiParam(value = TOP, name = LogSearchConstants.REQUEST_PARAM_TOP, required = true) + void setTop(Integer top); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UnitParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UnitParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/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-server/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/e8ca4ee9/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java new file mode 100644 index 0000000..dd74b6f --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.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.UserConfigDescriptions.FILTER_NAME_D; +import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.ROW_TYPE_D; + +public interface UserConfigParamDefinition { + + 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); +}