This is an automated email from the ASF dual-hosted git repository.

oleewere pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ambari-logsearch.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b4b74b  Cleanup metadata: remove/rename event history references (#45)
2b4b74b is described below

commit 2b4b74bc5abcc20824e539ad9b3b5914d7aa6af2
Author: Olivér Szabó <oleew...@gmail.com>
AuthorDate: Tue Nov 27 15:47:58 2018 +0100

    Cleanup metadata: remove/rename event history references (#45)
---
 .../EventHistoryRequestQueryConverter.java         | 67 ----------------------
 .../converter/MetadataRequestQueryConverter.java   | 67 ++++++++++++++++++++++
 ...cator.java => SolrMetadataHealthIndicator.java} |  6 +-
 .../ambari/logsearch/manager/MetadataManager.java  | 42 +++++++-------
 ...efinition.java => MetadataParamDefinition.java} |  2 +-
 ...entHistoryRequest.java => MetadataRequest.java} |  4 +-
 .../request/impl/query/MetadataQueryRequest.java   |  4 +-
 ...java => MetadataRequestQueryConverterTest.java} | 10 ++--
 8 files changed, 101 insertions(+), 101 deletions(-)

diff --git 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverter.java
 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverter.java
deleted file mode 100644
index c67c31b..0000000
--- 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverter.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.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.EventHistoryRequest;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.SolrQuery;
-
-import javax.inject.Named;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static 
org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.CLUSTER;
-import static 
org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.FILTER_NAME;
-import static 
org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.ROW_TYPE;
-
-@Named
-public class EventHistoryRequestQueryConverter extends 
AbstractConverterAware<EventHistoryRequest, SolrQuery> {
-
-  @Override
-  public SolrQuery convert(EventHistoryRequest eventHistoryRequest) {
-    SolrQuery eventHistoryQuery = new SolrQuery();
-    eventHistoryQuery.setQuery("*:*");
-
-    int startIndex = 
StringUtils.isNotEmpty(eventHistoryRequest.getStartIndex()) && 
StringUtils.isNumeric(eventHistoryRequest.getStartIndex())
-      ? Integer.parseInt(eventHistoryRequest.getStartIndex()) : 0;
-    int maxRows = StringUtils.isNotEmpty(eventHistoryRequest.getPageSize()) && 
StringUtils.isNumeric(eventHistoryRequest.getPageSize())
-      ? Integer.parseInt(eventHistoryRequest.getPageSize()) : 10;
-
-    SolrQuery.ORDER order = eventHistoryRequest.getSortType() != null && 
SolrQuery.ORDER.desc.equals(SolrQuery.ORDER.valueOf(eventHistoryRequest.getSortType()))
-      ? SolrQuery.ORDER.desc : SolrQuery.ORDER.asc;
-    String sortBy = StringUtils.isNotEmpty(eventHistoryRequest.getSortBy()) ? 
eventHistoryRequest.getSortBy() : FILTER_NAME;
-    String filterName = 
StringUtils.isBlank(eventHistoryRequest.getFilterName()) ? "*" : "*" + 
eventHistoryRequest.getFilterName() + "*";
-
-    eventHistoryQuery.addFilterQuery(String.format("%s:%s", ROW_TYPE, 
eventHistoryRequest.getRowType()));
-    eventHistoryQuery.addFilterQuery(String.format("%s:%s", FILTER_NAME, 
SolrUtil.makeSearcableString(filterName)));
-    eventHistoryQuery.setStart(startIndex);
-    eventHistoryQuery.setRows(maxRows);
-
-    SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(sortBy, 
order);
-    List<SolrQuery.SortClause> sort = new ArrayList<>();
-    sort.add(sortOrder);
-    eventHistoryQuery.setSorts(sort);
-
-    SolrUtil.addListFilterToSolrQuery(eventHistoryQuery, CLUSTER, 
eventHistoryRequest.getClusters());
-
-    return eventHistoryQuery;
-  }
-}
diff --git 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/MetadataRequestQueryConverter.java
 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/MetadataRequestQueryConverter.java
