You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/01/31 16:58:14 UTC
[1/9] stratos git commit: added a config file for unit test
Repository: stratos
Updated Branches:
refs/heads/master db2ad6b65 -> 0f3c78115
added a config file for unit test
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/27390847
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/27390847
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/27390847
Branch: refs/heads/master
Commit: 27390847706d71d3f7bf99d53168ec8dc62708e8
Parents: db2ad6b
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 11:15:46 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:04 2015 +0530
----------------------------------------------------------------------
.../publisher/ThriftClientConfig.java | 88 ++++++++++++++
.../publisher/ThriftClientConfigParser.java | 117 +++++++++++++++++++
.../statistics/publisher/ThriftClientInfo.java | 67 +++++++++++
.../publisher/ThriftClientConfigParserTest.java | 50 ++++++++
.../src/test/resources/thrift-client-config.xml | 23 ++++
.../conf/data-bridge/thrift-client-config.xml | 23 ++++
6 files changed, 368 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/27390847/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
new file mode 100644
index 0000000..30e6d6a
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
@@ -0,0 +1,88 @@
+/*
+ * 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.stratos.common.statistics.publisher;
+
+/**
+ * Thrift Client configuration.
+ *
+ * @author supunr
+ * @contact supunr@wso2.com
+ * @date 1/27/15
+ */
+public class ThriftClientConfig {
+
+ /**
+ * Setting the relative path to thrift-client-config.xml file
+ */
+ public static final String THRIFT_CLIENT_CONFIG_FILE_PATH = "thrift.client.config.file.path";
+ private static final String THRIFT_CLIENT_CONFIG_FILE_NAME = "thrift-client-config.xml";
+
+ // here "user.dir" has been used instead of "carbon.home"
+ // since "carbon.home" returned a null value in this instance
+ private static final String CARBON_HOME = "user.dir";
+ private static final String REPOSITORY_CONF = "/products/stratos/conf/data-bridge/";
+
+ private static volatile ThriftClientConfig instance;
+ private ThriftClientInfo thriftClientInfo;
+
+ /*
+ * A private Constructor prevents any other
+ * class from instantiating.
+ */
+ ThriftClientConfig(){}
+
+ public static ThriftClientConfig getInstance() {
+ if (instance == null) {
+ synchronized (ThriftClientConfig.class) {
+ if (instance == null) {
+ String defaultConfigFilePath = System.getProperty(CARBON_HOME) + REPOSITORY_CONF +
+ THRIFT_CLIENT_CONFIG_FILE_NAME;
+ String configFilePath = System.getProperty(THRIFT_CLIENT_CONFIG_FILE_PATH, defaultConfigFilePath);
+ instance = ThriftClientConfigParser.parse(configFilePath);
+ }
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * Returns an ThriftClientInfo Object that stores the credential information.
+ * CEP credential information can be found under thrift-client-config.xml file
+ * These credential information then get parsed and assigned into ThriftClientInfo
+ * Object.
+ * <p>
+ * This method is used to return the assigned values in ThriftClientInfo Object
+ *
+ * @return ThriftClientInfo object which consists of username,password,ip and port values
+ */
+ public ThriftClientInfo getThriftClientInfo() {
+ return thriftClientInfo;
+ }
+
+ /**
+ * Parsed values will be assigned to ThriftClientInfo object. Required fields will be taken
+ * from thrift-client-config.xml file.
+ *
+ * @param thriftClientInfo Object of the ThriftClientInfo
+ */
+ public void setThriftClientInfo(ThriftClientInfo thriftClientInfo) {
+ this.thriftClientInfo = thriftClientInfo;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/27390847/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java
new file mode 100644
index 0000000..755963f
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.common.statistics.publisher;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.stratos.common.util.AxiomXpathParserUtil;
+
+import java.io.File;
+import java.util.Iterator;
+
+/**
+ * Thrift Client config parser.
+ *
+ * @author supunr
+ * @contact supunr@wso2.com
+ * @date 1/27/15
+ */
+public class ThriftClientConfigParser {
+ /**
+ * Fields to be read from the thrift-client-config.xml file
+ */
+ private static final String USERNAME_ELEMENT = "username";
+ private static final String PASSWORD_ELEMENT = "password";
+ private static final String IP_ELEMENT = "ip";
+ private static final String PORT_ELEMENT = "port";
+
+ /**
+ * This method reads thrift-client-config.xml file and assign necessary credential
+ * values into thriftClientInfo object. A singleton design has been implemented
+ * with the use of thriftClientIConfig class.
+ * <p>
+ * The filePath argument is the path to thrift-client-config.xml file
+ *
+ * @param filePath the path to thrift-client-config.xml file
+ * @return ThriftClientConfig object
+ */
+ public static ThriftClientConfig parse(String filePath) {
+ try {
+ ThriftClientConfig thriftClientIConfig = new ThriftClientConfig();
+ ThriftClientInfo thriftClientInfo = new ThriftClientInfo();
+ thriftClientIConfig.setThriftClientInfo(thriftClientInfo);
+
+ OMElement document = AxiomXpathParserUtil.parse(new File(filePath));
+ Iterator thriftClientIterator = document.getChildElements();
+
+ String userNameValuesStr = null;
+ String passwordValueStr = null;
+ String ipValuesStr = null;
+ String portValueStr = null;
+
+ // Iterate the thrift-client-config.xml file and read child element
+ // consists of credential information necessary for WSO2CEPStatisticsPublisher
+ while (thriftClientIterator.hasNext()) {
+ OMElement thriftClientElement = (OMElement) thriftClientIterator.next();
+
+ if (USERNAME_ELEMENT.equals(thriftClientElement.getQName().getLocalPart())) {
+ userNameValuesStr = thriftClientElement.getText();
+ thriftClientInfo.setUsername(userNameValuesStr);
+ }
+
+ if (PASSWORD_ELEMENT.equals(thriftClientElement.getQName().getLocalPart())) {
+ passwordValueStr = thriftClientElement.getText();
+ thriftClientInfo.setPassword(passwordValueStr);
+ }
+
+ if (IP_ELEMENT.equals(thriftClientElement.getQName().getLocalPart())) {
+ ipValuesStr = thriftClientElement.getText();
+ thriftClientInfo.setIp(ipValuesStr);
+ }
+
+ if (PORT_ELEMENT.equals(thriftClientElement.getQName().getLocalPart())) {
+ portValueStr = thriftClientElement.getText();
+ thriftClientInfo.setPort(portValueStr);
+ }
+ }
+
+ if (userNameValuesStr == null) {
+ throw new RuntimeException("Username value not found in thriftClientConfiguration");
+ }
+ if (passwordValueStr == null) {
+ throw new RuntimeException("Password not found in thriftClientConfiguration ");
+ }
+
+ if (ipValuesStr == null) {
+ throw new RuntimeException("Ip values not found in thriftClientConfiguration ");
+ }
+
+ if (portValueStr == null) {
+ throw new RuntimeException("Port not found in thriftClientConfiguration ");
+ }
+
+ return thriftClientIConfig;
+
+ } catch (Exception e) {
+ throw new RuntimeException("Could not parse thrift client configuration", e);
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/27390847/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java
new file mode 100644
index 0000000..b13473c
--- /dev/null
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.common.statistics.publisher;
+
+/**
+ * Thrift Client Info
+ *
+ * @author supunr
+ * @contact supunr@wso2.com
+ * @date 1/27/15
+ */
+public class ThriftClientInfo {
+ private String username;
+ private String password;
+ private String ip;
+ private String port;
+
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/27390847/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java
new file mode 100644
index 0000000..5cdccf7
--- /dev/null
+++ b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.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.stratos.common.test.publisher;
+
+import junit.framework.TestCase;
+import org.apache.stratos.common.statistics.publisher.ThriftClientConfig;
+import org.junit.Test;
+
+/**
+ * Thrift Client configuration.
+ *
+ * @author supunr
+ * @contact supunr@wso2.com
+ * @date 1/27/15
+ */
+public class ThriftClientConfigParserTest extends TestCase {
+ /**
+ * Test ThriftClientConfigParser parse method to check whether it
+ * reads the correct xml filed values.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testName() throws Exception{
+ ThriftClientConfig thriftClientConfig = ThriftClientConfig.getInstance();
+ thriftClientConfig.getThriftClientInfo();
+
+ assertEquals("Incorrect Username","test User",thriftClientConfig.getThriftClientInfo().getUsername());
+ assertEquals("Incorrect Password","test pass",thriftClientConfig.getThriftClientInfo().getPassword());
+ assertEquals("Incorrect IP","195.168.10.1",thriftClientConfig.getThriftClientInfo().getIp());
+ assertEquals("Incorrect Port","8080",thriftClientConfig.getThriftClientInfo().getPort());
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/27390847/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml b/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml
new file mode 100644
index 0000000..284611b
--- /dev/null
+++ b/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml
@@ -0,0 +1,23 @@
+<!--
+ ~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ Licensed 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.
+ -->
+
+<!--Fields to be read and parsed into WSO2CEPStatisticsPublisher-->
+<thriftClientConfiguration>
+ <username>test User</username>
+ <password>test pass</password>
+ <ip>195.168.10.1</ip>
+ <port>8080</port>
+</thriftClientConfiguration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/27390847/products/stratos/conf/data-bridge/thrift-client-config.xml
----------------------------------------------------------------------
diff --git a/products/stratos/conf/data-bridge/thrift-client-config.xml b/products/stratos/conf/data-bridge/thrift-client-config.xml
new file mode 100644
index 0000000..284611b
--- /dev/null
+++ b/products/stratos/conf/data-bridge/thrift-client-config.xml
@@ -0,0 +1,23 @@
+<!--
+ ~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com)
+ ~
+ ~ Licensed 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.
+ -->
+
+<!--Fields to be read and parsed into WSO2CEPStatisticsPublisher-->
+<thriftClientConfiguration>
+ <username>test User</username>
+ <password>test pass</password>
+ <ip>195.168.10.1</ip>
+ <port>8080</port>
+</thriftClientConfiguration>
\ No newline at end of file
[2/9] stratos git commit: Config file for unit testing
Posted by im...@apache.org.
Config file for unit testing
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/bbd006c0
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/bbd006c0
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/bbd006c0
Branch: refs/heads/master
Commit: bbd006c0f28d4699185a8e4a99a5ab5b9195cddd
Parents: 38f63ae
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 13:01:06 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
.../src/test/resources/thrift-client-config.xml | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/bbd006c0/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml b/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml
index 284611b..4b1d820 100644
--- a/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml
+++ b/components/org.apache.stratos.common/src/test/resources/thrift-client-config.xml
@@ -15,9 +15,10 @@
-->
<!--Fields to be read and parsed into WSO2CEPStatisticsPublisher-->
+<!--Test configuration file-->
<thriftClientConfiguration>
- <username>test User</username>
- <password>test pass</password>
- <ip>195.168.10.1</ip>
- <port>8080</port>
+ <username>user1</username>
+ <password>1234</password>
+ <ip>194.168.10.1</ip>
+ <port>9300</port>
</thriftClientConfiguration>
\ No newline at end of file
[7/9] stratos git commit: Changed author info
Posted by im...@apache.org.
Changed author info
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/68f79dbf
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/68f79dbf
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/68f79dbf
Branch: refs/heads/master
Commit: 68f79dbffc6d533155b9b7edeefdd3914856daef
Parents: bffe3c7
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 12:57:29 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
.../stratos/common/statistics/publisher/ThriftClientInfo.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/68f79dbf/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java
index b13473c..514d907 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientInfo.java
@@ -21,10 +21,6 @@ package org.apache.stratos.common.statistics.publisher;
/**
* Thrift Client Info
- *
- * @author supunr
- * @contact supunr@wso2.com
- * @date 1/27/15
*/
public class ThriftClientInfo {
private String username;
[5/9] stratos git commit: exception message changed to thrift Client
Configuration
Posted by im...@apache.org.
exception message changed to thrift Client Configuration
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/bffe3c7b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/bffe3c7b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/bffe3c7b
Branch: refs/heads/master
Commit: bffe3c7b61f0cbb1ebf3b2cd127252ded4327588
Parents: e9b4bcb
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 12:55:58 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
.../statistics/publisher/ThriftClientConfigParser.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/bffe3c7b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java
index 755963f..05c4e8c 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java
@@ -27,10 +27,6 @@ import java.util.Iterator;
/**
* Thrift Client config parser.
- *
- * @author supunr
- * @contact supunr@wso2.com
- * @date 1/27/15
*/
public class ThriftClientConfigParser {
/**
@@ -92,18 +88,18 @@ public class ThriftClientConfigParser {
}
if (userNameValuesStr == null) {
- throw new RuntimeException("Username value not found in thriftClientConfiguration");
+ throw new RuntimeException("Username value not found in thrift Client Configuration");
}
if (passwordValueStr == null) {
- throw new RuntimeException("Password not found in thriftClientConfiguration ");
+ throw new RuntimeException("Password not found in thrift Client Configuration ");
}
if (ipValuesStr == null) {
- throw new RuntimeException("Ip values not found in thriftClientConfiguration ");
+ throw new RuntimeException("Ip values not found in thrift Client Configuration ");
}
if (portValueStr == null) {
- throw new RuntimeException("Port not found in thriftClientConfiguration ");
+ throw new RuntimeException("Port not found in thrift Client Configuration ");
}
return thriftClientIConfig;
[6/9] stratos git commit: changed the method name
Posted by im...@apache.org.
changed the method name
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4ba2984e
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4ba2984e
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4ba2984e
Branch: refs/heads/master
Commit: 4ba2984ef51db1d2700ae8d6a2bf183a6a8c1e31
Parents: 2739084
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 12:49:58 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
.../common/test/publisher/ThriftClientConfigParserTest.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4ba2984e/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java
index 5cdccf7..5073cbc 100644
--- a/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java
+++ b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/publisher/ThriftClientConfigParserTest.java
@@ -23,12 +23,9 @@ import junit.framework.TestCase;
import org.apache.stratos.common.statistics.publisher.ThriftClientConfig;
import org.junit.Test;
+
/**
* Thrift Client configuration.
- *
- * @author supunr
- * @contact supunr@wso2.com
- * @date 1/27/15
*/
public class ThriftClientConfigParserTest extends TestCase {
/**
@@ -38,11 +35,11 @@ public class ThriftClientConfigParserTest extends TestCase {
* @throws Exception
*/
@Test
- public void testName() throws Exception{
+ public void testThriftClientConfigParser() throws Exception{
ThriftClientConfig thriftClientConfig = ThriftClientConfig.getInstance();
thriftClientConfig.getThriftClientInfo();
- assertEquals("Incorrect Username","test User",thriftClientConfig.getThriftClientInfo().getUsername());
+ assertEquals("Incorrect Password","test User",thriftClientConfig.getThriftClientInfo().getUsername());
assertEquals("Incorrect Password","test pass",thriftClientConfig.getThriftClientInfo().getPassword());
assertEquals("Incorrect IP","195.168.10.1",thriftClientConfig.getThriftClientInfo().getIp());
assertEquals("Incorrect Port","8080",thriftClientConfig.getThriftClientInfo().getPort());
[9/9] stratos git commit: File path changed to test configuration
Posted by im...@apache.org.
File path changed to test configuration
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/d40ba80c
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/d40ba80c
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/d40ba80c
Branch: refs/heads/master
Commit: d40ba80c6439a4aea666ec4e9587b64594786a32
Parents: bbd006c
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 13:16:53 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
.../stratos/common/statistics/publisher/ThriftClientConfig.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/d40ba80c/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
index 050440f..8336426 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
@@ -55,7 +55,6 @@ public class ThriftClientConfig {
String defaultConfigFilePath = System.getProperty(CARBON_HOME) + REPOSITORY_CONF +
THRIFT_CLIENT_CONFIG_FILE_NAME;
String configFilePath = System.getProperty(THRIFT_CLIENT_CONFIG_FILE_PATH, defaultConfigFilePath);
- //System.out.println(filePath);
instance = ThriftClientConfigParser.parse(configFilePath);
}
}
[4/9] stratos git commit: Changed hard coded fileds to be read from
config file
Posted by im...@apache.org.
Changed hard coded fileds to be read from config file
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/38f63ae1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/38f63ae1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/38f63ae1
Branch: refs/heads/master
Commit: 38f63ae16b8ca5b4399b86eb5f4c93d805952b9f
Parents: 68f79db
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 12:59:50 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
.../publisher/WSO2CEPStatisticsPublisher.java | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/38f63ae1/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/WSO2CEPStatisticsPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/WSO2CEPStatisticsPublisher.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/WSO2CEPStatisticsPublisher.java
index 5db61cd..b5f3e2a 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/WSO2CEPStatisticsPublisher.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/WSO2CEPStatisticsPublisher.java
@@ -45,12 +45,21 @@ public class WSO2CEPStatisticsPublisher implements StatisticsPublisher {
private String password;
private boolean enabled = false;
+ /**
+ * Credential information stored inside thrift-client-config.xml file
+ * is parsed and assigned into ip,port,username and password fields
+ *
+ * @param streamDefinition
+ */
public WSO2CEPStatisticsPublisher(StreamDefinition streamDefinition) {
+ ThriftClientConfig thriftClientConfig = ThriftClientConfig.getInstance();
+ thriftClientConfig.getThriftClientInfo();
+
this.streamDefinition = streamDefinition;
- this.ip = System.getProperty("thrift.receiver.ip");
- this.port = System.getProperty("thrift.receiver.port");
- this.username = "admin";
- this.password = "admin";
+ this.ip = thriftClientConfig.getThriftClientInfo().getIp();
+ this.port = thriftClientConfig.getThriftClientInfo().getPort();
+ this.username = thriftClientConfig.getThriftClientInfo().getUsername();
+ this.password = thriftClientConfig.getThriftClientInfo().getPassword();
enabled = Boolean.getBoolean("cep.stats.publisher.enabled");
if (enabled) {
[8/9] stratos git commit: This closes #200 on GitHub
Posted by im...@apache.org.
This closes #200 on GitHub
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/0f3c7811
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/0f3c7811
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/0f3c7811
Branch: refs/heads/master
Commit: 0f3c78115a9b4bc1e81ece27be010638ba0ba1bf
Parents: d40ba80
Author: Imesh Gunaratne <im...@apache.org>
Authored: Sat Jan 31 21:28:05 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
----------------------------------------------------------------------
[3/9] stratos git commit: file path changed to test config file path
Posted by im...@apache.org.
file path changed to test config file path
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e9b4bcb8
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e9b4bcb8
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e9b4bcb8
Branch: refs/heads/master
Commit: e9b4bcb8cc792ba8d8567386cc7b46d492f8a962
Parents: 4ba2984
Author: Supun Muthutantri <su...@wso2.com>
Authored: Sat Jan 31 12:53:02 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 21:28:05 2015 +0530
----------------------------------------------------------------------
.../common/statistics/publisher/ThriftClientConfig.java | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/e9b4bcb8/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
index 30e6d6a..050440f 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfig.java
@@ -19,12 +19,9 @@
package org.apache.stratos.common.statistics.publisher;
+
/**
* Thrift Client configuration.
- *
- * @author supunr
- * @contact supunr@wso2.com
- * @date 1/27/15
*/
public class ThriftClientConfig {
@@ -37,7 +34,10 @@ public class ThriftClientConfig {
// here "user.dir" has been used instead of "carbon.home"
// since "carbon.home" returned a null value in this instance
private static final String CARBON_HOME = "user.dir";
- private static final String REPOSITORY_CONF = "/products/stratos/conf/data-bridge/";
+
+ // Test configuration file path is used here
+ // Main configuration file path can be found under "/products/stratos/conf/data-bridge/"
+ private static final String REPOSITORY_CONF = "/components/org.apache.stratos.common/src/test/resources/";
private static volatile ThriftClientConfig instance;
private ThriftClientInfo thriftClientInfo;
@@ -55,6 +55,7 @@ public class ThriftClientConfig {
String defaultConfigFilePath = System.getProperty(CARBON_HOME) + REPOSITORY_CONF +
THRIFT_CLIENT_CONFIG_FILE_NAME;
String configFilePath = System.getProperty(THRIFT_CLIENT_CONFIG_FILE_PATH, defaultConfigFilePath);
+ //System.out.println(filePath);
instance = ThriftClientConfigParser.parse(configFilePath);
}
}