stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [18/50] [abbrv] stratos git commit: Adding statsPublisherEnabled element to thrift-client-config.xml
Date Tue, 01 Sep 2015 12:29:56 GMT
Adding statsPublisherEnabled element to thrift-client-config.xml


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/65b1b2ac
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/65b1b2ac
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/65b1b2ac

Branch: refs/heads/master
Commit: 65b1b2ac2089cdaa806a393fd057c73e30ca83be
Parents: 0770ff1
Author: Thanuja <thanujau@wso2.com>
Authored: Thu Aug 20 13:49:02 2015 +0530
Committer: Thanuja <thanujau@wso2.com>
Committed: Fri Aug 21 18:45:13 2015 +0530

----------------------------------------------------------------------
 .../statistics/publisher/ThriftClientConfigParser.java      | 9 +++++++--
 .../common/statistics/publisher/ThriftClientInfo.java       | 8 ++++++++
 .../statistics/publisher/ThriftStatisticsPublisher.java     | 6 ++----
 .../wso2/cep/WSO2CEPHealthStatisticsPublisher.java          | 3 +--
 .../publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java | 3 +--
 .../stratos/common/test/ThriftClientConfigParserTest.java   | 2 ++
 .../src/test/resources/thrift-client-config.xml             | 2 ++
 products/stratos/conf/thrift-client-config.xml              | 2 ++
 8 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/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 e2684ac..361b56a 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
