ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [41/58] [abbrv] ambari git commit: AMBARI-18310. Logsearch - Refactor solr query layer (oleewere)
Date Sat, 05 Nov 2016 14:56:31 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverter.java
new file mode 100644
index 0000000..cefc029
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverter.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogComponentLevelRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogComponentLevelRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogComponentLevelRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel()); // TODO: add @Valid on request object to make sure not throw exception if levels are missing
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogComponentLevelRequest request) {
+    facetOptions.addFacetOnPivot(COMPONENT, LEVEL);
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverter.java
new file mode 100644
index 0000000..afdac70
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverter.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+import java.util.List;
+
+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.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogComponentRequestFacetQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogComponentHostRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogComponentHostRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogComponentHostRequest request) {
+    facetOptions.addFacetOnPivot(COMPONENT, HOST, LEVEL);
+    facetOptions.addFacetOnPivot(COMPONENT, LEVEL);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverter.java
new file mode 100644
index 0000000..18fd204
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverter.java
@@ -0,0 +1,52 @@
+/*
+ * 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.ServiceLogLevelCountRequest;
+import org.springframework.data.solr.core.query.FacetOptions;
+
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+
+@Named
+public class ServiceLogLevelCountRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogLevelCountRequest> {
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.COUNT;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogLevelCountRequest request) {
+    facetOptions.addFacetOnField(LEVEL);
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverter.java
new file mode 100644
index 0000000..2ff528d
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverter.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 com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import javax.inject.Named;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogLevelDateRangeRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<ServiceGraphRequest>{
+
+  @Override
+  public String getDateFieldName() {
+    return LOGTIME;
+  }
+
+  @Override
+  public String getTypeFieldName() {
+    return LEVEL;
+  }
+
+  @Override
+  public SolrQuery convert(ServiceGraphRequest request) {
+    SolrQuery solrQuery = super.convert(request);
+    if (StringUtils.isNotEmpty(request.getLevel())) {
+      List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+      solrQuery.addFilterQuery(String.format("%s:(%s)", LEVEL, StringUtils.join(levels, " OR ")));
+    }
+    return solrQuery;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverter.java
new file mode 100644
index 0000000..f9cdb0b
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverter.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.converter;
+
+import com.google.common.base.Splitter;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest;
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleFilterQuery;
+
+import javax.inject.Named;
+
+import java.util.List;
+
+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.LEVEL;
+import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOGTIME;
+
+@Named
+public class ServiceLogTreeRequestFacetQueryConverter extends AbstractLogRequestFacetQueryConverter<ServiceLogHostComponentRequest>{
+
+  @Override
+  public FacetOptions.FacetSort getFacetSort() {
+    return FacetOptions.FacetSort.INDEX;
+  }
+
+  @Override
+  public String getDateTimeField() {
+    return LOGTIME;
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  @Override
+  public void appendFacetQuery(SimpleFacetQuery facetQuery, ServiceLogHostComponentRequest request) {
+    List<String> levels = Splitter.on(",").splitToList(request.getLevel());
+    SimpleFilterQuery filterQuery = new SimpleFilterQuery();
+    filterQuery.addCriteria(new Criteria(LEVEL).in(levels));
+    facetQuery.addFilterQuery(filterQuery);
+  }
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, ServiceLogHostComponentRequest request) {
+    facetOptions.addFacetOnPivot(HOST, COMPONENT, LEVEL);
+    facetOptions.addFacetOnPivot(HOST, LEVEL);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverter.java
new file mode 100644
index 0000000..d0273ac
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverter.java
@@ -0,0 +1,95 @@
+/*
+ * 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.LogSearchConstants;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.solr.core.query.SimpleQuery;
+
+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.LOGTIME;
+
+public class ServiceLogTruncatedRequestQueryConverter extends AbstractServiceLogRequestQueryConverter<ServiceLogTruncatedRequest, SimpleQuery>{
+
+  private String sequenceId;
+
+  private String logTime;
+
+  @Override
+  public SimpleQuery extendLogQuery(ServiceLogTruncatedRequest request, SimpleQuery query) {
+    addEqualsFilterQuery(query, COMPONENT, request.getComponentName());
+    addEqualsFilterQuery(query, HOST, request.getHostName());
+    String scrollType = request.getScrollType();
+    if (LogSearchConstants.SCROLL_TYPE_BEFORE.equals(scrollType)) {
+      Integer secuenceIdNum = Integer.parseInt(getSequenceId()) - 1;
+      addRangeFilter(query, LOGTIME, null, getLogTime());
+      addRangeFilter(query, SEQUENCE_ID, null, secuenceIdNum.toString());
+    } else if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
+      Integer secuenceIdNum = Integer.parseInt(getSequenceId()) + 1;
+      addRangeFilter(query, LOGTIME, getLogTime(), null);
+      addRangeFilter(query, SEQUENCE_ID, secuenceIdNum.toString(), null);
+    }
+    query.setRows(request.getNumberRows());
+    return query;
+  }
+
+  @Override
+  public Sort sort(ServiceLogTruncatedRequest request) {
+    String scrollType = request.getScrollType();
+    Sort.Direction direction;
+    if (LogSearchConstants.SCROLL_TYPE_AFTER.equals(scrollType)) {
+      direction = Sort.Direction.ASC;
+    } else {
+      direction = Sort.Direction.DESC;
+    }
+    Sort.Order logtimeSortOrder = new Sort.Order(direction, LOGTIME);
+    Sort.Order secuqnceIdSortOrder = new Sort.Order(direction, SEQUENCE_ID);
+    return new Sort(logtimeSortOrder, secuqnceIdSortOrder);
+  }
+
+  @Override
+  public SimpleQuery createQuery() {
+    return new SimpleQuery();
+  }
+
+  @Override
+  public LogType getLogType() {
+    return LogType.SERVICE;
+  }
+
+  public String getSequenceId() {
+    return sequenceId;
+  }
+
+  public void setSequenceId(String sequenceId) {
+    this.sequenceId = sequenceId;
+  }
+
+  public String getLogTime() {
+    return logTime;
+  }
+
+  public void setLogTime(String logTime) {
+    this.logTime = logTime;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverter.java
new file mode 100644
index 0000000..faff0be
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverter.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.converter;
+
+import org.springframework.data.solr.core.query.Criteria;
+import org.springframework.data.solr.core.query.FacetOptions;
+import org.springframework.data.solr.core.query.SimpleFacetQuery;
+import org.springframework.data.solr.core.query.SimpleStringCriteria;
+
+import javax.inject.Named;
+
+@Named
+public class StringFieldFacetQueryConverter extends AbstractConverterAware<String, SimpleFacetQuery> {
+
+  @Override
+  public SimpleFacetQuery convert(String fieldName) {
+    Criteria criteria = new SimpleStringCriteria("*:*");
+    SimpleFacetQuery facetQuery = new SimpleFacetQuery();
+    facetQuery.addCriteria(criteria);
+    facetQuery.setRows(0);
+    FacetOptions facetOptions = new FacetOptions();
+    facetOptions.setFacetMinCount(1);
+    facetOptions.addFacetOnField(fieldName);
+    facetOptions.setFacetLimit(-1);
+    facetQuery.setFacetOptions(facetOptions);
+    return facetQuery;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
new file mode 100644
index 0000000..082f45c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
@@ -0,0 +1,71 @@
+/*
+ * 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.UserConfigRequest;
+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.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;
+import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.USER_NAME;
+
+@Named
+public class UserConfigRequestQueryConverter extends AbstractConverterAware<UserConfigRequest, SolrQuery> {
+
+  @Override
+  public SolrQuery convert(UserConfigRequest userConfigRequest) {
+    SolrQuery userConfigQuery = new SolrQuery();
+    userConfigQuery.setQuery("*:*");
+
+    int startIndex = StringUtils.isNotEmpty(userConfigRequest.getStartIndex()) && StringUtils.isNumeric(userConfigRequest.getStartIndex())
+      ? Integer.parseInt(userConfigRequest.getStartIndex()) : 0;
+    int maxRows = StringUtils.isNotEmpty(userConfigRequest.getPageSize()) && StringUtils.isNumeric(userConfigRequest.getStartIndex())
+      ? Integer.parseInt(userConfigRequest.getStartIndex()) : 10;
+
+    SolrQuery.ORDER order = userConfigRequest.getSortType() != null && SolrQuery.ORDER.desc.equals(SolrQuery.ORDER.valueOf(userConfigRequest.getSortType()))
+      ? SolrQuery.ORDER.desc : SolrQuery.ORDER.asc;
+    String sortBy = StringUtils.isNotEmpty(userConfigRequest.getSortBy()) ? userConfigRequest.getSortBy(): FILTER_NAME;
+    String filterName = StringUtils.isBlank(userConfigRequest.getFilterName()) ? "*" : "*" + userConfigRequest.getFilterName() + "*";
+
+    userConfigQuery.addFilterQuery(String.format("%s:%s",
+      ROW_TYPE, userConfigRequest.getRowType()));
+    userConfigQuery.addFilterQuery(String.format("%s:%s OR %s:%s",
+      USER_NAME, userConfigRequest.getUserId(),
+      SHARE_NAME_LIST, userConfigRequest.getUserId()));
+    userConfigQuery.addFilterQuery(String.format("%s:%s",
+      FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
+    userConfigQuery.setStart(startIndex);
+    userConfigQuery.setRows(maxRows);
+
+    SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(sortBy, order);
+    List<SolrQuery.SortClause> sort = new ArrayList<>();
+    sort.add(sortOrder);
+    userConfigQuery.setSorts(sort);
+
+    return userConfigQuery;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverter.java
new file mode 100644
index 0000000..6b7c00e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverter.java
@@ -0,0 +1,55 @@
+/*
+ * 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.UserExportRequest;
+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;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_REQUEST_USER;
+import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_RESOURCE;
+
+@Named
+public class UserExportRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<UserExportRequest> {
+
+  @Override
+  public void appendFacetOptions(FacetOptions facetOptions, UserExportRequest request) {
+    facetOptions.addFacetOnPivot(AUDIT_REQUEST_USER, AUDIT_COMPONENT);
+    facetOptions.addFacetOnPivot(AUDIT_RESOURCE, AUDIT_COMPONENT);
+  }
+
+  @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/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
index 8d6a4da..959d6f4 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/AuditSolrDao.java
@@ -21,17 +21,15 @@ package org.apache.ambari.logsearch.dao;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 
-@Component
+@Named
 public class AuditSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(AuditSolrDao.class);
@@ -40,7 +38,7 @@ public class AuditSolrDao extends SolrDaoBase {
   private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
 
   @Inject
-  @Qualifier("auditSolrTemplate")
+  @Named("auditSolrTemplate")
   private SolrTemplate auditSolrTemplate;
 
   @Inject
@@ -50,6 +48,7 @@ public class AuditSolrDao extends SolrDaoBase {
   private SolrCollectionDao solrCollectionDao;
 
   @Inject
+  @Named("auditSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   public AuditSolrDao() {
@@ -57,8 +56,8 @@ public class AuditSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) auditSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return auditSolrTemplate;
   }
 
   @PostConstruct
@@ -71,13 +70,17 @@ public class AuditSolrDao extends SolrDaoBase {
       boolean createAlias = (aliasNameIn != null && !StringUtils.isBlank(rangerAuditCollection));
       solrCollectionDao.setupCollections(getSolrClient(), solrAuditLogPropsConfig);
       if (createAlias) {
-        solrAliasDao.setupAlias(solrSchemaFieldDao, getSolrClient(), solrAuditLogPropsConfig, this);
+        solrAliasDao.setupAlias(solrSchemaFieldDao, getSolrClient(), solrAuditLogPropsConfig);
       } else {
-        solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrAuditLogPropsConfig, this);
+        solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrAuditLogPropsConfig);
       }
     } catch (Exception e) {
       LOG.error("Error while connecting to Solr for audit logs : solrUrl=" + solrAuditLogPropsConfig.getSolrUrl() + ", zkConnectString=" +
           solrAuditLogPropsConfig.getZkConnectString() + ", collection=" + solrAuditLogPropsConfig.getCollection(), e);
     }
   }
+
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
index a6f5acf..0e1d57c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDao.java
@@ -21,16 +21,14 @@ package org.apache.ambari.logsearch.dao;
 
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrServiceLogPropsConfig;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 
-@Component
+@Named
 public class ServiceLogsSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(ServiceLogsSolrDao.class);
@@ -42,10 +40,11 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
   private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
 
   @Inject
-  @Qualifier("serviceSolrTemplate")
+  @Named("serviceSolrTemplate")
   private SolrTemplate serviceSolrTemplate;
 
   @Inject
+  @Named("serviceSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   public ServiceLogsSolrDao() {
@@ -53,8 +52,8 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) serviceSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return serviceSolrTemplate;
   }
 
   @PostConstruct
@@ -63,11 +62,15 @@ public class ServiceLogsSolrDao extends SolrDaoBase {
     try {
       solrCollectionDao.checkSolrStatus(getSolrClient());
       solrCollectionDao.setupCollections(getSolrClient(), solrServiceLogPropsConfig);
-      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrServiceLogPropsConfig, this);
+      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrServiceLogPropsConfig);
     } catch (Exception e) {
       LOG.error("error while connecting to Solr for service logs : solrUrl=" + solrServiceLogPropsConfig.getSolrUrl()
         + ", zkConnectString=" + solrServiceLogPropsConfig.getZkConnectString()
         + ", collection=" + solrServiceLogPropsConfig.getCollection(), e);
     }
   }
+
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
index 81471d3..6389446 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrAliasDao.java
@@ -26,16 +26,16 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 
-@Component
+@Named
 public class SolrAliasDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrAliasDao.class);
@@ -46,7 +46,7 @@ public class SolrAliasDao {
   private SolrCollectionDao solrCollectionDao;
 
   protected void setupAlias(final SolrSchemaFieldDao solrSchemaFieldDao, final CloudSolrClient solrClient,
-                            final SolrAuditLogPropsConfig solrPropsConfig, final SolrDaoBase solrDaoBase) throws Exception {
+                            final SolrAuditLogPropsConfig solrPropsConfig) throws Exception {
     final Collection<String> collectionListIn = Arrays.asList(solrPropsConfig.getCollection(), solrPropsConfig.getRangerCollection().trim());
 
     if (solrPropsConfig.getAliasNameIn() == null || collectionListIn.size() == 0 || solrClient == null) {
@@ -71,7 +71,7 @@ public class SolrAliasDao {
               if (count == collectionListIn.size()) {
                 LOG.info("Setup for alias " + solrPropsConfig.getAliasNameIn() + " is successful. Exiting setup retry thread. " +
                   "Collections=" + collectionListIn);
-                solrSchemaFieldDao.populateSchemaFields(solrClient, solrPropsConfig, solrDaoBase);
+                solrSchemaFieldDao.populateSchemaFields(solrClient, solrPropsConfig);
                 break;
               }
             } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
index ed93b4d..1cbac31 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrCollectionDao.java
@@ -30,15 +30,15 @@ import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
+import javax.inject.Named;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 
-@Component
+@Named
 public class SolrCollectionDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrCollectionDao.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
index 8381948..d9a9464 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrDaoBase.java
@@ -19,88 +19,91 @@
 
 package org.apache.ambari.logsearch.dao;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
-import org.apache.ambari.logsearch.model.response.BarGraphData;
-import org.apache.ambari.logsearch.model.response.NameValueData;
-import org.apache.ambari.logsearch.util.DateUtil;
 import org.apache.ambari.logsearch.util.RESTErrorUtil;
 import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrRequest.METHOD;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
+import org.springframework.data.solr.core.DefaultQueryParser;
+import org.springframework.data.solr.core.SolrCallback;
+import org.springframework.data.solr.core.SolrTemplate;
+import org.springframework.data.solr.core.query.SolrDataQuery;
+
+import java.io.IOException;
 
 public abstract class SolrDaoBase {
 
+  private static final Logger LOG = Logger.getLogger(SolrDaoBase.class);
   private static final Logger LOG_PERFORMANCE = Logger.getLogger("org.apache.ambari.logsearch.performance");
 
-  public Map<String, String> schemaFieldNameMap = new HashMap<>();
-  public Map<String, String> schemaFieldTypeMap = new HashMap<>();
-
   private LogType logType;
   
   protected SolrDaoBase(LogType logType) {
     this.logType = logType;
   }
 
-  public QueryResponse process(SolrQuery solrQuery) throws SolrServerException, IOException {
+  public QueryResponse process(SolrQuery solrQuery, String event) {
     if (getSolrClient() != null) {
-      String event = solrQuery.get("event");
+      event = event == null ? solrQuery.get("event") : event;
       solrQuery.remove("event");
-      QueryResponse queryResponse = getSolrClient().query(solrQuery, METHOD.POST);
-      if (event != null && !"/audit/logs/live/count".equalsIgnoreCase(event)) {
-        LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
+      try {
+        QueryResponse queryResponse = getSolrClient().query(solrQuery, METHOD.POST);
+        if (event != null) {
+          LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Event :- " + event + " SolrQuery :- " +
             solrQuery + "\nQuery Time Execution :- " + queryResponse.getQTime() + " Total Time Elapsed is :- " +
             queryResponse.getElapsedTime());
+        }
+        return queryResponse;
+      } catch (Exception e){
+        LOG.error("Error during solrQuery=" + e);
+        throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
       }
-      return queryResponse;
     } else {
       throw RESTErrorUtil.createRESTException("Solr configuration improper for " + logType.getLabel() +" logs",
           MessageEnums.ERROR_SYSTEM);
     }
   }
 
-  @SuppressWarnings("unchecked")
-  public void extractValuesFromBuckets(SimpleOrderedMap<Object> jsonFacetResponse, String outerField, String innerField,
-                                        List<BarGraphData> histogramData) {
-    NamedList<Object> stack = (NamedList<Object>) jsonFacetResponse.get(outerField);
-    ArrayList<Object> stackBuckets = (ArrayList<Object>) stack.get("buckets");
-    for (Object temp : stackBuckets) {
-      BarGraphData vBarGraphData = new BarGraphData();
-
-      SimpleOrderedMap<Object> level = (SimpleOrderedMap<Object>) temp;
-      String name = ((String) level.getVal(0)).toUpperCase();
-      vBarGraphData.setName(name);
+  public QueryResponse process(SolrQuery solrQuery) {
+    return process(solrQuery, null);
+  }
 
-      Collection<NameValueData> vNameValues = new ArrayList<>();
-      vBarGraphData.setDataCount(vNameValues);
-      ArrayList<Object> levelBuckets = (ArrayList<Object>) ((NamedList<Object>) level.get(innerField)).get("buckets");
-      for (Object temp1 : levelBuckets) {
-        SimpleOrderedMap<Object> countValue = (SimpleOrderedMap<Object>) temp1;
-        String value = DateUtil.convertDateWithMillisecondsToSolrDate((Date) countValue.getVal(0));
+  public QueryResponse process(SolrDataQuery solrDataQuery) {
+    return process(new DefaultQueryParser().doConstructSolrQuery(solrDataQuery));
+  }
 
-        String count = "" + countValue.getVal(1);
-        NameValueData vNameValue = new NameValueData();
-        vNameValue.setName(value);
-        vNameValue.setValue(count);
-        vNameValues.add(vNameValue);
+  public long count(final SolrDataQuery solrDataQuery) {
+    return getSolrTemplate().execute(new SolrCallback<Long>() {
+      @Override
+      public Long doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
+        SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(solrDataQuery);
+        solrQuery.setStart(0);
+        solrQuery.setRows(0);
+        QueryResponse queryResponse = solrClient.query(solrQuery);
+        long count = solrClient.query(solrQuery).getResults().getNumFound();
+        LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() + " Count SolrQuery :- " +
+          solrQuery + "\nQuery Time Execution :- " + queryResponse.getQTime() + " Total Time Elapsed is :- " +
+          queryResponse.getElapsedTime() + " Count result :- " + count);
+        return count;
       }
-      histogramData.add(vBarGraphData);
-    }
+    });
+  }
+
+  public QueryResponse process(SolrDataQuery solrDataQuery, String event) {
+    return process(new DefaultQueryParser().doConstructSolrQuery(solrDataQuery), event);
   }
 
-  public abstract CloudSolrClient getSolrClient();
+  public CloudSolrClient getSolrClient() {
+    return (CloudSolrClient) getSolrTemplate().getSolrClient();
+  }
+
+  public abstract SolrTemplate getSolrTemplate();
+
+  public abstract SolrSchemaFieldDao getSolrSchemaFieldDao();
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
index b6764d0..f16dc41 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
@@ -33,16 +33,12 @@ import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
 
 import javax.inject.Inject;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-@Component
-@Scope(value = "prototype")
 public class SolrSchemaFieldDao {
 
   private static final Logger LOG = LoggerFactory.getLogger(SolrSchemaFieldDao.class);
@@ -52,11 +48,13 @@ public class SolrSchemaFieldDao {
 
   private boolean populateFieldsThreadActive = false;
 
+  private Map<String, String> schemaFieldNameMap = new HashMap<>();
+  private Map<String, String> schemaFieldTypeMap = new HashMap<>();
+
   @Inject
   private SolrUserPropsConfig solrUserPropsConfig;
 
-  public void populateSchemaFields(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig,
-                                   final SolrDaoBase solrDao) {
+  public void populateSchemaFields(final CloudSolrClient solrClient, final SolrPropsConfig solrPropsConfig) {
     if (!populateFieldsThreadActive) {
       populateFieldsThreadActive = true;
       LOG.info("Creating thread to populated fields for collection=" + solrPropsConfig.getCollection());
@@ -69,7 +67,7 @@ public class SolrSchemaFieldDao {
             try {
               Thread.sleep(SETUP_RETRY_SECOND * 1000);
               retryCount++;
-              boolean _result = _populateSchemaFields(solrClient, solrPropsConfig, solrDao);
+              boolean _result = _populateSchemaFields(solrClient, solrPropsConfig);
               if (_result) {
                 LOG.info("Populate fields for collection " + solrPropsConfig.getCollection() + " is success, Update it after " +
                   SETUP_UPDATE_SECOND + " sec");
@@ -94,7 +92,7 @@ public class SolrSchemaFieldDao {
   /**
    * Called from the thread. Don't call this directly
    */
-  private boolean _populateSchemaFields(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig, SolrDaoBase solrDao) {
+  private boolean _populateSchemaFields(CloudSolrClient solrClient, SolrPropsConfig solrPropsConfig) {
     SolrRequest<SchemaResponse> request = new SchemaRequest();
     request.setMethod(SolrRequest.METHOD.GET);
     request.setPath("/schema");
@@ -109,7 +107,7 @@ public class SolrSchemaFieldDao {
       }
 
       if (namedList != null) {
-        extractSchemaFieldsName(namedList.toString(), solrDao.schemaFieldNameMap, solrDao.schemaFieldTypeMap);
+        extractSchemaFieldsName(namedList.toString(), schemaFieldNameMap, schemaFieldTypeMap);
         return true;
       }
     }
@@ -156,4 +154,12 @@ public class SolrSchemaFieldDao {
       LOG.error(e + "Credentials not specified in logsearch.properties " + MessageEnums.ERROR_SYSTEM);
     }
   }
+
+  public Map<String, String> getSchemaFieldTypeMap() {
+    return schemaFieldTypeMap;
+  }
+
+  public Map<String, String> getSchemaFieldNameMap() {
+    return schemaFieldNameMap;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
index 88c4577..a6ea77c 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
@@ -28,14 +28,15 @@ import java.util.List;
 import java.util.Scanner;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
+import javax.inject.Named;
 
+import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.LogType;
 import org.apache.ambari.logsearch.conf.SolrUserPropsConfig;
-import org.apache.ambari.logsearch.view.VLogfeederFilterWrapper;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.common.LogFeederDataMap;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.UpdateResponse;
 import org.apache.solr.common.SolrDocument;
@@ -47,15 +48,18 @@ import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import com.google.gson.JsonParseException;
 
-import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
 import org.apache.ambari.logsearch.util.JSONUtil;
 import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.solr.core.SolrTemplate;
-import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
-@Component
+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;
+
+@Named
 public class UserConfigSolrDao extends SolrDaoBase {
 
   private static final Logger LOG = Logger.getLogger(UserConfigSolrDao.class);
@@ -69,10 +73,11 @@ public class UserConfigSolrDao extends SolrDaoBase {
   private SolrCollectionDao solrCollectionDao;
 
   @Inject
+  @Named("serviceSolrFieldDao")
   private SolrSchemaFieldDao solrSchemaFieldDao;
 
   @Inject
-  @Qualifier("userConfigSolrTemplate")
+  @Named("userConfigSolrTemplate")
   private SolrTemplate userConfigSolrTemplate;
 
   public UserConfigSolrDao() {
@@ -80,11 +85,10 @@ public class UserConfigSolrDao extends SolrDaoBase {
   }
 
   @Override
-  public CloudSolrClient getSolrClient() {
-    return (CloudSolrClient) userConfigSolrTemplate.getSolrClient();
+  public SolrTemplate getSolrTemplate() {
+    return userConfigSolrTemplate;
   }
 
-
   @PostConstruct
   public void postConstructor() {
     String solrUrl = solrUserConfig.getSolrUrl();
@@ -94,7 +98,7 @@ public class UserConfigSolrDao extends SolrDaoBase {
     try {
       solrCollectionDao.checkSolrStatus(getSolrClient());
       solrCollectionDao.setupCollections(getSolrClient(), solrUserConfig);
-      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrUserConfig, this);
+      solrSchemaFieldDao.populateSchemaFields(getSolrClient(), solrUserConfig);
       intializeLogFeederFilter();
 
     } catch (Exception e) {
@@ -111,15 +115,15 @@ public class UserConfigSolrDao extends SolrDaoBase {
     }
   }
 
-  public void saveUserFilter(VLogfeederFilterWrapper logfeederFilterWrapper) throws SolrException, SolrServerException, IOException {
+  public void saveUserFilter(LogFeederDataMap logfeederFilterWrapper) throws SolrException, SolrServerException, IOException {
     String filterName = LogSearchConstants.LOGFEEDER_FILTER_NAME;
     String json = JSONUtil.objToJson(logfeederFilterWrapper);
     SolrInputDocument configDocument = new SolrInputDocument();
-    configDocument.addField(LogSearchConstants.ID, logfeederFilterWrapper.getId());
-    configDocument.addField(LogSearchConstants.ROW_TYPE, filterName);
-    configDocument.addField(LogSearchConstants.VALUES, json);
-    configDocument.addField(LogSearchConstants.USER_NAME, filterName);
-    configDocument.addField(LogSearchConstants.FILTER_NAME, filterName);
+    configDocument.addField(ID, logfeederFilterWrapper.getId());
+    configDocument.addField(ROW_TYPE, filterName);
+    configDocument.addField(VALUES, json);
+    configDocument.addField(USER_NAME, filterName);
+    configDocument.addField(FILTER_NAME, filterName);
     addDocs(configDocument);
   }
 
@@ -144,23 +148,23 @@ public class UserConfigSolrDao extends SolrDaoBase {
   }
 
 	@SuppressWarnings("unchecked")
-  public VLogfeederFilterWrapper getUserFilter() throws SolrServerException, IOException {
+  public LogFeederDataMap getUserFilter() throws SolrServerException, IOException {
 
     SolrQuery solrQuery = new SolrQuery();
     solrQuery.setQuery("*:*");
-    String fq = LogSearchConstants.ROW_TYPE + ":" + LogSearchConstants.LOGFEEDER_FILTER_NAME;
+    String fq = ROW_TYPE + ":" + LogSearchConstants.LOGFEEDER_FILTER_NAME;
     solrQuery.setFilterQueries(fq);
 
     QueryResponse response = process(solrQuery);
     SolrDocumentList documentList = response.getResults();
-    VLogfeederFilterWrapper logfeederFilterWrapper = null;
+    LogFeederDataMap logfeederDataMap = null;
     if (!CollectionUtils.isEmpty(documentList)) {
       SolrDocument configDoc = documentList.get(0);
       String configJson = JSONUtil.objToJson(configDoc);
       HashMap<String, Object> configMap = JSONUtil.jsonToMapObject(configJson);
-      String json = (String) configMap.get(LogSearchConstants.VALUES);
-      logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(json, VLogfeederFilterWrapper.class);
-      logfeederFilterWrapper.setId("" + configDoc.get(LogSearchConstants.ID));
+      String json = (String) configMap.get(VALUES);
+      logfeederDataMap = (LogFeederDataMap) JSONUtil.jsonToObj(json, LogFeederDataMap.class);
+      logfeederDataMap.setId("" + configDoc.get(ID));
 
     } else {
       List<String> logfeederDefaultLevels = solrUserConfig.getLogLevels();
@@ -189,16 +193,21 @@ public class UserConfigSolrDao extends SolrDaoBase {
           }
         }
         jsonValue.put("filter", componentList);
-        logfeederFilterWrapper = (VLogfeederFilterWrapper) JSONUtil.jsonToObj(jsonValue.toString(), VLogfeederFilterWrapper.class);
-        logfeederFilterWrapper.setId(""+new Date().getTime());
-        saveUserFilter(logfeederFilterWrapper);
+        logfeederDataMap = (LogFeederDataMap) JSONUtil.jsonToObj(jsonValue.toString(), LogFeederDataMap.class);
+        logfeederDataMap.setId(""+new Date().getTime());
+        saveUserFilter(logfeederDataMap);
 
       } catch (JsonParseException | JSONException je) {
         LOG.error("Error parsing JSON. key=" + key + ", componentArray=" + componentArray, je);
-        logfeederFilterWrapper = new VLogfeederFilterWrapper();
+        logfeederDataMap = new LogFeederDataMap();
       }
     }
-    return logfeederFilterWrapper;
+    return logfeederDataMap;
+  }
+
+  @Override
+  public SolrSchemaFieldDao getSolrSchemaFieldDao() {
+    return solrSchemaFieldDao;
   }
 
   private String getHadoopServiceConfigJSON() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7164202/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
index 0df2ca3..e6f5103 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
@@ -44,6 +44,7 @@ public class DocConstants {
     public static final String IS_LAST_PAGE_D = "Show last page (true/false)";
     public static final String FIELD_D = "Get values for particular field";
     public static final String FORMAT_D = "File Export format, can be 'txt' or 'json'";
+    public static final String TOP = "Number that defines how many top element you would like to see.";
   }
 
   public class AuditOperationDescriptions {
@@ -51,11 +52,7 @@ public class DocConstants {
     public static final String GET_AUDIT_LOGS_OD = "Get the list of logs details";
     public static final String GET_AUDIT_COMPONENTS_OD = "Get the list of audit components currently active or having data in Solr";
     public static final String GET_AUDIT_LINE_GRAPH_DATA_OD = "Get the data required for line graph";
-    public static final String GET_TOP_AUDIT_USERS_OD = "Get the top audit users having maximum access";
-    public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resources having maximum access";
-    public static final String GET_LIVE_LOGS_COUNT_OD = "not required";
-    public static final String GET_REQUEST_USER_LINE_GRAPH_OD = "not required";
-    public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
+    public static final String GET_TOP_AUDIT_RESOURCES_OD = "Get the top audit resource count (grouped by type)";
     public static final String EXPORT_USER_TALBE_TO_TEXT_FILE_OD = "Export the tables shown on Audit tab";
     public static final String GET_SERVICE_LOAD_OD = "The graph for showing the top users accessing the services";
   }
@@ -64,7 +61,6 @@ public class DocConstants {
     public static final String LEVEL_D = "filter for log level";
     public static final String BUNDLE_ID = "filter for host";
     public static final String FILE_NAME_D = "File name filter which is supported from browser url";
-    public static final String DATE_RANGE_LABEL_D = "Date range label (e.g.: Today)";
     public static final String HOST_NAME_D = "Host name filter which is supported from browser url";
     public static final String COMPONENT_NAME_D = "Component name filter which is supported from browser url";
     public static final String FIND_D = "Finding particular text on subsequent pages in case of table view with pagination";
@@ -72,7 +68,6 @@ public class DocConstants {
     public static final String KEYWORD_TYPE_D = "Serching the find param value in previous or next in paginated table";
     public static final String TOKEN_D = "unique number used along with FIND_D. The request can be canceled using this token";
     public static final String SOURCE_LOG_ID_D = "fetch the record set having that log Id";
-    public static final String G_MUST_NOT_D = "not required";
     public static final String NUMBER_ROWS_D = "Getting rows after particular log entry - used in 'Preview' option";
     public static final String SCROLL_TYPE_D = "Used in 'Preview' feature for getting records 'after' or 'before'";
     public static final String UTC_OFFSET_D = "timezone offset";
@@ -86,18 +81,15 @@ public class DocConstants {
     public static final String GET_LOG_LEVELS_COUNT_OD = "Get Log levels with their counts";
     public static final String GET_COMPONENTS_COUNT_OD = "Get components with their counts";
     public static final String GET_HOSTS_COUNT_OD = "Get hosts with their counts";
-    public static final String GET_TREE_EXTENSION_OD = "Get host and compoenets hierarchy";
+    public static final String GET_TREE_EXTENSION_OD = "Get host and compoenets hierarchy with log counts";
     public static final String GET_HISTOGRAM_DATA_OD = "Get data for histogram";
-    public static final String CANCEL_FIND_REQUEST_OD = "Cancel the FIND_D param request using TOKEN_D";
     public static final String EXPORT_TO_TEXT_FILE_OD = "Export the table data in file";
     public static final String GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD = "Get components with log level distribution count";
-    public static final String GET_EXTREME_DATES_FOR_BUNDLE_ID_OD = "Get the start and end time of particular bundle_id";
-    public static final String GET_SERVICE_LOGS_FIELD_NAME_OD = "Get service logs schema fields name (Human readable)";
-    public static final String GET_ANY_GRAPH_DATA_OD = "Get the data generic enough to use for graph plots";
-    public static final String GET_AFTER_BEFORE_LOGS_OD = "Preview feature data";
+    public static final String GET_ANY_GRAPH_COUNT_DATA_OD = "Get the data generic enough to use for graph plots (yAzis is always count)";
     public static final String GET_HOST_LIST_BY_COMPONENT_OD = "Get host list of components";
     public static final String GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD = "Get service logs schema fields";
     public static final String GET_HADOOP_SERVICE_CONFIG_JSON_OD = "Get the json having meta data of services supported by logsearch";
+    public static final String GET_AFTER_BEFORE_LOGS_OD = "Preview feature data";
   }
 
   public class PublicOperationDescriptions {


Mime
View raw message