You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2016/09/07 23:38:18 UTC
[28/50] [abbrv] ambari git commit: AMBARI-18310. Refactor logsearch
portal side code (oleewere)
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java
deleted file mode 100644
index 7832fcc..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCount.java
+++ /dev/null
@@ -1,62 +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.view;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class VCount implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
-
- protected String name;
-
- protected Long count;
-
- /**
- * Default constructor. This will set all the attributes to default value.
- */
- public VCount() {
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Long getCount() {
- return count;
- }
-
- public void setCount(Long count) {
- this.count = count;
- }
-
- public String toString() {
- String str = "VLogLevel={";
- str += super.toString();
- str += "name={" + name + "} ";
- str += "count={" + count + "} ";
- str += "}";
- return str;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java
deleted file mode 100644
index f105478..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VCountList.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VCountList extends VList {
- private static final long serialVersionUID = 1L;
-
- protected List<VCount> vCounts;
-
- public VCountList() {
- super();
- vCounts = new ArrayList<VCount>();
- }
-
- public VCountList(List<VCount> logList) {
- super(logList);
- this.vCounts = logList;
- }
-
- public void setCounts(List<VCount> list) {
- this.vCounts = list;
- }
-
- @Override
- public int getListSize() {
- if (vCounts != null)
- return vCounts.size();
- return 0;
- }
-
- @Override
- public List<VCount> getList() {
- return vCounts;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java
deleted file mode 100644
index 1eebfac..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphData.java
+++ /dev/null
@@ -1,79 +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.view;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VGraphData implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected String name;
-
- protected Long count;
-
- protected List<VGraphData> dataList;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Long getCount() {
- return count;
- }
-
- public void setCount(Long info) {
- this.count = info;
- }
-
- public List<VGraphData> getDataList() {
- return dataList;
- }
-
- public void setDataList(List<VGraphData> dataList) {
- this.dataList = dataList;
- }
-
- @Override
- public String toString() {
- String str = "VGraphData={";
- str += super.toString();
- str += "info={ " + count + " } ";
- str += "dataList={ " + dataList + " } ";
- return str;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java
deleted file mode 100644
index 2bf75b5..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGraphInfo.java
+++ /dev/null
@@ -1,62 +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.view;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VGraphInfo implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- protected List<VGraphData> graphData;
-
- public List<VGraphData> getGraphData() {
- return graphData;
- }
-
- public void setGraphData(List<VGraphData> graphData) {
- this.graphData = graphData;
- }
-
- @Override
- public String toString() {
- String str = "VGraphInfo={";
- str += super.toString();
- str += "graphData={ " + graphData + " }";
- return str;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java
deleted file mode 100644
index 5e6c3fa..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VGroupList.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.view;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.solr.common.SolrDocumentList;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VGroupList extends VList {
- private static final long serialVersionUID = 1L;
-
- protected SolrDocumentList groupList;
-
- public VGroupList() {
- super();
- groupList = new SolrDocumentList();
- }
-
- public VGroupList(SolrDocumentList logList) {
- super(logList);
- this.groupList = logList;
- }
-
- public void setGroupDocuments(SolrDocumentList list) {
- this.groupList = list;
- }
-
- @Override
- public int getListSize() {
- if (groupList != null)
- return groupList.size();
- return 0;
- }
-
- @Override
- public SolrDocumentList getList() {
- return groupList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java
deleted file mode 100644
index 57e32d2..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFile.java
+++ /dev/null
@@ -1,56 +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.view;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VLogFile {
-
- private String name;
-
- 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/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java
deleted file mode 100644
index a79dae7..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VLogFileList.java
+++ /dev/null
@@ -1,70 +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.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VLogFileList extends VList {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private List<VLogFile> logFiles;
-
- public VLogFileList() {
- logFiles = new ArrayList<VLogFile>();
- }
-
- @Override
- public int getListSize() {
- if (logFiles == null) {
- return 0;
- }
- return logFiles.size();
- }
-
- @Override
- public List<?> getList() {
- return logFiles;
- }
-
- public List<VLogFile> getLogFiles() {
- return logFiles;
- }
-
- public void setLogFiles(List<VLogFile> logFiles) {
- this.logFiles = logFiles;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java
deleted file mode 100644
index adbd6e0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValue.java
+++ /dev/null
@@ -1,123 +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.view;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class VNameValue implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Name
- */
- protected String name;
- /**
- * Value
- */
- protected String value;
-
- /**
- * Default constructor. This will set all the attributes to default value.
- */
- public VNameValue() {
- }
-
- /**
- * @param name
- * the key
- * @param value
- * the value
- */
- public VNameValue(String name, String value) {
-
- this.name = name;
- this.value = value;
- }
-
- /**
- * This method sets the value to the member attribute <b>name</b>. You
- * cannot set null to the attribute.
- *
- * @param name
- * Value to set member attribute <b>name</b>
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Returns the value for the member attribute <b>name</b>
- *
- * @return String - value of member attribute <b>name</b>.
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * This method sets the value to the member attribute <b>value</b>. You
- * cannot set null to the attribute.
- *
- * @param value
- * Value to set member attribute <b>value</b>
- */
- public void setValue(String value) {
- if(value.contains(".") && (value.contains("e") || value.contains("E"))){
- this.value=getExponentialValueReplaced(value);
- }else{
- this.value = value;
- }
- }
-
- /**
- * Returns the value for the member attribute <b>value</b>
- *
- * @return String - value of member attribute <b>value</b>.
- */
- public String getValue() {
- return this.value;
- }
-
- /**
- * This return the bean content in string format
- *
- * @return formatedStr
- */
- public String toString() {
- String str = "VNameValue={";
- str += super.toString();
- str += "name={" + name + "} ";
- str += "value={" + value + "} ";
- str += "}";
- return str;
- }
-
- private String getExponentialValueReplaced(String value) {
- try{
- Double number = Double.parseDouble(value);
- String newValue = String.format("%.0f", number);
- return newValue;
-
- }catch(Exception e){
- return value;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java
deleted file mode 100644
index e95249d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNameValueList.java
+++ /dev/null
@@ -1,78 +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.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VNameValueList extends VList {
- private static final long serialVersionUID = 1L;
- protected List<VNameValue> vNameValues = new ArrayList<VNameValue>();
-
- public VNameValueList() {
- super();
- }
-
- public VNameValueList(List<VNameValue> objList) {
- super(objList);
- this.vNameValues = objList;
- }
-
- /**
- * @return the vNameValues
- */
- public List<VNameValue> getVNameValues() {
- return vNameValues;
- }
-
- /**
- * @param vNameValues
- * the vNameValues to set
- */
- public void setVNameValues(List<VNameValue> vNameValues) {
- this.vNameValues = vNameValues;
- }
-
- @Override
- public int getListSize() {
- if (vNameValues != null) {
- return vNameValues.size();
- }
- return 0;
- }
-
- @Override
- public List<?> getList() {
- // TODO Auto-generated method stub
- return null;
- }
-
-// @Override
-// public List<VNameValue> getList() {
-// return vNameValues;
-// }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java
deleted file mode 100644
index a16ded8..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNode.java
+++ /dev/null
@@ -1,122 +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.view;
-
-import java.util.Collection;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VNode {
-
- private String name;
-
- private String type;
-
- private String value;
-
- private boolean isRoot;
-
- private Collection<VNode> childs;
-
- private Collection<VNameValue> logLevelCount;
-
- private boolean isParent;
-
- 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 boolean isRoot() {
- return isRoot;
- }
-
- public void setRoot(boolean isRoot) {
- this.isRoot = isRoot;
- }
-
- public Collection<VNode> getChilds() {
- return childs;
- }
-
- public void setChilds(Collection<VNode> childs) {
- this.childs = childs;
- }
-
- public boolean isParent() {
- return isParent;
- }
-
- public void setParent(boolean isParent) {
- this.isParent = isParent;
- }
-
- public Collection<VNameValue> getLogLevelCount() {
- return logLevelCount;
- }
-
- public void setLogLevelCount(Collection<VNameValue> logLevelCount) {
- this.logLevelCount = logLevelCount;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- String str = "VNode={";
- str += "name={" + name + "} ";
- str += "value={" + value + "} ";
- str += "type={" + type + "} ";
- str += "isRoot={" + isRoot + "} ";
- str += "isParent={" + isParent + "} ";
- str += "logLevelCount={" + logLevelCount + "} ";
- str += "childs={" + childs + "} ";
- str += "}";
- return str;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.java
deleted file mode 100644
index 78f32ce..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VNodeList.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.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VNodeList extends VList {
- private static final long serialVersionUID = 1L;
- protected List<VNode> vNodeList = new ArrayList<VNode>();
-
- public List<VNode> getvNodeList() {
- return vNodeList;
- }
-
- public void setvNodeList(List<VNode> vNodeList) {
- this.vNodeList = vNodeList;
- }
-
- @Override
- public int getListSize() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public List<VNode> getList() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.java
deleted file mode 100644
index 55cc089..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSolrLogList.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.view;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.solr.common.SolrDocumentList;
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-
-@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class VSolrLogList extends VList {
- private static final long serialVersionUID = 1L;
-
- protected SolrDocumentList logList;
-
- public VSolrLogList() {
- super();
- logList = new SolrDocumentList();
- }
-
- public VSolrLogList(SolrDocumentList logList) {
- super(logList);
- this.logList = logList;
- }
-
- public void setSolrDocuments(SolrDocumentList list) {
- this.logList = list;
- }
-
- @Override
- public int getListSize() {
- if (logList != null){
- return logList.size();
- }
- return 0;
- }
-
- @Override
- public SolrDocumentList getList() {
- return logList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java
deleted file mode 100644
index bda7565..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VString.java
+++ /dev/null
@@ -1,52 +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.view;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class VString {
-
- /**
- * Value
- */
- protected String value;
-
- /**
- * Default constructor. This will set all the attributes to default value.
- */
- public VString() {
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String toString() {
- String str = "VString={";
- str += super.toString();
- str += "value={" + value + "} ";
- str += "}";
- return str;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java
deleted file mode 100644
index b8606d0..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCount.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ambari.logsearch.view;
-
-import java.util.List;
-
-public class VSummaryCount {
-
- protected String level;
-
- protected List<String> cricticalMsg;
-
- protected List<String> compName;
-
- protected List<Long> countMsg;
-
- public String getLevel() {
- return level;
- }
-
- public void setLevel(String level) {
- this.level = level;
- }
-
- public List<String> getCricticalMsg() {
- return cricticalMsg;
- }
-
- public void setCricticalMsg(List<String> cricticalMsg) {
- this.cricticalMsg = cricticalMsg;
- }
-
- public List<String> getCompName() {
- return compName;
- }
-
- public void setCompName(List<String> compName) {
- this.compName = compName;
- }
-
- public List<Long> getCountMsg() {
- return countMsg;
- }
-
- public void setCountMsg(List<Long> countMsg) {
- this.countMsg = countMsg;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java
deleted file mode 100644
index fcab0b7..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/view/VSummaryCountList.java
+++ /dev/null
@@ -1,37 +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.view;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class VSummaryCountList {
-
- protected Collection<VSummaryCount> countList = new ArrayList<VSummaryCount>();
-
- public Collection<VSummaryCount> getCountList() {
- return countList;
- }
-
- public void setCountList(Collection<VSummaryCount> countList) {
- this.countList = countList;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
index 9fb285e..a34fbd0 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchSecurityContextFormationFilter.java
@@ -20,6 +20,7 @@ package org.apache.ambari.logsearch.web.filters;
import java.io.IOException;
+import javax.inject.Inject;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
@@ -30,11 +31,10 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.ambari.logsearch.common.LogSearchContext;
-import org.apache.ambari.logsearch.manager.SessionMgr;
+import org.apache.ambari.logsearch.manager.SessionManager;
import org.apache.ambari.logsearch.util.CommonUtil;
import org.apache.ambari.logsearch.web.model.User;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
@@ -47,8 +47,8 @@ public class LogsearchSecurityContextFormationFilter extends GenericFilterBean {
public static final String LOGSEARCH_SC_SESSION_KEY = "LOGSEARCH_SECURITY_CONTEXT";
public static final String USER_AGENT = "User-Agent";
- @Autowired
- SessionMgr sessionMgr;
+ @Inject
+ SessionManager sessionManager;
public LogsearchSecurityContextFormationFilter() {
}
@@ -94,7 +94,7 @@ public class LogsearchSecurityContextFormationFilter extends GenericFilterBean {
httpSession.setAttribute(LOGSEARCH_SC_SESSION_KEY, context);
}
LogSearchContext.setContext(context);
- User user = sessionMgr.processSuccessLogin();
+ User user = sessionManager.processSuccessLogin();
context.setUser(user);
}
chain.doFilter(request, response);
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
index 0f7377d..3534818 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAuthenticationProvider.java
@@ -23,7 +23,6 @@ import java.util.HashMap;
import org.apache.ambari.logsearch.dao.UserDao;
import org.apache.ambari.logsearch.util.JSONUtil;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
@@ -31,6 +30,8 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.stereotype.Component;
+import javax.inject.Inject;
+
@Component
public class LogsearchAuthenticationProvider extends
LogsearchAbstractAuthenticationProvider {
@@ -39,19 +40,19 @@ public class LogsearchAuthenticationProvider extends
private static Logger auditLogger = Logger
.getLogger("org.apache.ambari.logsearch.audit");
- @Autowired
+ @Inject
UserDao userDao;
- @Autowired
+ @Inject
LogsearchLdapAuthenticationProvider ldapAuthenticationProvider;
- @Autowired
+ @Inject
LogsearchFileAuthenticationProvider fileAuthenticationProvider;
- @Autowired
+ @Inject
LogsearchSimpleAuthenticationProvider simpleAuthenticationProvider;
-
- @Autowired
+
+ @Inject
LogsearchExternalServerAuthenticationProvider externalServerAuthenticationProvider;
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
index 4eea3e1..a06a381 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchExternalServerAuthenticationProvider.java
@@ -22,14 +22,15 @@ import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
+import javax.inject.Inject;
import org.apache.ambari.logsearch.common.ExternalServerClient;
import org.apache.ambari.logsearch.common.PropertiesHelper;
+import org.apache.ambari.logsearch.conf.AuthConfig;
import org.apache.ambari.logsearch.util.JSONUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -95,16 +96,11 @@ public class LogsearchExternalServerAuthenticationProvider extends
};
}
- @Autowired
- ExternalServerClient externalServerClient;
+ @Inject
+ private ExternalServerClient externalServerClient;
- private String loginAPIURL = "/api/v1/users/$USERNAME/privileges?fields=*";// default
-
- @PostConstruct
- public void initialization() {
- loginAPIURL = PropertiesHelper.getProperty(AUTH_METHOD_PROP_START_WITH
- + "external_auth.login_url", loginAPIURL);
- }
+ @Inject
+ private AuthConfig authConfig;
/**
* Authenticating user from external-server using REST call
@@ -134,7 +130,7 @@ public class LogsearchExternalServerAuthenticationProvider extends
password = StringEscapeUtils.unescapeHtml(password);
username = StringEscapeUtils.unescapeHtml(username);
try {
- String finalLoginUrl = loginAPIURL.replace("$USERNAME", username);
+ String finalLoginUrl = authConfig.getExternalAuthLoginUrl().replace("$USERNAME", username);
String responseObj = (String) externalServerClient.sendGETRequest(
finalLoginUrl, String.class, null, username, password);
if (!isAllowedRole(responseObj)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
index 44c31c5..180de31 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchFileAuthenticationProvider.java
@@ -24,7 +24,6 @@ import org.apache.ambari.logsearch.util.CommonUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -34,12 +33,14 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Component;
+import javax.inject.Inject;
+
@Component
public class LogsearchFileAuthenticationProvider extends LogsearchAbstractAuthenticationProvider {
private static Logger logger = Logger.getLogger(LogsearchFileAuthenticationProvider.class);
- @Autowired
+ @Inject
private UserDetailsService userDetailsService;
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh
deleted file mode 100755
index e9d3106..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/add_config_set.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-# 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.
-
-if [ $# -ne 4 ]; then
- echo "Usage: $0 <solr_home> <zk_host_with_path> <config_name> <config_folder>"
- echo "Example: $0 /opt/solr MY_ZKHOST/solr hadoop_logs `dirname $0`/configsets/hadoop_logs"
- exit 1
-fi
-
-curr_dir=`pwd`
-cd `dirname $0`; script_dir=`pwd`; cd $curr_dir
-
-
-solr_home=$1
-zk_host=$2
-config_name=$3
-config_folder=$4
-
-tmp_folder=/tmp/solr_config_${config_name}_$USER
-rm -rf $tmp_folder
-
-$solr_home/server/scripts/cloud-scripts/zkcli.sh -zkhost $zk_host -cmd downconfig -confdir $tmp_folder -confname $config_name > /dev/null 2>&1
-
-if [ -d $tmp_folder ]; then
- echo "Config $config_name already existing. Will not add to zookeeper"
-else
- echo "Adding config to $config_name to $zk_host"
- $solr_home/server/scripts/cloud-scripts/zkcli.sh -zkhost $zk_host -cmd upconfig -confdir $config_folder -confname $config_name
- echo "Added config to $config_name to $zk_host"
-fi
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.sh
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.sh
deleted file mode 100755
index be728aa..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/create_collections.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-# 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.
-
-if [ $# -ne 4 ]; then
- echo "Usage: $0 <solr_home> <number of shards> <number of replications> [configset folder]"
- exit 1
-fi
-
-curr_dir=`pwd`
-cd `dirname $0`; script_dir=`pwd`; cd $curr_dir
-
-
-solr_home=$1
-shards=$2
-replications=$3
-
-configsets_folder=$4
-if [ "$configsets_folder" = "" ]; then
- configsets_folder=${script_dir}/solr_configsets
-fi
-
-${solr_home}/bin/solr create -c hadoop_logs -d ${configsets_folder}/hadoop_logs/conf -s ${shards} -rf ${replications}
-${solr_home}/bin/solr create -c history -d ${configsets_folder}/history/conf -s 1 -rf ${shards}
-${solr_home}/bin/solr create -c audit_logs -d ${configsets_folder}/audit_logs/conf -s ${shards} -rf ${replications}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
deleted file mode 100644
index b457a1d..0000000
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
-xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
-xmlns:task="http://www.springframework.org/schema/task" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns:util="http://www.springframework.org/schema/util"
-xsi:schemaLocation="http://www.springframework.org/schema/aop
-http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
-http://www.springframework.org/schema/beans
-http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
-http://www.springframework.org/schema/context
-http://www.springframework.org/schema/context/spring-context-4.2.xsd
-http://www.springframework.org/schema/jee
-http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
-http://www.springframework.org/schema/tx
-http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
-http://www.springframework.org/schema/task
-http://www.springframework.org/schema/task/spring-task-4.2.xsd
-http://www.springframework.org/schema/util
-http://www.springframework.org/schema/util/spring-util.xsd">
-
- <context:component-scan base-package="org.apache.ambari.logsearch" />
- <task:annotation-driven />
- <bean id="xmlPropertyConfigurer" class="org.apache.ambari.logsearch.common.XMLPropertiesHelper" />
-
- <bean id="propertyConfigurer" class="org.apache.ambari.logsearch.common.PropertiesHelper">
- <property name="locations">
- <list>
- <value>classpath:default.properties</value>
- <value>classpath:logsearch.properties</value>
- <value>classpath:logsearch-admin-site.xml</value>
- </list>
- </property>
- <property name="propertiesPersister" ref="xmlPropertyConfigurer" />
- </bean>
-
- <bean id="host" class="java.net.InetAddress" factory-method="getLocalHost"/>
- <bean id="apiListingResource" class="io.swagger.jaxrs.listing.ApiListingResource"/>
- <bean id="swaggerSerializers" class="io.swagger.jaxrs.listing.SwaggerSerializers" scope="singleton"/>
- <bean id="beanConfig" class="io.swagger.jaxrs.config.BeanConfig">
- <property name="schemes" value="http" /> <!-- TODO: set this from property -->
- <property name="resourcePackage" value="org.apache.ambari.logsearch.rest"/>
- <property name="version" value="1.0.0"/>
- <property name="host" value="#{host.hostAddress}:61888"/> <!-- TODO: set port from property -->
- <property name="basePath" value="/api/v1"/>
- <property name="title" value="Log Search REST API"/>
- <property name="description" value="Log aggregation, analysis, and visualization."/>
- <property name="license" value="Apache 2.0"/>
- <property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
- <property name="scan" value="true"/>
- </bean>
-
-</beans>
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
index 233fad4..9961cd0 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml
@@ -34,6 +34,7 @@ http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<security:http pattern="/favicon.ico" security="none" />
<security:http pattern="/api/v1/public/**" security="none" />
<security:http pattern="/api/v1/swagger.json" security="none"/>
+ <security:http pattern="/api/v1/swagger.yaml" security="none"/>
<security:http disable-url-rewriting="true" use-expressions="true" create-session="always" entry-point-ref="authenticationProcessingFilterEntryPoint">
<csrf disabled="true"/>
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
index dbe5210..0f1beec 100755
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml
@@ -16,21 +16,20 @@
limitations under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
-
-
- <display-name>LogSearch</display-name>
-
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>META-INF/applicationContext.xml
- META-INF/security-applicationContext.xml
- </param-value>
- </context-param>
-
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <context-param>
+ <param-name>contextClass</param-name>
+ <param-value>
+ org.springframework.web.context.support.AnnotationConfigWebApplicationContext
+ </param-value>
+ </context-param>
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>org.apache.ambari.logsearch.conf.ApplicationConfig</param-value>
+ </context-param>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
index da299a0..cd469de 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/model_bases/VUserFilterBase.js
@@ -27,7 +27,7 @@ define(['require',
var VUserFilterBase = BaseModel.extend(
/** @lends VUserFilterBase.prototype */
{
- urlRoot: Globals.baseURL + 'userconfig/users/filter',
+ urlRoot: Globals.baseURL + 'userconfig/filters',
defaults: {},
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
index b8c43bb..2afb4e1 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/dashboard/ComponentListView.js
@@ -68,7 +68,7 @@ define(['require',
pageSize: 99999
}
});
- this.componentsList.url = Globals.baseURL + "service/logs/components/level/counts";
+ this.componentsList.url = Globals.baseURL + "service/logs/components/levels/counts";
this.hostList = new VNodeList([],{
state: {
firstPage: 0,
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
index 35d0c9a..728d721 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/graphs/GraphLayoutView.js
@@ -84,7 +84,7 @@ define(['require',
this.collection.url = Globals.baseURL + "service/logs/histogram";
this.collection.modelAttrName = "graphData";
} else {
- this.collection.url = Globals.baseURL + "audit/logs/linegraph";
+ this.collection.url = Globals.baseURL + "audit/logs/bargraph";
this.collection.modelAttrName = "graphData";
this.lineView = true;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
index 8999e01..e250b02 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/graphs/backup.js
@@ -81,7 +81,7 @@ define(['require',
this.collection.url = Globals.baseURL + "service/logs/histogram";
this.collection.modelAttrName = "graphData";
} else {
- this.collection.url = Globals.baseURL + "audit/logs/linegraph";
+ this.collection.url = Globals.baseURL + "audit/logs/bargraph";
this.collection.modelAttrName = "graphData";
this.lineView = true;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
index 0b94b60..017d7a8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/AuditSolrDaoTest.java
@@ -21,18 +21,38 @@ package org.apache.ambari.logsearch.dao;
import java.util.ArrayList;
+import org.apache.ambari.logsearch.conf.SolrAuditLogConfig;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.util.NamedList;
import org.easymock.Capture;
import org.easymock.CaptureType;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
public class AuditSolrDaoTest {
+ @TestSubject
+ private AuditSolrDao dao = new AuditSolrDao();
+
+ @Mock
+ private SolrAuditLogConfig configMock;
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
+
@Test
public void testAuditSolrDaoPostConstructor() throws Exception {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
@@ -42,6 +62,18 @@ public class AuditSolrDaoTest {
header.add("status", 0);
response.add("responseHeader", header);
response.add("collections", new ArrayList<String>());
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_audit_logs_config_name");
+ EasyMock.expect(configMock.getCollection()).andReturn("test_audit_logs_collection");
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(123);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(456);
+ EasyMock.expect(configMock.getAliasNameIn()).andReturn("alias");
+ EasyMock.expect(configMock.getRangerCollection()).andReturn("ranger_audit");
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
@@ -50,9 +82,8 @@ public class AuditSolrDaoTest {
mockSolrClient.request(EasyMock.capture(captureCreateRequest), EasyMock.anyString());
EasyMock.expectLastCall().andReturn(response);
- EasyMock.replay(mockSolrClient);
-
- AuditSolrDao dao = new AuditSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
index 2985a62..bdee8a8 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/ServiceLogsSolrDaoTest.java
@@ -21,18 +21,38 @@ package org.apache.ambari.logsearch.dao;
import java.util.ArrayList;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
+import org.apache.ambari.logsearch.conf.SolrServiceLogConfig;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.util.NamedList;
import org.easymock.Capture;
import org.easymock.CaptureType;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
public class ServiceLogsSolrDaoTest {
+ @TestSubject
+ private ServiceLogsSolrDao dao = new ServiceLogsSolrDao();
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Mock
+ private SolrServiceLogConfig configMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
+
@Test
public void testServiceLogsSolrDaoPostConstructor() throws Exception {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
@@ -42,20 +62,29 @@ public class ServiceLogsSolrDaoTest {
header.add("status", 0);
response.add("responseHeader", header);
response.add("collections", new ArrayList<String>());
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_service_logs_config_name");
+ EasyMock.expect(configMock.getCollection()).andReturn("test_service_logs_collection");
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(789);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(987);
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
mockSolrClient.request(EasyMock.capture(captureCreateRequest), EasyMock.anyString()); EasyMock.expectLastCall().andReturn(response);
- EasyMock.replay(mockSolrClient);
-
- ServiceLogsSolrDao dao = new ServiceLogsSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
dao.postConstructor();
- EasyMock.verify(mockSolrClient);
+ EasyMock.verify(mockSolrClient, configMock, kerbConfigMock);
CollectionAdminRequest.Create createRequest = captureCreateRequest.getValue();
Assert.assertEquals(createRequest.getConfigName(), "test_service_logs_config_name");
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
index ba5b074..22b10c3 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/SolrDaoBaseTest.java
@@ -24,11 +24,10 @@ import java.util.Arrays;
import javax.ws.rs.WebApplicationException;
-import org.apache.ambari.logsearch.manager.MgrBase.LogType;
-import org.apache.ambari.logsearch.util.RESTErrorUtil;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
+import org.apache.ambari.logsearch.manager.ManagerBase.LogType;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
@@ -38,6 +37,10 @@ import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.util.NamedList;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -45,14 +48,30 @@ import org.junit.rules.ExpectedException;
import junit.framework.Assert;
public class SolrDaoBaseTest {
+
+ @TestSubject
+ private SolrDaoBase dao = new SolrDaoBase(LogType.SERVICE) {};
+
@Rule
public ExpectedException expectedException = ExpectedException.none();
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
// ----------------------------------------------------------- connectToSolr -----------------------------------------------------------
@Test
public void testConnectToSolrWithConnectString() throws Exception {
- SolrDaoBase dao = new SolrDaoBase(null) {};
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
SolrClient solrClient = dao.connectToSolr(null, "zk_connect_string", "collection");
Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
@@ -60,7 +79,11 @@ public class SolrDaoBaseTest {
@Test
public void testConnectToSolrWithUrl() throws Exception {
- SolrDaoBase dao = new SolrDaoBase(null) {};
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
SolrClient solrClient = dao.connectToSolr("url", null, "collection");
Assert.assertEquals(solrClient.getClass(), HttpSolrClient.class);
@@ -68,7 +91,11 @@ public class SolrDaoBaseTest {
@Test
public void testConnectToSolrWithBoth() throws Exception {
- SolrDaoBase dao = new SolrDaoBase(null) {};
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
SolrClient solrClient = dao.connectToSolr("url", "zk_connect_string", "collection");
Assert.assertEquals(solrClient.getClass(), CloudSolrClient.class);
@@ -76,10 +103,14 @@ public class SolrDaoBaseTest {
@Test
public void testConnectToSolrWithNeither() throws Exception {
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
+
+ EasyMock.replay(kerbConfigMock);
+
expectedException.expect(Exception.class);
expectedException.expectMessage("Both zkConnectString and URL are empty. zkConnectString=null, collection=collection, url=null");
- SolrDaoBase dao = new SolrDaoBase(null) {};
dao.connectToSolr(null, null, "collection");
}
@@ -88,7 +119,6 @@ public class SolrDaoBaseTest {
expectedException.expect(Exception.class);
expectedException.expectMessage("For solr, collection name is mandatory. zkConnectString=zk_connect_string, collection=null, url=url");
- SolrDaoBase dao = new SolrDaoBase(null) {};
dao.connectToSolr("url", "zk_connect_string", null);
}
@@ -106,8 +136,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
boolean status = dao.checkSolrStatus(10000);
@@ -120,8 +149,7 @@ public class SolrDaoBaseTest {
public void testCheckSolrStatusNotSuccessful() throws Exception {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
boolean status = dao.checkSolrStatus(10000);
@@ -148,8 +176,7 @@ public class SolrDaoBaseTest {
mockSolrClouldClient.setDefaultCollection("alias_name"); EasyMock.expectLastCall();
EasyMock.replay(mockSolrClient, mockSolrClouldClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.isZkConnectString = true;
dao.solrClient = mockSolrClient;
dao.solrClouldClient = mockSolrClouldClient;
@@ -177,8 +204,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class), EasyMock.anyString())).andReturn(response);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.isZkConnectString = true;
dao.solrClient = mockSolrClient;
dao.collectionName = "test_collection";
@@ -201,8 +227,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.List.class), EasyMock.anyString())).andReturn(response);
EasyMock.expect(mockSolrClient.request(EasyMock.anyObject(CollectionAdminRequest.Create.class), EasyMock.anyString())).andReturn(response);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.isZkConnectString = true;
dao.solrClient = mockSolrClient;
@@ -218,8 +243,7 @@ public class SolrDaoBaseTest {
SolrClient mockSolrClient = EasyMock.strictMock(SolrClient.class);
EasyMock.expect(mockSolrClient.query(EasyMock.anyObject(SolrQuery.class), EasyMock.eq(METHOD.POST))).andReturn(new QueryResponse());
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
dao.process(new SolrQuery());
@@ -230,8 +254,7 @@ public class SolrDaoBaseTest {
@Test
public void testProcessNoConnection() throws Exception {
expectedException.expect(WebApplicationException.class);
-
- SolrDaoBase dao = new SolrDaoBase(LogType.SERVICE) {};
+
dao.process(new SolrQuery());
}
@@ -251,8 +274,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.add(EasyMock.anyObject(SolrInputDocument.class))).andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
dao.addDocs(new SolrInputDocument());
@@ -274,8 +296,7 @@ public class SolrDaoBaseTest {
EasyMock.expect(mockSolrClient.deleteByQuery(EasyMock.anyString())).andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
EasyMock.replay(mockSolrClient);
-
- SolrDaoBase dao = new SolrDaoBase(null) {};
+
dao.solrClient = mockSolrClient;
dao.removeDoc("query");
http://git-wip-us.apache.org/repos/asf/ambari/blob/e9e834bf/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
index dddbf31..3b01a19 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/dao/UserConfigSolrDaoTest.java
@@ -20,7 +20,10 @@
package org.apache.ambari.logsearch.dao;
import java.util.ArrayList;
+import java.util.Arrays;
+import org.apache.ambari.logsearch.conf.SolrKerberosConfig;
+import org.apache.ambari.logsearch.conf.SolrUserConfig;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@@ -32,11 +35,29 @@ import org.apache.solr.common.util.NamedList;
import org.easymock.Capture;
import org.easymock.CaptureType;
import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.easymock.Mock;
+import org.easymock.TestSubject;
+import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
public class UserConfigSolrDaoTest {
+
+ @TestSubject
+ private UserConfigSolrDao dao = new UserConfigSolrDao();
+
+ @Mock
+ private SolrUserConfig configMock;
+
+ @Mock
+ private SolrKerberosConfig kerbConfigMock;
+
+ @Before
+ public void setUp() {
+ EasyMockSupport.injectMocks(this);
+ }
@Test
public void testUserConfigDaoPostConstructor() throws Exception {
@@ -56,6 +77,17 @@ public class UserConfigSolrDaoTest {
updateResponseHeader.add("QTime", 1);
updateResponseContent.add("responseHeader", updateResponseHeader);
updateResponse.setResponse(updateResponseContent);
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null).times(2);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181").times(2);
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_history_logs_config_name").times(2);
+ EasyMock.expect(configMock.getCollection()).andReturn("test_history_logs_collection").times(2);
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none").times(2);
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(123).times(2);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(234).times(2);
+ EasyMock.expect(configMock.getLogLevels()).andReturn(Arrays.asList("TRACE")).times(2);
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false).times(2);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file").times(2);
Capture<CollectionAdminRequest.Create> captureCreateRequest = EasyMock.newCapture(CaptureType.LAST);
Capture<SolrParams> captureSolrParams = EasyMock.newCapture(CaptureType.LAST);
@@ -67,9 +99,8 @@ public class UserConfigSolrDaoTest {
mockSolrClient.query(EasyMock.capture(captureSolrParams), EasyMock.capture(captureMethod)); EasyMock.expectLastCall().andReturn(queryResponse);
mockSolrClient.add(EasyMock.capture(captureSolrInputDocument)); EasyMock.expectLastCall().andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient);
-
- UserConfigSolrDao dao = new UserConfigSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.postConstructor();
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
@@ -92,7 +123,7 @@ public class UserConfigSolrDaoTest {
SolrInputDocument solrInputDocument = captureSolrInputDocument.getValue();
Assert.assertNotNull(solrInputDocument.getFieldValue("id"));
Assert.assertEquals(solrInputDocument.getFieldValue("rowtype"), "log_feeder_config");
- Assert.assertEquals(solrInputDocument.getFieldValue("jsons"), "{\"filter\":{\"test_component2\":{\"label\":\"test_component2\",\"hosts\":[],\"defaultLevels\":[\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],\"overrideLevels\":[]},\"test_component1\":{\"label\":\"test_component1\",\"hosts\":[],\"defaultLevels\":[\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],\"overrideLevels\":[]}},\"id\":\"" + solrInputDocument.getFieldValue("id") + "\"}");
+ Assert.assertEquals(solrInputDocument.getFieldValue("jsons"), "{\"filter\":{\"test_component2\":{\"label\":\"test_component2\",\"hosts\":[],\"defaultLevels\":[\"TRACE\"],\"overrideLevels\":[]},\"test_component1\":{\"label\":\"test_component1\",\"hosts\":[],\"defaultLevels\":[\"TRACE\"],\"overrideLevels\":[]}},\"id\":\"" + solrInputDocument.getFieldValue("id") + "\"}");
Assert.assertEquals(solrInputDocument.getFieldValue("username"), "log_feeder_config");
Assert.assertEquals(solrInputDocument.getFieldValue("filtername"), "log_feeder_config");
}
@@ -107,18 +138,27 @@ public class UserConfigSolrDaoTest {
header.add("QTime", 1);
response.add("responseHeader", header);
updateResponse.setResponse(response);
+
+ EasyMock.expect(configMock.getSolrUrl()).andReturn(null);
+ EasyMock.expect(configMock.getZkConnectString()).andReturn("dummyHost1:2181,dummyHost2:2181");
+ EasyMock.expect(configMock.getConfigName()).andReturn("test_history_logs_config_name");
+ EasyMock.expect(configMock.getCollection()).andReturn("test_history_logs_collection");
+ EasyMock.expect(configMock.getSplitInterval()).andReturn("none");
+ EasyMock.expect(configMock.getNumberOfShards()).andReturn(123);
+ EasyMock.expect(configMock.getReplicationFactor()).andReturn(234);
+ EasyMock.expect(kerbConfigMock.isEnabled()).andReturn(false);
+ EasyMock.expect(kerbConfigMock.getJaasFile()).andReturn("jaas_file");
EasyMock.expect(mockSolrClient.deleteByQuery("id:test_id")).andReturn(updateResponse);
EasyMock.expect(mockSolrClient.commit()).andReturn(updateResponse);
- EasyMock.replay(mockSolrClient);
-
- UserConfigSolrDao dao = new UserConfigSolrDao();
+ EasyMock.replay(mockSolrClient, configMock, kerbConfigMock);
+
dao.postConstructor();
dao.solrClient = mockSolrClient;
dao.isZkConnectString = true;
dao.deleteUserConfig("test_id");
- EasyMock.verify(mockSolrClient);
+ EasyMock.verify(mockSolrClient, configMock, kerbConfigMock);
}
}