http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.java new file mode 100644 index 0000000..5a67606 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileData.java @@ -0,0 +1,48 @@ +/* + * 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; + +@ApiModel +public class LogFileData { + + @ApiModelProperty + private String name; + + @ApiModelProperty + private String path; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } +}
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.java new file mode 100644 index 0000000..57614c3 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogFileDataListResponse.java @@ -0,0 +1,48 @@ +/* + * 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.ArrayList; +import java.util.List; + +@ApiModel +public class LogFileDataListResponse extends SearchResponse { + + @ApiModelProperty + private List<LogFileData> logFiles = new ArrayList<LogFileData>(); + + @Override + public int getListSize() { + if (logFiles == null) { + return 0; + } + return logFiles.size(); + } + + public List<LogFileData> getLogFiles() { + return logFiles; + } + + public void setLogFiles(List<LogFileData> logFiles) { + this.logFiles = logFiles; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java new file mode 100644 index 0000000..c075fe2 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogListResponse.java @@ -0,0 +1,27 @@ +/* + * 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 java.util.List; + +public interface LogListResponse<T extends LogData> { + List<T> getLogList(); + + void setLogList(List<T> logList); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java new file mode 100644 index 0000000..a63415b --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/LogSearchResponse.java @@ -0,0 +1,22 @@ +/* + * 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; + +abstract public class LogSearchResponse<T extends LogData> extends SearchResponse implements LogListResponse<T> { +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.java new file mode 100644 index 0000000..3f320e7 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueData.java @@ -0,0 +1,62 @@ +/* + * 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +@JsonIgnoreProperties(ignoreUnknown = true) +public class NameValueData { + + @ApiModelProperty + private String name; + @ApiModelProperty + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + if (value.contains(".") && (value.contains("e") || value.contains("E"))) { + this.value = getExponentialValueReplaced(value); + } else { + this.value = value; + } + } + + private String getExponentialValueReplaced(String value) { + try{ + Double number = Double.parseDouble(value); + return String.format("%.0f", number); + } catch(Exception e){ + return value; + } + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.java new file mode 100644 index 0000000..4cb983f --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NameValueDataListResponse.java @@ -0,0 +1,49 @@ +/* + * 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; + +@ApiModel +@JsonIgnoreProperties(ignoreUnknown = true) +public class NameValueDataListResponse extends SearchResponse { + @ApiModelProperty + protected List<NameValueData> vNameValues = new ArrayList<>(); + + public List<NameValueData> getvNameValues() { + return vNameValues; + } + + public void setvNameValues(List<NameValueData> vNameValues) { + this.vNameValues = vNameValues; + } + + @Override + public int getListSize() { + if (vNameValues != null) { + return vNameValues.size(); + } + return 0; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java new file mode 100644 index 0000000..b226ef8 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeData.java @@ -0,0 +1,110 @@ +/* + * 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 com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Collection; + +@ApiModel +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class NodeData { + + @ApiModelProperty + private String name; + + @ApiModelProperty + private String type; + + @ApiModelProperty + private String value; + + @ApiModelProperty + private Collection<NodeData> childs; + + @ApiModelProperty + private Collection<NameValueData> logLevelCount; + + @ApiModelProperty + @JsonProperty("isParent") + private boolean parent; + + @ApiModelProperty + @JsonProperty("isRoot") + private boolean root; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public boolean isRoot() { + return root; + } + + public void setRoot(boolean root) { + this.root = root; + } + + public Collection<NodeData> getChilds() { + return childs; + } + + public void setChilds(Collection<NodeData> childs) { + this.childs = childs; + } + + public Collection<NameValueData> getLogLevelCount() { + return logLevelCount; + } + + public void setLogLevelCount(Collection<NameValueData> logLevelCount) { + this.logLevelCount = logLevelCount; + } + + public boolean isParent() { + return parent; + } + + public void setParent(boolean parent) { + this.parent = parent; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.java new file mode 100644 index 0000000..51044b3 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/NodeListResponse.java @@ -0,0 +1,50 @@ +/* + * 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.List; + +@ApiModel +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeListResponse extends SearchResponse { + + @ApiModelProperty + protected List<NodeData> vNodeList = new ArrayList<NodeData>(); + + public List<NodeData> getvNodeList() { + return vNodeList; + } + + public void setvNodeList(List<NodeData> vNodeList) { + this.vNodeList = vNodeList; + } + + @Override + public int getListSize() { + if (vNodeList == null) { + return 0; + } + return vNodeList.size(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java new file mode 100644 index 0000000..dd88d29 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/SearchResponse.java @@ -0,0 +1,110 @@ +/* + * 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public abstract class SearchResponse { + /** + * Start index for the result + */ + private int startIndex; + /** + * Page size used for the result + */ + private int pageSize; + /** + * Total records in the database for the given search conditions + */ + private long totalCount; + /** + * Number of rows returned for the search condition + */ + private int resultSize; + /** + * Sort type. Either desc or asc + */ + private String sortType; + /** + * Comma seperated list of the fields for sorting + */ + private String sortBy; + + private long queryTimeMS = System.currentTimeMillis(); + + public int getStartIndex() { + return startIndex; + } + + public int getPageSize() { + return pageSize; + } + + public long getTotalCount() { + return totalCount; + } + + public int getResultSize() { + return resultSize; + } + + public String getSortType() { + return sortType; + } + + public String getSortBy() { + return sortBy; + } + + public long getQueryTimeMS() { + return queryTimeMS; + } + + public void setStartIndex(int startIndex) { + this.startIndex = startIndex; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public void setTotalCount(long totalCount) { + this.totalCount = totalCount; + } + + public void setResultSize(int resultSize) { + this.resultSize = resultSize; + } + + public void setSortType(String sortType) { + this.sortType = sortType; + } + + public void setSortBy(String sortBy) { + this.sortBy = sortBy; + } + + public void setQueryTimeMS(long queryTimeMS) { + this.queryTimeMS = queryTimeMS; + } + + public abstract int getListSize(); + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java new file mode 100644 index 0000000..16aed16 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogData.java @@ -0,0 +1,63 @@ +/* + * 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Date; + +@JsonIgnoreProperties(ignoreUnknown = true) +public interface ServiceLogData extends CommonLogData, ComponentTypeLogData, HostLogData { + + @JsonProperty("level") + String getLevel(); + + void setLevel(String level); + + @JsonProperty("line_number") + Integer getLineNumber(); + + void setLineNumber(Integer lineNumber); + + @JsonProperty("logtime") + Date getLogTime(); + + void setLogTime(Date logTime); + + @JsonProperty("ip") + String getIp(); + + void setIp(String ip); + + @JsonProperty("path") + String getPath(); + + void setPath(String path); + + @JsonProperty("type") + String getType(); + + void setType(String type); + + @JsonProperty("host") + String getHost(); + + void setHost(String host); +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.java new file mode 100644 index 0000000..2e689c1 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/ServiceLogResponse.java @@ -0,0 +1,48 @@ +/* + * 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +@ApiModel +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceLogResponse extends LogSearchResponse<ServiceLogData> { + + @ApiModelProperty + private List<ServiceLogData> logList; + + @Override + public List<ServiceLogData> getLogList() { + return logList; + } + + @Override + public void setLogList(List<ServiceLogData> logList) { + this.logList = logList; + } + + @Override + public int getListSize() { + return logList == null ? 0 : logList.size(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java new file mode 100644 index 0000000..05deebd --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/TemplateData.java @@ -0,0 +1,36 @@ +/* + * 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; + +public class TemplateData { + + private String data; + + public TemplateData(String data) { + this.data = data; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/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 new file mode 100644 index 0000000..ef4e0be --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigData.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 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/b0f1e340/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 new file mode 100644 index 0000000..5c445b2 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/response/UserConfigDataListResponse.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 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/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java new file mode 100644 index 0000000..2013dc7 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java @@ -0,0 +1,120 @@ +/* + * 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.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +import freemarker.template.TemplateException; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.ambari.logsearch.common.StatusMessage; +import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest; +import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest; +import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest; +import org.apache.ambari.logsearch.model.request.impl.UserExportRequest; +import org.apache.ambari.logsearch.model.response.AuditLogResponse; +import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse; +import org.apache.ambari.logsearch.model.response.GroupListResponse; +import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest; +import org.apache.ambari.logsearch.manager.AuditLogsManager; +import org.springframework.context.annotation.Scope; + +import static org.apache.ambari.logsearch.doc.DocConstants.AuditOperationDescriptions.*; + +@Api(value = "audit/logs", description = "Audit log operations") +@Path("audit/logs") +@Named +@Scope("request") +public class AuditLogsResource { + + @Inject + private AuditLogsManager auditLogsManager; + + @GET + @Path("/schema/fields") + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD) + public String getSolrFieldList() { + return auditLogsManager.getAuditLogsSchemaFieldsName(); + } + + @GET + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_LOGS_OD) + public AuditLogResponse getAuditLogs(@BeanParam AuditLogRequest auditLogRequest) { + return auditLogsManager.getLogs(auditLogRequest); + } + + @DELETE + @Produces({"application/json"}) + @ApiOperation(PURGE_AUDIT_LOGS_OD) + public StatusMessage deleteAuditLogs(@BeanParam AuditLogRequest auditLogRequest) { + return auditLogsManager.deleteLogs(auditLogRequest); + } + + @GET + @Path("/components") + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_COMPONENTS_OD) + public GroupListResponse getAuditComponents(@BeanParam AuditComponentRequest request) { + return auditLogsManager.getAuditComponents(request); + } + + @GET + @Path("/bargraph") + @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_LINE_GRAPH_DATA_OD) + public BarGraphDataListResponse getAuditBarGraphData(@BeanParam AuditBarGraphRequest request) { + return auditLogsManager.getAuditBarGraphData(request); + } + + @GET + @Path("/resources/{top}") + @Produces({"application/json"}) + @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD) + public BarGraphDataListResponse getResources(@BeanParam FieldAuditLogRequest request) { + return auditLogsManager.topResources(request); + } + + @GET + @Path("/export") + @Produces({"application/json"}) + @ApiOperation(EXPORT_USER_TALBE_TO_TEXT_FILE_OD) + public Response exportUserTableToTextFile(@BeanParam UserExportRequest request) throws TemplateException { + return auditLogsManager.export(request); + } + + @GET + @Path("/serviceload") + @Produces({"application/json"}) + @ApiOperation(GET_SERVICE_LOAD_OD) + public BarGraphDataListResponse getServiceLoad(@BeanParam AuditServiceLoadRequest request) { + return auditLogsManager.getServiceLoad(request); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java new file mode 100644 index 0000000..df83d44 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/PublicResource.java @@ -0,0 +1,48 @@ +/* + * 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.GET; +import javax.ws.rs.Path; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.ambari.logsearch.manager.PublicManager; +import org.springframework.context.annotation.Scope; + +import static org.apache.ambari.logsearch.doc.DocConstants.PublicOperationDescriptions.OBTAIN_GENERAL_CONFIG_OD; + +@Api(value = "public", description = "Public operations") +@Path("public") +@Named +@Scope("request") +public class PublicResource { + + @Inject + private PublicManager publicManager; + + @GET + @Path("/config") + @ApiOperation(OBTAIN_GENERAL_CONFIG_OD) + public String getGeneralConfig() { + return publicManager.getGeneralConfig(); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java new file mode 100644 index 0000000..498da69 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java @@ -0,0 +1,222 @@ +/* + * 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.annotation.Nullable; +import javax.inject.Inject; +import javax.inject.Named; +import javax.validation.Valid; +import javax.validation.executable.ValidateOnExecution; +import javax.ws.rs.BeanParam; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import org.apache.ambari.logsearch.common.LogSearchConstants; +import org.apache.ambari.logsearch.common.StatusMessage; +import org.apache.ambari.logsearch.model.request.impl.HostLogFilesRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogAggregatedInfoRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogExportRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogLevelCountRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest; +import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest; +import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse; +import org.apache.ambari.logsearch.model.response.CountDataListResponse; +import org.apache.ambari.logsearch.model.response.GraphDataListResponse; +import org.apache.ambari.logsearch.model.response.GroupListResponse; +import org.apache.ambari.logsearch.model.response.HostLogFilesResponse; +import org.apache.ambari.logsearch.model.response.NameValueDataListResponse; +import org.apache.ambari.logsearch.model.response.NodeListResponse; +import org.apache.ambari.logsearch.model.response.ServiceLogResponse; +import org.apache.ambari.logsearch.manager.ServiceLogsManager; +import org.springframework.context.annotation.Scope; + +import static org.apache.ambari.logsearch.doc.DocConstants.ServiceOperationDescriptions.*; + +@Api(value = "service/logs", description = "Service log operations") +@Path("service/logs") +@Named +@Scope("request") +public class ServiceLogsResource { + + @Inject + private ServiceLogsManager serviceLogsManager; + + @GET + @Produces({"application/json"}) + @ApiOperation(SEARCH_LOGS_OD) + public ServiceLogResponse searchServiceLogs(@BeanParam ServiceLogRequest request) { + return serviceLogsManager.searchLogs(request); + } + + @DELETE + @Produces({"application/json"}) + @ApiOperation(PURGE_LOGS_OD) + public StatusMessage deleteServiceLogs(@BeanParam ServiceLogRequest request) { + return serviceLogsManager.deleteLogs(request); + } + + @GET + @Path("/hosts") + @Produces({"application/json"}) + @ApiOperation(GET_HOSTS_OD) + public GroupListResponse getHosts(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) { + return serviceLogsManager.getHosts(clusters); + } + + @GET + @Path("/components") + @Produces({"application/json"}) + @ApiOperation(GET_COMPONENTS_OD) + public GroupListResponse getComponents(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) { + return serviceLogsManager.getComponents(clusters); + } + + @GET + @Path("/aggregated") + @Produces({"application/json"}) + @ApiOperation(GET_AGGREGATED_INFO_OD) + public GraphDataListResponse getAggregatedInfo(@BeanParam ServiceLogAggregatedInfoRequest request) { + return serviceLogsManager.getAggregatedInfo(request); + } + + @GET + @Path("/components/count") + @Produces({"application/json"}) + @ApiOperation(GET_COMPONENTS_COUNT_OD) + public CountDataListResponse getComponentsCount(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) { + return serviceLogsManager.getComponentsCount(clusters); + } + + @GET + @Path("/hosts/count") + @Produces({"application/json"}) + @ApiOperation(GET_HOSTS_COUNT_OD) + public CountDataListResponse getHostsCount(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) { + return serviceLogsManager.getHostsCount(clusters); + } + + @GET + @Path("/tree") + @Produces({"application/json"}) + @ApiOperation(GET_TREE_EXTENSION_OD) + public NodeListResponse getTreeExtension(@BeanParam ServiceLogHostComponentRequest request) { + return serviceLogsManager.getTreeExtension(request); + } + + @GET + @Path("/levels/counts") + @Produces({"application/json"}) + @ApiOperation(GET_LOG_LEVELS_COUNT_OD) + public NameValueDataListResponse getLogsLevelCount(@BeanParam ServiceLogLevelCountRequest request) { + return serviceLogsManager.getLogsLevelCount(request); + } + + @GET + @Path("/histogram") + @Produces({"application/json"}) + @ApiOperation(GET_HISTOGRAM_DATA_OD) + public BarGraphDataListResponse getHistogramData(@BeanParam ServiceGraphRequest request) { + return serviceLogsManager.getHistogramData(request); + } + + @GET + @Path("/export") + @Produces({"application/json"}) + @ApiOperation(EXPORT_TO_TEXT_FILE_OD) + public Response exportToTextFile(@BeanParam ServiceLogExportRequest request) { + return serviceLogsManager.export(request); + } + + @GET + @Path("/hosts/components") + @Produces({"application/json"}) + @ApiOperation(GET_HOST_LIST_BY_COMPONENT_OD) + public NodeListResponse getHostListByComponent(@BeanParam ServiceLogComponentHostRequest request) { + return serviceLogsManager.getHostListByComponent(request); + } + + @GET + @Path("/components/levels/counts") + @Produces({"application/json"}) + @ApiOperation(GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD) + public NodeListResponse getComponentListWithLevelCounts(@BeanParam ServiceLogComponentLevelRequest request) { + return serviceLogsManager.getComponentListWithLevelCounts(request); + } + @GET + @Path("/schema/fields") + @Produces({"application/json"}) + @ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD) + public String getServiceLogsSchemaFieldsName() { + return serviceLogsManager.getServiceLogsSchemaFieldsName(); + } + + @GET + @Path("/count/anygraph") + @Produces({"application/json"}) + @ApiOperation(GET_ANY_GRAPH_COUNT_DATA_OD) + public BarGraphDataListResponse getAnyGraphCountData(@BeanParam ServiceAnyGraphRequest request) { + return serviceLogsManager.getAnyGraphCountData(request); + } + + @GET + @Path("/truncated") + @Produces({"application/json"}) + @ApiOperation(GET_AFTER_BEFORE_LOGS_OD) + public ServiceLogResponse getAfterBeforeLogs(@BeanParam ServiceLogTruncatedRequest request) { + return serviceLogsManager.getAfterBeforeLogs(request); + } + + @GET + @Path("/serviceconfig") + @Produces({"application/json"}) + @ApiOperation(GET_HADOOP_SERVICE_CONFIG_JSON_OD) + public String getHadoopServiceConfigJSON() { + return serviceLogsManager.getHadoopServiceConfigJSON(); + } + + @GET + @Path("/request/cancel") + @Produces({"application/json"}) + @ApiOperation(REQUEST_CANCEL) + public String cancelRequest() { + // TODO: create function that cancels an ongoing solr request + return "{\"endpoint status\": \"not supported yet\"}"; + } + + @GET + @Path("/files") + @Produces({"application/json"}) + @ApiOperation(GET_HOST_LOGFILES_OD) + @ValidateOnExecution + public HostLogFilesResponse getHostLogFiles(@Valid @BeanParam HostLogFilesRequest request) { + return serviceLogsManager.getHostLogFileData(request); + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java new file mode 100644 index 0000000..8cc6b94 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/StatusResource.java @@ -0,0 +1,91 @@ +/* + * 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 io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.ambari.logsearch.conf.global.SolrCollectionState; +import org.springframework.context.annotation.Scope; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.AUDIT_LOGS_STATUS_OD; +import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.SERVICE_LOGS_STATUS_OD; +import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.STATUS_OD; +import static org.apache.ambari.logsearch.doc.DocConstants.StatusOperationDescriptions.USER_CONFIG_STATUS_OD; + +@Api(value = "status", description = "Status Operations") +@Path("status") +@Named +@Scope("request") +public class StatusResource { + + @Inject + @Named("solrServiceLogsState") + private SolrCollectionState solrServiceLogsState; + + @Inject + @Named("solrAuditLogsState") + private SolrCollectionState solrAuditLogsState; + + @Inject + @Named("solrUserConfigState") + private SolrCollectionState solrUserConfigState; + + @GET + @Produces({"application/json"}) + @ApiOperation(STATUS_OD) + public Map<String, SolrCollectionState> getStatus() { + Map<String, SolrCollectionState> response = new HashMap<>(); + response.put("serviceLogs", solrServiceLogsState); + response.put("auditLogs", solrAuditLogsState); + response.put("userConfig", solrUserConfigState); + return response; + } + + @GET + @Path("/servicelogs") + @Produces({"application/json"}) + @ApiOperation(SERVICE_LOGS_STATUS_OD) + public SolrCollectionState getServiceLogStatus() { + return solrServiceLogsState; + } + + @GET + @Path("/auditlogs") + @Produces({"application/json"}) + @ApiOperation(AUDIT_LOGS_STATUS_OD) + public SolrCollectionState getSolrAuditLogsStatus() { + return solrAuditLogsState; + } + + @GET + @Path("/userconfig") + @Produces({"application/json"}) + @ApiOperation(USER_CONFIG_STATUS_OD) + public SolrCollectionState getSolrUserConfigStatus() { + return solrUserConfigState; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java new file mode 100644 index 0000000..19cfbed --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/UserConfigResource.java @@ -0,0 +1,100 @@ +/* + * 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.PUT; +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.UserConfigManager; +import org.apache.ambari.logsearch.model.common.LogFeederDataMap; +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.springframework.context.annotation.Scope; + +import java.util.List; + +import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigOperationDescriptions.*; + +@Api(value = "userconfig", description = "User config operations") +@Path("userconfig") +@Named +@Scope("request") +public class UserConfigResource { + + @Inject + private UserConfigManager userConfigManager; + + @POST + @Produces({"application/json"}) + @ApiOperation(SAVE_USER_CONFIG_OD) + public String saveUserConfig(UserConfigData userConfig) { + return userConfigManager.saveUserConfig(userConfig); + } + + @DELETE + @Path("/{id}") + @ApiOperation(DELETE_USER_CONFIG_OD) + public void deleteUserConfig(@PathParam("id") String id) { + userConfigManager.deleteUserConfig(id); + } + + @GET + @Produces({"application/json"}) + @ApiOperation(GET_USER_CONFIG_OD) + public UserConfigDataListResponse getUserConfig(@BeanParam UserConfigRequest request) { + return userConfigManager.getUserConfig(request); + } + + @GET + @Path("/filters") + @Produces({"application/json"}) + @ApiOperation(GET_USER_FILTER_OD) + public LogFeederDataMap getUserFilter() { + return userConfigManager.getUserFilter(); + } + + @PUT + @Path("/filters/{id}") + @Produces({"application/json"}) + @ApiOperation(UPDATE_USER_FILTER_OD) + public LogFeederDataMap updateUserFilter(LogFeederDataMap request) { + return userConfigManager.saveUserFiter(request); + } + + @GET + @Path("/names") + @Produces({"application/json"}) + @ApiOperation(GET_ALL_USER_NAMES_OD) + public List<String> getAllUserName() { + return userConfigManager.getAllUserName(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/service/UserService.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/service/UserService.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/service/UserService.java new file mode 100644 index 0000000..ba4431d --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/service/UserService.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ambari.logsearch.service; + +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; +import org.apache.ambari.logsearch.dao.UserDao; +import org.apache.ambari.logsearch.web.model.User; +import org.apache.log4j.Logger; + +import javax.inject.Inject; + + +@Service +public class UserService implements UserDetailsService { + private static final Logger logger = Logger.getLogger(UserService.class); + + @Inject + private UserDao userDao; + + @Override + public User loadUserByUsername(final String username) throws UsernameNotFoundException { + logger.debug(userDao + " loadUserByUsername " + username); + return userDao.loadUserByUsername(username); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java new file mode 100644 index 0000000..74e9c11 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/ResponseDataGenerator.java @@ -0,0 +1,452 @@ +/* + * 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.solr; + +import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.COMPONENT; +import static org.apache.ambari.logsearch.solr.SolrConstants.ServiceLogConstants.PATH; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import org.apache.ambari.logsearch.model.response.BarGraphData; +import org.apache.ambari.logsearch.model.response.BarGraphDataListResponse; +import org.apache.ambari.logsearch.model.response.CountData; +import org.apache.ambari.logsearch.model.response.CountDataListResponse; +import org.apache.ambari.logsearch.model.response.GraphData; +import org.apache.ambari.logsearch.model.response.GraphDataListResponse; +import org.apache.ambari.logsearch.model.response.HostLogFilesResponse; +import org.apache.ambari.logsearch.model.response.NameValueData; +import org.apache.ambari.logsearch.model.response.NameValueDataListResponse; +import org.apache.ambari.logsearch.model.response.NodeData; +import org.apache.ambari.logsearch.model.response.NodeListResponse; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.solr.client.solrj.response.FacetField; +import org.apache.solr.client.solrj.response.FacetField.Count; +import org.apache.solr.client.solrj.response.PivotField; +import org.apache.solr.client.solrj.response.QueryResponse; +import org.apache.solr.client.solrj.response.RangeFacet; +import org.apache.solr.common.util.NamedList; + +import javax.inject.Named; + +@Named +public class ResponseDataGenerator { + + public BarGraphDataListResponse generateBarGraphDataResponseWithRanges(QueryResponse response, String typeField, boolean typeUppercase) { + BarGraphDataListResponse dataList = new BarGraphDataListResponse(); + if (response == null) { + return dataList; + } + NamedList<List<PivotField>> facetPivotResponse = response.getFacetPivot(); + if (response.getFacetPivot() == null) { + return dataList; + } + List<PivotField> pivotFields = facetPivotResponse.get(typeField); + for (int pivotIndex = 0; pivotIndex < pivotFields.size(); pivotIndex++) { + PivotField pivotField = facetPivotResponse.get(typeField).get(pivotIndex); + List<NameValueData> nameValues = generateNameValueDataList(pivotField.getFacetRanges()); + BarGraphData barGraphData = new BarGraphData(); + barGraphData.setDataCount(nameValues); + String typeValue = typeUppercase ? StringUtils.upperCase(pivotField.getValue().toString()) : pivotField.getValue().toString(); + barGraphData.setName(typeValue); + dataList.getGraphData().add(barGraphData); + } + return dataList; + } + + public BarGraphDataListResponse generateSecondLevelBarGraphDataResponse(QueryResponse response, int val) { + BarGraphDataListResponse barGraphDataListResponse = new BarGraphDataListResponse(); + NamedList<List<PivotField>> pivotFieldNameList = response.getFacetPivot(); + if (pivotFieldNameList == null) { + return barGraphDataListResponse; + } + List<PivotField> pivotFields = pivotFieldNameList.getVal(val); + List<BarGraphData> barGraphDataList = new ArrayList<>(); + for (PivotField pivotField : pivotFields) { + BarGraphData barGraphData = new BarGraphData(); + barGraphData.setName(String.valueOf(pivotField.getValue())); + List<PivotField> secondLevelPivotFields = pivotField.getPivot(); + List<NameValueData> nameValueDataList = new ArrayList<>(); + for (PivotField sPivotField : secondLevelPivotFields) { + NameValueData nvD = new NameValueData(); + nvD.setName(String.valueOf(sPivotField.getValue())); + nvD.setValue(String.valueOf(sPivotField.getCount())); + nameValueDataList.add(nvD); + } + barGraphData.setDataCount(nameValueDataList); + barGraphDataList.add(barGraphData); + } + barGraphDataListResponse.setGraphData(barGraphDataList); + return barGraphDataListResponse; + } + + public BarGraphDataListResponse generateBarGraphFromFieldFacet(QueryResponse response, String facetField) { + BarGraphDataListResponse dataList = new BarGraphDataListResponse(); + Collection<BarGraphData> vaDatas = new ArrayList<>(); + dataList.setGraphData(vaDatas); + if (response == null) { + return dataList; + } + FacetField facetFieldObj = response.getFacetField(facetField); + if (facetFieldObj == null) { + return dataList; + } + + List<Count> counts = facetFieldObj.getValues(); + if (counts == null) { + return dataList; + } + for (Count cnt : counts) { + List<NameValueData> valueList = new ArrayList<>(); + BarGraphData vBarGraphData = new BarGraphData(); + vaDatas.add(vBarGraphData); + NameValueData vNameValue = new NameValueData(); + vNameValue.setName(cnt.getName()); + vBarGraphData.setName(cnt.getName().toUpperCase()); + vNameValue.setValue("" + cnt.getCount()); + valueList.add(vNameValue); + vBarGraphData.setDataCount(valueList); + } + return dataList; + } + + public List<NameValueData> generateNameValueDataList(List<RangeFacet> rangeFacet) { + List<NameValueData> nameValues = new ArrayList<>(); + if (rangeFacet == null) { + return nameValues; + } + RangeFacet range = rangeFacet.get(0); + + if (range == null) { + return nameValues; + } + List<RangeFacet.Count> listCount = range.getCounts(); + for (RangeFacet.Count cnt : listCount) { + NameValueData nameValue = new NameValueData(); + nameValue.setName(String.valueOf(cnt.getValue())); + nameValue.setValue(String.valueOf(cnt.getCount())); + nameValues.add(nameValue); + } + return nameValues; + } + + public List<Count> generateCount(QueryResponse response) { + List<Count> counts = new ArrayList<>(); + List<FacetField> facetFields = null; + FacetField facetField = null; + if (response == null) { + return counts; + } + + facetFields = response.getFacetFields(); + if (facetFields == null) { + return counts; + } + if (!facetFields.isEmpty()) { + facetField = facetFields.get(0); + } + if (facetField != null) { + counts = facetField.getValues(); + } + return counts; + } + + public BarGraphDataListResponse getGraphDataWithDefaults(QueryResponse queryResponse, String field, String[] defaults) { + BarGraphDataListResponse response = new BarGraphDataListResponse(); + BarGraphData barGraphData = new BarGraphData(); + List<NameValueData> nameValues = generateLevelCountData(queryResponse, defaults, true); + barGraphData.setName(field); + barGraphData.setDataCount(nameValues); + response.setGraphData(Lists.newArrayList(barGraphData)); + return response; + } + + public NameValueDataListResponse getNameValueDataListResponseWithDefaults(QueryResponse response, String[] defaults, boolean emptyResponseDisabled) { + NameValueDataListResponse result = new NameValueDataListResponse(); + result.setvNameValues(generateLevelCountData(response, defaults, emptyResponseDisabled)); + return result; + } + + public NodeListResponse generateServiceNodeTreeFromFacetResponse(QueryResponse queryResponse, + String firstHierarchy, String secondHierarchy, + String firstType, String secondType) { + NodeListResponse response = new NodeListResponse(); + if (queryResponse == null) { + return response; + } + NamedList<List<PivotField>> namedPivotFieldList = queryResponse.getFacetPivot(); + List<PivotField> firstLevelPivots = namedPivotFieldList.get(firstHierarchy); + List<PivotField> secondLevelPivots = namedPivotFieldList.get(secondHierarchy); + if (!CollectionUtils.isNotEmpty(firstLevelPivots) || !CollectionUtils.isNotEmpty(secondLevelPivots)) { + return response; + } + List<NodeData> nodeDataList = buidTreeData(firstLevelPivots, secondLevelPivots, firstType, secondType); + response.setvNodeList(nodeDataList); + return response; + } + + public NodeListResponse generateOneLevelServiceNodeTree(QueryResponse queryResponse, String componentLevelHirachy) { + NodeListResponse response = new NodeListResponse(); + List<NodeData> datatList = new ArrayList<>(); + List<List<PivotField>> listPivotField = new ArrayList<>(); + NamedList<List<PivotField>> namedList = queryResponse.getFacetPivot(); + if (namedList != null) { + listPivotField = namedList.getAll(componentLevelHirachy); + } + List<PivotField> secondHirarchicalPivotFields = null; + if (listPivotField == null || listPivotField.isEmpty()) { + return response; + } else { + secondHirarchicalPivotFields = listPivotField.get(0); + } + for (PivotField singlePivotField : secondHirarchicalPivotFields) { + if (singlePivotField != null) { + NodeData comp = new NodeData(); + comp.setName("" + singlePivotField.getValue()); + List<PivotField> levelList = singlePivotField.getPivot(); + List<NameValueData> levelCountList = new ArrayList<>(); + comp.setLogLevelCount(levelCountList); + if (levelList != null) { + for (PivotField levelPivot : levelList) { + NameValueData level = new NameValueData(); + level.setName(("" + levelPivot.getValue()).toUpperCase()); + level.setValue("" + levelPivot.getCount()); + levelCountList.add(level); + } + } + datatList.add(comp); + } + } + response.setvNodeList(datatList); + return response; + } + + private List<NodeData> buidTreeData(List<PivotField> firstHirarchicalPivotFields, + List<PivotField> secondHirarchicalPivotFields, + String firstPriority, String secondPriority) { + List<NodeData> extensionTree = new ArrayList<>(); + if (firstHirarchicalPivotFields != null) { + for (PivotField pivotHost : firstHirarchicalPivotFields) { + if (pivotHost != null) { + NodeData hostNode = new NodeData(); + String name = (pivotHost.getValue() == null ? "" : "" + pivotHost.getValue()); + String value = "" + pivotHost.getCount(); + if (StringUtils.isNotBlank(name)) { + hostNode.setName(name); + } + if (StringUtils.isNotBlank(value)) { + hostNode.setValue(value); + } + if (StringUtils.isNotBlank(firstPriority)) { + hostNode.setType(firstPriority); + } + + hostNode.setParent(true); + hostNode.setRoot(true); + PivotField hostPivot = null; + for (PivotField searchHost : secondHirarchicalPivotFields) { + if (StringUtils.isNotBlank(hostNode.getName()) + && hostNode.getName().equals(searchHost.getValue())) { + hostPivot = searchHost; + break; + } + } + List<PivotField> pivotLevelHost = hostPivot == null? null : hostPivot.getPivot(); + if (pivotLevelHost != null) { + Collection<NameValueData> logLevelCount = new ArrayList<>(); + for (PivotField pivotLevel : pivotLevelHost) { + if (pivotLevel != null) { + NameValueData vnameValue = new NameValueData(); + String levelName = (pivotLevel.getValue() == null ? "" : "" + pivotLevel.getValue()); + vnameValue.setName(levelName.toUpperCase()); + vnameValue.setValue("" + pivotLevel.getCount()); + logLevelCount.add(vnameValue); + } + } + hostNode.setLogLevelCount(logLevelCount); + } + List<PivotField> pivotComponents = pivotHost.getPivot(); + if (pivotComponents != null) { + Collection<NodeData> componentNodes = new ArrayList<>(); + for (PivotField pivotComp : pivotComponents) { + if (pivotComp != null) { + NodeData compNode = new NodeData(); + String compName = (pivotComp.getValue() == null ? "" : "" + pivotComp.getValue()); + compNode.setName(compName); + if (StringUtils.isNotBlank(secondPriority)) { + compNode.setType(secondPriority); + } + compNode.setValue("" + pivotComp.getCount()); + compNode.setParent(false); + compNode.setRoot(false); + List<PivotField> pivotLevels = pivotComp.getPivot(); + if (pivotLevels != null) { + Collection<NameValueData> logLevelCount = new ArrayList<>(); + for (PivotField pivotLevel : pivotLevels) { + if (pivotLevel != null) { + NameValueData vnameValue = new NameValueData(); + String compLevel = pivotLevel.getValue() == null ? "" : "" + pivotLevel.getValue(); + vnameValue.setName((compLevel).toUpperCase()); + + vnameValue.setValue("" + pivotLevel.getCount()); + logLevelCount.add(vnameValue); + } + } + compNode.setLogLevelCount(logLevelCount); + } + componentNodes.add(compNode); + } + } + hostNode.setChilds(componentNodes); + } + extensionTree.add(hostNode); + } + } + } + + return extensionTree; + } + + private List<NameValueData> generateLevelCountData(QueryResponse queryResponse, String[] defaults, boolean emptyResponseEnabled) { + List<NameValueData> nameValues = Lists.newLinkedList(); + Map<String, NameValueData> linkedMap = Maps.newLinkedHashMap(); + List<Count> counts = generateCount(queryResponse); + if (!CollectionUtils.isNotEmpty(counts) && emptyResponseEnabled) { + return nameValues; + } + for (String defaultValue : defaults) { + NameValueData nameValue = new NameValueData(); + nameValue.setName(defaultValue); + nameValue.setValue("0"); + linkedMap.put(defaultValue, nameValue); + } + if (CollectionUtils.isNotEmpty(counts)) { + for (Count count : counts) { + if (!linkedMap.containsKey(count.getName())) { + NameValueData nameValue = new NameValueData(); + String name = count.getName().toUpperCase(); + nameValue.setName(name); + nameValue.setValue(String.valueOf(count.getCount())); + linkedMap.put(name, nameValue); + } + } + } + + for (Map.Entry<String, NameValueData> nameValueDataEntry : linkedMap.entrySet()) { + nameValues.add(nameValueDataEntry.getValue()); + } + return nameValues; + } + + public CountDataListResponse generateCountResponseByField(QueryResponse response, String field) { + CountDataListResponse collection = new CountDataListResponse(); + List<CountData> vCounts = new ArrayList<>(); + if (response == null) { + return collection; + } + FacetField facetFields = response.getFacetField(field); + if (facetFields == null) { + return collection; + } + List<Count> fieldList = facetFields.getValues(); + + if (fieldList == null) { + return collection; + } + + for (Count cnt : fieldList) { + if (cnt != null) { + CountData vCount = new CountData(); + vCount.setName(cnt.getName()); + vCount.setCount(cnt.getCount()); + vCounts.add(vCount); + } + } + collection.setvCounts(vCounts); + return collection; + } + + public GraphDataListResponse generateSimpleGraphResponse(QueryResponse response, String hierarchy) { + GraphDataListResponse graphInfo = new GraphDataListResponse(); + if (response == null) { + return graphInfo; + } + List<List<PivotField>> hirarchicalPivotField = new ArrayList<List<PivotField>>(); + List<GraphData> dataList = new ArrayList<>(); + NamedList<List<PivotField>> namedList = response.getFacetPivot(); + if (namedList != null) { + hirarchicalPivotField = namedList.getAll(hierarchy); + } + if (!hirarchicalPivotField.isEmpty()) { + dataList = buidGraphData(hirarchicalPivotField.get(0)); + } + if (!dataList.isEmpty()) { + graphInfo.setGraphData(dataList); + } + + return graphInfo; + } + + private List<GraphData> buidGraphData(List<PivotField> pivotFields) { + List<GraphData> logList = new ArrayList<>(); + if (pivotFields != null) { + for (PivotField pivotField : pivotFields) { + if (pivotField != null) { + GraphData logLevel = new GraphData(); + logLevel.setName("" + pivotField.getValue()); + logLevel.setCount(Long.valueOf(pivotField.getCount())); + if (pivotField.getPivot() != null) { + logLevel.setDataList(buidGraphData(pivotField.getPivot())); + } + logList.add(logLevel); + } + } + } + return logList; + } + + + public HostLogFilesResponse generateHostLogFilesResponse(QueryResponse queryResponse) { + HostLogFilesResponse response = new HostLogFilesResponse(); + Map<String, List<String>> componentLogFiles = response.getHostLogFiles(); + + NamedList<List<PivotField>> facetPivot = queryResponse.getFacetPivot(); + List<PivotField> componentFields = facetPivot.get(COMPONENT + "," + PATH); + for (PivotField componentField : componentFields) { + String component = (String)componentField.getValue(); + LinkedList<String> logFileList = new LinkedList<>(); + componentLogFiles.put(component, logFileList); + + for (PivotField logField : componentField.getPivot()) { + // the log file names are in increasing order of their cardinality, using addFirst reverses the list + logFileList.addFirst((String)logField.getValue()); + } + } + + return response; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java new file mode 100644 index 0000000..39e134a --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/solr/SolrConstants.java @@ -0,0 +1,112 @@ +/* + * 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.solr; + +public class SolrConstants { + + private SolrConstants() { + } + + public class CommonLogConstants { + private CommonLogConstants() { + } + + public static final String ID = "id"; + public static final String SEQUENCE_ID = "seq_num"; + public static final String BUNDLE_ID = "bundle_id"; + public static final String CASE_ID = "case_id"; + public static final String CLUSTER = "cluster"; + public static final String LOG_MESSAGE = "log_message"; + public static final String LOGFILE_LINE_NUMBER = "logfile_line_number"; + public static final String EVENT_DURATION_MD5 = "event_dur_m5"; + public static final String FILE = "file"; + public static final String EVENT_COUNT = "event_count"; + public static final String EVENT_MD5 = "event_md5"; + public static final String MESSAGE_MD5= "message_md5"; + public static final String TTL = "_ttl_"; + public static final String EXPIRE_AT = "_expire_at_"; + public static final String VERSION = "_version_"; + public static final String ROUTER_FIELD = "_router_field_"; + public static final String TYPE = "type"; + } + + public class ServiceLogConstants { + + private ServiceLogConstants() { + } + + public static final String BUNDLE_ID = "bundle_id"; + public static final String LOGTIME = "logtime"; + public static final String COMPONENT = "type"; + public static final String LOG_MESSAGE = "log_message"; + public static final String KEY_LOG_MESSAGE = "key_log_message"; + public static final String HOST = "host"; + public static final String LEVEL = "level"; + public static final String THREAD_NAME = "thread_name"; + public static final String LOGGER_NAME = "logger_name"; + public static final String LINE_NUMBER = "line_number"; + public static final String PATH = "path"; + public static final String IP = "ip"; + public static final String STORED_TOKEN_DYNAMIC_FIELDS = "std_*"; + public static final String KEY_DYNAMIC_FIELDS = "key_*"; + public static final String WS_DYNAMIC_FIELDS = "ws_*"; + } + + public class AuditLogConstants { + private AuditLogConstants() { + } + + public static final String AUDIT_LOG_TYPE = "logType"; + public static final String AUDIT_POLICY = "policy"; + public static final String AUDIT_ACCESS = "access"; + public static final String AUDIT_ACTION = "action"; + public static final String AUDIT_AGENT = "agent"; + public static final String AUDIT_AGENT_HOST = "agentHost"; + public static final String AUDIT_CLIENT_IP = "cliIP"; + public static final String AUDIT_CLIENT_TYPE = "cliType"; + public static final String AUDIT_REQEST_CONTEXT = "reqContext"; + public static final String AUDIT_ENFORCER = "enforcer"; + public static final String AUDIT_REASON = "reason"; + public static final String AUDIT_PROXY_USERS = "proxyUsers"; + public static final String AUDIT_REPO_TYPE = "repoType"; + public static final String AUDIT_REQEST_DATA = "reqData"; + public static final String AUDIT_RESPONSE_TYPE = "resType"; + public static final String AUDIT_SESSION = "sess"; + public static final String AUDIT_TEXT = "text"; + public static final String AUDIT_RESULT = "result"; + public static final String AUDIT_COMPONENT = "repo"; + public static final String AUDIT_EVTTIME = "evtTime"; + public static final String AUDIT_REQUEST_USER = "reqUser"; + public static final String AUDIT_RESOURCE = "resource"; + public static final String AUDIT_TAGS = "tags"; + public static final String AUDIT_TAGS_STR = "tags_str"; + } + + public class UserConfigConstants { + private UserConfigConstants() { + } + + public static final String ID = "id"; + public static final String USER_NAME = "username"; + public static final String VALUES = "jsons"; + public static final String FILTER_NAME = "filtername"; + public static final String ROW_TYPE = "rowtype"; + public static final String SHARE_NAME_LIST = "share_username_list"; + } +}