new file mode 100644
index 0000000..1010770
--- /dev/null
+++ 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/MetadataRequestQueryConverter.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.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.MetadataRequest;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import javax.inject.Named;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static 
org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.CLUSTER;
+import static 
org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.FILTER_NAME;
+import static 
org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.ROW_TYPE;
+
+@Named
+public class MetadataRequestQueryConverter extends 
AbstractConverterAware<MetadataRequest, SolrQuery> {
+
+  @Override
+  public SolrQuery convert(MetadataRequest metadataRequest) {
+    SolrQuery metadataQuery = new SolrQuery();
+    metadataQuery.setQuery("*:*");
+
+    int startIndex = StringUtils.isNotEmpty(metadataRequest.getStartIndex()) 
&& StringUtils.isNumeric(metadataRequest.getStartIndex())
+      ? Integer.parseInt(metadataRequest.getStartIndex()) : 0;
+    int maxRows = StringUtils.isNotEmpty(metadataRequest.getPageSize()) && 
StringUtils.isNumeric(metadataRequest.getPageSize())
+      ? Integer.parseInt(metadataRequest.getPageSize()) : 10;
+
+    SolrQuery.ORDER order = metadataRequest.getSortType() != null && 
SolrQuery.ORDER.desc.equals(SolrQuery.ORDER.valueOf(metadataRequest.getSortType()))
+      ? SolrQuery.ORDER.desc : SolrQuery.ORDER.asc;
+    String sortBy = StringUtils.isNotEmpty(metadataRequest.getSortBy()) ? 
metadataRequest.getSortBy() : FILTER_NAME;
+    String filterName = StringUtils.isBlank(metadataRequest.getFilterName()) ? 
"*" : "*" + metadataRequest.getFilterName() + "*";
+
+    metadataQuery.addFilterQuery(String.format("%s:%s", ROW_TYPE, 
metadataRequest.getRowType()));
+    metadataQuery.addFilterQuery(String.format("%s:%s", FILTER_NAME, 
SolrUtil.makeSearcableString(filterName)));
+    metadataQuery.setStart(startIndex);
+    metadataQuery.setRows(maxRows);
+
+    SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(sortBy, 
order);
+    List<SolrQuery.SortClause> sort = new ArrayList<>();
+    sort.add(sortOrder);
+    metadataQuery.setSorts(sort);
+
+    SolrUtil.addListFilterToSolrQuery(metadataQuery, CLUSTER, 
metadataRequest.getClusters());
+
+    return metadataQuery;
+  }
+}
diff --git 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/health/SolrEventHistoryHealthIndicator.java
 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/health/SolrMetadataHealthIndicator.java
similarity index 85%
rename from 
ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/health/SolrEventHistoryHealthIndicator.java
rename to 
ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/health/SolrMetadataHealthIndicator.java
index ab3136f..5ffa489 100644
--- 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/health/SolrEventHistoryHealthIndicator.java
+++ 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/health/SolrMetadataHealthIndicator.java
@@ -25,13 +25,13 @@ import javax.inject.Inject;
 import javax.inject.Named;
 
 @Named
