You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by SupunrWork <gi...@git.apache.org> on 2015/01/31 09:07:06 UTC

[GitHub] stratos pull request: Modification to Thrift-Client-Configuration

GitHub user SupunrWork opened a pull request:

    https://github.com/apache/stratos/pull/200

    Modification to Thrift-Client-Configuration

    Didn't change "user.dir" in ThriftClientConfig.java, since getCarbonHome() returned an null pointer exception. Added a different config file for unit testing. 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/SupunrWork/stratos master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/stratos/pull/200.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #200
    
----
commit 4b01fb4ef0b12d135cd75d5e82b7f0c569fa9aaa
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T05:45:46Z

    added a config file for unit test

commit b0baba32c07f790f7ff79ba56d7b423f2da06cc5
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T07:19:58Z

    changed the method name

commit 92522271bed98613e90b9b4cd3378f228c4770a4
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T07:23:02Z

    file path changed to test config file path

commit 0dbc847d4a23e886cf13fd48663514565f52bcf4
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T07:25:58Z

    exception message changed to thrift Client Configuration

commit 21704b0810a17b8690f36fa958c8994409edb89e
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T07:27:29Z

    Changed author info

commit 3873c05b129600a80cbf1618dbf6a8521c45b5a4
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T07:29:50Z

    Changed hard coded fileds to be read from config file

commit 747e1e558b0b2f2087fe132ccfd5957fbf899e37
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T07:31:06Z

    Config file for unit testing

commit 18f8dae053729034e2a99c61f09614a89ccdf30b
Author: Supun Muthutantri <su...@wso2.com>
Date:   2015-01-31T07:46:53Z

    File path changed to  test configuration

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] stratos pull request: Modification to Thrift-Client-Configuration

Posted by imesh <gi...@git.apache.org>.
Github user imesh commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/200#discussion_r23889745
  
    --- Diff: 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>
    --- End diff --
    
    We might need to update default username/password to admin/admin.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] stratos pull request: Modification to Thrift-Client-Configuration

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/stratos/pull/200


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] stratos pull request: Modification to Thrift-Client-Configuration

Posted by imesh <gi...@git.apache.org>.
Github user imesh commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/200#discussion_r23890488
  
    --- Diff: 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.
    + */
    +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";
    +
    +    // 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/";
    --- End diff --
    
    This is not a good practice. We need to handle this other way around. The default should be carbon conf folder, the unit test need to set the system property specifically.
    Thanks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] stratos pull request: Modification to Thrift-Client-Configuration

Posted by imesh <gi...@git.apache.org>.
Github user imesh commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/200#discussion_r23890505
  
    --- Diff: components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftClientConfigParser.java ---
    @@ -0,0 +1,113 @@
    +/*
    + * 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.
    + */
    +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 thrift Client Configuration");
    +            }
    --- End diff --
    
    Shall we make the character "C" lower case: "client configuration"?
    Thanks


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] stratos pull request: Modification to Thrift-Client-Configuration

Posted by imesh <gi...@git.apache.org>.
Github user imesh commented on the pull request:

    https://github.com/apache/stratos/pull/200#issuecomment-72323378
  
    Thanks @SupunrWork for the pull request! It looks good! We have now merged this to master branch.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---