You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/07/11 11:28:11 UTC

[7/7] git commit: Applying 0001-Refactor-status-monitor-module.patch

Applying 0001-Refactor-status-monitor-module.patch


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

Branch: refs/heads/master
Commit: fcb90b183d3edb786d00337199879b4bd785615b
Parents: df3475c
Author: Lakmal Warusawithana <la...@wso2.com>
Authored: Thu Jul 11 14:57:48 2013 +0530
Committer: Lakmal Warusawithana <la...@wso2.com>
Committed: Thu Jul 11 14:57:48 2013 +0530

----------------------------------------------------------------------
 .../pom.xml                                     | 109 ++++++++
 .../agent/clients/ClientThreadsInitializer.java | 150 ++++++++++
 .../clients/common/LoadBalanceAgentClient.java  |  94 +++++++
 .../clients/common/ServiceLoginClient.java      | 100 +++++++
 .../service/ApplicationServerClient.java        | 253 +++++++++++++++++
 .../agent/clients/service/BAMServerClient.java  |  74 +++++
 .../agent/clients/service/BPSServerClient.java  | 128 +++++++++
 .../agent/clients/service/BRSServerClient.java  | 138 +++++++++
 .../agent/clients/service/CEPServerClient.java  | 154 +++++++++++
 .../agent/clients/service/DataServerClient.java | 190 +++++++++++++
 .../agent/clients/service/ESBServerClient.java  | 244 ++++++++++++++++
 .../clients/service/GadgetServerClient.java     | 111 ++++++++
 .../service/GovernanceRegistryServerClient.java | 182 ++++++++++++
 .../clients/service/IdentityServerClient.java   | 116 ++++++++
 .../clients/service/ManagerServiceClient.java   | 113 ++++++++
 .../clients/service/MashupServerClient.java     | 192 +++++++++++++
 .../service/MessageBrokerServiceClient.java     | 158 +++++++++++
 .../constants/StatusMonitorAgentConstants.java  |  55 ++++
 .../internal/StatusMonitorAgentComponent.java   | 110 ++++++++
 .../agent/internal/core/MySQLConnector.java     | 277 +++++++++++++++++++
 .../pom.xml                                     |  81 ++++++
 .../core/StatusMonitorConfigurationBuilder.java | 247 +++++++++++++++++
 .../monitor/core/beans/AuthConfigBean.java      |  61 ++++
 .../core/beans/SampleTenantConfigBean.java      |  34 +++
 .../core/constants/StatusMonitorConstants.java  | 152 ++++++++++
 .../core/exception/StatusMonitorException.java  |  33 +++
 .../internal/StatusMonitorCoreComponent.java    |  92 ++++++
 .../core/jdbc/MySQLConnectionInitializer.java   | 247 +++++++++++++++++
 .../monitor/core/util/StatusMonitorUtil.java    |  72 +++++
 .../src/main/resources/META-INF/component.xml   |  44 +++
 .../resources/database/wso2_slive_status.sql    | 148 ++++++++++
 .../pom.xml                                     |  86 ++++++
 .../ui/clients/HealthMonitorServiceClient.java  | 105 +++++++
 .../monitor/ui/utils/StatusMonitorUtil.java     | 107 +++++++
 .../src/main/resources/META-INF/component.xml   |  49 ++++
 .../monitor/ui/i18n/JSResources.properties      |   0
 .../status/monitor/ui/i18n/Resources.properties |  12 +
 .../resources/web/status-monitor/css/status.css |  62 +++++
 .../status-monitor/docs/images/view-details.png | Bin 0 -> 121916 bytes
 .../status-monitor/docs/images/view-status.png  | Bin 0 -> 149085 bytes
 .../web/status-monitor/docs/userguide.html      |  57 ++++
 .../web/status-monitor/images/services.gif      | Bin 0 -> 604 bytes
 .../web/status-monitor/images/services1.gif     | Bin 0 -> 608 bytes
 .../web/status-monitor/service-status.jsp       | 127 +++++++++
 .../web/status-monitor/status-details.jsp       | 138 +++++++++
 .../org.apache.stratos.status.monitor/pom.xml   |  82 ++++++
 .../beans/ServiceStateDetailInfoBean.java       |  62 +++++
 .../monitor/beans/ServiceStateInfoBean.java     |  61 ++++
 .../internal/StatusMonitorServiceComponent.java | 103 +++++++
 .../monitor/internal/core/MySQLConnector.java   | 171 ++++++++++++
 .../monitor/services/HealthMonitorService.java  |  68 +++++
 .../src/main/resources/META-INF/component.xml   |  44 +++
 .../src/main/resources/META-INF/services.xml    |  36 +++
 .../2.1.0/pom.xml                               | 105 -------
 .../agent/clients/ClientThreadsInitializer.java | 147 ----------
 .../clients/common/LoadBalanceAgentClient.java  |  91 ------
 .../clients/common/ServiceLoginClient.java      |  98 -------
 .../service/ApplicationServerClient.java        | 250 -----------------
 .../agent/clients/service/BAMServerClient.java  |  71 -----
 .../agent/clients/service/BPSServerClient.java  | 125 ---------
 .../agent/clients/service/BRSServerClient.java  | 135 ---------
 .../agent/clients/service/CEPServerClient.java  | 151 ----------
 .../agent/clients/service/DataServerClient.java | 187 -------------
 .../agent/clients/service/ESBServerClient.java  | 241 ----------------
 .../clients/service/GadgetServerClient.java     | 108 --------
 .../service/GovernanceRegistryServerClient.java | 179 ------------
 .../clients/service/IdentityServerClient.java   | 114 --------
 .../clients/service/ManagerServiceClient.java   | 111 --------
 .../clients/service/MashupServerClient.java     | 189 -------------
 .../service/MessageBrokerServiceClient.java     | 155 -----------
 .../constants/StatusMonitorAgentConstants.java  |  52 ----
 .../internal/StatusMonitorAgentComponent.java   | 109 --------
 .../agent/internal/core/MySQLConnector.java     | 274 ------------------
 .../2.1.0/pom.xml                               |  78 ------
 .../core/StatusMonitorConfigurationBuilder.java | 244 ----------------
 .../monitor/core/beans/AuthConfigBean.java      |  58 ----
 .../core/beans/SampleTenantConfigBean.java      |  31 ---
 .../core/constants/StatusMonitorConstants.java  | 149 ----------
 .../core/exception/StatusMonitorException.java  |  33 ---
 .../internal/StatusMonitorCoreComponent.java    |  91 ------
 .../core/jdbc/MySQLConnectionInitializer.java   | 244 ----------------
 .../monitor/core/util/StatusMonitorUtil.java    |  69 -----
 .../src/main/resources/META-INF/component.xml   |  41 ---
 .../resources/database/wso2_slive_status.sql    | 148 ----------
 .../2.1.0/pom.xml                               |  80 ------
 .../ui/clients/HealthMonitorServiceClient.java  | 104 -------
 .../monitor/ui/utils/StatusMonitorUtil.java     | 107 -------
 .../src/main/resources/META-INF/component.xml   |  48 ----
 .../monitor/ui/i18n/JSResources.properties      |   0
 .../status/monitor/ui/i18n/Resources.properties |  12 -
 .../resources/web/status-monitor/css/status.css |  62 -----
 .../status-monitor/docs/images/view-details.png | Bin 121916 -> 0 bytes
 .../status-monitor/docs/images/view-status.png  | Bin 149085 -> 0 bytes
 .../web/status-monitor/docs/userguide.html      |  56 ----
 .../web/status-monitor/images/services.gif      | Bin 604 -> 0 bytes
 .../web/status-monitor/images/services1.gif     | Bin 608 -> 0 bytes
 .../web/status-monitor/service-status.jsp       | 126 ---------
 .../web/status-monitor/status-details.jsp       | 137 ---------
 .../2.1.0/pom.xml                               |  79 ------
 .../beans/ServiceStateDetailInfoBean.java       |  59 ----
 .../monitor/beans/ServiceStateInfoBean.java     |  58 ----
 .../internal/StatusMonitorServiceComponent.java | 102 -------
 .../monitor/internal/core/MySQLConnector.java   | 168 -----------
 .../monitor/services/HealthMonitorService.java  |  65 -----
 .../src/main/resources/META-INF/component.xml   |  41 ---
 .../src/main/resources/META-INF/services.xml    |  34 ---
 components/stratos/status-monitor/pom.xml       |  42 ---
 107 files changed, 5529 insertions(+), 5458 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/pom.xml b/components/org.apache.stratos.status.monitor.agent/pom.xml