-public class SolrEventHistoryHealthIndicator extends 
AbstractSolrHealthIndicator {
+public class SolrMetadataHealthIndicator extends AbstractSolrHealthIndicator {
 
   @Inject
-  private MetadataSolrDao eventHistorySolrDao;
+  private MetadataSolrDao metadataSolrDao;
 
   @Override
   public SolrTemplate getSolrTemplate() {
-    return eventHistorySolrDao.getSolrTemplate();
+    return metadataSolrDao.getSolrTemplate();
   }
 }
diff --git 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/MetadataManager.java
 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/MetadataManager.java
index 8ec5552..d98842e 100644
--- 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/MetadataManager.java
+++ 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/MetadataManager.java
@@ -25,7 +25,7 @@ import java.util.List;
 
 import org.apache.ambari.logsearch.common.LogSearchContext;
 import org.apache.ambari.logsearch.dao.MetadataSolrDao;
-import org.apache.ambari.logsearch.model.request.impl.EventHistoryRequest;
+import org.apache.ambari.logsearch.model.request.impl.MetadataRequest;
 import org.apache.ambari.logsearch.model.response.LogsearchMetaData;
 import 
org.apache.ambari.logsearch.model.response.LogSearchMetaDataListResponse;
 import org.apache.ambari.logsearch.util.SolrUtil;
@@ -62,23 +62,23 @@ public class MetadataManager extends JsonManagerBase {
   @Inject
   private ConversionService conversionService;
 
-  public String saveMetadata(LogsearchMetaData eventHistoryData) {
-    String filterName = eventHistoryData.getFiltername();
+  public String saveMetadata(LogsearchMetaData metadata) {
+    String filterName = metadata.getFiltername();
 
     SolrInputDocument solrInputDoc = new SolrInputDocument();
-    if (!isValid(eventHistoryData)) {
+    if (!isValid(metadata)) {
       throw new MalformedInputException("No FilterName Specified");
     }
 
     if (isNotUnique(filterName)) {
-      throw new AlreadyExistsException(String.format("Name '%s' already 
exists", eventHistoryData.getFiltername()));
+      throw new AlreadyExistsException(String.format("Name '%s' already 
exists", metadata.getFiltername()));
     }
-    solrInputDoc.addField(ID, eventHistoryData.getId());
+    solrInputDoc.addField(ID, metadata.getId());
     solrInputDoc.addField(USER_NAME, LogSearchContext.getCurrentUsername());
-    solrInputDoc.addField(VALUES, eventHistoryData.getValues());
+    solrInputDoc.addField(VALUES, metadata.getValues());
     solrInputDoc.addField(FILTER_NAME, filterName);
-    solrInputDoc.addField(ROW_TYPE, eventHistoryData.getRowType());
-    List<String> shareNameList = eventHistoryData.getShareNameList();
+    solrInputDoc.addField(ROW_TYPE, metadata.getRowType());
+    List<String> shareNameList = metadata.getShareNameList();
     if (CollectionUtils.isNotEmpty(shareNameList)) {
       solrInputDoc.addField(SHARE_NAME_LIST, shareNameList);
     }
@@ -119,36 +119,36 @@ public class MetadataManager extends JsonManagerBase {
   }
 
   @SuppressWarnings("unchecked")
-  public LogSearchMetaDataListResponse getMetadata(EventHistoryRequest 
request) {
+  public LogSearchMetaDataListResponse getMetadata(MetadataRequest request) {
     LogSearchMetaDataListResponse response = new 
LogSearchMetaDataListResponse();
     String rowType = request.getRowType();
     if (StringUtils.isBlank(rowType)) {
       throw new MalformedInputException("Row type was not specified");
     }
 
-    SolrQuery evemtHistoryQuery = conversionService.convert(request, 
SolrQuery.class);
-    evemtHistoryQuery.addFilterQuery(String.format("%s:%s OR %s:%s", 
USER_NAME, LogSearchContext.getCurrentUsername(),
+    SolrQuery metadataQueryQuery = conversionService.convert(request, 
SolrQuery.class);
+    metadataQueryQuery.addFilterQuery(String.format("%s:%s OR %s:%s", 
USER_NAME, LogSearchContext.getCurrentUsername(),
         SHARE_NAME_LIST, LogSearchContext.getCurrentUsername()));
-    SolrDocumentList solrList = 
metadataSolrDao.process(evemtHistoryQuery).getResults();
+    SolrDocumentList solrList = 
metadataSolrDao.process(metadataQueryQuery).getResults();
 
     Collection<LogsearchMetaData> configList = new ArrayList<>();
 
     for (SolrDocument solrDoc : solrList) {
-      LogsearchMetaData eventHistoryData = new LogsearchMetaData();
-      eventHistoryData.setFiltername("" + solrDoc.get(FILTER_NAME));
-      eventHistoryData.setId("" + solrDoc.get(ID));
-      eventHistoryData.setValues("" + solrDoc.get(VALUES));
-      eventHistoryData.setRowType("" + solrDoc.get(ROW_TYPE));
+      LogsearchMetaData metadata = new LogsearchMetaData();
+      metadata.setFiltername("" + solrDoc.get(FILTER_NAME));
+      metadata.setId("" + solrDoc.get(ID));
+      metadata.setValues("" + solrDoc.get(VALUES));
+      metadata.setRowType("" + solrDoc.get(ROW_TYPE));
       try {
         List<String> shareNameList = (List<String>) 
solrDoc.get(SHARE_NAME_LIST);
-        eventHistoryData.setShareNameList(shareNameList);
+        metadata.setShareNameList(shareNameList);
       } catch (Exception e) {
         // do nothing
       }
 
-      eventHistoryData.setUserName("" + solrDoc.get(USER_NAME));
+      metadata.setUserName("" + solrDoc.get(USER_NAME));
 
-      configList.add(eventHistoryData);
+      configList.add(metadata);
     }
 
     response.setName("metadataList");
diff --git 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/EventHistoryParamDefinition.java
 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/MetadataParamDefinition.java
similarity index 96%
rename from 
ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/EventHistoryParamDefinition.java
rename to 
ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/MetadataParamDefinition.java
index d7a5b01..39375df 100644
--- 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/EventHistoryParamDefinition.java
+++ 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/MetadataParamDefinition.java
@@ -24,7 +24,7 @@ import org.apache.ambari.logsearch.common.LogSearchConstants;
 import static 
org.apache.ambari.logsearch.doc.DocConstants.EventHistoryDescriptions.FILTER_NAME_D;
 import static 
org.apache.ambari.logsearch.doc.DocConstants.EventHistoryDescriptions.ROW_TYPE_D;
 
-public interface EventHistoryParamDefinition {
+public interface MetadataParamDefinition {
 
   String getFilterName();
 
diff --git 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/EventHistoryRequest.java
 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/MetadataRequest.java
similarity index 84%
rename from 
ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/EventHistoryRequest.java
rename to 
ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/MetadataRequest.java
index f3f8b61..3a2c1e6 100644
--- 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/EventHistoryRequest.java
+++ 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/MetadataRequest.java
@@ -19,8 +19,8 @@
 package org.apache.ambari.logsearch.model.request.impl;
 
 import org.apache.ambari.logsearch.common.Marker;
-import org.apache.ambari.logsearch.model.request.EventHistoryParamDefinition;
+import org.apache.ambari.logsearch.model.request.MetadataParamDefinition;
 
 @Marker
-public interface EventHistoryRequest extends CommonSearchRequest, 
EventHistoryParamDefinition {
+public interface MetadataRequest extends CommonSearchRequest, 
MetadataParamDefinition {
 }
diff --git 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/query/MetadataQueryRequest.java
 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/query/MetadataQueryRequest.java
index 9a6d7cc..ec55d9c 100644
--- 
a/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/query/MetadataQueryRequest.java
+++ 
b/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/query/MetadataQueryRequest.java
@@ -19,11 +19,11 @@
 package org.apache.ambari.logsearch.model.request.impl.query;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.impl.EventHistoryRequest;
+import org.apache.ambari.logsearch.model.request.impl.MetadataRequest;
 
 import javax.ws.rs.QueryParam;
 
-public class MetadataQueryRequest extends CommonSearchQueryRequest implements 
EventHistoryRequest {
+public class MetadataQueryRequest extends CommonSearchQueryRequest implements 
MetadataRequest {
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
   private String filterName;
diff --git 
a/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverterTest.java
 
b/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/MetadataRequestQueryConverterTest.java
similarity index 82%
rename from 
ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverterTest.java
rename to 
ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/MetadataRequestQueryConverterTest.java
index 705c792..b30fdd4 100644
--- 
a/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverterTest.java
+++ 
b/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/MetadataRequestQueryConverterTest.java
@@ -18,7 +18,7 @@
  */
 package org.apache.ambari.logsearch.converter;
 
-import org.apache.ambari.logsearch.model.request.impl.EventHistoryRequest;
+import org.apache.ambari.logsearch.model.request.impl.MetadataRequest;
 import 
org.apache.ambari.logsearch.model.request.impl.query.MetadataQueryRequest;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.junit.Before;
@@ -26,19 +26,19 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 
-public class EventHistoryRequestQueryConverterTest extends 
AbstractRequestConverterTest {
+public class MetadataRequestQueryConverterTest extends 
AbstractRequestConverterTest {
 
-  private EventHistoryRequestQueryConverter underTest;
+  private MetadataRequestQueryConverter underTest;
 
   @Before
   public void setUp() {
-    underTest = new EventHistoryRequestQueryConverter();
+    underTest = new MetadataRequestQueryConverter();
   }
 
   @Test
   public void testConvert() {
     // GIVEN
-    EventHistoryRequest request = new MetadataQueryRequest();
+    MetadataRequest request = new MetadataQueryRequest();
     request.setRowType("myRowType"); // TODO: validate these 3 fields @Valid 
on EventHistoryRequest object -> not null
     request.setFilterName("myFilterName");
     request.setClusters("cl1,cl2");

Reply via email to