@@ -40,6 +40,7 @@ public class ThriftClientConfigParser {
      * Fields to be read from the thrift-client-config.xml file
      */
     private static final String NAME_ELEMENT = "name";
+    private static final String STATS_PUBLISHER_ENABLED = "statsPublisherEnabled";
     private static final String USERNAME_ELEMENT = "username";
     private static final String PASSWORD_ELEMENT = "password";
     private static final String IP_ELEMENT = "ip";
@@ -79,6 +80,7 @@ public class ThriftClientConfigParser {
             SecretResolver secretResolver = SecretResolverFactory.create(document, false);
 
             String nameValuesStr = null;
+            boolean statsPublisherEnabled;
             String userNameValuesStr = null;
             String passwordValueStr = null;
             String ipValuesStr = null;
@@ -93,11 +95,9 @@ public class ThriftClientConfigParser {
                 OMElement thriftClientConfig = (OMElement) thriftClientIterator.next();
                 Iterator thriftClientConfigIterator = thriftClientConfig.getChildElements();
                 ThriftClientInfo thriftClientInfo = new ThriftClientInfo();
-                log.info("Client Config: " + thriftClientConfigIterator.toString());
 
                 while (thriftClientConfigIterator.hasNext()) {
                     OMElement thriftClientConfigElement = (OMElement) thriftClientConfigIterator.next();
-                    log.info("Client Config Element: " + thriftClientConfigElement);
 
                     if (NAME_ELEMENT.equals(thriftClientConfigElement.getQName().getLocalPart()))
{
                         nameValuesStr = thriftClientConfigElement.getText();
@@ -108,6 +108,11 @@ public class ThriftClientConfigParser {
                         }
                     }
 
+                    if (STATS_PUBLISHER_ENABLED.equals(thriftClientConfigElement.getQName().getLocalPart()))
{
+                        statsPublisherEnabled = Boolean.parseBoolean(thriftClientConfigElement.getText());
+                        thriftClientInfo.setStatsPublisherEnabled(statsPublisherEnabled);
+                    }
+
                     if (USERNAME_ELEMENT.equals(thriftClientConfigElement.getQName().getLocalPart()))
{
                         userNameValuesStr = thriftClientConfigElement.getText();
                         thriftClientInfo.setUsername(userNameValuesStr);

http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/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 514d907..162c04f 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
@@ -23,11 +23,19 @@ package org.apache.stratos.common.statistics.publisher;
  * Thrift Client Info
  */
 public class ThriftClientInfo {
+    private boolean statsPublisherEnabled;
     private String username;
     private String password;
     private String ip;
     private String port;
 
+    public boolean isStatsPublisherEnabled() {
+        return statsPublisherEnabled;
+    }
+
+    public void setStatsPublisherEnabled(boolean statsPublisherEnabled) {
+        this.statsPublisherEnabled = statsPublisherEnabled;
+    }
 
     public String getUsername() {
         return username;

http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftStatisticsPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftStatisticsPublisher.java
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftStatisticsPublisher.java
index 9242e41..151137e 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftStatisticsPublisher.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftStatisticsPublisher.java
@@ -50,21 +50,19 @@ public class ThriftStatisticsPublisher implements StatisticsPublisher
{
      * is parsed and assigned into ip,port,username and password fields
      *
      * @param streamDefinition      Thrift Event Stream Definition
-     * @param statsPublisherEnabled Whether thrift statistics publisher is enabled
      * @param thriftClientName      Thrift Client Name
      */
-    public ThriftStatisticsPublisher(StreamDefinition streamDefinition, String statsPublisherEnabled,
-                                     String thriftClientName) {
+    public ThriftStatisticsPublisher(StreamDefinition streamDefinition, String thriftClientName)
{
         ThriftClientConfig thriftClientConfig = ThriftClientConfig.getInstance();
         ThriftClientInfo thriftClientInfo = thriftClientConfig.getThriftClientInfo(thriftClientName);
 
         this.streamDefinition = streamDefinition;
+        this.enabled = thriftClientInfo.isStatsPublisherEnabled();
         this.ip = thriftClientInfo.getIp();
         this.port = thriftClientInfo.getPort();
         this.username = thriftClientInfo.getUsername();
         this.password = thriftClientInfo.getPassword();
 
-        enabled = Boolean.getBoolean(statsPublisherEnabled);
         if (enabled) {
             init();
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java
index f98e46c..fbc4030 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java
@@ -37,13 +37,12 @@ public class WSO2CEPHealthStatisticsPublisher extends ThriftStatisticsPublisher
 
     private static final Log log = LogFactory.getLog(WSO2CEPHealthStatisticsPublisher.class);
 
-    private static final String STATS_PUBLISHER_ENABLED = "cep.stats.publisher.enabled";
     private static final String DATA_STREAM_NAME = "cartridge_agent_health_stats";
     private static final String VERSION = "1.0.0";
     private static final String CEP_THRIFT_CLIENT_NAME = "cep";
 
     public WSO2CEPHealthStatisticsPublisher() {
-        super(createStreamDefinition(), STATS_PUBLISHER_ENABLED, CEP_THRIFT_CLIENT_NAME);
+        super(createStreamDefinition(), CEP_THRIFT_CLIENT_NAME);
     }
 
     private static StreamDefinition createStreamDefinition() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java
b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java
index 4780a3d..9114074 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java
@@ -39,13 +39,12 @@ import java.util.List;
 public class WSO2CEPInFlightRequestPublisher extends ThriftStatisticsPublisher implements
InFlightRequestPublisher {
     private static final Log log = LogFactory.getLog(WSO2CEPInFlightRequestPublisher.class);
 
-    private static final String STATS_PUBLISHER_ENABLED = "cep.stats.publisher.enabled";
     private static final String DATA_STREAM_NAME = "in_flight_requests";
     private static final String VERSION = "1.0.0";
     private static final String CEP_THRIFT_CLIENT_NAME = "cep";
 
     public WSO2CEPInFlightRequestPublisher() {
-        super(createStreamDefinition(), STATS_PUBLISHER_ENABLED, CEP_THRIFT_CLIENT_NAME);
+        super(createStreamDefinition(), CEP_THRIFT_CLIENT_NAME);
     }
 
     private static StreamDefinition createStreamDefinition() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftClientConfigParserTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftClientConfigParserTest.java
b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftClientConfigParserTest.java
index c51fa7e..1627c40 100644
--- a/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftClientConfigParserTest.java
+++ b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftClientConfigParserTest.java
@@ -47,11 +47,13 @@ public class ThriftClientConfigParserTest extends TestCase {
         ThriftClientInfo dasThriftClientInfo = thriftClientConfig.getThriftClientInfo(
                 ThriftClientConfig.DAS_THRIFT_CLIENT_NAME);
 
+        assertEquals("CEP Stats Publisher not enabled",true,cepThriftClientInfo.isStatsPublisherEnabled());
         assertEquals("Incorrect Username", "admin", cepThriftClientInfo.getUsername());
         assertEquals("Incorrect Password", "1234", cepThriftClientInfo.getPassword());
         assertEquals("Incorrect IP", "192.168.10.10", cepThriftClientInfo.getIp());
         assertEquals("Incorrect Port", "9300", cepThriftClientInfo.getPort());
 
+        assertEquals("DAS Stats Publisher not enabled",true,dasThriftClientInfo.isStatsPublisherEnabled());
         assertEquals("Incorrect Username", "admin1", dasThriftClientInfo.getUsername());
         assertEquals("Incorrect Password", "12345", dasThriftClientInfo.getPassword());
         assertEquals("Incorrect IP", "192.168.10.11", dasThriftClientInfo.getIp());

http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/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 80d5796..8b10756 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
@@ -22,6 +22,7 @@
 <thriftClientConfiguration>
     <config>
         <name>cep</name>
+        <statsPublisherEnabled>true</statsPublisherEnabled>
         <username>admin</username>
         <password>1234</password>
         <ip>192.168.10.10</ip>
@@ -29,6 +30,7 @@
     </config>
     <config>
         <name>das</name>
+        <statsPublisherEnabled>true</statsPublisherEnabled>
         <username>admin1</username>
         <password>12345</password>
         <ip>192.168.10.11</ip>

http://git-wip-us.apache.org/repos/asf/stratos/blob/65b1b2ac/products/stratos/conf/thrift-client-config.xml
----------------------------------------------------------------------
diff --git a/products/stratos/conf/thrift-client-config.xml b/products/stratos/conf/thrift-client-config.xml
index 4b3b5b9..e5ea9c8 100644
--- a/products/stratos/conf/thrift-client-config.xml
+++ b/products/stratos/conf/thrift-client-config.xml
@@ -22,6 +22,7 @@
 <thriftClientConfiguration>
     <config>
         <name>cep</name>
+        <statsPublisherEnabled>true</statsPublisherEnabled>
         <username>admin</username>
         <password>admin</password>
         <ip>localhost</ip>
@@ -29,6 +30,7 @@
     </config>
     <config>
         <name>das</name>
+        <statsPublisherEnabled>true</statsPublisherEnabled>
         <username>admin</username>
         <password>admin</password>
         <ip>localhost</ip>


Mime
View raw message