You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by GitBox <gi...@apache.org> on 2018/11/27 14:48:00 UTC

[GitHub] oleewere closed pull request #45: Cleanup metadata: remove/rename event history references

oleewere closed pull request #45: Cleanup metadata: remove/rename event history references
URL: https://github.com/apache/ambari-logsearch/pull/45
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 c67c31b54c..0000000000
--- 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 0000000000..10107707d0
--- /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 ab3136f96d..5ffa489ccb 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.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 8ec55520ea..d98842e35f 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 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 @@
   @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 void deleteMetadata(String id) {
   }
 
   @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 d7a5b01502..39375df7ae 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 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 f3f8b61dbf..3a2c1e6c4f 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 9a6d7cc4b1..ec55d9c253 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 705c792cd9..b30fdd4ba4 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 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");


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services