ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject ambari git commit: AMBARI-20623. Cleanup swagger rest api doc for Log Search (oleewere)
Date Thu, 30 Mar 2017 19:48:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 25bfb9ec6 -> 651310663


AMBARI-20623. Cleanup swagger rest api doc for Log Search (oleewere)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/65131066
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/65131066
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/65131066

Branch: refs/heads/trunk
Commit: 651310663d99ea8513d105f5af707097c31b9fa4
Parents: 25bfb9e
Author: oleewere <oleewere@gmail.com>
Authored: Thu Mar 30 21:47:36 2017 +0200
Committer: oleewere <oleewere@gmail.com>
Committed: Thu Mar 30 21:47:58 2017 +0200

----------------------------------------------------------------------
 .../FieldAuditLogRequestQueryConverter.java     |  1 -
 .../TopFieldAuditLogRequestQueryConverter.java  | 54 +++++++++++++++++
 .../logsearch/manager/AuditLogsManager.java     |  3 +-
 .../request/impl/FieldAuditLogRequest.java      | 17 +-----
 .../request/impl/TopFieldAuditLogRequest.java   | 40 +++++++++++++
 .../logsearch/rest/AuditLogsResource.java       |  4 +-
 .../logsearch/rest/UserConfigResource.java      |  2 +-
 .../FieldAuditLogRequestQueryConverterTest.java |  3 +-
 ...pFieldAuditLogRequestQueryConverterTest.java | 61 ++++++++++++++++++++
 .../main/webapp/scripts/views/common/Header.js  |  6 +-
 10 files changed, 165 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
index a4e613b..bf6a457 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverter.java
@@ -33,7 +33,6 @@ public class FieldAuditLogRequestQueryConverter extends AbstractLogRequestFacetQ
   @Override
   public void appendFacetOptions(FacetOptions facetOptions, FieldAuditLogRequest request)
{
     facetOptions.addFacetOnPivot(request.getField(), AUDIT_COMPONENT);
-    facetOptions.setFacetLimit(request.getTop());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverter.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverter.java
new file mode 100644
index 0000000..9985a18
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverter.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.converter;
+
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.TopFieldAuditLogRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
+
+@Named
+public class TopFieldAuditLogRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<TopFieldAuditLogRequest>
{
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, TopFieldAuditLogRequest request)
{
+    facetOptions.addFacetOnPivot(request.getField(), AUDIT_COMPONENT);
+    facetOptions.setFacetLimit(request.getTop());
+  }
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return AUDIT_EVTTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.AUDIT;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
index 49465d5..25e3271 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/AuditLogsManager.java
@@ -47,6 +47,7 @@ import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
 import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
 import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
 import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.TopFieldAuditLogRequest;
 import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
 import org.apache.ambari.logsearch.model.response.AuditLogResponse;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
@@ -134,7 +135,7 @@ public class AuditLogsManager extends ManagerBase<SolrAuditLogData,
AuditLogResp
     return responseDataGenerator.generateBarGraphDataResponseWithRanges(response, SolrConstants.AuditLogConstants.AUDIT_COMPONENT,
true);
   }
 
