You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2017/03/27 19:17:58 UTC
[27/37] ambari git commit: AMBARI-20528. Rename Log Search Portal
module to Log Search Server (oleewere)
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
deleted file mode 100644
index 482438a..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrServiceLogPropsConfig.java
+++ /dev/null
@@ -1,91 +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.conf;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class SolrServiceLogPropsConfig extends SolrConnectionPropsConfig {
-
- @Value("${logsearch.solr.collection.service.logs:hadoop_logs}")
- private String collection;
-
- @Value("${logsearch.service.logs.split.interval.mins:none}")
- private String splitInterval;
-
- @Value("${logsearch.solr.service.logs.config.name:hadoop_logs}")
- private String configName;
-
- @Value("${logsearch.collection.service.logs.numshards:1}")
- private Integer numberOfShards;
-
- @Value("${logsearch.collection.service.logs.replication.factor:1}")
- private Integer replicationFactor;
-
- @Override
- public String getCollection() {
- return collection;
- }
-
- @Override
- public void setCollection(String collection) {
- this.collection = collection;
- }
-
- @Override
- public String getSplitInterval() {
- return splitInterval;
- }
-
- @Override
- public void setSplitInterval(String splitInterval) {
- this.splitInterval = splitInterval;
- }
-
- @Override
- public String getConfigName() {
- return configName;
- }
-
- @Override
- public void setConfigName(String configName) {
- this.configName = configName;
- }
-
- @Override
- public Integer getNumberOfShards() {
- return numberOfShards;
- }
-
- @Override
- public void setNumberOfShards(Integer numberOfShards) {
- this.numberOfShards = numberOfShards;
- }
-
- @Override
- public Integer getReplicationFactor() {
- return replicationFactor;
- }
-
- @Override
- public void setReplicationFactor(Integer replicationFactor) {
- this.replicationFactor = replicationFactor;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
deleted file mode 100644
index c8c96c8..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
+++ /dev/null
@@ -1,116 +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.conf;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.List;
-
-@Configuration
-public class SolrUserPropsConfig extends SolrConnectionPropsConfig {
-
- @Value("${logsearch.solr.collection.history:history}")
- private String collection;
-
- @Value("${logsearch.history.split.interval.mins:none}")
- private String splitInterval;
-
- @Value("${logsearch.solr.history.config.name:history}")
- private String configName;
-
- @Value("${logsearch.collection.history.numshards:1}")
- private Integer numberOfShards;
-
- @Value("${logsearch.collection.history.replication.factor:2}")
- private Integer replicationFactor;
-
- @Value("#{'${logsearch.logfeeder.include.default.level:FATAL,ERROR,WARN,INFO,DEBUG,TRACE,UNKNOWN}'.split(',')}")
- private List<String> logLevels;
-
- @Value("${logsearch.schema.fields.populate.interval.mins:1}")
- private Integer populateIntervalMins;
-
- @Override
- public String getCollection() {
- return collection;
- }
-
- @Override
- public void setCollection(String collection) {
- this.collection = collection;
- }
-
- @Override
- public String getSplitInterval() {
- return splitInterval;
- }
-
- @Override
- public void setSplitInterval(String splitInterval) {
- this.splitInterval = splitInterval;
- }
-
- @Override
- public String getConfigName() {
- return configName;
- }
-
- @Override
- public void setConfigName(String configName) {
- this.configName = configName;
- }
-
- @Override
- public Integer getNumberOfShards() {
- return numberOfShards;
- }
-
- @Override
- public void setNumberOfShards(Integer numberOfShards) {
- this.numberOfShards = numberOfShards;
- }
-
- @Override
- public Integer getReplicationFactor() {
- return replicationFactor;
- }
-
- @Override
- public void setReplicationFactor(Integer replicationFactor) {
- this.replicationFactor = replicationFactor;
- }
-
- public List<String> getLogLevels() {
- return logLevels;
- }
-
- public void setLogLevels(List<String> logLevels) {
- this.logLevels = logLevels;
- }
-
-
- public Integer getPopulateIntervalMins() {
- return populateIntervalMins;
- }
-
- void setPopulateIntervalMins(Integer populateIntervalMins) {
- this.populateIntervalMins = populateIntervalMins;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrAuditLogsState.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrAuditLogsState.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrAuditLogsState.java
deleted file mode 100644
index 546a5dc..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrAuditLogsState.java
+++ /dev/null
@@ -1,68 +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.conf.global;
-
-import javax.inject.Named;
-
-@Named
-public class SolrAuditLogsState implements SolrCollectionState {
-
- private volatile boolean znodeReady;
- private volatile boolean solrCollectionReady;
- private volatile boolean solrAliasReady;
- private volatile boolean configurationUploaded;
-
- @Override
- public boolean isZnodeReady() {
- return znodeReady;
- }
-
- @Override
- public void setZnodeReady(boolean znodeAvailable) {
- this.znodeReady = znodeAvailable;
- }
-
- @Override
- public boolean isSolrCollectionReady() {
- return solrCollectionReady;
- }
-
- @Override
- public void setSolrCollectionReady(boolean solrCollectionReady) {
- this.solrCollectionReady = solrCollectionReady;
- }
-
- @Override
- public boolean isConfigurationUploaded() {
- return configurationUploaded;
- }
-
- @Override
- public void setConfigurationUploaded(boolean configurationUploaded) {
- this.configurationUploaded = configurationUploaded;
- }
-
- public boolean isSolrAliasReady() {
- return solrAliasReady;
- }
-
- public void setSolrAliasReady(boolean solrAliasReady) {
- this.solrAliasReady = solrAliasReady;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrCollectionState.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrCollectionState.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrCollectionState.java
deleted file mode 100644
index 5885611..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrCollectionState.java
+++ /dev/null
@@ -1,33 +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.conf.global;
-
-public interface SolrCollectionState {
- boolean isZnodeReady();
-
- void setZnodeReady(boolean znodeAvailable);
-
- boolean isSolrCollectionReady();
-
- void setSolrCollectionReady(boolean solrCollectionCreated);
-
- boolean isConfigurationUploaded();
-
- void setConfigurationUploaded(boolean configurationUploaded);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrServiceLogsState.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrServiceLogsState.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrServiceLogsState.java
deleted file mode 100644
index 60eafc5..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrServiceLogsState.java
+++ /dev/null
@@ -1,59 +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.conf.global;
-
-import javax.inject.Named;
-
-@Named
-public class SolrServiceLogsState implements SolrCollectionState {
-
- private volatile boolean znodeReady;
- private volatile boolean solrCollectionReady;
- private volatile boolean configurationUploaded;
-
- @Override
- public boolean isZnodeReady() {
- return znodeReady;
- }
-
- @Override
- public void setZnodeReady(boolean znodeAvailable) {
- this.znodeReady = znodeAvailable;
- }
-
- @Override
- public boolean isSolrCollectionReady() {
- return solrCollectionReady;
- }
-
- @Override
- public void setSolrCollectionReady(boolean solrCollectionReady) {
- this.solrCollectionReady = solrCollectionReady;
- }
-
- @Override
- public boolean isConfigurationUploaded() {
- return configurationUploaded;
- }
-
- @Override
- public void setConfigurationUploaded(boolean configurationUploaded) {
- this.configurationUploaded = configurationUploaded;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrUserConfigState.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrUserConfigState.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrUserConfigState.java
deleted file mode 100644
index 06af14c..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/global/SolrUserConfigState.java
+++ /dev/null
@@ -1,60 +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.conf.global;
-
-import javax.inject.Named;
-
-@Named
-public class SolrUserConfigState implements SolrCollectionState {
-
- private volatile boolean znodeReady;
- private volatile boolean solrCollectionReady;
- private volatile boolean configurationUploaded;
-
- @Override
- public boolean isZnodeReady() {
- return znodeReady;
- }
-
- @Override
- public void setZnodeReady(boolean znodeAvailable) {
- this.znodeReady = znodeAvailable;
- }
-
- @Override
- public boolean isSolrCollectionReady() {
- return solrCollectionReady;
- }
-
- @Override
- public void setSolrCollectionReady(boolean solrCollectionReady) {
- this.solrCollectionReady = solrCollectionReady;
- }
-
- @Override
- public boolean isConfigurationUploaded() {
- return configurationUploaded;
- }
-
- @Override
- public void setConfigurationUploaded(boolean configurationUploaded) {
- this.configurationUploaded = configurationUploaded;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/LogfeederFilterConfigurer.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/LogfeederFilterConfigurer.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/LogfeederFilterConfigurer.java
deleted file mode 100644
index 34e1bec..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/LogfeederFilterConfigurer.java
+++ /dev/null
@@ -1,66 +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.configurer;
-
-import org.apache.ambari.logsearch.conf.SolrPropsConfig;
-import org.apache.ambari.logsearch.conf.global.SolrCollectionState;
-import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LogfeederFilterConfigurer implements SolrConfigurer {
-
- private static final Logger LOG = LoggerFactory.getLogger(LogfeederFilterConfigurer.class);
-
- private static final int SETUP_RETRY_SECOND = 10;
-
- private final UserConfigSolrDao userConfigSolrDao;
-
- public LogfeederFilterConfigurer(final UserConfigSolrDao userConfigSolrDao) {
- this.userConfigSolrDao = userConfigSolrDao;
- }
-
- @Override
- public void start() {
- final SolrPropsConfig solrPropsConfig = userConfigSolrDao.getSolrPropsConfig();
- final SolrCollectionState state = userConfigSolrDao.getSolrCollectionState();
- Thread setupFiltersThread = new Thread("logfeeder_filter_setup") {
- @Override
- public void run() {
- LOG.info("logfeeder_filter_setup thread started (to upload logfeeder config)");
- while (true) {
- int retryCount = 0;
- try {
- retryCount++;
- Thread.sleep(SETUP_RETRY_SECOND * 1000);
- if (state.isSolrCollectionReady()) {
- LOG.info("Tries to initialize logfeeder filters in '{}' collection", solrPropsConfig.getCollection());
- userConfigSolrDao.getUserFilter();
- break;
- }
- } catch (Exception e) {
- LOG.error("Not able to save logfeeder filter while initialization, retryCount=" + retryCount, e);
- }
- }
- }
- };
- setupFiltersThread.setDaemon(true);
- setupFiltersThread.start();
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
deleted file mode 100644
index c80a10d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrAuditAliasConfigurer.java
+++ /dev/null
@@ -1,136 +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.configurer;
-
-import org.apache.ambari.logsearch.conf.SolrAuditLogPropsConfig;
-import org.apache.ambari.logsearch.conf.global.SolrAuditLogsState;
-import org.apache.ambari.logsearch.dao.AuditSolrDao;
-import org.apache.ambari.logsearch.handler.ListCollectionHandler;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-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 java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-public class SolrAuditAliasConfigurer implements SolrConfigurer {
-
- private static final Logger LOG = LoggerFactory.getLogger(SolrAuditAliasConfigurer.class);
-
- private static final int ALIAS_SETUP_RETRY_SECOND = 30 * 60;
-
- private final AuditSolrDao auditSolrDao;
-
- public SolrAuditAliasConfigurer(final AuditSolrDao auditSolrDao) {
- this.auditSolrDao = auditSolrDao;
- }
-
- @Override
- public void start() {
- final SolrAuditLogPropsConfig solrPropsConfig = (SolrAuditLogPropsConfig) auditSolrDao.getSolrPropsConfig();
- final SolrAuditLogsState state = (SolrAuditLogsState) auditSolrDao.getSolrCollectionState();
- final Collection<String> collectionListIn =
- Arrays.asList(solrPropsConfig.getCollection(), solrPropsConfig.getRangerCollection().trim());
-
- if (solrPropsConfig.getAliasNameIn() == null || collectionListIn.size() == 0) {
- LOG.info("Will not create alias {} for {}", solrPropsConfig.getAliasNameIn(), collectionListIn.toString());
- return;
- }
-
- LOG.info("setupAlias " + solrPropsConfig.getAliasNameIn() + " for " + collectionListIn.toString());
- // Start a background thread to do setup
- Thread setupThread = new Thread("setup_alias_" + solrPropsConfig.getAliasNameIn()) {
- @Override
- public void run() {
- LOG.info("Started monitoring thread to check availability of Solr server. alias=" + solrPropsConfig.getAliasNameIn() +
- ", collections=" + collectionListIn.toString());
- int retryCount = 0;
- while (true) {
- if (state.isSolrCollectionReady()) {
- try {
- CloudSolrClient solrClient = auditSolrDao.getSolrClient();
- int count = createAlias(solrClient, solrPropsConfig.getAliasNameIn(), collectionListIn);
- if (count > 0) {
- solrClient.setDefaultCollection(solrPropsConfig.getAliasNameIn());
- if (count == collectionListIn.size()) {
- LOG.info("Setup for alias " + solrPropsConfig.getAliasNameIn() + " is successful. Exiting setup retry thread. " +
- "Collections=" + collectionListIn);
- state.setSolrAliasReady(true);
- break;
- }
- } else {
- LOG.warn("Not able to create alias=" + solrPropsConfig.getAliasNameIn() + ", retryCount=" + retryCount);
- }
- } catch (Exception e) {
- LOG.error("Error setting up alias=" + solrPropsConfig.getAliasNameIn(), e);
- }
- }
- try {
- Thread.sleep(ALIAS_SETUP_RETRY_SECOND * 1000);
- } catch (InterruptedException sleepInterrupted) {
- LOG.info("Sleep interrupted while setting up alias " + solrPropsConfig.getAliasNameIn());
- break;
- }
- retryCount++;
- }
- }
- };
- setupThread.setDaemon(true);
- setupThread.start();
- }
-
- private int createAlias(final CloudSolrClient solrClient, String aliasNameIn, Collection<String> collectionListIn)
- throws SolrServerException, IOException {
- List<String> collectionToAdd = new ArrayList<>();
- try {
- collectionToAdd = new ListCollectionHandler().handle(solrClient, null);
- } catch (Exception e) {
- LOG.error("Invalid state during getting collections for creating alias");
- }
- collectionToAdd.retainAll(collectionListIn);
-
- String collectionsCSV = null;
- if (!collectionToAdd.isEmpty()) {
- collectionsCSV = StringUtils.join(collectionToAdd, ',');
- CollectionAdminRequest.CreateAlias aliasCreateRequest = new CollectionAdminRequest.CreateAlias();
- aliasCreateRequest.setAliasName(aliasNameIn);
- aliasCreateRequest.setAliasedCollections(collectionsCSV);
- CollectionAdminResponse createResponse = aliasCreateRequest.process(solrClient);
- if (createResponse.getStatus() != 0) {
- LOG.error("Error creating alias. alias=" + aliasNameIn + ", collectionList=" + collectionsCSV
- + ", response=" + createResponse);
- return 0;
- }
- }
- if (collectionToAdd.size() == collectionListIn.size()) {
- LOG.info("Created alias for all collections. alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV);
- } else {
- LOG.info("Created alias for " + collectionToAdd.size() + " out of " + collectionListIn.size() + " collections. " +
- "alias=" + aliasNameIn + ", collectionsCSV=" + collectionsCSV);
- }
- return collectionToAdd.size();
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
deleted file mode 100644
index 7edc6aa..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrCollectionConfigurer.java
+++ /dev/null
@@ -1,230 +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.configurer;
-
-import org.apache.ambari.logsearch.conf.SolrPropsConfig;
-import org.apache.ambari.logsearch.conf.global.SolrCollectionState;
-import org.apache.ambari.logsearch.dao.SolrDaoBase;
-import org.apache.ambari.logsearch.handler.ACLHandler;
-import org.apache.ambari.logsearch.handler.CreateCollectionHandler;
-import org.apache.ambari.logsearch.handler.ListCollectionHandler;
-import org.apache.ambari.logsearch.handler.ReloadCollectionHandler;
-import org.apache.ambari.logsearch.handler.UploadConfigurationHandler;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.client.solrj.impl.HttpClientUtil;
-import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooKeeper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.data.solr.core.SolrTemplate;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class SolrCollectionConfigurer implements SolrConfigurer {
-
- private Logger LOG = LoggerFactory.getLogger(SolrCollectionConfigurer.class);
-
- private static final int SETUP_RETRY_SECOND = 10;
- private static final int SESSION_TIMEOUT = 15000;
- private static final int CONNECTION_TIMEOUT = 30000;
-
- private final SolrDaoBase solrDaoBase;
-
- public SolrCollectionConfigurer(final SolrDaoBase solrDaoBase) {
- this.solrDaoBase = solrDaoBase;
- }
-
- @Override
- public void start() {
- setupSecurity();
- final SolrPropsConfig solrPropsConfig = solrDaoBase.getSolrPropsConfig();
- final SolrCollectionState state = solrDaoBase.getSolrCollectionState();
- final String separator = FileSystems.getDefault().getSeparator();
- final String localConfigSetLocation = String.format("%s%s%s%sconf", solrPropsConfig.getConfigSetFolder(), separator,
- solrPropsConfig.getConfigName(), separator);
- final File configSetFolder = new File(localConfigSetLocation);
- if (!configSetFolder.exists()) { // show exception only once during startup
- throw new RuntimeException(String.format("Cannot load config set location: %s", localConfigSetLocation));
- }
- Thread setupThread = new Thread("setup_collection_" + solrPropsConfig.getCollection()) {
- @Override
- public void run() {
- LOG.info("Started monitoring thread to check availability of Solr server. collection=" + solrPropsConfig.getCollection());
- while (!stopSetupCondition(state)) {
- int retryCount = 0;
- try {
- retryCount++;
- Thread.sleep(SETUP_RETRY_SECOND * 1000);
- openZkConnectionAndUpdateStatus(state, solrPropsConfig);
- if (solrDaoBase.getSolrTemplate() == null) {
- solrDaoBase.setSolrTemplate(createSolrTemplate(solrPropsConfig));
- }
- CloudSolrClient cloudSolrClient = (CloudSolrClient) solrDaoBase.getSolrTemplate().getSolrClient();
- boolean reloadCollectionNeeded = uploadConfigurationsIfNeeded(cloudSolrClient, configSetFolder, state, solrPropsConfig);
- checkSolrStatus(cloudSolrClient);
- createCollectionsIfNeeded(cloudSolrClient, state, solrPropsConfig, reloadCollectionNeeded);
- } catch (Exception e) {
- retryCount++;
- LOG.error("Error setting collection. collection=" + solrPropsConfig.getCollection() + ", retryCount=" + retryCount, e);
- }
- }
- }
- };
- setupThread.setDaemon(true);
- setupThread.start();
- }
-
- private boolean uploadConfigurationsIfNeeded(CloudSolrClient cloudSolrClient, File configSetFolder, SolrCollectionState state, SolrPropsConfig solrPropsConfig) throws Exception {
- boolean reloadCollectionNeeded = new UploadConfigurationHandler(configSetFolder).handle(cloudSolrClient, solrPropsConfig);
- if (!state.isConfigurationUploaded()) {
- state.setConfigurationUploaded(true);
- }
- return reloadCollectionNeeded;
- }
-
- public boolean stopSetupCondition(SolrCollectionState state) {
- return state.isSolrCollectionReady();
- }
-
- public SolrTemplate createSolrTemplate(SolrPropsConfig solrPropsConfig) {
- return new SolrTemplate(createClient(
- solrPropsConfig.getSolrUrl(),
- solrPropsConfig.getZkConnectString(),
- solrPropsConfig.getCollection()));
- }
-
- private CloudSolrClient createClient(String solrUrl, String zookeeperConnectString, String defaultCollection) {
- if (StringUtils.isNotEmpty(zookeeperConnectString)) {
- CloudSolrClient cloudSolrClient = new CloudSolrClient(zookeeperConnectString);
- cloudSolrClient.setDefaultCollection(defaultCollection);
- return cloudSolrClient;
- } else if (StringUtils.isNotEmpty(solrUrl)) {
- throw new UnsupportedOperationException("Currently only cloud mode is supported. Set zookeeper connect string.");
- }
- throw new IllegalStateException(
- "Solr url or zookeeper connection string is missing. collection: " + defaultCollection);
- }
-
- private void setupSecurity() {
- String jaasFile = solrDaoBase.getSolrKerberosConfig().getJaasFile();
- boolean securityEnabled = solrDaoBase.getSolrKerberosConfig().isEnabled();
- if (securityEnabled) {
- System.setProperty("java.security.auth.login.config", jaasFile);
- HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
- LOG.info("setupSecurity() called for kerberos configuration, jaas file: " + jaasFile);
- }
- }
-
- private void openZkConnectionAndUpdateStatus(final SolrCollectionState state, final SolrPropsConfig solrPropsConfig) throws Exception {
- ZooKeeper zkClient = null;
- try {
- LOG.info("Checking that Znode ('{}') is ready or not... ", solrPropsConfig.getZkConnectString());
- zkClient = openZookeeperConnection(solrPropsConfig);
- if (!state.isZnodeReady()) {
- LOG.info("State change: Zookeeper ZNode is available for {}", solrPropsConfig.getZkConnectString());
- state.setZnodeReady(true);
- }
- } catch (Exception e) {
- LOG.error("Error occurred during the creation of zk client (connection string: {})", solrPropsConfig.getZkConnectString());
- throw e;
- } finally {
- try {
- if (zkClient != null) {
- zkClient.close();
- }
- } catch (Exception e) {
- LOG.error("Could not close zk connection properly.", e);
- }
- }
- }
-
- private ZooKeeper openZookeeperConnection(final SolrPropsConfig solrPropsConfig) throws InterruptedException, IOException {
- final CountDownLatch connSignal = new CountDownLatch(1);
- ZooKeeper zooKeeper = new ZooKeeper(solrPropsConfig.getZkConnectString(), SESSION_TIMEOUT, new Watcher() {
- public void process(WatchedEvent event) {
- if (event.getState() == Event.KeeperState.SyncConnected) {
- connSignal.countDown();
- }
- }
- });
- connSignal.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
- return zooKeeper;
- }
-
- private boolean checkSolrStatus(CloudSolrClient cloudSolrClient) {
- int waitDurationMS = 3 * 60 * 1000;
- boolean status = false;
- try {
- long beginTimeMS = System.currentTimeMillis();
- long waitIntervalMS = 2000;
- int pingCount = 0;
- while (true) {
- pingCount++;
- try {
- List<String> collectionList = new ListCollectionHandler().handle(cloudSolrClient, null);
- if (collectionList != null) {
- LOG.info("checkSolrStatus(): Solr getCollections() is success. collectionList=" + collectionList);
- status = true;
- break;
- }
- } catch (Exception ex) {
- LOG.error("Error while doing Solr check", ex);
- }
- if (System.currentTimeMillis() - beginTimeMS > waitDurationMS) {
- LOG.error("Solr is not reachable even after " + (System.currentTimeMillis() - beginTimeMS) + " ms. " +
- "If you are using alias, then you might have to restart LogSearch after Solr is up and running.");
- break;
- } else {
- LOG.warn("Solr is not not reachable yet. getCollections() attempt count=" + pingCount + ". " +
- "Will sleep for " + waitIntervalMS + " ms and try again.");
- }
- Thread.sleep(waitIntervalMS);
-
- }
- } catch (Throwable t) {
- LOG.error("Seems Solr is not up.");
- }
- return status;
- }
-
- private void createCollectionsIfNeeded(CloudSolrClient solrClient, SolrCollectionState state, SolrPropsConfig solrPropsConfig, boolean reloadCollectionNeeded) {
- try {
- List<String> allCollectionList = new ListCollectionHandler().handle(solrClient, null);
- boolean collectionCreated = new CreateCollectionHandler(allCollectionList).handle(solrClient, solrPropsConfig);
- boolean collectionReloaded = true;
- if (reloadCollectionNeeded) {
- collectionReloaded = new ReloadCollectionHandler().handle(solrClient, solrPropsConfig);
- }
- boolean aclsUpdated = new ACLHandler().handle(solrClient, solrPropsConfig);
- if (!state.isSolrCollectionReady() && collectionCreated && collectionReloaded && aclsUpdated) {
- state.setSolrCollectionReady(true);
- }
- } catch (Exception ex) {
- LOG.error("Error during creating/updating collection. collectionName=" + solrPropsConfig.getCollection(), ex);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrConfigurer.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrConfigurer.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrConfigurer.java
deleted file mode 100644
index 67cb9d1..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/configurer/SolrConfigurer.java
+++ /dev/null
@@ -1,23 +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.configurer;
-
-interface SolrConfigurer {
- void start();
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java
deleted file mode 100644
index 5656c88..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractAuditLogRequestQueryConverter.java
+++ /dev/null
@@ -1,59 +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.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.solr.core.query.Query;
-
-import java.util.List;
-
-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.CommonLogConstants.SEQUENCE_ID;
-
-public abstract class AbstractAuditLogRequestQueryConverter<SOURCE extends BaseLogRequest, RESULT extends Query>
- extends AbstractLogRequestQueryConverter<SOURCE, RESULT>{
-
- @Override
- public Sort sort(SOURCE request) {
- String sortBy = request.getSortBy();
- String sortType = request.getSortType();
- Sort.Order defaultSortOrder;
- if (StringUtils.isNotBlank(sortBy)) {
- Sort.Direction direction = StringUtils.equals(sortType , LogSearchConstants.ASCENDING_ORDER) ? Sort.Direction.ASC : Sort.Direction.DESC;
- defaultSortOrder = new Sort.Order(direction, sortBy);
- } else {
- defaultSortOrder = new Sort.Order(Sort.Direction.DESC, AUDIT_EVTTIME);
- }
- Sort.Order sequenceIdOrder = new Sort.Order(Sort.Direction.DESC, SEQUENCE_ID);
- return new Sort(defaultSortOrder, sequenceIdOrder);
- }
-
- @Override
- public void addComponentFilters(SOURCE request, RESULT query) {
- List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
- List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
- addInFilterQuery(query, AUDIT_COMPONENT, includeTypes);
- addInFilterQuery(query, AUDIT_COMPONENT, excludeTypes, true);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java
deleted file mode 100644
index a4db91f..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractConverterAware.java
+++ /dev/null
@@ -1,47 +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.springframework.core.convert.ConversionService;
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.core.convert.converter.ConverterRegistry;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-public abstract class AbstractConverterAware<SOURCE, RESULT> implements Converter<SOURCE, RESULT> {
-
- @Inject
- @Named("conversionService")
- private ConversionService conversionService;
-
- public ConversionService getConversionService() {
- return conversionService;
- }
-
- @PostConstruct
- private void register() {
- if (conversionService instanceof ConverterRegistry) {
- ((ConverterRegistry) conversionService).addConverter(this);
- } else {
- throw new IllegalStateException("Can't register Converter to ConverterRegistry");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java
deleted file mode 100644
index 2143f56..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractDateRangeFacetQueryConverter.java
+++ /dev/null
@@ -1,55 +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.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.DateRangeParamDefinition;
-import org.apache.ambari.logsearch.model.request.UnitParamDefinition;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.SolrQuery;
-
-import java.util.Locale;
-
-public abstract class AbstractDateRangeFacetQueryConverter<SOURCE extends DateRangeParamDefinition & UnitParamDefinition>
- extends AbstractOperationHolderConverter<SOURCE , SolrQuery> {
-
- @Override
- public SolrQuery convert(SOURCE request) {
- SolrQuery solrQuery = new SolrQuery();
- String unit = StringUtils.defaultIfEmpty(request.getUnit(), "+1HOUR");
- solrQuery.setQuery("*:*");
- solrQuery.setFacet(true);
- solrQuery.addFacetPivotField("{!range=r1}" + getTypeFieldName());
- solrQuery.setFacetMinCount(1);
- solrQuery.setFacetLimit(-1);
- solrQuery.setFacetSort(LogSearchConstants.FACET_INDEX);
- solrQuery.add("facet.range", "{!tag=r1}" + getDateFieldName());
- solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.start"}), request.getFrom());
- solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.end"}), request.getTo());
- solrQuery.add(String.format(Locale.ROOT, "f.%s.%s", new Object[]{getDateFieldName(), "facet.range.gap"}), unit);
- solrQuery.remove("sort");
- solrQuery.setRows(0);
- solrQuery.setStart(0);
- return solrQuery;
- }
-
- public abstract String getDateFieldName();
-
- public abstract String getTypeFieldName();
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java
deleted file mode 100644
index d5e807b..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestFacetQueryConverter.java
+++ /dev/null
@@ -1,88 +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.common.LogType;
-import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.lang.StringUtils;
-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 org.springframework.data.solr.core.query.SimpleStringCriteria;
-
-import java.util.List;
-
-import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.CLUSTER;
-import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
-import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
-
-public abstract class AbstractLogRequestFacetQueryConverter<SOURCE extends BaseLogRequest> extends AbstractOperationHolderConverter<SOURCE, SimpleFacetQuery>{
-
- @Override
- public SimpleFacetQuery convert(SOURCE request) {
- String fromValue = StringUtils.isNotEmpty(request.getFrom()) ? request.getFrom() : "*";
- String toValue = StringUtils.isNotEmpty(request.getTo()) ? request.getTo() : "*";
- Criteria criteria = new SimpleStringCriteria("*:*");
- SimpleFacetQuery facetQuery = new SimpleFacetQuery();
- facetQuery.addCriteria(criteria);
- SimpleFilterQuery simpleFilterQuery = new SimpleFilterQuery();
- simpleFilterQuery.addCriteria(new SimpleStringCriteria(getDateTimeField() + ":[" + fromValue +" TO "+ toValue+ "]" ));
- facetQuery.addFilterQuery(simpleFilterQuery);
- FacetOptions facetOptions = new FacetOptions();
- facetOptions.setFacetMinCount(1);
- facetOptions.setFacetSort(getFacetSort());
- facetOptions.setFacetLimit(-1);
- appendFacetOptions(facetOptions, request);
- addIncludeFieldValues(facetQuery, StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
- addExcludeFieldValues(facetQuery, StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
- facetQuery.setFacetOptions(facetOptions);
- facetQuery.setRows(0);
- addComponentFilters(facetQuery, request);
- appendFacetQuery(facetQuery, request);
- addInFilterQuery(facetQuery, CLUSTER, splitValueAsList(request.getClusters(), ","));
- return facetQuery;
- }
-
- public abstract FacetOptions.FacetSort getFacetSort();
-
- public abstract String getDateTimeField();
-
- public abstract LogType getLogType();
-
- public void appendFacetQuery(SimpleFacetQuery facetQuery, SOURCE request) {
- }
-
- public void appendFacetOptions(FacetOptions facetOptions, SOURCE request) {
- facetOptions.setFacetLimit(-1);
- }
-
- private void addComponentFilters(SimpleFacetQuery query, SOURCE request) {
- List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
- List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
- if (LogType.AUDIT.equals(getLogType())) {
- addInFilterQuery(query, AUDIT_COMPONENT, includeTypes);
- addInFilterQuery(query, AUDIT_COMPONENT, excludeTypes, true);
- } else if (LogType.SERVICE.equals(getLogType())) {
- addInFilterQuery(query, COMPONENT, includeTypes);
- addInFilterQuery(query, COMPONENT, excludeTypes, true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java
deleted file mode 100644
index d9f51f4..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractLogRequestQueryConverter.java
+++ /dev/null
@@ -1,42 +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.BaseLogRequest;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.data.solr.core.query.Query;
-
-import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.CLUSTER;
-
-public abstract class AbstractLogRequestQueryConverter<REQUEST_TYPE extends BaseLogRequest, QUERY_TYPE extends Query>
- extends AbstractSearchRequestQueryConverter<REQUEST_TYPE, QUERY_TYPE> {
-
- @Override
- public QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query) {
- addComponentFilters(request, query);
- addIncludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getIncludeQuery()));
- addExcludeFieldValues(query, StringEscapeUtils.unescapeXml(request.getExcludeQuery()));
- addInFilterQuery(query, CLUSTER, splitValueAsList(request.getClusters(), ","));
- return extendLogQuery(request, query);
- }
-
- public abstract QUERY_TYPE extendLogQuery(REQUEST_TYPE request, QUERY_TYPE query);
-
- public abstract void addComponentFilters(REQUEST_TYPE request, QUERY_TYPE query);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java
deleted file mode 100644
index c92dd14..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractOperationHolderConverter.java
+++ /dev/null
@@ -1,180 +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 com.google.common.base.Splitter;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-import org.apache.ambari.logsearch.common.LogType;
-import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.text.StrTokenizer;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.springframework.data.solr.core.query.Criteria;
-import org.springframework.data.solr.core.query.Query;
-import org.springframework.data.solr.core.query.SimpleFilterQuery;
-import org.springframework.data.solr.core.query.SimpleStringCriteria;
-
-import javax.inject.Inject;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.LOG_MESSAGE;
-
-public abstract class AbstractOperationHolderConverter <REQUEST_TYPE, QUERY_TYPE>
- extends AbstractConverterAware<REQUEST_TYPE, QUERY_TYPE> {
-
- @Inject
- private SolrSchemaFieldDao solrSchemaFieldDao;
-
- public List<String> splitValueAsList(String value, String separator) {
- return StringUtils.isNotEmpty(value) ? Splitter.on(separator).omitEmptyStrings().splitToList(value) : null;
- }
-
- public Query addEqualsFilterQuery(Query query, String field, String value) {
- return this.addEqualsFilterQuery(query, field, value, false);
- }
-
- public Query addEqualsFilterQuery(Query query, String field, String value, boolean negate) {
- if (StringUtils.isNotEmpty(value)) {
- addFilterQuery(query, new Criteria(field).is(value), negate);
- }
- return query;
- }
-
- public Query addContainsFilterQuery(Query query, String field, String value) {
- return this.addContainsFilterQuery(query, field, value, false);
- }
-
- public Query addContainsFilterQuery(Query query, String field, String value, boolean negate) {
- if (StringUtils.isNotEmpty(value)) {
- addFilterQuery(query, new Criteria(field).contains(value), negate);
- }
- return query;
- }
-
- public Query addInFilterQuery(Query query, String field, List<String> values) {
- return this.addInFilterQuery(query, field, values, false);
- }
-
- public Query addInFiltersIfNotNullAndEnabled(Query query, String value, String field, boolean condition) {
- if (value != null && condition) {
- List<String> values = value.length() == 0 ? Arrays.asList("-1") : splitValueAsList(value, ",");
- addInFilterQuery(query, field, values);
- }
- return query;
- }
-
- public Query addInFilterQuery(Query query, String field, List<String> values, boolean negate) {
- if (CollectionUtils.isNotEmpty(values)) {
- addFilterQuery(query, new Criteria(field).is(values), negate);
- }
- return query;
- }
-
- public Query addRangeFilter(Query query, String field, String from, String to) {
- return this.addRangeFilter(query, field, from, to, false);
- }
-
- public Query addRangeFilter(Query query, String field, String from, String to, boolean negate) { // TODO use criteria.between without escaping
- String fromValue = StringUtils.defaultIfEmpty(from, "*");
- String toValue = StringUtils.defaultIfEmpty(to, "*");
- addFilterQuery(query, new SimpleStringCriteria(field + ":[" + fromValue +" TO "+ toValue + "]" ), negate);
- return query;
- }
-
- public void addFilterQuery(Query query, Criteria criteria, boolean negate) {
- if (negate) {
- criteria.not();
- }
- query.addFilterQuery(new SimpleFilterQuery(criteria));
- }
-
- public Query addIncludeFieldValues(Query query, String fieldValuesMapStr) {
- if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
- List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
- new TypeToken<List<HashMap<String, String>>>(){}.getType());
- for (Map<String, String> criteriaMap : criterias) {
- for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
- if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
- addLogMessageFilter(query, fieldEntry.getValue(), false);
- } else {
- addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeNonLogMessageField(fieldEntry)), false);
- }
- }
- }
- }
- return query;
- }
-
- public Query addExcludeFieldValues(Query query, String fieldValuesMapStr) {
- if (StringUtils.isNotEmpty(fieldValuesMapStr)) {
- List<Map<String, String>> criterias = new Gson().fromJson(fieldValuesMapStr,
- new TypeToken<List<HashMap<String, String>>>(){}.getType());
- for (Map<String, String> criteriaMap : criterias) {
- for (Map.Entry<String, String> fieldEntry : criteriaMap.entrySet()) {
- if (fieldEntry.getKey().equalsIgnoreCase(LOG_MESSAGE)) {
- addLogMessageFilter(query, fieldEntry.getValue(), true);
- } else {
- addFilterQuery(query, new Criteria(fieldEntry.getKey()).is(escapeNonLogMessageField(fieldEntry)), true);
- }
- }
- }
- }
- return query;
- }
-
- public SolrQuery addListFilterToSolrQuery(SolrQuery solrQuery, String fieldName, String fieldValue) {
- return SolrUtil.addListFilterToSolrQuery(solrQuery, fieldName, fieldValue);
- }
-
- public abstract LogType getLogType();
-
- private void addLogMessageFilter(Query query, String value, boolean negate) {
- StrTokenizer tokenizer = new StrTokenizer(value, ' ', '"');
- for (String token : tokenizer.getTokenArray()) {
- token = token.trim();
- if (token.contains(" ") || !token.startsWith("*") && !token.endsWith("*")) {
- addFilterQuery(query, new Criteria(LOG_MESSAGE).is(SolrUtil.escapeQueryChars(token)), negate);
- } else if (token.startsWith("*") && token.endsWith("*")) {
- String plainToken = StringUtils.substring(token, 1, -1);
- addFilterQuery(query, new Criteria(LOG_MESSAGE).contains(SolrUtil.escapeQueryChars(plainToken)), negate);
- } else if (token.startsWith("*") && !token.endsWith("*")) {
- String plainToken = StringUtils.substring(token, 1);
- addFilterQuery(query, new Criteria(LOG_MESSAGE).endsWith(SolrUtil.escapeQueryChars(plainToken)), negate);
- } else if (!token.startsWith("*") && token.endsWith("*")) {
- String plainToken = StringUtils.substring(token, 0, -1);
- addFilterQuery(query, new Criteria(LOG_MESSAGE).startsWith(SolrUtil.escapeQueryChars(plainToken)), negate);
- }
- }
- }
-
- private String escapeNonLogMessageField(Map.Entry<String, String> fieldEntry) {
- Map<String, String> schemaFieldNameMap = solrSchemaFieldDao.getSchemaFieldNameMap(getLogType());
- Map<String, String> schemaFieldTypeMap = solrSchemaFieldDao.getSchemaFieldTypeMap(getLogType());
- String fieldType = schemaFieldNameMap.get(fieldEntry.getKey());
- String fieldTypeMetaData = schemaFieldTypeMap.get(fieldType);
- return SolrUtil.putWildCardByType(fieldEntry.getValue(), fieldType, fieldTypeMetaData);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java
deleted file mode 100644
index d4fc48b..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractSearchRequestQueryConverter.java
+++ /dev/null
@@ -1,72 +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 java.util.ArrayList;
-import java.util.List;
-
-import org.apache.ambari.logsearch.model.request.LastPageParamDefinition;
-import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.data.solr.core.query.Criteria;
-import org.springframework.data.solr.core.query.Query;
-import org.springframework.data.solr.core.query.SimpleStringCriteria;
-
-public abstract class AbstractSearchRequestQueryConverter<REQUEST_TYPE extends CommonSearchRequest, QUERY_TYPE extends Query>
- extends AbstractOperationHolderConverter<REQUEST_TYPE, QUERY_TYPE> {
-
- @Override
- public QUERY_TYPE convert(REQUEST_TYPE request) {
- QUERY_TYPE query = createQuery();
- addPageRequest(request, query);
- Criteria criteria = new SimpleStringCriteria("*:*");
- query.addCriteria(criteria);
- return extendSolrQuery(request, query);
- }
-
- private void addPageRequest(REQUEST_TYPE request, QUERY_TYPE query) {
- int page = StringUtils.isNumeric(request.getPage()) ? new Integer(request.getPage()) : 0;
- int pageSize = StringUtils.isNumeric(request.getPageSize()) ? new Integer(request.getPageSize()) : 99999;
- Sort sort = sort(request);
-
- boolean isLastPage = (request instanceof LastPageParamDefinition) ?
- ((LastPageParamDefinition)request).isLastPage() :
- false;
- if (isLastPage) {
- page = 0;
- List<Sort.Order> newOrders = new ArrayList<>();
- for (Sort.Order order : sort) {
- newOrders.add(new Sort.Order(order.getDirection() == Direction.ASC ? Direction.DESC : Direction.ASC, order.getProperty()));
- }
- sort = new Sort(newOrders);
- }
-
- PageRequest pageRequest = new PageRequest(page, pageSize, sort);
- query.setPageRequest(pageRequest);
- }
-
- public abstract QUERY_TYPE extendSolrQuery(REQUEST_TYPE request, QUERY_TYPE query);
-
- public abstract Sort sort(REQUEST_TYPE request);
-
- public abstract QUERY_TYPE createQuery();
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestFacetQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestFacetQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestFacetQueryConverter.java
deleted file mode 100644
index 0fc12e8..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestFacetQueryConverter.java
+++ /dev/null
@@ -1,44 +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.BaseServiceLogRequest;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.data.solr.core.query.SimpleFacetQuery;
-
-import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.BUNDLE_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.LEVEL;
-import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.PATH;
-
-public abstract class AbstractServiceLogRequestFacetQueryConverter<SOURCE extends BaseServiceLogRequest>
- extends AbstractLogRequestFacetQueryConverter<SOURCE> {
-
- @Override
- public void appendFacetQuery(SimpleFacetQuery facetQuery, SOURCE request) {
- addEqualsFilterQuery(facetQuery, HOST, SolrUtil.escapeQueryChars(request.getHostName()));
- addEqualsFilterQuery(facetQuery, PATH, SolrUtil.escapeQueryChars(request.getFileName()));
- addEqualsFilterQuery(facetQuery, COMPONENT, SolrUtil.escapeQueryChars(request.getComponentName()));
- addEqualsFilterQuery(facetQuery, BUNDLE_ID, request.getBundleId());
- addInFiltersIfNotNullAndEnabled(facetQuery, request.getLevel(), LEVEL, true);
- addInFiltersIfNotNullAndEnabled(facetQuery, request.getHostList(), HOST, StringUtils.isEmpty(request.getHostName()));
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java
deleted file mode 100644
index e1cd077..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AbstractServiceLogRequestQueryConverter.java
+++ /dev/null
@@ -1,44 +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.common.LogType;
-import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest;
-import org.springframework.data.solr.core.query.Query;
-
-import java.util.List;
-
-import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT;
-
-public abstract class AbstractServiceLogRequestQueryConverter<REQUEST_TYPE extends BaseLogRequest, QUERY_TYPE extends Query>
- extends AbstractLogRequestQueryConverter<REQUEST_TYPE, QUERY_TYPE> {
-
- @Override
- public LogType getLogType() {
- return LogType.SERVICE;
- }
-
- @Override
- public void addComponentFilters(REQUEST_TYPE request, QUERY_TYPE query) {
- List<String> includeTypes = splitValueAsList(request.getMustBe(), ",");
- List<String> excludeTypes = splitValueAsList(request.getMustNot(), ",");
- addInFilterQuery(query, COMPONENT, includeTypes);
- addInFilterQuery(query, COMPONENT, excludeTypes, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java
deleted file mode 100644
index 06dfae9..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverter.java
+++ /dev/null
@@ -1,55 +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.common.LogType;
-import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest;
-import org.apache.solr.client.solrj.SolrQuery;
-
-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.CommonLogConstants.CLUSTER;
-
-@Named
-public class AuditBarGraphRequestQueryConverter extends AbstractDateRangeFacetQueryConverter<AuditBarGraphRequest> {
-
- @Override
- public String getDateFieldName() {
- return AUDIT_EVTTIME;
- }
-
- @Override
- public String getTypeFieldName() {
- return AUDIT_COMPONENT;
- }
-
- @Override
- public LogType getLogType() {
- return LogType.AUDIT;
- }
-
- @Override
- public SolrQuery convert(AuditBarGraphRequest request) {
- SolrQuery query = super.convert(request);
- addListFilterToSolrQuery(query, CLUSTER, request.getClusters());
- return query;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java
deleted file mode 100644
index bf77444..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditComponentsRequestQueryConverter.java
+++ /dev/null
@@ -1,53 +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.common.LogType;
-import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest;
-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 AuditComponentsRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<AuditComponentRequest> {
-
- @Override
- public FacetOptions.FacetSort getFacetSort() {
- return FacetOptions.FacetSort.INDEX;
- }
-
- @Override
- public String getDateTimeField() {
- return AUDIT_EVTTIME;
- }
-
- @Override
- public LogType getLogType() {
- return LogType.AUDIT;
- }
-
- @Override
- public void appendFacetOptions(FacetOptions facetOptions, AuditComponentRequest request) {
- facetOptions.addFacetOnField(AUDIT_COMPONENT);
- facetOptions.setFacetLimit(-1);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java
deleted file mode 100644
index a2c1d81..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditLogRequestQueryConverter.java
+++ /dev/null
@@ -1,44 +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.common.LogType;
-import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest;
-import org.springframework.data.solr.core.query.SimpleQuery;
-
-import javax.inject.Named;
-
-@Named
-public class AuditLogRequestQueryConverter extends AbstractAuditLogRequestQueryConverter<AuditLogRequest, SimpleQuery> {
-
- @Override
- public SimpleQuery extendLogQuery(AuditLogRequest request, SimpleQuery query) {
- return query;
- }
-
- @Override
- public SimpleQuery createQuery() {
- return new SimpleQuery();
- }
-
- @Override
- public LogType getLogType() {
- return LogType.AUDIT;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java
deleted file mode 100644
index d88ec6d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverter.java
+++ /dev/null
@@ -1,53 +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.common.LogType;
-import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest;
-import org.springframework.data.solr.core.query.FacetOptions;
-
-import javax.inject.Named;
-
-import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_EVTTIME;
-import static org.apache.ambari.logsearch.solr.SolrConstants.AuditLogConstants.AUDIT_COMPONENT;
-
-@Named
-public class AuditServiceLoadRequestQueryConverter extends AbstractLogRequestFacetQueryConverter<AuditServiceLoadRequest> {
-
- @Override
- public FacetOptions.FacetSort getFacetSort() {
- return FacetOptions.FacetSort.COUNT;
- }
-
- @Override
- public String getDateTimeField() {
- return AUDIT_EVTTIME;
- }
-
- @Override
- public LogType getLogType() {
- return LogType.AUDIT;
- }
-
- @Override
- public void appendFacetOptions(FacetOptions facetOptions, AuditServiceLoadRequest request) {
- facetOptions.addFacetOnField(AUDIT_COMPONENT);
- facetOptions.setFacetLimit(10);
- }
-}