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:07 UTC
[3/7] Applying 0001-Refactor-status-monitor-module.patch
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ESBServerClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ESBServerClient.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ESBServerClient.java
deleted file mode 100644
index b722d32..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ESBServerClient.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
-* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.wso2.carbon.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.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.status.monitor.agent.clients.common.ServiceLoginClient;
-import org.wso2.carbon.status.monitor.agent.constants.StatusMonitorAgentConstants;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.StatusMonitorConfigurationBuilder;
-import org.wso2.carbon.status.monitor.core.beans.AuthConfigBean;
-import org.wso2.carbon.status.monitor.core.beans.SampleTenantConfigBean;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.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;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GadgetServerClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GadgetServerClient.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GadgetServerClient.java
deleted file mode 100644
index 97b3c55..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GadgetServerClient.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.wso2.carbon.status.monitor.agent.clients.service;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.registry.app.RemoteRegistry;
-import org.wso2.carbon.registry.core.Resource;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.status.monitor.agent.clients.common.ServiceLoginClient;
-import org.wso2.carbon.status.monitor.agent.constants.StatusMonitorAgentConstants;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.StatusMonitorConfigurationBuilder;
-import org.wso2.carbon.status.monitor.core.beans.AuthConfigBean;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.status.monitor.core.jdbc.MySQLConnectionInitializer;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.sql.SQLException;
-import java.text.ParseException;
-
-/**
- * Status Monitor Agent client class for Gadget Server
- */
-public class GadgetServerClient extends Thread{
-
- private static final Log log = LogFactory.getLog(GadgetServerClient.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);
- }
- }
- }
-
- static RemoteRegistry registry = null;
-
- private static void executeService() throws IOException, SQLException, ParseException {
- int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.GADGET);
-
- if (ServiceLoginClient.loginChecker(StatusMonitorConstants.GADGETS_HOST, serviceID)) {
- try {
- registry = new RemoteRegistry(new URL(StatusMonitorConstants.GADGETS_HTTP +
- "/t/" + authConfigBean.getTenant() + "/registry"),
- authConfigBean.getUserName(), authConfigBean.getPassword());
- } catch (RegistryException e) {
- log.error(e);
- } catch (MalformedURLException e) {
- log.error(e);
- }
-
- /*get resource */
- try {
- Resource r2 = registry.get(StatusMonitorAgentConstants.GS_SAMPLE_TEST_RESOURCE_PATH);
- if(log.isDebugEnabled()) {
- log.debug("MediaType in the executeService() of GadgetServerClient in Status" +
- " Monitor Agent: " + r2.getMediaType());
- }
-
- if (r2.getMediaType().equalsIgnoreCase("application/vnd.wso2-gadget+xml")) {
- MySQLConnector.insertStats(serviceID, true);
- MySQLConnector.insertState(serviceID, true, "");
- }
- } catch (RegistryException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "Exception in executing the service for GadgetServerClient - Status Monitor Agent";
- log.error(msg, e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GovernanceRegistryServerClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GovernanceRegistryServerClient.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GovernanceRegistryServerClient.java
deleted file mode 100644
index eb25db7..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/GovernanceRegistryServerClient.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
-* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.wso2.carbon.status.monitor.agent.clients.service;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.registry.app.RemoteRegistry;
-import org.wso2.carbon.registry.core.Resource;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.status.monitor.agent.clients.common.ServiceLoginClient;
-import org.wso2.carbon.status.monitor.agent.constants.StatusMonitorAgentConstants;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.StatusMonitorConfigurationBuilder;
-import org.wso2.carbon.status.monitor.core.beans.AuthConfigBean;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.status.monitor.core.jdbc.MySQLConnectionInitializer;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.sql.SQLException;
-import java.text.ParseException;
-
-/**
- * Status Monitor Agent client class for Governance Registry
- */
-public class GovernanceRegistryServerClient extends Thread{
- private static final Log log = LogFactory.getLog(GovernanceRegistryServerClient.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);
- }
- }
- }
-
- static RemoteRegistry registry = null;
-
- private static void executeService() throws IOException, SQLException, ParseException {
- boolean getValue = false;
- boolean putValue = false;
- boolean deleteValue = false;
- int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.GOVERNANCE);
-
- if (ServiceLoginClient.loginChecker(StatusMonitorConstants.GOVERNANCE_HOST, serviceID)) {
- try {
-
- registry = new RemoteRegistry(new URL(StatusMonitorConstants.GOVERNANCE_HTTP +
- "/t/" + authConfigBean.getTenant() + "/registry"),
- authConfigBean.getUserName(), authConfigBean.getPassword());
- } catch (RegistryException e) {
- log.error(e);
- } catch (MalformedURLException e) {
- log.error(e);
- } catch (Exception e) {
- log.error(e);
- }
-
- /*put resource */
- Resource r1;
-
- try {
- r1 = registry.newResource();
- r1.setContent("test content".getBytes());
- r1.setMediaType("text/plain");
- String pathValue = registry.put(
- StatusMonitorAgentConstants.GREG_SAMPLE_TEST_RESOURCE_PATH, r1);
-
- if (pathValue.equalsIgnoreCase(
- StatusMonitorAgentConstants.GREG_SAMPLE_TEST_RESOURCE_PATH)) {
- putValue = true;
- }
- } catch (RegistryException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- log.warn(e);
- } catch (Exception e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- log.warn(e);
- }
-
- /*get resource */
- try {
- if (putValue) {
- Resource r2 = registry.get(
- StatusMonitorAgentConstants.GREG_SAMPLE_TEST_RESOURCE_PATH);
- if (log.isDebugEnabled()) {
- log.debug("Media Type: " + r2.getMediaType());
- }
-
- if (r2.getMediaType().equalsIgnoreCase("text/plain")) {
- getValue = true;
- }
- }
- } catch (RegistryException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- log.warn(e);
- } catch (Exception e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- log.warn(e);
- }
-
- /*Delete resource */
- try {
- if (getValue) {
- registry.delete(StatusMonitorAgentConstants.GREG_SAMPLE_TEST_RESOURCE_PATH);
-
- if (!registry.resourceExists(
- StatusMonitorAgentConstants.GREG_SAMPLE_TEST_RESOURCE_PATH)) {
- deleteValue = true;
- }
- }
-
- } catch (RegistryException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- log.warn(e);
- } catch (Exception e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- log.warn(e);
- }
-
- //write to mysql db
- try {
- if (getValue & putValue & deleteValue) {
- if (log.isDebugEnabled()) {
- log.debug("Governance Registry Status Monitor agent: Writing to the database");
- }
- MySQLConnector.insertStats(serviceID, true);
- MySQLConnector.insertState(serviceID, true, "");
- }
- } catch (SQLException e) {
- String msg = "Error in writing to the database for Governance Registry - status monitor agent";
- log.error(msg, e);
- }
- }
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/IdentityServerClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/IdentityServerClient.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/IdentityServerClient.java
deleted file mode 100644
index bceeb45..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/IdentityServerClient.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.wso2.carbon.status.monitor.agent.clients.service;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
-import org.wso2.carbon.status.monitor.agent.constants.StatusMonitorAgentConstants;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.StatusMonitorConfigurationBuilder;
-import org.wso2.carbon.status.monitor.core.beans.AuthConfigBean;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.status.monitor.core.jdbc.MySQLConnectionInitializer;
-
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-
-/**
- * Status Monitor Agent client class for Identity Server
- */
-public class IdentityServerClient extends Thread{
- private static final Log log = LogFactory.getLog(IdentityServerClient.class);
- private static 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);
- }
- }
- }
-
- private static void executeService() throws SQLException, IOException {
-
- System.setProperty(StatusMonitorAgentConstants.TRUST_STORE, authConfigBean.getJksLocation());
- System.setProperty(StatusMonitorAgentConstants.TRUST_STORE_PASSWORD, "wso2carbon");
- System.setProperty(StatusMonitorAgentConstants.TRUST_STORE_TYPE, "JKS");
-
- File newFile = new File(authConfigBean.getJksLocation());
- if(log.isDebugEnabled()){
- log.debug("Canonical Path: " + newFile.getCanonicalPath());
- }
-
- int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.IDENTITY);
- String authenticationServiceURL = StatusMonitorConstants.IDENTITY_HTTPS +
- StatusMonitorAgentConstants.AUTHENTICATION_ADMIN_PATH;
- AuthenticationAdminStub authenticationAdminStub;
- try {
- authenticationAdminStub = new AuthenticationAdminStub(authenticationServiceURL);
- ServiceClient client = authenticationAdminStub._getServiceClient();
- Options options = client.getOptions();
- options.setManageSession(true);
-
- Boolean status;
- status = authenticationAdminStub.login(authConfigBean.getUserName(),
- authConfigBean.getPassword(), StatusMonitorConstants.IDENTITY_HOST);
- ServiceContext serviceContext = authenticationAdminStub.
- _getServiceClient().getLastOperationContext().getServiceContext();
- // String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
-
- if (status) {
- MySQLConnector.insertStats(serviceID, true);
- MySQLConnector.insertState(serviceID, true, "");
- }
- } catch (AxisFault e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "Fault in executing the service for IS client - Status Monitor Agent";
- log.warn(msg, e);
-
- } catch (Exception e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "Exception in executing the service for IS client - Status Monitor Agent";
- log.warn(msg, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ManagerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ManagerServiceClient.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ManagerServiceClient.java
deleted file mode 100644
index 2f225e0..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/ManagerServiceClient.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wso2.carbon.status.monitor.agent.clients.service;
-
-import org.apache.axis2.client.Options;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
-import org.wso2.carbon.status.monitor.agent.constants.StatusMonitorAgentConstants;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.StatusMonitorConfigurationBuilder;
-import org.wso2.carbon.status.monitor.core.beans.AuthConfigBean;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.status.monitor.core.jdbc.MySQLConnectionInitializer;
-
-import java.io.IOException;
-import java.sql.SQLException;
-
-/**
- * Status Monitor Agent client class for Stratos Manager
- */
-public class ManagerServiceClient extends Thread{
-
- private static final Log log = LogFactory.getLog(ManagerServiceClient.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);
- }
- }
- }
-
- private static void executeService() throws SQLException, IOException {
-
- System.setProperty(StatusMonitorAgentConstants.TRUST_STORE, authConfigBean.getJksLocation());
- System.setProperty(StatusMonitorAgentConstants.TRUST_STORE_PASSWORD, "wso2carbon");
- System.setProperty(StatusMonitorAgentConstants.TRUST_STORE_TYPE, "JKS");
-
- String userName = authConfigBean.getUserName();
- String password = authConfigBean.getPassword();
- int serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.MANAGER);
- String authenticationServiceURL = StatusMonitorConstants.MANAGER_HTTPS +
- StatusMonitorAgentConstants.AUTHENTICATION_ADMIN_PATH;
- AuthenticationAdminStub authenticationAdminStub;
- try {
- authenticationAdminStub = new AuthenticationAdminStub(authenticationServiceURL);
- ServiceClient client = authenticationAdminStub._getServiceClient();
- Options options = client.getOptions();
- options.setManageSession(true);
-
- Boolean status;
- status = authenticationAdminStub.login(userName, password,
- StatusMonitorConstants.MANAGER_HOST);
- ServiceContext serviceContext = authenticationAdminStub.
- _getServiceClient().getLastOperationContext().getServiceContext();
- // String sessionCookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING);
-
- if (status) {
- MySQLConnector.insertStats(serviceID, true);
- MySQLConnector.insertState(serviceID, true, "");
- }
- } catch (AxisFault e) {
- MySQLConnector.insertStats(serviceID, false);
-
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "Fault in executing the service - Status Monitor Agent for Manager";
- log.warn(msg, e);
- } catch (Exception e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "Exception in executing the service - Status Monitor Agent for Manager";
- log.warn(msg, e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MashupServerClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MashupServerClient.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MashupServerClient.java
deleted file mode 100644
index 0acd932..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MashupServerClient.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
-* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.wso2.carbon.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.wso2.carbon.status.monitor.agent.clients.common.ServiceLoginClient;
-import org.wso2.carbon.status.monitor.agent.constants.StatusMonitorAgentConstants;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.StatusMonitorConfigurationBuilder;
-import org.wso2.carbon.status.monitor.core.beans.AuthConfigBean;
-import org.wso2.carbon.status.monitor.core.beans.SampleTenantConfigBean;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.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 Mashup Server
- */
-public class MashupServerClient extends Thread{
-
- private static final Log log = LogFactory.getLog(MashupServerClient.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://services.mashup.wso2.org/schemaTest1", "ns1");
- OMElement method = fac.createOMElement("echoJSString", omNs);
- OMElement value = fac.createOMElement("param", null);
- value.addChild(fac.createOMText(value, "Hello World"));
- method.addChild(value);
- return method;
- }
-
- private static void executeService() throws IOException, SQLException, ParseException {
-
- serviceID = MySQLConnectionInitializer.getServiceID(StatusMonitorConstants.MASHUP);
-
- OMElement result;
- OMElement payload = createPayLoad();
- ServiceClient serviceclient = new ServiceClient();
- Options opts = new Options();
-
- opts.setTo(new EndpointReference(StatusMonitorConstants.MASHUP_HTTP +
- StatusMonitorAgentConstants.TENANT_SERVICES + authConfigBean.getTenant() +
- "/test123/schemaTest1/ "));
- opts.setAction("http://services.mashup.wso2.org/schemaTest1");
-
- if (ServiceLoginClient.loginChecker(StatusMonitorConstants.MASHUP_HOST, serviceID)) {
- serviceclient.setOptions(opts);
- try {
- result = serviceclient.sendReceive(payload);
-
- if ((result.toString().indexOf("Hello World")) > 0) {
- if (executeRelatedProductsService()) {
- 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 = "Error in executing the service - Status Monitor Agent for MashupServerClient";
- log.warn(msg, e);
- }
- catch (NullPointerException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "NPE in executing the service - Status Monitor Agent for MashupServerClient";
- log.warn(msg, e);
- } catch (XMLStreamException e) {
- String msg = "XMLStreamException in execting the service - Status Monitor Agent for MashupServerClient";
- log.warn(msg, e);
- }
- }
- }
-
- private static Boolean executeRelatedProductsService() throws IOException, SQLException, ParseException, XMLStreamException {
-
- Boolean relatedProductsServiceStatus = false;
-
- OMElement result;
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://services.mashup.wso2.org/RelatedProducts?xsd", "rel");
- OMElement payload = fac.createOMElement("getRelatedProducts", omNs);
- OMElement value1 = fac.createOMElement("query", null);
- OMElement value2 = fac.createOMElement("count", null);
- OMElement value3 = fac.createOMElement("format", null);
- value1.addChild(fac.createOMText(value1, "mac"));
- value2.addChild(fac.createOMText(value2, "2"));
- value3.addChild(fac.createOMText(value3, "xml"));
-
- payload.addChild(value1);
- payload.addChild(value2);
- payload.addChild(value3);
-
- ServiceClient serviceclient = new ServiceClient();
- Options opts = new Options();
- opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
-
- opts.setTo(new EndpointReference(StatusMonitorConstants.MASHUP_HTTP +
- StatusMonitorAgentConstants.TENANT_SERVICES +
- sampleTenantConfigBean.getTenant() + "/carbon/RelatedProducts"));
- opts.setAction("http://services.mashup.wso2.org/RelatedProducts?xsd/RelatedProducts");
-
- serviceclient.setOptions(opts);
- try {
- result = serviceclient.sendReceive(payload);
-
- if ((result.toString().contains("New USB Graphics Drawing Tablet Mouse Pad"))) {
- relatedProductsServiceStatus = true;
- } else {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, "Platform Sample: RelatedProducts service Invocation failed");
- }
- } catch (AxisFault e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, "Platform Sample: RelatedProducts - " + e.getMessage());
- String msg = "Error in executing the related products service";
- log.warn(msg, e);
- }
- catch (NullPointerException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, "Platform Sample: RelatedProducts - " + e.getMessage());
- String msg = "NPE in executing the related products service";
- log.warn(msg, e);
- }
- return relatedProductsServiceStatus;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MessageBrokerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MessageBrokerServiceClient.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MessageBrokerServiceClient.java
deleted file mode 100644
index 02ed7a4..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/clients/service/MessageBrokerServiceClient.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.wso2.carbon.status.monitor.agent.clients.service;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.status.monitor.agent.clients.common.ServiceLoginClient;
-import org.wso2.carbon.status.monitor.agent.constants.StatusMonitorAgentConstants;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.StatusMonitorConfigurationBuilder;
-import org.wso2.carbon.status.monitor.core.beans.AuthConfigBean;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.status.monitor.core.jdbc.MySQLConnectionInitializer;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.sql.SQLException;
-import java.util.Properties;
-
-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.jms.QueueConnectionFactory;
-
-/**
- * Status Monitor Agent client class for Message Broker Service
- */
-public class MessageBrokerServiceClient extends Thread{
-
- private static final Log log = LogFactory.getLog(MessageBrokerServiceClient.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.MESSAGING);
- AuthConfigBean authConfigBean = StatusMonitorConfigurationBuilder.getAuthConfigBean();
-
- String userName = authConfigBean.getUserName();
- tcpUserName = userName.replace('@','!');
-
- //check whether login success
- if (ServiceLoginClient.loginChecker(StatusMonitorConstants.MESSAGING_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()));
-
- if (log.isDebugEnabled()) {
- log.debug("getTCPConnectionURL(username,password) = " +
- getTCPConnectionURL(tcpUserName,
- authConfigBean.getPassword()));
- }
- try {
- InitialContext 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_MB +
- ";{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 (message.getText().equals("Test Message Hello")) {
- MySQLConnector.insertStats(serviceID, true);
- MySQLConnector.insertState(serviceID, true, "");
- } else {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, "Send and retrieve messages failed");
- }
- queueSender.close();
- queueSession.close();
- queueConnection.close();
-
- } catch (JMSException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "Exception in executing the client - " +
- "Status Monitor Agent for MessageBrokerServiceClient";
- log.warn(msg, e);
-
- } catch (NamingException e) {
- MySQLConnector.insertStats(serviceID, false);
- MySQLConnector.insertState(serviceID, false, e.getMessage());
- String msg = "Naming exception in executing the client - " +
- "Status Monitor agent for MessageBrokerServiceClient";
- 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.MESSAGING_HOST).
- append(":").append(StatusMonitorConstants.MESSAGING_DEFAULT_PORT).
- append("'").toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/constants/StatusMonitorAgentConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/constants/StatusMonitorAgentConstants.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/constants/StatusMonitorAgentConstants.java
deleted file mode 100644
index f504af3..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/constants/StatusMonitorAgentConstants.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wso2.carbon.status.monitor.agent.constants;
-
-/**
- * Constants specific to the Status Monitor Agents
- */
-public class StatusMonitorAgentConstants {
-
- /*CEP and MB Specific constants*/
- public static final String QPID_ICF = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
- public static final String CF_NAME_PREFIX = "connectionfactory.";
- public static final String CF_NAME = "qpidConnectionfactory";
-
- public static final String CARBON_CLIENT_ID = "carbon";
- public static final String CARBON_VIRTUAL_HOST_NAME = "carbon";
-
- /*CEP Server client specific constants*/
- public static final String CEP_DEFAULT_PORT = "5674";
- public static final String QUEUE_NAME_CEP = "testQueueQACEP1";
-
- /*MB Server client specific constants*/
- public static final String QUEUE_NAME_MB = "testQueueQA6";
-
- /*Gadget Server specific constants*/
- public static final String GS_SAMPLE_TEST_RESOURCE_PATH =
- "/_system/config/repository/gadget-server/gadgets/AmazonSearchGadget/amazon-search.xml";
- public static final String GREG_SAMPLE_TEST_RESOURCE_PATH =
- "/_system/local/registry.txt";
-
- /*TrustStore and Identity constants*/
- public static final String TRUST_STORE = "javax.net.ssl.trustStore";
- public static final String TRUST_STORE_PASSWORD = "javax.net.ssl.trustStorePassword";
- public static final String TRUST_STORE_TYPE = "javax.net.ssl.trustStoreType";
- public static final String AUTHENTICATION_ADMIN_PATH = "/services/AuthenticationAdmin";
-
- /*Common constants*/
- public static final String TENANT_SERVICES = "/services/t/";
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/StatusMonitorAgentComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/StatusMonitorAgentComponent.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/StatusMonitorAgentComponent.java
deleted file mode 100644
index 765214e..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/StatusMonitorAgentComponent.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* Copyright (c) 2005-2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. 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.wso2.carbon.status.monitor.agent.internal;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.status.monitor.agent.clients.ClientThreadsInitializer;
-import org.wso2.carbon.status.monitor.agent.internal.core.MySQLConnector;
-import org.wso2.carbon.status.monitor.core.exception.StatusMonitorException;
-import org.wso2.carbon.status.monitor.core.util.StatusMonitorUtil;
-import org.wso2.carbon.utils.ConfigurationContextService;
-
-/**
- * @scr.component name="org.wso2.carbon.status.monitor.agent" immediate="true"
- * @scr.reference name="configuration.context.service"
- * interface="org.wso2.carbon.utils.ConfigurationContextService"
- * cardinality="1..1" policy="dynamic"
- * bind="setConfigurationContextService"
- * unbind="unsetConfigurationContextService"
- */
-public class StatusMonitorAgentComponent {
- private static Log log = LogFactory.getLog(StatusMonitorAgentComponent.class);
-
- private static BundleContext bundleContext;
- private static ConfigurationContextService configurationContextService;
-
- protected void activate(ComponentContext context) {
- try {
- bundleContext = context.getBundleContext();
- if (StatusMonitorUtil.getStatusMonitorConfiguration() == null) {
- StatusMonitorUtil.initStatusMonitor(context.getBundleContext());
- if (log.isDebugEnabled()) {
- log.debug("Status Monitor Agent initialized");
- }
- }
- initConnector();
- if (log.isDebugEnabled()) {
- log.debug("******* Status Monitor agent bundle is activated ******* ");
- }
- ClientThreadsInitializer.initializeThreads();
- if (log.isDebugEnabled()) {
- log.debug("Client threads of the Status Monitor Agent are started.");
- }
- } catch (Exception e) {
- log.error("******* Status Monitor agent bundle failed activating ****", e);
- }
- }
-
- private void initConnector() throws StatusMonitorException {
- try {
- MySQLConnector.initialize();
- } catch (Exception e) {
- String msg = "Error in initializing the mysql connection for the health monitoring";
- log.error(msg, e);
- throw new StatusMonitorException(msg, e);
- }
- }
-
- protected void deactivate(ComponentContext context) {
- log.debug("******* Status Monitor bundle is deactivated ******* ");
- }
-
- protected void setConfigurationContextService(
- ConfigurationContextService configurationContextService) {
- log.debug("Receiving ConfigurationContext Service");
- StatusMonitorAgentComponent.
- configurationContextService = configurationContextService;
-
- }
-
- protected void unsetConfigurationContextService(
- ConfigurationContextService configurationContextService) {
- log.debug("Unsetting ConfigurationContext Service");
- setConfigurationContextService(null);
- }
-
- public static BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public static ConfigurationContextService getConfigurationContextService() {
- return configurationContextService;
- }
-
- public static ConfigurationContext getConfigurationContext() {
- if (configurationContextService.getServerConfigContext() == null) {
- return null;
- }
- return configurationContextService.getServerConfigContext();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/core/MySQLConnector.java
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/core/MySQLConnector.java b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/core/MySQLConnector.java
deleted file mode 100644
index 920c5df..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.agent/2.1.0/src/main/java/org/wso2/carbon/status/monitor/agent/internal/core/MySQLConnector.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wso2.carbon.status.monitor.agent.internal.core;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.status.monitor.core.constants.StatusMonitorConstants;
-import org.wso2.carbon.status.monitor.core.jdbc.MySQLConnectionInitializer;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * The class connecting with the mysql database for the Status Monitor Agent
- */
-public class MySQLConnector {
- private static Connection conn;
- private static final Log log = LogFactory.getLog(MySQLConnector.class);
-
- private static List<String> serviceList = new ArrayList<String>();
- private static List<String> statusList = new ArrayList<String>();
-
- private static int resolvedNotFixed = 0;
- private static int resolvedWSLID;
-
- /**
- * gets the sql connection and initializes the MySQLConnectionInitializer.
- *
- * @return Static Connection
- * @throws Exception, throws exception
- */
- public static Connection initialize() throws Exception {
- //gets the sql connection.
- conn = MySQLConnectionInitializer.initialize();
-
- //initializes the service and state lists.
- serviceList = MySQLConnectionInitializer.getServiceList();
- statusList = MySQLConnectionInitializer.getStatusList();
-
- if (log.isDebugEnabled()) {
- log.debug("Connection to the status database is initialized from status.monitor");
- }
-
- return conn;
- }
-
- /**
- * Inserts into the heartbeats table
- *
- * @param serviceID serviceId
- * @param status - status of the service
- * @throws SQLException, if inserting the stats failed
- */
- public static void insertStats(int serviceID, Boolean status) throws SQLException {
- String sql = StatusMonitorConstants.INSERT_STAT_SQL;
- PreparedStatement pstmt = conn.prepareStatement(sql);
- try {
- pstmt.setString(1, null);
- pstmt.setInt(2, serviceID);
- pstmt.setBoolean(3, status);
- pstmt.setString(4, null);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- String msg = "Inserting stats failed";
- log.error(msg, e);
- throw new SQLException(msg, e);
- } finally {
- pstmt.close();
- }
- }
-
- /**
- * Inserting state into the state table.
- *
- * @param serviceID, service id
- * @param status, status of the service {"Up & Running", "Broken", "Down", and "Fixed"}
- * @param details, the service state details.
- * @throws SQLException, if writing to the database failed.
- */
- public static void insertState(int serviceID, Boolean status, String details) throws SQLException {
-
- int stateID = MySQLConnectionInitializer.getServiceStateID(serviceID);
- if (!status) {
- insertStateDetails(stateID, status, details);
- }
-
- // boolean insertStatus = getInsertStatus(serviceID);
- if (/*insertStatus & */(resolvedNotFixed == 0 || resolvedNotFixed == 1)) {
- if (log.isDebugEnabled()) {
- log.debug("Inserting data into the state database");
- }
- String sql = StatusMonitorConstants.INSERT_STATE_SQL;
- PreparedStatement pstmt = conn.prepareStatement(sql);
- try {
-
- pstmt.setString(1, null);
- pstmt.setInt(2, serviceID);
- if (status) {
- pstmt.setInt(3, 1);
- } else {
- pstmt.setInt(3, 2);
- }
- pstmt.setString(4, null);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- String msg = "Inserting state failed";
- log.error(msg, e);
- throw new SQLException(msg, e);
- } finally {
- resolvedWSLID = 0;
- resolvedNotFixed = 0;
- pstmt.close();
- }
- }
-
- if (/*insertStatus & */resolvedNotFixed == 2) {
- String sql = StatusMonitorConstants.UPDATE_STATE_SQL;
- PreparedStatement pstmtUpdate = conn.prepareStatement(sql);
- try {
- if (status) {
- pstmtUpdate.setInt(1, 1);
- } else {
- pstmtUpdate.setInt(1, 2);
- }
- pstmtUpdate.setInt(2, resolvedWSLID);
- pstmtUpdate.executeUpdate();
- } catch (SQLException e) {
- String msg = "Inserting state failed";
- log.error(msg, e);
- throw new SQLException(msg, e);
- } finally {
- resolvedNotFixed = 0;
- resolvedWSLID = 0;
- pstmtUpdate.close();
- }
- }
- }
-
- /**
- * Inserts the state details into the
- *
- * @param serviceStateID, service state ID
- * @param status, boolean: status of the service
- * @param detail, service state detail
- * @throws SQLException, if writing to the database failed.
- */
- public static void insertStateDetails(int serviceStateID, boolean status, String detail) throws SQLException {
-
- String sql = StatusMonitorConstants.INSERT_STATE_DETAIL_SQL;
- PreparedStatement pstmt = conn.prepareStatement(sql);
-
- try {
- pstmt.setString(1, null);
- pstmt.setInt(2, serviceStateID);
- if (!status) {
- pstmt.setString(3, detail);
- }
- pstmt.setString(4, null);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- String msg = "Inserting state details failed";
- log.error(msg, e);
- throw new SQLException(msg, e);
- } finally {
- pstmt.close();
- }
- }
-
- /**
- * Gets the insert status
- *
- * @param ServiceID, id of the service
- * @return true, if insert status was successful
- * @throws SQLException, if writing to the database failed.
- */
- public static boolean getInsertStatus(int ServiceID) throws SQLException {
-
- ResultSet rs = null;
- Statement stmtCon = null;
- boolean currentStatus = false;
- String sqlGetStateID = StatusMonitorConstants.SELECT_ALL_FROM_WSL_SERVICE_STATE_SQL + ServiceID +
- StatusMonitorConstants.ORDER_BY_TIMESTAMP_SQL_DESC_LIMIT_01_SQL;
-
- DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- Date SystemDate = new Date();
- dateFormat.format(SystemDate);
-
- int state_id;
- Date date;
- try {
- stmtCon = conn.createStatement();
- stmtCon.executeQuery(sqlGetStateID);
- rs = stmtCon.getResultSet();
- if (rs != null) {
-
- while (rs.next()) {
- state_id = rs.getInt(StatusMonitorConstants.STATE_ID);
-
- if (state_id == 1) {
- if (log.isDebugEnabled()) {
- log.debug("Up and Running :" + state_id);
- }
- currentStatus = true;
- }
-
- if (state_id == 2) {
- if (log.isDebugEnabled()) {
- log.debug("Broken :" + state_id);
- }
- currentStatus = true;
- }
-
- if (state_id == 4) {
- currentStatus = true;
- date = rs.getTimestamp(StatusMonitorConstants.TIMESTAMP);
- resolvedWSLID = rs.getInt(StatusMonitorConstants.ID);
-
- long currentTimeMs = SystemDate.getTime();
- long resolvedTimeMs = date.getTime();
-
- double time_diff = ((currentTimeMs - resolvedTimeMs) / (double) StatusMonitorConstants.HOUR_IN_MILLIS);
- if (log.isDebugEnabled()) {
- log.debug("State ID: " + state_id);
- }
- if (time_diff >= 1.0) {
- resolvedNotFixed = 1;
- } else {
- resolvedNotFixed = 2;
- }
- }
- }
-
- } else {
- currentStatus = true;
- }
- } catch (SQLException e) {
- String msg = "Getting Insert state failed";
- log.error(msg, e);
- throw new SQLException(msg, e);
- } finally {
- if (rs != null) {
- rs.close();
- }
- if (stmtCon != null) {
- stmtCon.close();
- }
- }
- return currentStatus;
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fcb90b18/components/stratos/status-monitor/org.wso2.carbon.status.monitor.core/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.core/2.1.0/pom.xml b/components/stratos/status-monitor/org.wso2.carbon.status.monitor.core/2.1.0/pom.xml
deleted file mode 100644
index 951da1f..0000000
--- a/components/stratos/status-monitor/org.wso2.carbon.status.monitor.core/2.1.0/pom.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<!--
-# Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
- -->
-<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.wso2.carbon</groupId>
- <artifactId>status-monitor-parent</artifactId>
- <version>2.1.0</version>
-<relativePath>../../pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>org.wso2.carbon.status.monitor.core</artifactId>
- <packaging>bundle</packaging>
- <name>WSO2 Stratos - Stratos Status Monitor Core</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>
- <Export-Package>
- org.wso2.carbon.status.monitor.core.*,
- </Export-Package>
- <Private-Package>
- org.wso2.carbon.status.monitor.core.internal.*,
- </Private-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}",
- *;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.wso2.carbon</groupId>
- <artifactId>org.wso2.carbon.stratos.common</artifactId>
- </dependency>
- </dependencies>
-
-</project>