You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2017/06/14 21:19:49 UTC
[18/26] ambari git commit: AMBARI-21228. Rename userconfig resource
to event history in Log Search Portal (oleewere)
AMBARI-21228. Rename userconfig resource to event history in Log Search Portal (oleewere)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fc00b2ca
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fc00b2ca
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fc00b2ca
Branch: refs/heads/branch-feature-AMBARI-20859
Commit: fc00b2caf927d083c70812bf1552aafa68958d1f
Parents: 27a9938
Author: oleewere <ol...@gmail.com>
Authored: Mon Jun 12 17:12:58 2017 +0200
Committer: oleewere <ol...@gmail.com>
Committed: Tue Jun 13 13:47:23 2017 +0200
----------------------------------------------------------------------
.../logfeeder/common/LogFeederConstants.java | 2 +-
.../ambari/logsearch/conf/SecurityConfig.java | 18 +-
.../ambari/logsearch/conf/SolrConfig.java | 12 +-
.../conf/SolrEventHistoryPropsConfig.java | 116 +++++++++++
.../logsearch/conf/SolrUserPropsConfig.java | 116 -----------
.../conf/global/SolrEventHistoryState.java | 60 ++++++
.../conf/global/SolrUserConfigState.java | 60 ------
.../EventHistoryRequestQueryConverter.java | 67 +++++++
.../UserConfigRequestQueryConverter.java | 67 -------
.../logsearch/dao/EventHistorySolrDao.java | 117 +++++++++++
.../logsearch/dao/SolrSchemaFieldDao.java | 8 +-
.../ambari/logsearch/dao/UserConfigSolrDao.java | 117 -----------
.../ambari/logsearch/doc/DocConstants.java | 12 +-
.../logsearch/manager/EventHistoryManager.java | 199 +++++++++++++++++++
.../logsearch/manager/UserConfigManager.java | 199 -------------------
.../request/EventHistoryParamDefinition.java | 38 ++++
.../request/UserConfigParamDefinition.java | 38 ----
.../model/request/impl/EventHistoryRequest.java | 53 +++++
.../model/request/impl/UserConfigRequest.java | 53 -----
.../model/response/EventHistoryData.java | 97 +++++++++
.../response/EventHistoryDataListResponse.java | 55 +++++
.../model/response/UserConfigData.java | 97 ---------
.../response/UserConfigDataListResponse.java | 55 -----
.../logsearch/rest/EventHistoryResource.java | 82 ++++++++
.../ambari/logsearch/rest/StatusResource.java | 16 +-
.../logsearch/rest/UserConfigResource.java | 82 --------
.../ambari/logsearch/solr/SolrConstants.java | 4 +-
.../LogsearchEventHistoryStateFilter.java | 52 +++++
.../filters/LogsearchUserConfigStateFilter.java | 52 -----
.../EventHistoryRequestQueryConverterTest.java | 50 +++++
.../UserConfigRequestQueryConverterTest.java | 50 -----
.../collection_bases/VEventHistoryListBase.js | 8 +-
.../scripts/model_bases/VUserFilterBase.js | 2 +-
.../main/webapp/scripts/views/common/Header.js | 2 +-
34 files changed, 1028 insertions(+), 1028 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/common/LogFeederConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/common/LogFeederConstants.java b/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/common/LogFeederConstants.java
index a7559aa..a7cccc6 100644
--- a/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/common/LogFeederConstants.java
+++ b/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/common/LogFeederConstants.java
@@ -29,7 +29,7 @@ public class LogFeederConstants {
public static final String SOLR_COMPONENT = "type";
public static final String SOLR_HOST = "host";
- // UserConfig Constants History
+ // Event History Constants History
public static final String VALUES = "jsons";
public static final String ROW_TYPE = "rowtype";
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
index 973dc4b..441b628 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
@@ -33,7 +33,7 @@ import org.apache.ambari.logsearch.web.filters.LogsearchKRBAuthenticationFilter;
import org.apache.ambari.logsearch.web.filters.LogsearchJWTFilter;
import org.apache.ambari.logsearch.web.filters.LogsearchSecurityContextFormationFilter;
import org.apache.ambari.logsearch.web.filters.LogsearchServiceLogsStateFilter;
-import org.apache.ambari.logsearch.web.filters.LogsearchUserConfigStateFilter;
+import org.apache.ambari.logsearch.web.filters.LogsearchEventHistoryStateFilter;
import org.apache.ambari.logsearch.web.filters.LogsearchUsernamePasswordAuthenticationFilter;
import org.apache.ambari.logsearch.web.security.LogsearchAuthenticationProvider;
import org.springframework.context.annotation.Bean;
@@ -71,7 +71,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
private SolrAuditLogPropsConfig solrAuditLogPropsConfig;
@Inject
- private SolrUserPropsConfig solrUserPropsConfig;
+ private SolrEventHistoryPropsConfig solrEventHistoryPropsConfig;
@Inject
@Named("solrServiceLogsState")
@@ -82,8 +82,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
private SolrCollectionState solrAuditLogsState;
@Inject
- @Named("solrUserConfigState")
- private SolrCollectionState solrUserConfigState;
+ @Named("solrEventHistoryState")
+ private SolrCollectionState solrEventHistoryState;
@Inject
private LogSearchConfigState logSearchConfigState;
@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.addFilterBefore(logsearchUsernamePasswordAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(logsearchKRBAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.addFilterAfter(securityContextFormationFilter(), FilterSecurityInterceptor.class)
- .addFilterAfter(logsearchUserConfigFilter(), LogsearchSecurityContextFormationFilter.class)
+ .addFilterAfter(logsearchEventHistoryFilter(), LogsearchSecurityContextFormationFilter.class)
.addFilterAfter(logsearchAuditLogFilter(), LogsearchSecurityContextFormationFilter.class)
.addFilterAfter(logsearchServiceLogFilter(), LogsearchSecurityContextFormationFilter.class)
.addFilterAfter(logSearchConfigStateFilter(), LogsearchSecurityContextFormationFilter.class)
@@ -179,8 +179,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
}
@Bean
- public LogsearchUserConfigStateFilter logsearchUserConfigFilter() {
- return new LogsearchUserConfigStateFilter(userConfigRequestMatcher(), solrUserConfigState, solrUserPropsConfig);
+ public LogsearchEventHistoryStateFilter logsearchEventHistoryFilter() {
+ return new LogsearchEventHistoryStateFilter(eventHistoryRequestMatcher(), solrEventHistoryState, solrEventHistoryPropsConfig);
}
public LogSearchConfigStateFilter logSearchConfigStateFilter() {
@@ -213,8 +213,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return new AntPathRequestMatcher("/api/v1/audit/logs/**");
}
- public RequestMatcher userConfigRequestMatcher() {
- return new AntPathRequestMatcher("/api/v1/userconfig/**");
+ public RequestMatcher eventHistoryRequestMatcher() {
+ return new AntPathRequestMatcher("/api/v1/history/**");
}
public RequestMatcher logsearchConfigRequestMatcher() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
index f00e8c5..f9144ff 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrConfig.java
@@ -21,7 +21,7 @@ package org.apache.ambari.logsearch.conf;
import org.apache.ambari.logsearch.conf.global.SolrAuditLogsState;
import org.apache.ambari.logsearch.conf.global.SolrCollectionState;
import org.apache.ambari.logsearch.conf.global.SolrServiceLogsState;
-import org.apache.ambari.logsearch.conf.global.SolrUserConfigState;
+import org.apache.ambari.logsearch.conf.global.SolrEventHistoryState;
import org.apache.ambari.logsearch.dao.SolrSchemaFieldDao;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -46,9 +46,9 @@ public class SolrConfig {
return null;
}
- @Bean(name = "userConfigSolrTemplate")
+ @Bean(name = "eventHistorySolrTemplate")
@DependsOn("serviceSolrTemplate")
- public SolrTemplate userConfigSolrTemplate() {
+ public SolrTemplate eventHistorySolrTemplate() {
return null;
}
@@ -68,9 +68,9 @@ public class SolrConfig {
return new SolrAuditLogsState();
}
- @Bean(name = "solrUserConfigState")
- public SolrCollectionState solrUserConfigState() {
- return new SolrUserConfigState();
+ @Bean(name = "solrEventHistoryState")
+ public SolrCollectionState solrEventHistoryState() {
+ return new SolrEventHistoryState();
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrEventHistoryPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrEventHistoryPropsConfig.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrEventHistoryPropsConfig.java
new file mode 100644
index 0000000..a117501
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrEventHistoryPropsConfig.java
@@ -0,0 +1,116 @@
+/*
+ * 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 SolrEventHistoryPropsConfig 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/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/SolrUserPropsConfig.java
deleted file mode 100644
index c8c96c8..0000000
--- a/ambari-logsearch/ambari-logsearch-server/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/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/global/SolrEventHistoryState.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/global/SolrEventHistoryState.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/global/SolrEventHistoryState.java
new file mode 100644
index 0000000..c31e69e
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/global/SolrEventHistoryState.java
@@ -0,0 +1,60 @@
+/*
+ * 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 SolrEventHistoryState 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/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/global/SolrUserConfigState.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/global/SolrUserConfigState.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/conf/global/SolrUserConfigState.java
deleted file mode 100644
index 06af14c..0000000
--- a/ambari-logsearch/ambari-logsearch-server/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/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverter.java
new file mode 100644
index 0000000..c67c31b
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/EventHistoryRequestQueryConverter.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.converter;
+
+import org.apache.ambari.logsearch.model.request.impl.EventHistoryRequest;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.solr.client.solrj.SolrQuery;
+
+import javax.inject.Named;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.CommonLogConstants.CLUSTER;
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.FILTER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.ROW_TYPE;
+
+@Named
+public class EventHistoryRequestQueryConverter extends AbstractConverterAware<EventHistoryRequest, SolrQuery> {
+
+ @Override
+ public SolrQuery convert(EventHistoryRequest eventHistoryRequest) {
+ SolrQuery eventHistoryQuery = new SolrQuery();
+ eventHistoryQuery.setQuery("*:*");
+
+ int startIndex = StringUtils.isNotEmpty(eventHistoryRequest.getStartIndex()) && StringUtils.isNumeric(eventHistoryRequest.getStartIndex())
+ ? Integer.parseInt(eventHistoryRequest.getStartIndex()) : 0;
+ int maxRows = StringUtils.isNotEmpty(eventHistoryRequest.getPageSize()) && StringUtils.isNumeric(eventHistoryRequest.getPageSize())
+ ? Integer.parseInt(eventHistoryRequest.getPageSize()) : 10;
+
+ SolrQuery.ORDER order = eventHistoryRequest.getSortType() != null && SolrQuery.ORDER.desc.equals(SolrQuery.ORDER.valueOf(eventHistoryRequest.getSortType()))
+ ? SolrQuery.ORDER.desc : SolrQuery.ORDER.asc;
+ String sortBy = StringUtils.isNotEmpty(eventHistoryRequest.getSortBy()) ? eventHistoryRequest.getSortBy() : FILTER_NAME;
+ String filterName = StringUtils.isBlank(eventHistoryRequest.getFilterName()) ? "*" : "*" + eventHistoryRequest.getFilterName() + "*";
+
+ eventHistoryQuery.addFilterQuery(String.format("%s:%s", ROW_TYPE, eventHistoryRequest.getRowType()));
+ eventHistoryQuery.addFilterQuery(String.format("%s:%s", FILTER_NAME, SolrUtil.makeSearcableString(filterName)));
+ eventHistoryQuery.setStart(startIndex);
+ eventHistoryQuery.setRows(maxRows);
+
+ SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(sortBy, order);
+ List<SolrQuery.SortClause> sort = new ArrayList<>();
+ sort.add(sortOrder);
+ eventHistoryQuery.setSorts(sort);
+
+ SolrUtil.addListFilterToSolrQuery(eventHistoryQuery, CLUSTER, eventHistoryRequest.getClusters());
+
+ return eventHistoryQuery;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
deleted file mode 100644
index 594f23b..0000000
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.ambari.logsearch.converter;
-
-import org.apache.ambari.logsearch.model.request.impl.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.CommonLogConstants.CLUSTER;
-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 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.getPageSize())
- ? Integer.parseInt(userConfigRequest.getPageSize()) : 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", 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);
-
- SolrUtil.addListFilterToSolrQuery(userConfigQuery, CLUSTER, userConfigRequest.getClusters());
-
- return userConfigQuery;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/EventHistorySolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/EventHistorySolrDao.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/EventHistorySolrDao.java
new file mode 100644
index 0000000..aff4061
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/EventHistorySolrDao.java
@@ -0,0 +1,117 @@
+/*
+ * 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.dao;
+
+import java.io.IOException;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.LogType;
+import org.apache.ambari.logsearch.conf.SolrPropsConfig;
+import org.apache.ambari.logsearch.conf.SolrEventHistoryPropsConfig;
+import org.apache.ambari.logsearch.conf.global.SolrCollectionState;
+import org.apache.ambari.logsearch.configurer.SolrCollectionConfigurer;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.UpdateResponse;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+
+import org.apache.log4j.Logger;
+import org.springframework.data.solr.core.SolrTemplate;
+
+@Named
+public class EventHistorySolrDao extends SolrDaoBase {
+
+ private static final Logger LOG = Logger.getLogger(EventHistorySolrDao.class);
+
+ private static final Logger LOG_PERFORMANCE = Logger.getLogger("org.apache.ambari.logsearch.performance");
+
+ @Inject
+ private SolrEventHistoryPropsConfig solrEventHistoryPropsConfig;
+
+ @Inject
+ @Named("eventHistorySolrTemplate")
+ private SolrTemplate eventHistorySolrTemplate;
+
+ @Inject
+ @Named("solrEventHistoryState")
+ private SolrCollectionState solrEventHistoryState;
+
+ public EventHistorySolrDao() {
+ super(LogType.SERVICE);
+ }
+
+ @Override
+ public SolrTemplate getSolrTemplate() {
+ return eventHistorySolrTemplate;
+ }
+
+ @Override
+ public void setSolrTemplate(SolrTemplate solrTemplate) {
+ this.eventHistorySolrTemplate = solrTemplate;
+ }
+
+ @PostConstruct
+ public void postConstructor() {
+ String solrUrl = solrEventHistoryPropsConfig.getSolrUrl();
+ String zkConnectString = solrEventHistoryPropsConfig.getZkConnectString();
+ String collection = solrEventHistoryPropsConfig.getCollection();
+
+ try {
+ new SolrCollectionConfigurer(this, false).start();
+ } catch (Exception e) {
+ LOG.error("error while connecting to Solr for history logs : solrUrl=" + solrUrl + ", zkConnectString=" + zkConnectString +
+ ", collection=" + collection, e);
+ }
+ }
+
+ public void deleteEventHistoryData(String id) throws SolrException, SolrServerException, IOException {
+ removeDoc("id:" + id);
+ }
+
+ public UpdateResponse addDocs(SolrInputDocument doc) throws SolrServerException, IOException, SolrException {
+ UpdateResponse updateResoponse = getSolrClient().add(doc);
+ LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
+ " Update Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
+ getSolrClient().commit();
+ return updateResoponse;
+ }
+
+ public UpdateResponse removeDoc(String query) throws SolrServerException, IOException, SolrException {
+ UpdateResponse updateResoponse = getSolrClient().deleteByQuery(query);
+ getSolrClient().commit();
+ LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
+ " Remove Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
+ return updateResoponse;
+ }
+
+ @Override
+ public SolrCollectionState getSolrCollectionState() {
+ return solrEventHistoryState;
+ }
+
+ @Override
+ public SolrPropsConfig getSolrPropsConfig() {
+ return solrEventHistoryPropsConfig;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
index 01378c1..d99694b 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/SolrSchemaFieldDao.java
@@ -21,7 +21,7 @@ package org.apache.ambari.logsearch.dao;
import org.apache.ambari.logsearch.common.LogSearchConstants;
import org.apache.ambari.logsearch.common.LogType;
import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.conf.SolrUserPropsConfig;
+import org.apache.ambari.logsearch.conf.SolrEventHistoryPropsConfig;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -68,7 +68,7 @@ public class SolrSchemaFieldDao {
private AuditSolrDao auditSolrDao;
@Inject
- private SolrUserPropsConfig solrUserConfigPropsConfig;
+ private SolrEventHistoryPropsConfig solrEventHistoryPropsConfig;
private int retryCount;
private int skipCount;
@@ -117,9 +117,9 @@ public class SolrSchemaFieldDao {
if (schemaResponse != null) {
extractSchemaFieldsName(lukeResponses, schemaResponse, schemaFieldNameMap, schemaFieldTypeMap);
LOG.debug("Populate fields for collection " + solrClient.getDefaultCollection()+ " was successful, next update it after " +
- solrUserConfigPropsConfig.getPopulateIntervalMins() + " minutes");
+ solrEventHistoryPropsConfig.getPopulateIntervalMins() + " minutes");
retryCount = 0;
- skipCount = (solrUserConfigPropsConfig.getPopulateIntervalMins() * 60) / RETRY_SECOND - 1;
+ skipCount = (solrEventHistoryPropsConfig.getPopulateIntervalMins() * 60) / RETRY_SECOND - 1;
}
else {
retryCount++;
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
deleted file mode 100644
index a0e01a3..0000000
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/dao/UserConfigSolrDao.java
+++ /dev/null
@@ -1,117 +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.dao;
-
-import java.io.IOException;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.apache.ambari.logsearch.common.LogSearchContext;
-import org.apache.ambari.logsearch.common.LogType;
-import org.apache.ambari.logsearch.conf.SolrPropsConfig;
-import org.apache.ambari.logsearch.conf.SolrUserPropsConfig;
-import org.apache.ambari.logsearch.conf.global.SolrCollectionState;
-import org.apache.ambari.logsearch.configurer.SolrCollectionConfigurer;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrInputDocument;
-
-import org.apache.log4j.Logger;
-import org.springframework.data.solr.core.SolrTemplate;
-
-@Named
-public class UserConfigSolrDao extends SolrDaoBase {
-
- private static final Logger LOG = Logger.getLogger(UserConfigSolrDao.class);
-
- private static final Logger LOG_PERFORMANCE = Logger.getLogger("org.apache.ambari.logsearch.performance");
-
- @Inject
- private SolrUserPropsConfig solrUserConfig;
-
- @Inject
- @Named("userConfigSolrTemplate")
- private SolrTemplate userConfigSolrTemplate;
-
- @Inject
- @Named("solrUserConfigState")
- private SolrCollectionState solrUserConfigState;
-
- public UserConfigSolrDao() {
- super(LogType.SERVICE);
- }
-
- @Override
- public SolrTemplate getSolrTemplate() {
- return userConfigSolrTemplate;
- }
-
- @Override
- public void setSolrTemplate(SolrTemplate solrTemplate) {
- this.userConfigSolrTemplate = solrTemplate;
- }
-
- @PostConstruct
- public void postConstructor() {
- String solrUrl = solrUserConfig.getSolrUrl();
- String zkConnectString = solrUserConfig.getZkConnectString();
- String collection = solrUserConfig.getCollection();
-
- try {
- new SolrCollectionConfigurer(this, false).start();
- } catch (Exception e) {
- LOG.error("error while connecting to Solr for history logs : solrUrl=" + solrUrl + ", zkConnectString=" + zkConnectString +
- ", collection=" + collection, e);
- }
- }
-
- public void deleteUserConfig(String id) throws SolrException, SolrServerException, IOException {
- removeDoc("id:" + id);
- }
-
- public UpdateResponse addDocs(SolrInputDocument doc) throws SolrServerException, IOException, SolrException {
- UpdateResponse updateResoponse = getSolrClient().add(doc);
- LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
- " Update Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
- getSolrClient().commit();
- return updateResoponse;
- }
-
- public UpdateResponse removeDoc(String query) throws SolrServerException, IOException, SolrException {
- UpdateResponse updateResoponse = getSolrClient().deleteByQuery(query);
- getSolrClient().commit();
- LOG_PERFORMANCE.info("\n Username :- " + LogSearchContext.getCurrentUsername() +
- " Remove Time Execution :- " + updateResoponse.getQTime() + " Total Time Elapsed is :- " + updateResoponse.getElapsedTime());
- return updateResoponse;
- }
-
- @Override
- public SolrCollectionState getSolrCollectionState() {
- return solrUserConfigState;
- }
-
- @Override
- public SolrPropsConfig getSolrPropsConfig() {
- return solrUserConfig;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
index 885771d..2ab5f0a 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java
@@ -104,15 +104,15 @@ public class DocConstants {
public static final String OBTAIN_GENERAL_CONFIG_OD = "Obtain general config";
}
- public class UserConfigDescriptions {
+ public class EventHistoryDescriptions {
public static final String FILTER_NAME_D = "The saved query as filter in Solr, search is sopprted by this param";
public static final String ROW_TYPE_D = "Row type is solr to identify as filter query";
}
- public class UserConfigOperationDescriptions {
- public static final String SAVE_USER_CONFIG_OD = "Save user config";
- public static final String DELETE_USER_CONFIG_OD = "Delete user config";
- public static final String GET_USER_CONFIG_OD = "Get user config";
+ public class EventHistoryOperationDescriptions {
+ public static final String SAVE_EVENT_HISTORY_DATA_OD = "Save event history data";
+ public static final String DELETE_EVENT_HISTORY_DATA_OD = "Delete event history data";
+ public static final String GET_EVENT_HISTORY_DATA_OD = "Get event history data";
public static final String GET_ALL_USER_NAMES_OD = "Get all user names";
}
@@ -128,6 +128,6 @@ public class DocConstants {
public static final String STATUS_OD = "Get statuses for collections (not health state - show true if something already done)";
public static final String SERVICE_LOGS_STATUS_OD = "Get statuses for service log collection (not health state - show true if something already done)";
public static final String AUDIT_LOGS_STATUS_OD = "Get statuses for collections (not health state - show true if something already done)";
- public static final String USER_CONFIG_STATUS_OD = "Get statuses for userconfig collection (not health state - show true if something already done)";
+ public static final String EVENT_HISTORY_STATUS_OD = "Get statuses for history collection (not health state - show true if something already done)";
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/EventHistoryManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/EventHistoryManager.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/EventHistoryManager.java
new file mode 100644
index 0000000..389f8eb
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/EventHistoryManager.java
@@ -0,0 +1,199 @@
+/*
+ * 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.manager;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.ambari.logsearch.common.LogSearchContext;
+import org.apache.ambari.logsearch.common.MessageEnums;
+import org.apache.ambari.logsearch.dao.EventHistorySolrDao;
+import org.apache.ambari.logsearch.model.request.impl.EventHistoryRequest;
+import org.apache.ambari.logsearch.model.response.EventHistoryData;
+import org.apache.ambari.logsearch.model.response.EventHistoryDataListResponse;
+import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.util.SolrUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.response.FacetField.Count;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
+import org.springframework.core.convert.ConversionService;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.ID;
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.USER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.VALUES;
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.FILTER_NAME;
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.ROW_TYPE;
+import static org.apache.ambari.logsearch.solr.SolrConstants.EventHistoryConstants.SHARE_NAME_LIST;
+
+@Named
+public class EventHistoryManager extends JsonManagerBase {
+
+ private static final Logger logger = Logger.getLogger(EventHistoryManager.class);
+
+ @Inject
+ private EventHistorySolrDao eventHistorySolrDao;
+ @Inject
+ private ConversionService conversionService;
+
+ public String saveEvent(EventHistoryData eventHistoryData) {
+ String filterName = eventHistoryData.getFiltername();
+
+ SolrInputDocument solrInputDoc = new SolrInputDocument();
+ if (!isValid(eventHistoryData)) {
+ throw RESTErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA);
+ }
+
+ if (isNotUnique(filterName)) {
+ throw RESTErrorUtil.createRESTException( "Name '" + eventHistoryData.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
+ }
+ solrInputDoc.addField(ID, eventHistoryData.getId());
+ solrInputDoc.addField(USER_NAME, LogSearchContext.getCurrentUsername());
+ solrInputDoc.addField(VALUES, eventHistoryData.getValues());
+ solrInputDoc.addField(FILTER_NAME, filterName);
+ solrInputDoc.addField(ROW_TYPE, eventHistoryData.getRowType());
+ List<String> shareNameList = eventHistoryData.getShareNameList();
+ if (CollectionUtils.isNotEmpty(shareNameList)) {
+ solrInputDoc.addField(SHARE_NAME_LIST, shareNameList);
+ }
+
+ try {
+ eventHistorySolrDao.addDocs(solrInputDoc);
+ return convertObjToString(solrInputDoc);
+ } catch (SolrException | SolrServerException | IOException e) {
+ logger.error("Error saving user config. solrDoc=" + solrInputDoc, e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ private boolean isNotUnique(String filterName) {
+
+ if (filterName != null) {
+ SolrQuery solrQuery = new SolrQuery();
+ filterName = SolrUtil.makeSearcableString(filterName);
+ solrQuery.setQuery("*:*");
+ solrQuery.addFilterQuery(FILTER_NAME + ":" + filterName);
+ solrQuery.addFilterQuery(USER_NAME + ":" + LogSearchContext.getCurrentUsername());
+ SolrUtil.setRowCount(solrQuery, 0);
+ try {
+ Long numFound = eventHistorySolrDao.process(solrQuery).getResults().getNumFound();
+ if (numFound > 0) {
+ return true;
+ }
+ } catch (SolrException e) {
+ logger.error("Error while checking if event history data is unique.", e);
+ }
+ }
+ return false;
+ }
+
+ private boolean isValid(EventHistoryData vHistory) {
+ return StringUtils.isNotBlank(vHistory.getFiltername())
+ && StringUtils.isNotBlank(vHistory.getRowType())
+ && StringUtils.isNotBlank(vHistory.getValues());
+ }
+
+ public void deleteEvent(String id) {
+ try {
+ eventHistorySolrDao.deleteEventHistoryData(id);
+ } catch (SolrException | SolrServerException | IOException e) {
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public EventHistoryDataListResponse getEventHistory(EventHistoryRequest request) {
+ EventHistoryDataListResponse response = new EventHistoryDataListResponse();
+ String rowType = request.getRowType();
+ if (StringUtils.isBlank(rowType)) {
+ throw RESTErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA);
+ }
+
+ SolrQuery evemtHistoryQuery = conversionService.convert(request, SolrQuery.class);
+ evemtHistoryQuery.addFilterQuery(String.format("%s:%s OR %s:%s", USER_NAME, LogSearchContext.getCurrentUsername(),
+ SHARE_NAME_LIST, LogSearchContext.getCurrentUsername()));
+ SolrDocumentList solrList = eventHistorySolrDao.process(evemtHistoryQuery).getResults();
+
+ Collection<EventHistoryData> configList = new ArrayList<>();
+
+ for (SolrDocument solrDoc : solrList) {
+ EventHistoryData eventHistoryData = new EventHistoryData();
+ eventHistoryData.setFiltername("" + solrDoc.get(FILTER_NAME));
+ eventHistoryData.setId("" + solrDoc.get(ID));
+ eventHistoryData.setValues("" + solrDoc.get(VALUES));
+ eventHistoryData.setRowType("" + solrDoc.get(ROW_TYPE));
+ try {
+ List<String> shareNameList = (List<String>) solrDoc.get(SHARE_NAME_LIST);
+ eventHistoryData.setShareNameList(shareNameList);
+ } catch (Exception e) {
+ // do nothing
+ }
+
+ eventHistoryData.setUserName("" + solrDoc.get(USER_NAME));
+
+ configList.add(eventHistoryData);
+ }
+
+ response.setName("historyList");
+ response.setEventHistoryDataList(configList);
+
+ response.setStartIndex(Integer.parseInt(request.getStartIndex()));
+ response.setPageSize(Integer.parseInt(request.getPageSize()));
+
+ response.setTotalCount((long) solrList.getNumFound());
+
+ return response;
+
+ }
+
+ public List<String> getAllUserName() {
+ List<String> userList = new ArrayList<String>();
+ try {
+ SolrQuery userListQuery = new SolrQuery();
+ userListQuery.setQuery("*:*");
+ SolrUtil.setFacetField(userListQuery, USER_NAME);
+ QueryResponse queryResponse = eventHistorySolrDao.process(userListQuery);
+ if (queryResponse == null) {
+ return userList;
+ }
+ List<Count> counList = queryResponse.getFacetField(USER_NAME).getValues();
+ for (Count cnt : counList) {
+ String userName = cnt.getName();
+ userList.add(userName);
+ }
+ } catch (SolrException e) {
+ logger.warn("Error getting all users.", e);
+ throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
+ }
+ return userList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
deleted file mode 100644
index 1df9f5a..0000000
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/manager/UserConfigManager.java
+++ /dev/null
@@ -1,199 +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.manager;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.ambari.logsearch.common.LogSearchContext;
-import org.apache.ambari.logsearch.common.MessageEnums;
-import org.apache.ambari.logsearch.dao.UserConfigSolrDao;
-import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest;
-import org.apache.ambari.logsearch.model.response.UserConfigData;
-import org.apache.ambari.logsearch.model.response.UserConfigDataListResponse;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
-import org.apache.ambari.logsearch.util.SolrUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrInputDocument;
-import org.springframework.core.convert.ConversionService;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-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;
-import static org.apache.ambari.logsearch.solr.SolrConstants.UserConfigConstants.SHARE_NAME_LIST;
-
-@Named
-public class UserConfigManager extends JsonManagerBase {
-
- private static final Logger logger = Logger.getLogger(UserConfigManager.class);
-
- @Inject
- private UserConfigSolrDao userConfigSolrDao;
- @Inject
- private ConversionService conversionService;
-
- public String saveUserConfig(UserConfigData userConfig) {
- String filterName = userConfig.getFiltername();
-
- SolrInputDocument solrInputDoc = new SolrInputDocument();
- if (!isValid(userConfig)) {
- throw RESTErrorUtil.createRESTException("No FilterName Specified", MessageEnums.INVALID_INPUT_DATA);
- }
-
- if (isNotUnique(filterName)) {
- throw RESTErrorUtil.createRESTException( "Name '" + userConfig.getFiltername() + "' already exists", MessageEnums.INVALID_INPUT_DATA);
- }
- solrInputDoc.addField(ID, userConfig.getId());
- solrInputDoc.addField(USER_NAME, LogSearchContext.getCurrentUsername());
- solrInputDoc.addField(VALUES, userConfig.getValues());
- solrInputDoc.addField(FILTER_NAME, filterName);
- solrInputDoc.addField(ROW_TYPE, userConfig.getRowType());
- List<String> shareNameList = userConfig.getShareNameList();
- if (CollectionUtils.isNotEmpty(shareNameList)) {
- solrInputDoc.addField(SHARE_NAME_LIST, shareNameList);
- }
-
- try {
- userConfigSolrDao.addDocs(solrInputDoc);
- return convertObjToString(solrInputDoc);
- } catch (SolrException | SolrServerException | IOException e) {
- logger.error("Error saving user config. solrDoc=" + solrInputDoc, e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- private boolean isNotUnique(String filterName) {
-
- if (filterName != null) {
- SolrQuery solrQuery = new SolrQuery();
- filterName = SolrUtil.makeSearcableString(filterName);
- solrQuery.setQuery("*:*");
- solrQuery.addFilterQuery(FILTER_NAME + ":" + filterName);
- solrQuery.addFilterQuery(USER_NAME + ":" + LogSearchContext.getCurrentUsername());
- SolrUtil.setRowCount(solrQuery, 0);
- try {
- Long numFound = userConfigSolrDao.process(solrQuery).getResults().getNumFound();
- if (numFound > 0) {
- return true;
- }
- } catch (SolrException e) {
- logger.error("Error while checking if userConfig is unique.", e);
- }
- }
- return false;
- }
-
- private boolean isValid(UserConfigData vHistory) {
- return StringUtils.isNotBlank(vHistory.getFiltername())
- && StringUtils.isNotBlank(vHistory.getRowType())
- && StringUtils.isNotBlank(vHistory.getValues());
- }
-
- public void deleteUserConfig(String id) {
- try {
- userConfigSolrDao.deleteUserConfig(id);
- } catch (SolrException | SolrServerException | IOException e) {
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- }
-
- @SuppressWarnings("unchecked")
- public UserConfigDataListResponse getUserConfig(UserConfigRequest request) {
- UserConfigDataListResponse response = new UserConfigDataListResponse();
- String rowType = request.getRowType();
- if (StringUtils.isBlank(rowType)) {
- throw RESTErrorUtil.createRESTException("row type was not specified", MessageEnums.INVALID_INPUT_DATA);
- }
-
- SolrQuery userConfigQuery = conversionService.convert(request, SolrQuery.class);
- userConfigQuery.addFilterQuery(String.format("%s:%s OR %s:%s", USER_NAME, LogSearchContext.getCurrentUsername(),
- SHARE_NAME_LIST, LogSearchContext.getCurrentUsername()));
- SolrDocumentList solrList = userConfigSolrDao.process(userConfigQuery).getResults();
-
- Collection<UserConfigData> configList = new ArrayList<>();
-
- for (SolrDocument solrDoc : solrList) {
- UserConfigData userConfig = new UserConfigData();
- userConfig.setFiltername("" + solrDoc.get(FILTER_NAME));
- userConfig.setId("" + solrDoc.get(ID));
- userConfig.setValues("" + solrDoc.get(VALUES));
- userConfig.setRowType("" + solrDoc.get(ROW_TYPE));
- try {
- List<String> shareNameList = (List<String>) solrDoc.get(SHARE_NAME_LIST);
- userConfig.setShareNameList(shareNameList);
- } catch (Exception e) {
- // do nothing
- }
-
- userConfig.setUserName("" + solrDoc.get(USER_NAME));
-
- configList.add(userConfig);
- }
-
- response.setName("historyList");
- response.setUserConfigList(configList);
-
- response.setStartIndex(Integer.parseInt(request.getStartIndex()));
- response.setPageSize(Integer.parseInt(request.getPageSize()));
-
- response.setTotalCount((long) solrList.getNumFound());
-
- return response;
-
- }
-
- public List<String> getAllUserName() {
- List<String> userList = new ArrayList<String>();
- try {
- SolrQuery userListQuery = new SolrQuery();
- userListQuery.setQuery("*:*");
- SolrUtil.setFacetField(userListQuery, USER_NAME);
- QueryResponse queryResponse = userConfigSolrDao.process(userListQuery);
- if (queryResponse == null) {
- return userList;
- }
- List<Count> counList = queryResponse.getFacetField(USER_NAME).getValues();
- for (Count cnt : counList) {
- String userName = cnt.getName();
- userList.add(userName);
- }
- } catch (SolrException e) {
- logger.warn("Error getting all users.", e);
- throw RESTErrorUtil.createRESTException(MessageEnums.SOLR_ERROR.getMessage().getMessage(), MessageEnums.ERROR_SYSTEM);
- }
- return userList;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/EventHistoryParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/EventHistoryParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/EventHistoryParamDefinition.java
new file mode 100644
index 0000000..d7a5b01
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/EventHistoryParamDefinition.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request;
+
+import io.swagger.annotations.ApiParam;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.EventHistoryDescriptions.FILTER_NAME_D;
+import static org.apache.ambari.logsearch.doc.DocConstants.EventHistoryDescriptions.ROW_TYPE_D;
+
+public interface EventHistoryParamDefinition {
+
+ String getFilterName();
+
+ @ApiParam(value = FILTER_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
+ void setFilterName(String filterName);
+
+ String getRowType();
+
+ @ApiParam(value = ROW_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_ROW_TYPE)
+ void setRowType(String rowType);
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
deleted file mode 100644
index dd74b6f..0000000
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/UserConfigParamDefinition.java
+++ /dev/null
@@ -1,38 +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.model.request;
-
-import io.swagger.annotations.ApiParam;
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-
-import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.FILTER_NAME_D;
-import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.ROW_TYPE_D;
-
-public interface UserConfigParamDefinition {
-
- String getFilterName();
-
- @ApiParam(value = FILTER_NAME_D, name = LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
- void setFilterName(String filterName);
-
- String getRowType();
-
- @ApiParam(value = ROW_TYPE_D, name = LogSearchConstants.REQUEST_PARAM_ROW_TYPE)
- void setRowType(String rowType);
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/EventHistoryRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/EventHistoryRequest.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/EventHistoryRequest.java
new file mode 100644
index 0000000..17be988
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/EventHistoryRequest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.request.impl;
+
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.EventHistoryParamDefinition;
+
+import javax.ws.rs.QueryParam;
+
+public class EventHistoryRequest extends CommonSearchRequest implements EventHistoryParamDefinition {
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
+ private String filterName;
+
+ @QueryParam(LogSearchConstants.REQUEST_PARAM_ROW_TYPE)
+ private String rowType;
+
+ @Override
+ public String getFilterName() {
+ return filterName;
+ }
+
+ @Override
+ public void setFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+ @Override
+ public String getRowType() {
+ return rowType;
+ }
+
+ @Override
+ public void setRowType(String rowType) {
+ this.rowType = rowType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.java
deleted file mode 100644
index cbbc6e6..0000000
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/UserConfigRequest.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.model.request.impl;
-
-import org.apache.ambari.logsearch.common.LogSearchConstants;
-import org.apache.ambari.logsearch.model.request.UserConfigParamDefinition;
-
-import javax.ws.rs.QueryParam;
-
-public class UserConfigRequest extends CommonSearchRequest implements UserConfigParamDefinition {
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_FILTER_NAME)
- private String filterName;
-
- @QueryParam(LogSearchConstants.REQUEST_PARAM_ROW_TYPE)
- private String rowType;
-
- @Override
- public String getFilterName() {
- return filterName;
- }
-
- @Override
- public void setFilterName(String filterName) {
- this.filterName = filterName;
- }
-
- @Override
- public String getRowType() {
- return rowType;
- }
-
- @Override
- public void setRowType(String rowType) {
- this.rowType = rowType;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryData.java
new file mode 100644
index 0000000..5edbc62
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryData.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.model.response;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+import java.util.List;
+
+public class EventHistoryData {
+
+ @ApiModelProperty
+ private String id;
+
+ @ApiModelProperty
+ private String userName;
+
+ @ApiModelProperty
+ private String filtername;
+
+ @ApiModelProperty
+ private String values;
+
+ @ApiModelProperty
+ private List<String> shareNameList;
+
+ @ApiModelProperty
+ private String rowType;
+
+ public EventHistoryData() {
+ id = String.valueOf(new Date().getTime());
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getFiltername() {
+ return filtername;
+ }
+
+ public void setFiltername(String filtername) {
+ this.filtername = filtername;
+ }
+
+ public List<String> getShareNameList() {
+ return shareNameList;
+ }
+
+ public void setShareNameList(List<String> shareNameList) {
+ this.shareNameList = shareNameList;
+ }
+
+ public String getValues() {
+ return values;
+ }
+
+ public void setValues(String values) {
+ this.values = values;
+ }
+
+ public String getRowType() {
+ return rowType;
+ }
+
+ public void setRowType(String rowType) {
+ this.rowType = rowType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryDataListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryDataListResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryDataListResponse.java
new file mode 100644
index 0000000..429005f
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/EventHistoryDataListResponse.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.model.response;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Collection;
+
+@ApiModel
+public class EventHistoryDataListResponse extends SearchResponse{
+
+ @ApiModelProperty
+ private String name;
+
+ @ApiModelProperty
+ private Collection<EventHistoryData> eventHistoryDataList;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Collection<EventHistoryData> getEventHistoryDataList() {
+ return eventHistoryDataList;
+ }
+
+ public void setEventHistoryDataList(Collection<EventHistoryData> eventHistoryDataList) {
+ this.eventHistoryDataList = eventHistoryDataList;
+ }
+
+ @Override
+ public int getListSize() {
+ return eventHistoryDataList != null ? eventHistoryDataList.size() : 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
deleted file mode 100644
index ef4e0be..0000000
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.java
+++ /dev/null
@@ -1,97 +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.model.response;
-
-import io.swagger.annotations.ApiModelProperty;
-
-import java.util.Date;
-import java.util.List;
-
-public class UserConfigData {
-
- @ApiModelProperty
- private String id;
-
- @ApiModelProperty
- private String userName;
-
- @ApiModelProperty
- private String filtername;
-
- @ApiModelProperty
- private String values;
-
- @ApiModelProperty
- private List<String> shareNameList;
-
- @ApiModelProperty
- private String rowType;
-
- public UserConfigData() {
- id = String.valueOf(new Date().getTime());
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getFiltername() {
- return filtername;
- }
-
- public void setFiltername(String filtername) {
- this.filtername = filtername;
- }
-
- public List<String> getShareNameList() {
- return shareNameList;
- }
-
- public void setShareNameList(List<String> shareNameList) {
- this.shareNameList = shareNameList;
- }
-
- public String getValues() {
- return values;
- }
-
- public void setValues(String values) {
- this.values = values;
- }
-
- public String getRowType() {
- return rowType;
- }
-
- public void setRowType(String rowType) {
- this.rowType = rowType;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigDataListResponse.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigDataListResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigDataListResponse.java
deleted file mode 100644
index 5c445b2..0000000
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigDataListResponse.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.model.response;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-
-import java.util.Collection;
-
-@ApiModel
-public class UserConfigDataListResponse extends SearchResponse{
-
- @ApiModelProperty
- private String name;
-
- @ApiModelProperty
- private Collection<UserConfigData> userConfigList;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Collection<UserConfigData> getUserConfigList() {
- return userConfigList;
- }
-
- public void setUserConfigList(Collection<UserConfigData> userConfigList) {
- this.userConfigList = userConfigList;
- }
-
- @Override
- public int getListSize() {
- return userConfigList != null ? userConfigList.size() : 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fc00b2ca/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/EventHistoryResource.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/EventHistoryResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/EventHistoryResource.java
new file mode 100644
index 0000000..aced94c
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/EventHistoryResource.java
@@ -0,0 +1,82 @@
+/*
+ * 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.rest;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.BeanParam;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.ambari.logsearch.manager.EventHistoryManager;
+import org.apache.ambari.logsearch.model.request.impl.EventHistoryRequest;
+import org.apache.ambari.logsearch.model.response.EventHistoryData;
+import org.apache.ambari.logsearch.model.response.EventHistoryDataListResponse;
+import org.springframework.context.annotation.Scope;
+
+import java.util.List;
+
+import static org.apache.ambari.logsearch.doc.DocConstants.EventHistoryOperationDescriptions.*;
+
+@Api(value = "history", description = "Event history operations")
+@Path("history")
+@Named
+@Scope("request")
+public class EventHistoryResource {
+
+ @Inject
+ private EventHistoryManager eventHistoryManager;
+
+ @POST
+ @Produces({"application/json"})
+ @ApiOperation(SAVE_EVENT_HISTORY_DATA_OD)
+ public String saveEvent(EventHistoryData eventHistoryData) {
+ return eventHistoryManager.saveEvent(eventHistoryData);
+ }
+
+ @DELETE
+ @Path("/{id}")
+ @ApiOperation(DELETE_EVENT_HISTORY_DATA_OD)
+ public void deleteEvent(@PathParam("id") String id) {
+ eventHistoryManager.deleteEvent(id);
+ }
+
+ @GET
+ @Produces({"application/json"})
+ @ApiOperation(GET_EVENT_HISTORY_DATA_OD)
+ public EventHistoryDataListResponse getEventHistory(@BeanParam EventHistoryRequest request) {
+ return eventHistoryManager.getEventHistory(request);
+ }
+
+ @GET
+ @Path("/names")
+ @Produces({"application/json"})
+ @ApiOperation(GET_ALL_USER_NAMES_OD)
+ public List<String> getAllUserName() {
+ return eventHistoryManager.getAllUserName();
+ }
+
+}