new file mode 100644
index 0000000..ce07ec2
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/pom.xml
@@ -0,0 +1,109 @@
+<!-- 
+  #  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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <groupId>org.apache.stratos</groupId>
+        <artifactId>stratos-components-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.stratos.status.monitor.agent</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Stratos - Stratos Status Monitor Agent</name>
+
+    <build>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Private-Package>
+                            org.apache.stratos.status.monitor.agent.internal.*,
+                        </Private-Package>
+                        <Export-Package>
+                            org.apache.stratos.status.monitor.agent.*,
+                        </Export-Package>
+                        <Import-Package>
+                            org.wso2.carbon.registry.core.*;version=1.0.1,
+                            javax.xml.namespace; version=0.0.0,
+                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
+                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+                            org.apache.stratos.status.monitor.core.*,
+                            *;resolution:=optional
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.status.monitor.core</artifactId>
+	    <version>3.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <!--dependencies for the service service-->
+        <!--dependencies for the Identity Server Client-->
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.authenticator.stub</artifactId>
+	    <version>4.0.0</version>
+        </dependency>
+
+        <!--dependencies for the CEP Server and MB Client-->
+        <dependency>
+            <groupId>org.apache.geronimo.specs.wso2</groupId>
+            <artifactId>geronimo-jms_1.1_spec</artifactId>
+            <version>${orbit.version.geronimo-jms_1.1_spec}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.qpid.wso2</groupId>
+            <artifactId>qpid-client</artifactId>
+            <version>0.12.wso2v1</version>
+        </dependency>
+
+        <!--dependencies to invoke the load average service-->
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.load.balance.agent.stub</artifactId>
+            <version>${wso2carbon.version}</version>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/ClientThreadsInitializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/ClientThreadsInitializer.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/ClientThreadsInitializer.java
new file mode 100644
index 0000000..9a641aa
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/ClientThreadsInitializer.java
@@ -0,0 +1,150 @@
+/*
+ * 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.status.monitor.agent.clients;
+
+import org.apache.stratos.status.monitor.agent.clients.service.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jms.JMSException;
+import javax.naming.NamingException;
+import javax.xml.stream.XMLStreamException;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.ParseException;
+
+/**
+ * The class that initializes the client threads
+ */
+public class ClientThreadsInitializer {
+    private static final Log log = LogFactory.getLog(ClientThreadsInitializer.class);
+
+    public static void initializeThreads() throws IOException, SQLException, NamingException,
+            JMSException, ParseException, XMLStreamException {
+
+        new Thread() {
+            public void run() {
+                try {
+                    ApplicationServerClient applicationServerClient = new ApplicationServerClient();
+                    applicationServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Application Server";
+                    log.warn(msg);
+                }
+                try {
+                    DataServerClient dataServerClient = new DataServerClient();
+                    dataServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Data Services Server";
+                    log.warn(msg);
+                }
+                try {
+                    ESBServerClient esbServerClient = new ESBServerClient();
+                    esbServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for ESB";
+                    log.warn(msg);
+                }
+                try {
+                    GovernanceRegistryServerClient governanceRegistryServerClient = new GovernanceRegistryServerClient();
+                    governanceRegistryServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Governance Registry";
+                    log.warn(msg);
+                }
+                try {
+                    BPSServerClient bpsServerClient = new BPSServerClient();
+                    bpsServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Business Process Server";
+                    log.warn(msg);
+                }
+                try {
+                    MashupServerClient mashupServerClient = new MashupServerClient();
+                    mashupServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Mashup Server";
+                    log.warn(msg);
+                }
+                try {
+                    BRSServerClient brsServerClient = new BRSServerClient();
+                    brsServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Business Rules Server";
+                    log.warn(msg);
+                }
+                try {
+                    GadgetServerClient gadgetServerClient = new GadgetServerClient();
+                    gadgetServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Gadgets Server";
+                    log.warn(msg);
+                }
+                try {
+                    IdentityServerClient serverClient = new IdentityServerClient();
+                    serverClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Identity Server";
+                    log.warn(msg);
+                }
+                try {
+                    BAMServerClient bamServerClient = new BAMServerClient();
+                    bamServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Business Activity Monitor";
+                    log.warn(msg);
+                }
+                try {
+                    ManagerServiceClient managerServiceClient = new ManagerServiceClient();
+                    managerServiceClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Manager";
+                    log.warn(msg);
+                }
+                try {
+                    MessageBrokerServiceClient messageBrokerServiceClient = new MessageBrokerServiceClient();
+                    messageBrokerServiceClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "Message Broker";
+                    log.warn(msg);
+                }
+                try {
+                    CEPServerClient cepServerClient = new CEPServerClient();
+                    cepServerClient.start();
+                } catch (Exception e) {
+                    String msg = "Error in starting the status monitoring thread for " +
+                            "CEP Server";
+                    log.warn(msg);
+                }
+            }
+        }.start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/LoadBalanceAgentClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/LoadBalanceAgentClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/LoadBalanceAgentClient.java
new file mode 100644
index 0000000..6c6b233
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/LoadBalanceAgentClient.java
@@ -0,0 +1,94 @@
+/*
+ *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.status.monitor.agent.clients.common;
+
+import org.apache.axis2.AxisFault;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.load.balance.agent.stub.LoadBalanceAgentServiceStub;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+
+import java.rmi.RemoteException;
+import java.sql.SQLException;
+
+/**
+ * The agent class that gets the load average of the service instances
+ */
+public class LoadBalanceAgentClient {
+    private static final Log log = LogFactory.getLog(LoadBalanceAgentClient.class);
+    /**
+     * Load Balance Agent - This gets the load information from the service instances of each of the
+     * service cluster.
+     */
+    private static final String serviceName = "LoadBalanceAgentService";
+    private static final String services = "/services/";
+
+
+    /**
+     * gets the load average from the remote instances given in the instances map.
+     *
+     * @param hostName, host name of the service
+     * @param serviceID, int
+     * @return the load average of the given instance.
+     * @throws java.sql.SQLException, if exception in writing to the database.
+     */
+    public static double getLoadAverageFromInstances(String hostName, int serviceID) throws SQLException {
+        double loadAverage = -1;
+        LoadBalanceAgentServiceStub stub;
+        String serviceUrl;
+
+        // gets the instance and the service
+        try {
+            serviceUrl = "https://" + hostName + services + serviceName;
+        } catch (Exception e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Unable to get the running application instances to get the " +
+                        "load average", e);
+            }
+            return loadAverage;
+        }
+
+        // gets the load average of the service instance
+        try {
+            stub = new LoadBalanceAgentServiceStub(serviceUrl);
+            loadAverage = stub.getLoadAverage();
+        } catch (AxisFault e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, e.getMessage());
+            String msg = "Invoking the Load Balance Agent Client Failed";
+            log.warn(msg, e);
+        } catch (RemoteException e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, e.getMessage());
+            String msg = "Remote Exception in invoking the Load Balance Agent Client";
+            log.warn(msg, e);
+        } catch (Exception e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, e.getMessage());
+            String msg = "Exception in invoking the Load Balance Agent Client";
+            log.warn(msg, e);
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("Load Average from the service: " + serviceUrl + ": " + loadAverage);
+        }
+        return loadAverage;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/ServiceLoginClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/ServiceLoginClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/ServiceLoginClient.java
new file mode 100644
index 0000000..c1f4d58
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/common/ServiceLoginClient.java
@@ -0,0 +1,100 @@
+/*
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+package org.apache.stratos.status.monitor.agent.clients.common;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.stratos.status.monitor.agent.constants.StatusMonitorAgentConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.stratos.status.monitor.core.StatusMonitorConfigurationBuilder;
+import org.apache.stratos.status.monitor.core.beans.AuthConfigBean;
+
+import java.sql.SQLException;
+
+/**
+ * The client class that tries to log in into each of the services.
+ */
+public class ServiceLoginClient {
+    private static final Log log = LogFactory.getLog(ServiceLoginClient.class);
+    private static AuthConfigBean authConfigBean = StatusMonitorConfigurationBuilder.getAuthConfigBean();
+
+    static {
+        System.setProperty(StatusMonitorAgentConstants.TRUST_STORE, authConfigBean.getJksLocation());
+        System.setProperty(StatusMonitorAgentConstants.TRUST_STORE_PASSWORD, "wso2carbon");
+        System.setProperty(StatusMonitorAgentConstants.TRUST_STORE_TYPE, "JKS");
+    }
+
+    /**
+     * Checks the log in
+     * @param hostName; host name of the service
+     * @param serviceID: int, service ID
+     * @return boolean: true, if successfully logged in
+     * @throws SQLException: if writing to the database failed.
+     */
+    public static boolean loginChecker(String hostName, int serviceID) throws SQLException {
+        if(log.isDebugEnabled()) {
+            log.debug("************** TRUST STORE : " +
+                    System.getProperty(StatusMonitorAgentConstants.TRUST_STORE));
+        }
+        String userName = authConfigBean.getUserName();
+        String password = authConfigBean.getPassword();
+        boolean loginStatus = false;
+        String authenticationServiceURL = "https://" + hostName +
+                StatusMonitorAgentConstants.AUTHENTICATION_ADMIN_PATH;
+        AuthenticationAdminStub authenticationAdminStub;
+        try {
+            authenticationAdminStub = new AuthenticationAdminStub(authenticationServiceURL);
+            ServiceClient client = authenticationAdminStub._getServiceClient();
+            Options options = client.getOptions();
+            options.setManageSession(true);
+
+            loginStatus = authenticationAdminStub.login(userName, password, hostName);
+            ServiceContext serviceContext = authenticationAdminStub.
+                    _getServiceClient().getLastOperationContext().getServiceContext();
+            // String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
+            String msg = "Log in client successfully logged in to the service: " + hostName;
+            if (log.isDebugEnabled()){
+                log.debug(msg);
+            }
+            if (!loginStatus) {
+                msg = "Login Checker failed for the service: " + hostName;
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, msg);
+                log.warn(msg);
+            }
+        } catch (AxisFault e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, e.getMessage());
+            String msg = "Failed to login; Inserting the stats in the db for the log in checker";
+            log.warn(msg, e);
+        } catch (Exception e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, e.getMessage());
+            String msg = "Exception in login; Inserting the stats in the db for the log in checker";
+            log.warn(msg, e);
+        }
+        return loginStatus;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ApplicationServerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ApplicationServerClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ApplicationServerClient.java
new file mode 100644
index 0000000..9472427
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ApplicationServerClient.java
@@ -0,0 +1,253 @@
+/*
+ *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.status.monitor.agent.clients.service;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.stratos.status.monitor.agent.clients.common.ServiceLoginClient;
+import org.apache.stratos.status.monitor.agent.constants.StatusMonitorAgentConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.stratos.status.monitor.core.StatusMonitorConfigurationBuilder;
+import org.apache.stratos.status.monitor.core.beans.AuthConfigBean;
+import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants;
+import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.sql.SQLException;
+import java.text.ParseException;
+
+/**
+ * Status Monitor Agent client class for Application Server service
+ */
+public class ApplicationServerClient extends Thread {
+    private static int serviceID;
+    private static final Log log = LogFactory.getLog(ApplicationServerClient.class);
+    private static final AuthConfigBean authConfigBean =
+            StatusMonitorConfigurationBuilder.getAuthConfigBean();
+
+    private static OMElement createPayLoad() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace(StatusMonitorConstants.CARBON_OM_NAMESPACE, "ns1");
+        OMElement method = fac.createOMElement("echoString", omNs);
+        OMElement value = fac.createOMElement("s", omNs);
+        value.addChild(fac.createOMText(value, "Hello World"));
+        method.addChild(value);
+        return method;
+    }
+
+    public void run() {
+        while (true) {
+            try {
+                executeService();
+//                LoadBalanceAgentClient.getLoadAverageFromInstances(StatusMonitorConstants.APPSERVER_HOST, serviceID);
+
+                // return from while loop if the thread is interrupted
+                if (isInterrupted()) {
+                    break;
+                }
+                // let the thread sleep for 15 mins
+                try {
+                    sleep(StatusMonitorConstants.SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } catch (IOException e) {
+                log.error(e);
+            } catch (SQLException e) {
+                log.error(e);
+            } catch (ParseException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    /**
+     * Executing the service
+     * @throws SQLException, exception in writing to the database
+     * @throws ParseException, parse exception
+     * @throws IOException, in initializing the service client
+     */
+    private static void executeService() throws SQLException, ParseException, IOException {
+        serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.APPSERVER);
+
+        OMElement result;
+        OMElement payload = createPayLoad();
+        ServiceClient serviceclient = new ServiceClient();
+        Options opts = new Options();
+
+        opts.setTo(new EndpointReference(StatusMonitorConstants.APPSERVER_HTTP +
+                StatusMonitorAgentConstants.TENANT_SERVICES + authConfigBean.getTenant() +
+                "/Axis2Service"));
+        opts.setAction(StatusMonitorConstants.CARBON_OM_NAMESPACE + "echoString");
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+
+
+        //check whether login success
+        if (ServiceLoginClient.loginChecker(StatusMonitorConstants.APPSERVER_HOST, serviceID)) {
+            if (!webappTest()) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, "Webapp Invocation failed");
+                log.warn("WebApp invocation failed");
+
+            } else {
+                serviceclient.setOptions(opts);
+                try {
+                    result = serviceclient.sendReceive(payload);
+                    if (log.isDebugEnabled()) {
+                        log.debug(result);
+                    }
+                    if ((result.toString().indexOf("Hello World")) > 0) {
+                        if (pingPlatformTenant()) {
+//                            if (new JmeterTestClient().getAarUploadResults()) {
+//                                if (log.isDebugEnabled()) {
+//                                    log.debug("Jmeter aar upload Fail");
+//                                }
+//                                MySQLConnector.insertStats(serviceID, false);
+//                                MySQLConnector.insertState(serviceID, false, "UI: AAR upload test failed");
+//                            } else {
+                                MySQLConnector.insertStats(serviceID, true);
+                                MySQLConnector.insertState(serviceID, true, "");
+//                            }
+                        }
+                    } else {
+                        MySQLConnector.insertStats(serviceID, false);
+                        MySQLConnector.insertState(serviceID, false, " Service Invocation failed");
+                        log.warn("Service Invocation Failed");
+                    }
+
+                } catch (AxisFault e) {
+                    MySQLConnector.insertStats(serviceID, false);
+                    MySQLConnector.insertState(serviceID, false, e.getMessage());
+                    String msg = "Axis Fault in invoking the Appserver Client";
+                    log.warn(msg, e);
+                }
+                catch (NullPointerException e) {
+                    MySQLConnector.insertStats(serviceID, false);
+                    MySQLConnector.insertState(serviceID, false, e.getMessage());
+                    String msg = "Null Pointer Exception in invoking the Appserver client";
+                    log.warn(msg, e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Pings the platform tenant
+     * @return true, if the ping was successful
+     * @throws IOException, in creating the service client
+     * @throws SQLException, in writing to the db.
+     * @throws ParseException, parse exception
+     */
+    private static Boolean pingPlatformTenant() throws IOException,
+            SQLException, ParseException {
+        Boolean pingPlatformTenantStatus = false;
+        OMElement result;
+        OMElement payload = createPayLoad();
+        ServiceClient serviceclient = new ServiceClient();
+        Options opts = new Options();
+
+        opts.setTo(new EndpointReference(StatusMonitorConstants.APPSERVER_HTTP +
+                StatusMonitorAgentConstants.TENANT_SERVICES +
+                StatusMonitorConfigurationBuilder.getSampleTenantConfigBean().getTenant() +
+                "/Axis2Service/"));
+        opts.setAction("http://service.carbon.wso2.org/echoString");
+        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+
+        serviceclient.setOptions(opts);
+        try {
+            result = serviceclient.sendReceive(payload);
+
+            if ((result.toString().indexOf("Hello World")) > 0) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Appserver test client - service invocation test passed");
+                }
+                pingPlatformTenantStatus = true;
+            } else {
+                String msg = "Ping to platform sample tenant domain failed";
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, msg);
+                log.warn(msg);
+            }
+
+        } catch (AxisFault e) {
+            MySQLConnector.insertStats(serviceID, false);
+            String msg = "Ping to platform sample tenant domain failed: ";
+            MySQLConnector.insertState(serviceID, false, msg + e.getMessage());
+            log.warn(msg, e);
+        }
+        catch (NullPointerException e) {
+            MySQLConnector.insertStats(serviceID, false);
+            String msg = "Ping to platform sample tenant domain failed: ";
+            MySQLConnector.insertState(serviceID, false, msg + e.getMessage());
+            log.warn(msg, e);
+        }
+        return pingPlatformTenantStatus;
+    }
+
+    /**
+     * Connects to the given web application.
+     * @return true, if successful
+     */
+    private static boolean webappTest() {
+        URL webAppURL;
+        BufferedReader in;
+        boolean webappStatus = false;
+
+        try {
+            webAppURL = new URL(StatusMonitorConstants.APPSERVER_HTTP + "/t/" +
+                    authConfigBean.getTenant() +
+                    "/webapps/SimpleServlet/simple-servlet");
+            URLConnection yc;
+            yc = webAppURL.openConnection();
+
+            in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
+
+            String inputLine;
+
+            while ((inputLine = in.readLine()) != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug(inputLine);
+                }
+                if (inputLine.indexOf("Hello, World") > 1) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("True : " + inputLine.indexOf("Hello, World"));
+                    }
+                    webappStatus = true;
+                }
+            }
+            in.close();
+        } catch (IOException e) {
+            log.error(e);
+        }
+        return webappStatus;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BAMServerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BAMServerClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BAMServerClient.java
new file mode 100644
index 0000000..0ef70af
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BAMServerClient.java
@@ -0,0 +1,74 @@
+/*
+ *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.status.monitor.agent.clients.service;
+
+import org.apache.stratos.status.monitor.agent.clients.common.ServiceLoginClient;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants;
+import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.ParseException;
+
+/**
+ * Status Monitor Agent client class for Business Activity Monitor
+ */
+public class BAMServerClient extends Thread {
+
+    public static int serviceID;
+    private static final Log log = LogFactory.getLog(BAMServerClient.class);
+
+    public void run() {
+        while (true) {
+            try {
+                executeService();
+
+                // return from while loop if the thread is interrupted
+                if (isInterrupted()) {
+                    break;
+                }
+                // let the thread sleep for 15 mins
+                try {
+                    sleep(StatusMonitorConstants.SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } catch (IOException e) {
+                log.error(e);
+            } catch (SQLException e) {
+                log.error(e);
+            } catch (ParseException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    private static void executeService() throws SQLException, IOException, ParseException {
+        int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.MONITOR);
+
+        if (ServiceLoginClient.loginChecker(StatusMonitorConstants.MONITOR_HOST, serviceID)) {
+            MySQLConnector.insertStats(serviceID, true);
+            MySQLConnector.insertState(serviceID, true, "");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BPSServerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BPSServerClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BPSServerClient.java
new file mode 100644
index 0000000..787ab02
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BPSServerClient.java
@@ -0,0 +1,128 @@
+/*
+ *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.status.monitor.agent.clients.service;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.status.monitor.agent.clients.common.ServiceLoginClient;
+import org.apache.stratos.status.monitor.agent.constants.StatusMonitorAgentConstants;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.stratos.status.monitor.core.StatusMonitorConfigurationBuilder;
+import org.apache.stratos.status.monitor.core.beans.AuthConfigBean;
+import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants;
+import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.ParseException;
+
+/**
+ * Status Monitor Agent client class for Business Process Server
+ */
+public class BPSServerClient extends Thread{
+    private static final Log log = LogFactory.getLog(BPSServerClient.class);
+    private static final AuthConfigBean authConfigBean =
+            StatusMonitorConfigurationBuilder.getAuthConfigBean();
+
+
+    public void run() {
+        while (true) {
+            try {
+                executeService();
+
+                // return from while loop if the thread is interrupted
+                if (isInterrupted()) {
+                    break;
+                }
+                // let the thread sleep for 15 mins
+                try {
+                    sleep(StatusMonitorConstants.SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } catch (IOException e) {
+                log.error(e);
+            } catch (SQLException e) {
+                log.error(e);
+            } catch (ParseException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    private static OMElement createPayLoad() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace("http://ode/bpel/unit-test.wsdl", "ns1");
+        OMElement method = fac.createOMElement("hello", omNs);
+        OMElement value = fac.createOMElement("TestPart", null);
+        value.addChild(fac.createOMText(value, "Hello"));
+        method.addChild(value);
+        return method;
+    }
+
+    private static void executeService() throws IOException, SQLException, ParseException {
+
+        int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.PROCESS);
+
+        OMElement result;
+        OMElement payload = createPayLoad();
+        ServiceClient serviceclient = new ServiceClient();
+        Options opts = new Options();
+        opts.setTo(new EndpointReference(StatusMonitorConstants.PROCESS_HTTP +
+                StatusMonitorAgentConstants.TENANT_SERVICES +
+                authConfigBean.getTenant() + "/HelloService"));
+        opts.setAction("http://ode/bpel/unit-test.wsdl/hello");
+
+        if (ServiceLoginClient.loginChecker(StatusMonitorConstants.PROCESS_HOST, serviceID)) {
+            serviceclient.setOptions(opts);
+            try {
+                result = serviceclient.sendReceive(payload);
+                if(log.isDebugEnabled()){
+                    log.debug("Result of BPS: " + result);
+                }
+
+                if ((result.toString().indexOf("Hello World")) > 0) {
+                    MySQLConnector.insertStats(serviceID, true);
+                    MySQLConnector.insertState(serviceID, true, "");
+                } else {
+                    MySQLConnector.insertStats(serviceID, false);
+                    MySQLConnector.insertState(serviceID, false, "Service Invocation failed");
+                }
+
+            } catch (AxisFault e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                log.warn(e);
+            }
+            catch (NullPointerException e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                log.warn(e);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BRSServerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BRSServerClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BRSServerClient.java
new file mode 100644
index 0000000..11ee7e1
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/BRSServerClient.java
@@ -0,0 +1,138 @@
+/*
+ *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.status.monitor.agent.clients.service;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.stratos.status.monitor.agent.clients.common.ServiceLoginClient;
+import org.apache.stratos.status.monitor.agent.constants.StatusMonitorAgentConstants;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.status.monitor.core.StatusMonitorConfigurationBuilder;
+import org.apache.stratos.status.monitor.core.beans.AuthConfigBean;
+import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants;
+import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.ParseException;
+
+/**
+ * Status Monitor Agent client class for Business Rule Server
+ */
+public class BRSServerClient extends Thread {
+    private static final Log log = LogFactory.getLog(BRSServerClient.class);
+    private static final AuthConfigBean authConfigBean =
+            StatusMonitorConfigurationBuilder.getAuthConfigBean();
+
+    public void run() {
+        while (true) {
+            try {
+                executeService();
+
+                // return from while loop if the thread is interrupted
+                if (isInterrupted()) {
+                    break;
+                }
+                // let the thread sleep for 15 mins
+                try {
+                    sleep(StatusMonitorConstants.SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } catch (IOException e) {
+                log.error(e);
+            } catch (SQLException e) {
+                log.error(e);
+            } catch (ParseException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    private static OMElement createPayLoad() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace("http://brs.carbon.wso2.org", "ns1");
+        OMNamespace nameNs = fac.createOMNamespace("http://greeting.samples/xsd", "ns2");
+        OMElement method = fac.createOMElement("greetMe", omNs);
+        OMElement value = fac.createOMElement("User", omNs);
+        OMElement NameValue = fac.createOMElement("name", nameNs);
+        NameValue.addChild(fac.createOMText(NameValue, "QAuser"));
+        value.addChild(NameValue);
+        method.addChild(value);
+        if (log.isDebugEnabled()) {
+            log.debug("Method in createPayload(): " + method.toString());
+        }
+        return method;
+    }
+
+    private static void executeService() throws IOException, SQLException, ParseException {
+
+        int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.RULE);
+
+        OMElement result;
+        OMElement payload = createPayLoad();
+        ServiceClient serviceclient = new ServiceClient();
+        Options opts = new Options();
+        opts.setTo(new EndpointReference(StatusMonitorConstants.RULE_HTTP +
+                StatusMonitorAgentConstants.TENANT_SERVICES +
+                authConfigBean.getTenant() + "/GreetingService"));
+        opts.setAction("http://brs.carbon.wso2.org/greetMe");
+
+        if (ServiceLoginClient.loginChecker(StatusMonitorConstants.RULE_HOST, serviceID)) {
+            serviceclient.setOptions(opts);
+            try {
+                result = serviceclient.sendReceive(payload);
+                if (log.isDebugEnabled()) {
+                    log.debug("Result in BRSServerClient: " + result.toString());
+                }
+
+                if ((result.toString().indexOf("QAuser")) > 0) {
+                    MySQLConnector.insertStats(serviceID, true);
+                    MySQLConnector.insertState(serviceID, true, "");
+                } else {
+                    MySQLConnector.insertStats(serviceID, false);
+                    MySQLConnector.insertState(serviceID, false, "Service Invocation failed");
+                }
+
+            } catch (AxisFault e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "Fault when executing service: BRSServerClient: ";
+                log.warn(msg, e);
+            }
+            catch (NullPointerException e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "NPE when executing service: BRSServerClient: ";
+                log.warn(msg, e);
+            }
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/CEPServerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/CEPServerClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/CEPServerClient.java
new file mode 100644
index 0000000..3b56307
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/CEPServerClient.java
@@ -0,0 +1,154 @@
+/*
+ *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.status.monitor.agent.clients.service;
+
+import org.apache.stratos.status.monitor.agent.clients.common.ServiceLoginClient;
+import org.apache.stratos.status.monitor.agent.constants.StatusMonitorAgentConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.stratos.status.monitor.core.StatusMonitorConfigurationBuilder;
+import org.apache.stratos.status.monitor.core.beans.AuthConfigBean;
+import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants;
+import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer;
+
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.sql.SQLException;
+import java.util.Properties;
+import javax.jms.QueueConnectionFactory;
+
+/**
+ * Status Monitor Agent client class for Complex Event Processing Server
+ */
+public class CEPServerClient extends Thread{
+    private static final Log log = LogFactory.getLog(CEPServerClient.class);
+    private static String tcpUserName;
+
+    public void run() {
+        while (true) {
+            try {
+                executeService();
+
+                // return from while loop if the thread is interrupted
+                if (isInterrupted()) {
+                    break;
+                }
+                // let the thread sleep for 15 mins
+                try {
+                    sleep(StatusMonitorConstants.SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } catch (SQLException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    private static void executeService() throws SQLException {
+        int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.CEP);
+        AuthConfigBean authConfigBean = StatusMonitorConfigurationBuilder.getAuthConfigBean();
+
+        String userName = authConfigBean.getUserName();
+        tcpUserName = userName.replace('@','!');
+
+
+        //check whether login success
+        if (ServiceLoginClient.loginChecker(StatusMonitorConstants.CEP_HOST, serviceID)) {
+
+
+            Properties properties = new Properties();
+            properties.put(Context.INITIAL_CONTEXT_FACTORY, StatusMonitorAgentConstants.QPID_ICF);
+            properties.put(StatusMonitorAgentConstants.CF_NAME_PREFIX +
+                    StatusMonitorAgentConstants.CF_NAME,
+                    getTCPConnectionURL(tcpUserName,
+                            authConfigBean.getPassword()));
+
+            InitialContext ctx;
+            try {
+                ctx = new InitialContext(properties);
+
+                // Lookup connection factory
+                QueueConnectionFactory connFactory =
+                        (QueueConnectionFactory) ctx.lookup(StatusMonitorAgentConstants.CF_NAME);
+                QueueConnection queueConnection = connFactory.createQueueConnection();
+                queueConnection.start();
+                QueueSession queueSession =
+                        queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+                // Send message
+                Queue queue = queueSession.createQueue(StatusMonitorAgentConstants.QUEUE_NAME_CEP +
+                        ";{create:always, node:{durable: True}}");
+
+                // create the message to send
+                TextMessage textMessage = queueSession.createTextMessage("Test Message Hello");
+                javax.jms.QueueSender queueSender = queueSession.createSender(queue);
+                queueSender.setTimeToLive(100000000);
+
+                QueueReceiver queueReceiver = queueSession.createReceiver(queue);
+                queueSender.send(textMessage);
+
+                TextMessage message = (TextMessage) queueReceiver.receiveNoWait();
+                if (log.isDebugEnabled()) {
+                    log.debug("Message in the execute() of CEPServer Client: " + message.getText());
+                }
+                if (message.getText().equals("Test Message Hello")) {
+                    MySQLConnector.insertStats(serviceID, true);
+                    MySQLConnector.insertState(serviceID, true, "");
+                } else {
+                    MySQLConnector.insertStats(serviceID, false);
+                    MySQLConnector.insertState(serviceID, false, "Send or retrieve messages failed");
+                }
+                queueSender.close();
+                queueSession.close();
+                queueConnection.close();
+
+            } catch (JMSException e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "JMS Exception in inserting stats into the DB for the CEPServerClient";
+                log.warn(msg, e);
+            } catch (NamingException e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "Naming Exception in inserting stats into the DB for the CEPServerClient";
+                log.warn(msg, e);
+            }
+        }
+    }
+
+    private static String getTCPConnectionURL(String username, String password) {
+        return new StringBuffer()
+                .append("amqp://").append(tcpUserName).append(":").append(password).append("@").
+                        append(StatusMonitorAgentConstants.CARBON_CLIENT_ID).append("/").
+                        append(StatusMonitorAgentConstants.CARBON_VIRTUAL_HOST_NAME).
+                        append("?brokerlist='tcp://").append(StatusMonitorConstants.CEP_HOST).
+                        append(":").append(StatusMonitorAgentConstants.CEP_DEFAULT_PORT).
+                        append("'").toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/DataServerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/DataServerClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/DataServerClient.java
new file mode 100644
index 0000000..580d6fb
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/DataServerClient.java
@@ -0,0 +1,190 @@
+/*
+ * 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.status.monitor.agent.clients.service;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.stratos.status.monitor.agent.clients.common.ServiceLoginClient;
+import org.apache.stratos.status.monitor.agent.constants.StatusMonitorAgentConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.stratos.status.monitor.core.StatusMonitorConfigurationBuilder;
+import org.apache.stratos.status.monitor.core.beans.AuthConfigBean;
+import org.apache.stratos.status.monitor.core.beans.SampleTenantConfigBean;
+import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants;
+import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.ParseException;
+
+/**
+ * Status Monitor Agent client class for Data
+ */
+public class DataServerClient extends Thread{
+    private static final Log log = LogFactory.getLog(DataServerClient.class);
+    private static final AuthConfigBean authConfigBean =
+            StatusMonitorConfigurationBuilder.getAuthConfigBean();
+    private static final SampleTenantConfigBean sampleTenantConfigBean =
+            StatusMonitorConfigurationBuilder.getSampleTenantConfigBean();
+
+    private static OMElement createPayLoad() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace("http://ws.wso2.org/dataservice", "ns1");
+        return fac.createOMElement("getCustomers", omNs);
+    }
+
+    public void run() {
+        while (true) {
+            try {
+                executeService();
+
+                // return from while loop if the thread is interrupted
+                if (isInterrupted()) {
+                    break;
+                }
+                // let the thread sleep for 15 mins
+                try {
+                    sleep(StatusMonitorConstants.SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } catch (IOException e) {
+                log.error(e);
+            } catch (SQLException e) {
+                log.error(e);
+            } catch (ParseException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    private static void executeService() throws IOException, SQLException, ParseException {
+        int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.DATA);
+
+        OMElement result;
+        OMElement payload = createPayLoad();
+        ServiceClient serviceclient = new ServiceClient();
+        Options opts = new Options();
+        opts.setTo(new EndpointReference(StatusMonitorConstants.DATA_HTTP +
+                StatusMonitorAgentConstants.TENANT_SERVICES +
+                 authConfigBean.getTenant() + "/GSpreadSample"));
+        opts.setAction("http://ws.wso2.org/dataservice/getCustomers");
+
+        if (ServiceLoginClient.loginChecker(StatusMonitorConstants.DATA_HOST, serviceID)) {
+            serviceclient.setOptions(opts);
+            try {
+                result = serviceclient.sendReceive(payload);
+                if (log.isDebugEnabled()) {
+                    log.debug(result);
+                }
+
+                if ((result.toString().indexOf("Signal Gift Stores")) > 0) {
+                    executeShoppingCartDSPlatformSample();
+
+                } else {
+                    MySQLConnector.insertStats(serviceID, false);
+                    MySQLConnector.insertState(serviceID, false, "Service Invocation failed");
+                }
+
+            } catch (AxisFault e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "Error in executing service for DSS Server client";
+                log.warn(msg, e);
+            }
+            catch (NullPointerException e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "NPE in executing the service for DSS client";
+                log.warn(msg, e);
+            }
+        }
+    }
+
+    private static boolean executeShoppingCartDSPlatformSample() throws IOException, SQLException, ParseException {
+        Boolean sampleStatus = false;
+        int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.DATA);
+        String payload = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
+                "   <soapenv:Header/>\n" +
+                "   <soapenv:Body/>\n" +
+                "</soapenv:Envelope>";
+        String action = "getAllCategories";
+
+        try {
+            OMElement result;
+            result = sendRequest(payload, action, new EndpointReference(
+                    StatusMonitorConstants.DATA_HTTP + StatusMonitorAgentConstants.TENANT_SERVICES +
+                            sampleTenantConfigBean.getTenant() + "/ShoppingCartDS"));
+
+            if ((result.toString().indexOf("Compact Lens-Shutter Cameras")) > 0) {
+                sampleStatus = true;
+                MySQLConnector.insertStats(serviceID, true);
+                MySQLConnector.insertState(serviceID, true, "");
+            } else {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, "Platform sample ShoppingCartDS invocation failed");
+            }
+        } catch (AxisFault e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, "Platform sample ShoppingCartDS: " + e.getMessage());
+            String msg = "Fault in executing the Shopping cart sample";
+            log.warn(msg, e);
+        }
+        catch (NullPointerException e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, "Platform sample ShoppingCartDS: " + e.getMessage());
+            String msg = "NPE in executing the shopping cart sample";
+            log.warn(msg, e);
+        } catch (XMLStreamException e) {
+            String msg = "XMLStreamException in executing the shopping cart sample";
+            log.warn(msg, e);
+        }
+        return sampleStatus;
+    }
+
+    private static OMElement sendRequest(String payloadStr, String action, EndpointReference targetEPR)
+            throws XMLStreamException, AxisFault {
+        OMElement payload = AXIOMUtil.stringToOM(payloadStr);
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setAction("urn:" + action); //since soapAction = ""
+
+        //Blocking invocation
+        ServiceClient sender = new ServiceClient();
+        sender.setOptions(options);
+        if (log.isDebugEnabled()){
+            log.debug("Request: " + payload.toString());
+        }
+        OMElement result = sender.sendReceive(payload);
+        if (log.isDebugEnabled()){
+            log.debug("Response: "+ payload.toString());
+        }
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ESBServerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ESBServerClient.java b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ESBServerClient.java
new file mode 100644
index 0000000..0cd7b86
--- /dev/null
+++ b/components/org.apache.stratos.status.monitor.agent/src/main/java/org/apache/stratos/status/monitor/agent/clients/service/ESBServerClient.java
@@ -0,0 +1,244 @@
+/*
+ * 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.status.monitor.agent.clients.service;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.AXIOMUtil;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.stratos.status.monitor.agent.clients.common.ServiceLoginClient;
+import org.apache.stratos.status.monitor.agent.constants.StatusMonitorAgentConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector;
+import org.apache.stratos.status.monitor.core.StatusMonitorConfigurationBuilder;
+import org.apache.stratos.status.monitor.core.beans.AuthConfigBean;
+import org.apache.stratos.status.monitor.core.beans.SampleTenantConfigBean;
+import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants;
+import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.ParseException;
+
+/**
+ * Status Monitor Agent client class for ESB
+ */
+public class ESBServerClient extends Thread{
+
+    private static final Log log = LogFactory.getLog(ESBServerClient.class);
+    private static final AuthConfigBean authConfigBean =
+            StatusMonitorConfigurationBuilder.getAuthConfigBean();
+    private static final SampleTenantConfigBean sampleTenantConfigBean =
+            StatusMonitorConfigurationBuilder.getSampleTenantConfigBean();
+
+    private static int serviceID;
+
+    public void run() {
+        while (true) {
+            try {
+                executeService();
+
+                // return from while loop if the thread is interrupted
+                if (isInterrupted()) {
+                    break;
+                }
+                // let the thread sleep for 15 mins
+                try {
+                    sleep(StatusMonitorConstants.SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                }
+            } catch (IOException e) {
+                log.error(e);
+            } catch (SQLException e) {
+                log.error(e);
+            } catch (ParseException e) {
+                log.error(e);
+            }
+        }
+    }
+
+    private static OMElement createPayLoad() {
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace omNs = fac.createOMNamespace("http://service.carbon.wso2.org", "ns1");
+        OMElement method = fac.createOMElement("echoString", omNs);
+        OMElement value = fac.createOMElement("s", omNs);
+        value.addChild(fac.createOMText(value, "Hello World"));
+
+        method.addChild(value);
+        return method;
+    }
+
+    private static void executeService() throws IOException, SQLException, ParseException {
+
+        OMElement result = null;
+        OMElement payload = createPayLoad();
+        ServiceClient serviceclient = new ServiceClient();
+        Options opts = new Options();
+        opts.setTo(new EndpointReference(StatusMonitorConstants.ESB_HTTP + ":" +
+                StatusMonitorConstants.ESB_NHTTP_PORT +
+                StatusMonitorAgentConstants.TENANT_SERVICES +
+                authConfigBean.getTenant() + "/DemoProxy"));
+        opts.setAction("http://service.carbon.wso2.org/echoString");
+        serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.ESB);
+
+        if (ServiceLoginClient.loginChecker(StatusMonitorConstants.ESB_HOST, serviceID)) {
+            serviceclient.setOptions(opts);
+            try {
+                result = serviceclient.sendReceive(payload);
+
+                if ((result.toString().indexOf("Hello World")) > 0) {
+                    executeProductPlatformSample();
+                } else {
+                    MySQLConnector.insertStats(serviceID, false);
+                    MySQLConnector.insertState(serviceID, false, "Service Invocation failed");
+                }
+
+            } catch (AxisFault e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "Error in executing service";
+                log.error(msg, e);
+            }
+            catch (NullPointerException e) {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, e.getMessage());
+                String msg = "NPE in executing the service";
+                log.error(msg, e);
+            }
+        }
+    }
+
+
+    private static boolean executeProductPlatformSample() throws IOException, SQLException, ParseException {
+        Boolean sampleStatus = false;
+        String payload = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
+                "   <soapenv:Header/>\n" +
+                "   <soapenv:Body/>\n" +
+                "</soapenv:Envelope>";
+        String action = "getAllCategories";
+
+        try {
+            OMElement result = null;
+            result = sendRequest(payload, action, new EndpointReference(
+                    StatusMonitorConstants.ESB_HTTP + ":" + StatusMonitorConstants.ESB_NHTTP_PORT +
+                            StatusMonitorAgentConstants.TENANT_SERVICES +
+                            sampleTenantConfigBean.getTenant() +
+                            "/ProductService"));
+
+            if ((result.toString().indexOf("Compact Lens-Shutter Cameras")) > 0) {
+                executeAdminServicePlatformSample();
+                sampleStatus = true;
+            } else {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, "Platform sample ProductService invocation failed");
+            }
+
+        } catch (AxisFault e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, "Platform sample: " + e.getMessage());
+            String msg = "Error in executing the product platform sample";
+            log.error(msg, e);
+        }
+        catch (NullPointerException e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, "Platform sample: " + e.getMessage());
+            String msg = "NPE in executing the product platform sample";
+            log.error(msg, e);
+        } catch (XMLStreamException e) {
+            String msg = "XMLStream exception in executing the product platform sample";
+            log.error(msg, e);
+        }
+        return sampleStatus;
+    }
+
+    private static boolean executeAdminServicePlatformSample() throws IOException, SQLException, ParseException {
+        Boolean sampleStatus = false;
+        int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.ESB);
+        String payload = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
+                "   <soapenv:Header/>\n" +
+                "   <soapenv:Body/>\n" +
+                "</soapenv:Envelope>";
+        String action = "getAllCategories";
+
+        try {
+            OMElement result;
+            result = sendRequest(payload, action, new EndpointReference(
+                    StatusMonitorConstants.ESB_HTTP + ":" + StatusMonitorConstants.ESB_NHTTP_PORT +
+                            StatusMonitorAgentConstants.TENANT_SERVICES +
+                            sampleTenantConfigBean.getTenant() +
+                            "/AdminService"));
+
+            if ((result.toString().indexOf("Compact Lens-Shutter Cameras")) > 0) {
+                sampleStatus = true;
+                MySQLConnector.insertStats(serviceID, true);
+                MySQLConnector.insertState(serviceID, true, "");
+            } else {
+                MySQLConnector.insertStats(serviceID, false);
+                MySQLConnector.insertState(serviceID, false, "Platform sample AdminService invocation failed");
+            }
+
+        } catch (AxisFault e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState( serviceID, false, "Platform sample AdminService: " + e.getMessage());
+            String msg = "Executing Admin Service Platform Sample failed";
+            log.error(msg, e);
+        }
+        catch (NullPointerException e) {
+            MySQLConnector.insertStats(serviceID, false);
+            MySQLConnector.insertState(serviceID, false, "Platform sample AdminService: " + e.getMessage());
+            String msg = "NPE in executing the admin service platform sample";
+            log.error(msg, e);
+        } catch (XMLStreamException e) {
+            String msg = "XMLStreamException in executing the admin service platform sample";
+            log.error(msg, e);
+        }
+
+        return sampleStatus;
+    }
+
+    private static OMElement sendRequest(String payloadStr, String action, EndpointReference targetEPR)
+            throws XMLStreamException, AxisFault {
+        OMElement payload = AXIOMUtil.stringToOM(payloadStr);
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setAction("urn:" + action); //since soapAction = ""
+
+        //Blocking invocation
+        ServiceClient sender = new ServiceClient();
+        sender.setOptions(options);
+        if (log.isDebugEnabled()) {
+            log.debug("Request: "+ payload.toString());
+        }
+        OMElement result = sender.sendReceive(payload);
+        if (log.isDebugEnabled()) {
+            log.debug("Response:" + payload.toString());
+        }
+
+        return result;
+    }
+}