-  public BarGraphDataListResponse topResources(FieldAuditLogRequest request) {
+  public BarGraphDataListResponse topResources(TopFieldAuditLogRequest request) {
     SimpleFacetQuery facetQuery = conversionService.convert(request, SimpleFacetQuery.class);
     QueryResponse queryResponse = auditSolrDao.process(facetQuery);
     return responseDataGenerator.generateSecondLevelBarGraphDataResponse(queryResponse, 0);

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
index 0bdcddf..2abc69f 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/FieldAuditLogRequest.java
@@ -20,19 +20,14 @@ package org.apache.ambari.logsearch.model.request.impl;
 
 import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.model.request.FieldParamDefinition;
-import org.apache.ambari.logsearch.model.request.TopParamDefinition;
 
-import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 
-public class FieldAuditLogRequest extends BaseLogRequest implements FieldParamDefinition,
TopParamDefinition {
+public class FieldAuditLogRequest extends BaseLogRequest implements FieldParamDefinition
{
 
   @QueryParam(LogSearchConstants.REQUEST_PARAM_FIELD)
   private String field;
 
-  @PathParam(LogSearchConstants.REQUEST_PARAM_TOP)
-  private Integer top;
-
   @Override
   public String getField() {
     return field;
@@ -42,14 +37,4 @@ public class FieldAuditLogRequest extends BaseLogRequest implements FieldParamDe
   public void setField(String field) {
     this.field = field;
   }
-
-  @Override
-  public Integer getTop() {
-    return top;
-  }
-
-  @Override
-  public void setTop(Integer top) {
-    this.top = top;
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/TopFieldAuditLogRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/TopFieldAuditLogRequest.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/TopFieldAuditLogRequest.java
new file mode 100644
index 0000000..4dd7c3e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/TopFieldAuditLogRequest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.TopParamDefinition;
+
+import javax.ws.rs.PathParam;
+
+public class TopFieldAuditLogRequest extends FieldAuditLogRequest implements TopParamDefinition
{
+
+  @PathParam(LogSearchConstants.REQUEST_PARAM_TOP)
+  private Integer top;
+
+  @Override
+  public Integer getTop() {
+    return top;
+  }
+
+  @Override
+  public void setTop(Integer top) {
+    this.top = top;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
index 2013dc7..00bf07c 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
@@ -35,7 +35,7 @@ import org.apache.ambari.logsearch.common.StatusMessage;
 import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
 import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
 import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
-import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest;
+import org.apache.ambari.logsearch.model.request.impl.TopFieldAuditLogRequest;
 import org.apache.ambari.logsearch.model.request.impl.UserExportRequest;
 import org.apache.ambari.logsearch.model.response.AuditLogResponse;
 import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse;
@@ -97,7 +97,7 @@ public class AuditLogsResource {
   @Path("/resources/{top}")
   @Produces({"application/json"})
   @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD)
-  public BarGraphDataListResponse getResources(@BeanParam FieldAuditLogRequest request) {
+  public BarGraphDataListResponse getResources(@BeanParam TopFieldAuditLogRequest request)
{
     return auditLogsManager.topResources(request);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
index 19cfbed..41dda05 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java
@@ -82,7 +82,7 @@ public class UserConfigResource {
   }
 
   @PUT
-  @Path("/filters/{id}")
+  @Path("/filters")
   @Produces({"application/json"})
   @ApiOperation(UPDATE_USER_FILTER_OD)
   public LogFeederDataMap updateUserFilter(LogFeederDataMap request) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java
b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java
index 08541e1..5b83615 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java
@@ -40,14 +40,13 @@ public class FieldAuditLogRequestQueryConverterTest extends AbstractRequestConve
     // GIVEN
     FieldAuditLogRequest request = new FieldAuditLogRequest();
     fillBaseLogRequestWithTestData(request);
-    request.setTop(10);
     request.setField("myfield");
     // WHEN
     SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request));
     // THEN
     assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D&fq=log_message%3Amyincludemessage"
+
       "&fq=-log_message%3Amyexcludemessage&fq=repo%3A%28logsearch_app+secure_log%29&fq=-repo%3A%28hst_agent+system_message%29&fq=cluster%3Acl1&facet=true"
+
-      "&facet.mincount=1&facet.limit=10&facet.pivot=myfield%2Crepo",
+      "&facet.mincount=1&facet.limit=-1&facet.pivot=myfield%2Crepo",
       query.toQueryString());
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverterTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverterTest.java
b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverterTest.java
new file mode 100644
index 0000000..2be9080
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/test/java/org/apache/ambari/logsearch/converter/TopFieldAuditLogRequestQueryConverterTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.TopFieldAuditLogRequest;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.data.solr.core.DefaultQueryParser;
+
+import static org.junit.Assert.assertEquals;
+
+public class TopFieldAuditLogRequestQueryConverterTest extends AbstractRequestConverterTest
{
+
+  private TopFieldAuditLogRequestQueryConverter underTest;
+
+  @Before
+  public void setUp() {
+    underTest = new TopFieldAuditLogRequestQueryConverter();
+  }
+
+  @Test
+  public void testConvert() {
+    // GIVEN
+    TopFieldAuditLogRequest request = new TopFieldAuditLogRequest();
+    fillBaseLogRequestWithTestData(request);
+    request.setTop(10);
+    request.setField("myfield");
+    // WHEN
+    SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request));
+    // THEN
+    assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D&fq=log_message%3Amyincludemessage"
+
+        "&fq=-log_message%3Amyexcludemessage&fq=repo%3A%28logsearch_app+secure_log%29&fq=-repo%3A%28hst_agent+system_message%29&fq=cluster%3Acl1&facet=true"
+
+        "&facet.mincount=1&facet.limit=10&facet.pivot=myfield%2Crepo",
+      query.toQueryString());
+  }
+
+  @Test(expected = IllegalArgumentException.class) // TODO: later use @Valid on the fields
to validate object
+  public void testConvertWithoutData() {
+    // GIVEN
+    TopFieldAuditLogRequest request = new TopFieldAuditLogRequest();
+    // WHEN
+    new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request));
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/65131066/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js
b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js
index deb0e28..bbd57465 100644
--- a/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js
+++ b/ambari-logsearch/ambari-logsearch-web/src/main/webapp/scripts/views/common/Header.js
@@ -232,11 +232,11 @@ define(['require',
                     //this.hostArray = content.ui.hostSelect2.val().split(',');
                     // this.levelArray = content.ui.levelSelect2.val().split(',');
 
-                    //this.filterList = { /*components : this.componentArray,*/hosts : this.hostArray/*,
levels : this.levelArray */};
-
+                    //this.filterList = { /*components : this.componentArray,*/hosts : this.hostArray/*,
levels : this.levelArray */}
                     content.model.set(content.setValues());
 
-                    content.model.save(content.model.attributes,{
+                    content.model.save(content.model.attributes, {
+                        url: Globals.baseURL + 'userconfig/filters',
                         success : function(model,response){
                             Utils.notifySuccess({
                                 content: "Filter has been saved."


Mime
View raw message