.classpath
| 1
modules/integration-tests/mod_cluster-plugin-test/pom.xml
| 396 ++++++
modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModClusterPluginIntegrationTest.java
| 229 +++
modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
| 210 ---
modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
| 13
modules/plugins/mod-cluster/pom.xml
| 64 -
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
| 95 +
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
| 102 -
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
| 118 --
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
| 157 ++
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
| 92 +
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterDiscoveryComponent.java
| 70 +
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
| 48
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServiceComponent.java
| 52
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
| 45
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
| 310 -----
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java
| 117 ++
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java
| 105 +
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
| 84 +
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
| 50
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
| 226 +++
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/helper/JBossHelper.java
| 49
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/model/ProxyInfo.java
| 310 +++++
modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
| 576 +++++++---
modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
| 2
modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
| 60 +
26 files changed, 2622 insertions(+), 959 deletions(-)
New commits:
commit 4a043396e8ef668b1daddc0f00cf7e1331552685
Merge: 0540bcd 1810577
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 13:54:43 2011 -0500
Merge branch 'mod_cluster_plugin'
commit 18105773312c888d884f71541f6ed778408aee6e
Merge: fbcf5fd 0b63dbe
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 13:42:57 2011 -0500
Merge branch 'mod_cluster_plugin' of
ssh://git.fedorahosted.org/git/rhq/rhq
into mod_cluster_plugin
commit fbcf5fd1fe8ef454578d00c2617bde54f353ecd7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 00:14:01 2011 -0500
Small refactoring and code formating change to make the class easier to read and
understand.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
index 6abf955..8cff302 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -75,6 +75,7 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
*/
public void setPropertyValue(String propertyName, String value) {
boolean propertyFound = false;
+
for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
Node currentNode = beanNode.getChildNodes().item(i);
@@ -107,8 +108,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
public String getPropertyValue(String propertyName) {
- for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
- Node currentNode = beanNode.getChildNodes().item(i);
+ NodeList nodeList = beanNode.getChildNodes();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node currentNode = nodeList.item(i);
if (currentNode.getNodeName().equals("property")
&& currentNode.getAttributes().getNamedItem("name") !=
null
@@ -126,10 +129,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
private Node getBeanNodeByClass(String className) {
- NodeList result = this.getDocument().getElementsByTagName("bean");
+ NodeList nodeList = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
- for (int i = 1; i < result.getLength(); i++) {
- Node node = result.item(i);
if (node.getAttributes().getNamedItem("class") != null
&&
className.equals(node.getAttributes().getNamedItem("class").getTextContent()))
{
return node;
@@ -144,10 +148,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
private Node getBeanNodeByName(String beanName) {
- NodeList result = this.getDocument().getElementsByTagName("bean");
+ NodeList nodeList = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
- for (int i = 1; i < result.getLength(); i++) {
- Node node = result.item(i);
if (node.getAttributes().getNamedItem("name") != null
&&
beanName.equals(node.getAttributes().getNamedItem("name").getTextContent())) {
return node;
@@ -163,17 +168,17 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
- List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
+ List<Node> nodeList = this.getChildrenNodesByName(beanNode,
"constructor");
- if (tempNodeList.size() > 0) {
- Node constructorNode = tempNodeList.get(0);
+ if (nodeList.size() > 0) {
+ Node constructorNode = nodeList.get(0);
- tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
+ nodeList = this.getChildrenNodesByName(constructorNode,
"parameter");
- if (tempNodeList.size() > 0) {
+ if (nodeList.size() > 0) {
Node parameterNode = null;
- for (Node currentNode : tempNodeList) {
+ for (Node currentNode : nodeList) {
if (currentNode.getAttributes().getNamedItem("class") !=
null
&&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
.getTextContent())) {
@@ -183,10 +188,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
}
if (parameterNode != null) {
- tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
+ nodeList = this.getChildrenNodesByName(parameterNode,
"inject");
- if (tempNodeList.size() > 0) {
- Node injectNode = tempNodeList.get(0);
+ if (nodeList.size() > 0) {
+ Node injectNode = nodeList.get(0);
Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
if (beanAttribute != null) {
@@ -205,17 +210,17 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @param nodeName
* @return
*/
- private List<Node> getChildNodesByName(Node node, String nodeName) {
- List<Node> listOfNodes = new ArrayList<Node>();
+ private List<Node> getChildrenNodesByName(Node node, String nodeName) {
+ List<Node> nodeList = new ArrayList<Node>();
for (int i = 0; i < node.getChildNodes().getLength(); i++) {
Node currentNode = node.getChildNodes().item(i);
if (nodeName.equals(currentNode.getNodeName())) {
- listOfNodes.add(currentNode);
+ nodeList.add(currentNode);
}
}
- return listOfNodes;
+ return nodeList;
}
}
commit 0967165a89cef5268c8dcf6834b71cdefbb31032
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 00:12:49 2011 -0500
Added the proxyInfo metric back to Catalina service context since it is readly
available.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 6f46849..3e523f7 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -374,6 +374,7 @@
</operation>
<metric property="proxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="proxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the
modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified
class name of the managed object" displayType="summary"
dataType="trait" />
<metric property="advertise" displayName="Enable autodiscovery
of httpd servers." displayType="summary" dataType="trait" />
commit 0a99815d01e6cf0d5554cc4c86bcac3b63d3bce6
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 24 11:18:01 2011 -0500
More updates to the naming of each plugin component to match the intent and purpose.
Also updated the integration tests to test each resource type.
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModClusterPluginIntegrationTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModClusterPluginIntegrationTest.java
new file mode 100644
index 0000000..625163b
--- /dev/null
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModClusterPluginIntegrationTest.java
@@ -0,0 +1,229 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.plugin.FileSystemPluginFinder;
+import org.rhq.core.pc.plugin.PluginEnvironment;
+import org.rhq.core.pc.plugin.PluginManager;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/**
+ * @author Stefan Negrea
+ */
+@SuppressWarnings("rawtypes")
+@Test(groups = "modcluster-plugin")
+public class ModClusterPluginIntegrationTest {
+ private Log log = LogFactory.getLog(this.getClass());
+ private static final String PLUGIN_NAME = "mod_cluster";
+
+ @BeforeSuite
+ public void start() {
+ try {
+ File pluginDir = new File("target/testsetup/plugins");
+ PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
+ pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
+ pcConfig.setPluginDirectory(pluginDir);
+
+ pcConfig.setInsideAgent(false);
+ PluginContainer.getInstance().setConfiguration(pcConfig);
+ PluginContainer.getInstance().initialize();
+ log.info("PC started.");
+ for (String plugin :
PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
+ log.info("...Loaded plugin: " + plugin);
+ }
+ } catch (Exception e) {
+ log.info("Error initializing the context", e);
+ }
+ }
+
+ @AfterSuite
+ public void stop() {
+ PluginContainer.getInstance().shutdown();
+ }
+
+ @Test
+ public void testPluginLoad() {
+ PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
+ PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
+ assert (pluginEnvironment != null) : "Null environment, plugin not
loaded";
+ assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
+ }
+
+ @Test(dependsOnMethods = "testPluginLoad")
+ public void testDiscovery() throws Exception {
+ InventoryReport report =
PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
+
+ Thread.sleep(1000);
+
+ report =
PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
+
+ Set<Resource> resources =
findResource(PluginContainer.getInstance().getInventoryManager().getPlatform());
+ log.info("Found " + resources.size() + " mod_cluster and
mod_cluster_context instance(s).");
+
+ assert (resources.size() != 0) : "No mod_cluster or related instances
found.";
+
+ if (resources.size() != 0) {
+ for (Object objectResource : resources.toArray()) {
+ Resource resource = (Resource) objectResource;
+ if (resource.getResourceType().getName().equals("mod_cluster"))
{
+ testMainResource(resource);
+ } else if (resource.getResourceType().getName().equals("Webapp
Context")) {
+ testWebappContext(resource);
+ } else if (resource.getResourceType().getName().equals("HA Service
Configuration")) {
+ testLoadServiceConfiguration(resource);
+ } else if (resource.getResourceType().getName().equals("HA
Service")) {
+ testServiceMeasurement(resource);
+ testServiceMethodInvocation(resource);
+ }
+ }
+ }
+ }
+
+ private void testServiceMethodInvocation(Resource resource) throws
InterruptedException, Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("p1", "1"));
+ config.put(new PropertySimple("p2",
java.util.concurrent.TimeUnit.SECONDS));
+ OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("stop", config);
+ log.info("Result of operation stopContext was: " +
result.getSimpleResult());
+ }
+
+ private void testLoadServiceConfiguration(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+ ((ConfigurationFacet) resourceComponent).loadResourceConfiguration();
+ }
+
+ private void testServiceMeasurement(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof MeasurementFacet) {
+ for (MeasurementDefinition def :
resource.getResourceType().getMetricDefinitions()) {
+ Set<MeasurementScheduleRequest> metricList = new
HashSet<MeasurementScheduleRequest>();
+ metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000,
true, def.getDataType(), null));
+ MeasurementReport report = new MeasurementReport();
+ ((MeasurementFacet) resourceComponent).getValues(report, metricList);
+
+ MeasurementData data = report.getTraitData().iterator().next();
+ assert data != null : "Unable to collect trait [" +
def.getName() + "] on " + resource;
+ log.info("Measurement: " + def.getName() + "=" +
data.getValue());
+ }
+ }
+ }
+
+ private void testMainResource(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof OperationFacet) {
+ OperationResult result = null;
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("reset", new Configuration());
+ log.info("Result of operation test was: " + result);
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("refresh", new Configuration());
+ log.info("Result of operation test was: " + result);
+ }
+ }
+
+ private void testWebappContext(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof OperationFacet) {
+ try {
+ OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation " + "enableContext" +
" was: " + result.getSimpleResult());
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("timeout", "1"));
+ config.put(new PropertySimple("unit",
java.util.concurrent.TimeUnit.SECONDS));
+ result = ((OperationFacet)
resourceComponent).invokeOperation("stopContext", config);
+ log.info("Result of operation stopContext was: " +
result.getSimpleResult());
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation enableContext was: " +
result.getSimpleResult());
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("disableContext", null);
+ log.info("Result of operation disableContext was: " +
result.getSimpleResult());
+
+ } catch (Exception e) {
+ log.info("Operation failed. ", e);
+ }
+
+ }
+ }
+
+ private Set<Resource> findResource(Resource parent) {
+ Set<Resource> found = new HashSet<Resource>();
+
+ Queue<Resource> discoveryQueue = new LinkedList<Resource>();
+ discoveryQueue.add(parent);
+
+ while (!discoveryQueue.isEmpty()) {
+ Resource currentResource = discoveryQueue.poll();
+
+ log.info("Discovered resource of type: " +
currentResource.getResourceType().getName());
+ if (currentResource.getResourceType().getPlugin().equals(PLUGIN_NAME)) {
+ found.add(currentResource);
+ }
+
+ if (currentResource.getChildResources() != null) {
+ for (Resource child : currentResource.getChildResources()) {
+ discoveryQueue.add(child);
+ }
+ }
+ }
+
+ return found;
+ }
+}
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
deleted file mode 100644
index f27b153..0000000
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster.test;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.MeasurementData;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.pc.PluginContainer;
-import org.rhq.core.pc.PluginContainerConfiguration;
-import org.rhq.core.pc.plugin.FileSystemPluginFinder;
-import org.rhq.core.pc.plugin.PluginEnvironment;
-import org.rhq.core.pc.plugin.PluginManager;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-/**
- * @author Stefan Negrea
- */
-@SuppressWarnings("rawtypes")
-@Test(groups = "modcluster-plugin")
-public class ModclusterPluginTest {
- private Log log = LogFactory.getLog(this.getClass());
- private static final String PLUGIN_NAME = "mod_cluster";
-
- @BeforeSuite
- public void start() {
- try {
- File pluginDir = new File("target/testsetup/plugins");
- PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
- pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
- pcConfig.setPluginDirectory(pluginDir);
-
- pcConfig.setInsideAgent(false);
- PluginContainer.getInstance().setConfiguration(pcConfig);
- PluginContainer.getInstance().initialize();
- log.info("PC started.");
- for (String plugin :
PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
- log.info("...Loaded plugin: " + plugin);
- }
- } catch (Exception e) {
- log.info("Error initializing the context", e);
- }
- }
-
- @AfterSuite
- public void stop() {
- PluginContainer.getInstance().shutdown();
- }
-
- @Test
- public void testPluginLoad() {
- PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
- PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
- assert (pluginEnvironment != null) : "Null environment, plugin not
loaded";
- assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
- }
-
- @Test(dependsOnMethods = "testPluginLoad")
- public void testDiscovery() throws Exception {
- InventoryReport report =
PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
- assert report != null;
- log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
-
- Thread.sleep(1000);
-
- report =
PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
- assert report != null;
- log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
-
- List<String> typeNames = new ArrayList<String>() {
- private static final long serialVersionUID = 1L;
-
- {
- add(PLUGIN_NAME);
- add("Webapp Context");
- add("HA Service Configuration");
- add("HA Service");
- }
- };
-
- Set<Resource> resources =
findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
- typeNames);
- log.info("Found " + resources.size() + " mod_cluster and
mod_cluster_context instance(s).");
-
- assert (resources.size() != 0) : "No mod_cluster or related instances
found.";
-
- if (resources.size() != 0) {
- for (Object objectResource : resources.toArray()) {
- Resource resource = (Resource) objectResource;
- if (resource.getResourceType().getName().equals("mod_cluster"))
{
- testResourceMeasurement(resource);
- } else if (resource.getResourceType().getName().equals("Webapp
Context")) {
- testContextOperations(resource);
- } else if (resource.getResourceType().getName().equals("HA Service
Configuration")) {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
- ((ConfigurationFacet)
resourceComponent).loadResourceConfiguration();
- } else if (resource.getResourceType().getName().equals("HA
Service")) {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
-
- Configuration config = new Configuration();
- config.put(new PropertySimple("p1", "1"));
- config.put(new PropertySimple("p2",
java.util.concurrent.TimeUnit.SECONDS));
- OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("stop", config);
- log.info("Result of operation stopContext was: " +
result.getSimpleResult());
- }
- }
- }
- }
-
- private void testResourceMeasurement(Resource resource) throws Exception {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
- if (resourceComponent instanceof MeasurementFacet) {
- for (MeasurementDefinition def :
resource.getResourceType().getMetricDefinitions()) {
- Set<MeasurementScheduleRequest> metricList = new
HashSet<MeasurementScheduleRequest>();
- metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000,
true, def.getDataType(), null));
- MeasurementReport report = new MeasurementReport();
- ((MeasurementFacet) resourceComponent).getValues(report, metricList);
-
- MeasurementData data = report.getTraitData().iterator().next();
- assert data != null : "Unable to collect trait [" +
def.getName() + "] on " + resource;
- log.info("Measurement: " + def.getName() + "=" +
data.getValue());
- }
- }
-
- if (resourceComponent instanceof OperationFacet) {
- OperationResult result = null;
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("reset", new Configuration());
- log.info("Result of operation test was: " + result);
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("disable", new Configuration());
- log.info("Result of operation test was: " +
result.getSimpleResult());
- }
- }
-
- private void testContextOperations(Resource resource) throws Exception {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
-
- if (resourceComponent instanceof OperationFacet) {
- try {
- OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation " + "enableContext" +
" was: " + result.getSimpleResult());
-
- Configuration config = new Configuration();
- config.put(new PropertySimple("timeout", "1"));
- config.put(new PropertySimple("unit",
java.util.concurrent.TimeUnit.SECONDS));
- result = ((OperationFacet)
resourceComponent).invokeOperation("stopContext", config);
- log.info("Result of operation stopContext was: " +
result.getSimpleResult());
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation enableContext was: " +
result.getSimpleResult());
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("disableContext", null);
- log.info("Result of operation disableContext was: " +
result.getSimpleResult());
-
- } catch (Exception e) {
- log.info("Operation failed. ", e);
- }
-
- }
- }
-
- private Set<Resource> findResource(Resource parent, List<String>
typeNames) {
- Set<Resource> found = new HashSet<Resource>();
-
- Queue<Resource> discoveryQueue = new LinkedList<Resource>();
- discoveryQueue.add(parent);
-
- while (!discoveryQueue.isEmpty()) {
- Resource currentResource = discoveryQueue.poll();
-
- log.info("Discovered resource of type: " +
currentResource.getResourceType().getName());
- if (typeNames.contains(currentResource.getResourceType().getName())) {
- found.add(currentResource);
- }
-
- if (currentResource.getChildResources() != null) {
- for (Resource child : currentResource.getChildResources()) {
- discoveryQueue.add(child);
- }
- }
- }
-
- return found;
- }
-}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
index b9ce25e..b854398 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
@@ -89,7 +89,7 @@ public class ClassNameMBeanDiscoveryComponent<T extends
JMXComponent> extends MB
emsConnection.queryBeans(objectName);
bean = emsConnection.getBean(objectName);
}
+
return bean;
}
-
-}
\ No newline at end of file
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
deleted file mode 100644
index 4c8b437..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.bean.EmsBean;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-import org.rhq.plugins.modcluster.helper.JBossHelper;
-
-/**
- * Manages a mod_cluster context entity.
- *
- * @author Stefan Negrea
- */
-@SuppressWarnings({ "rawtypes", "deprecation" })
-public class ContextComponent extends
MBeanResourceComponent<MBeanResourceComponent> {
-
- private static final Log log = LogFactory.getLog(ContextComponent.class);
-
- @Override
- protected EmsBean loadBean() {
- return getResourceContext().getParentResourceComponent().getEmsBean();
- }
-
- @Override
- public AvailabilityType getAvailability() {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
-
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
-
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
-
- ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
-
- int indexOfCurrentContext =
proxyInfo.getAvailableContexts().indexOf(context);
-
- if (indexOfCurrentContext != -1) {
- ProxyInfo.Context currentContext =
proxyInfo.getAvailableContexts().get(indexOfCurrentContext);
-
- if (currentContext.isEnabled()) {
- return AvailabilityType.UP;
- }
- }
-
- return AvailabilityType.DOWN;
- } catch (Exception e) {
- log.info(e);
- return AvailabilityType.DOWN;
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- }
-
- @Override
- public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
- if ("enableContext".equals(name) ||
"disableContext".equals(name) || "stopContext".equals(name)) {
-
- ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
-
- Object[] configuration = null;
- if ("stopContext".equals(name)) {
- configuration = new Object[] { context.getHost(), context.getPath(),
- parameters.getSimple("timeout").getLongValue(),
-
TimeUnit.valueOf(parameters.getSimple("unit").getStringValue()) };
- } else {
- configuration = new Object[] { context.getHost(), context.getPath() };
- }
-
- if (context.getPath().equals("/")) {
- configuration[1] = "ROOT";
- }
-
- log.info(name + " - " + context.getHost() + " " +
context.getPath());
-
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
-
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- Object resultObject =
getEmsBean().getOperation(name).invoke(configuration);
-
- if (resultObject instanceof OperationResult) {
- return (OperationResult) resultObject;
- } else {
- return new OperationResult(String.valueOf(resultObject));
- }
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- }
-
- throw new Exception("Operation " + name + " not available
mod_cluster WebApp service.");
- }
-}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
deleted file mode 100644
index 788cbce..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.mc4j.ems.connection.EmsConnection;
-import org.mc4j.ems.connection.bean.EmsBean;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-import org.rhq.plugins.modcluster.helper.JBossHelper;
-
-/**
- * Discovers mod_cluster contexts from the proxyInfo mbean property.
- *
- * @author Stefan Negrea
- */
-@SuppressWarnings("rawtypes")
-public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBeanResourceComponent> {
-
- private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
- private static final String ENGINE_OBJECT_NAME = "engineObjectName";
-
- /* (non-Javadoc)
- * @see
org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
- */
- public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
- String jvmRoute = this.getJvmRoute(context);
-
- EmsBean configBean = context.getParentResourceComponent().getEmsBean();
- String rawProxyInfo = JBossHelper.getRawProxyInfo(configBean);
-
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
- Set<DiscoveredResourceDetails> entities = new
HashSet<DiscoveredResourceDetails>();
-
- for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
- if (availableContext.getJvmRoute().equals(jvmRoute)) {
- DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(context.getResourceType(),
- availableContext.createKey(), availableContext.createName(), null,
"Webapp Context", null, null);
- entities.add(detail);
- }
- }
-
- return entities;
- }
-
- /**
- * Retrieves the jvm route for the node from the parent context.
- *
- * @param context the discovery context
- * @return node's jvm route
- */
- private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent>
context) {
- Configuration pluginConfig =
context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
- String engineObjectName =
pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue();
- EmsBean engineBean = this.loadBean(engineObjectName,
context.getParentResourceComponent());
-
- return (String)
engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
- }
-
- /**
- * Loads the bean with the given object name.
- *
- * Subclasses are free to override this method in order to load the bean.
- *
- * @param objectName the name of the bean to load
- * @return the bean that is loaded
- */
- protected EmsBean loadBean(String objectName, MBeanResourceComponent context) {
- EmsConnection emsConnection = context.getEmsConnection();
- EmsBean bean = emsConnection.getBean(objectName);
- if (bean == null) {
- // In some cases, this resource component may have been discovered by some
means other than querying its
- // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
- // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
- // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
- // bean before giving up.
- emsConnection.queryBeans(objectName);
- bean = emsConnection.getBean(objectName);
- }
- return bean;
- }
-}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
index 7d5f0dc..0db722e 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.modcluster;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.helper.JBossHelper;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
/**
* @author Stefan Negrea
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
deleted file mode 100644
index 8614402..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Simple parser for the raw proxy information provided by mod_cluster.
- *
- * @author Stefan Negrea
- */
-public class ProxyInfo {
-
- private Map<String, Node> availableNodes = new HashMap<String, Node>();
- private Map<String, Vhost> availableVhosts = new HashMap<String,
Vhost>();
- private List<Context> availableContexts = new
ArrayList<ProxyInfo.Context>();
-
- public ProxyInfo(String rawProxyInfo) {
- parseNodes(rawProxyInfo);
- parseVhosts(rawProxyInfo);
- parseContexts(rawProxyInfo);
- }
-
- private void parseNodes(String rawProxyInfo) {
- Pattern nodePattern = Pattern.compile("Node:.*\n");
- Matcher nodeMatcher = nodePattern.matcher(rawProxyInfo);
- while (nodeMatcher.find()) {
- String rawNode = nodeMatcher.group();
- String[] nodePieces = rawNode.split(",");
-
- String identifier = nodePieces[0];
- identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
-
- String jvmRoute = nodePieces[1];
- jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':') + 1).trim();
-
- availableNodes.put(identifier, new Node(jvmRoute, identifier));
- }
- }
-
- private void parseVhosts(String rawProxyInfo) {
- Pattern vhostPattern = Pattern.compile("Vhost:.*\n");
- Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
- while (vhostMatcher.find()) {
- String rawVhost = vhostMatcher.group();
- String[] vhostPieces = rawVhost.split(",");
-
- String identifier = vhostPieces[0].trim();
- identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
- identifier = identifier.substring(0, identifier.lastIndexOf(":"));
-
- String host = vhostPieces[1].trim();
- host = host.substring(host.indexOf(":") + 1).trim();
-
- availableVhosts.put(identifier, new Vhost(identifier, host));
- }
- }
-
- private void parseContexts(String rawProxyInfo) {
- Pattern contextPattern = Pattern.compile("Context:.*[\n|}]");
- Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
- while (contextMatcher.find()) {
- String rawContext = contextMatcher.group();
- String[] contextPieces = rawContext.split(",");
- String actualContext =
contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
-
- String identifier = contextPieces[0];
- identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
- identifier = identifier.substring(0, identifier.lastIndexOf(":"));
-
- String nodeIdentifier = contextPieces[0];
- nodeIdentifier =
nodeIdentifier.substring(nodeIdentifier.indexOf("[") + 1,
nodeIdentifier.indexOf("]"));
- nodeIdentifier = nodeIdentifier.substring(0,
nodeIdentifier.indexOf(":"));
- String jvmRoute = availableNodes.get(nodeIdentifier).getJvmRoute();
-
- String rawIsEnabled = contextPieces[2];
- rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') +
1).trim();
- boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
-
- Vhost relatedVhost = availableVhosts.get(identifier);
-
- availableContexts.add(new Context(jvmRoute, relatedVhost.getHost(),
actualContext, isEnabled));
- }
- }
-
- public List<Context> getAvailableContexts() {
- return Collections.unmodifiableList(availableContexts);
- }
-
- public List<Vhost> getAvailableVhosts() {
- return Collections.unmodifiableList(new
ArrayList<Vhost>(availableVhosts.values()));
- }
-
- public List<Node> getAvailableNodes() {
- return Collections.unmodifiableList(new
ArrayList<Node>(availableNodes.values()));
- }
-
- public static class Node {
- private String jvmRoute;
- private String nodeId;
-
- public Node(String jvmRoute, String nodeId) {
- this.jvmRoute = jvmRoute;
- this.nodeId = nodeId;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public String getJvmRoute() {
- return jvmRoute;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
- result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Node other = (Node) obj;
- if (jvmRoute == null) {
- if (other.jvmRoute != null)
- return false;
- } else if (!jvmRoute.equals(other.jvmRoute))
- return false;
- if (nodeId == null) {
- if (other.nodeId != null)
- return false;
- } else if (!nodeId.equals(other.nodeId))
- return false;
- return true;
- }
- }
-
- public static class Vhost {
- private String identifier;
- private String host;
-
- public Vhost(String identifier, String host) {
- this.identifier = identifier;
- this.host = host;
- }
-
- public String getIdentifier() {
- return identifier;
- }
-
- public String getHost() {
- return host;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((host == null) ? 0 : host.hashCode());
- result = prime * result + ((identifier == null) ? 0 :
identifier.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Vhost other = (Vhost) obj;
- if (host == null) {
- if (other.host != null)
- return false;
- } else if (!host.equals(other.host))
- return false;
- if (identifier == null) {
- if (other.identifier != null)
- return false;
- } else if (!identifier.equals(other.identifier))
- return false;
- return true;
- }
- }
-
- public static class Context {
- private String path;
- private String host;
- private String jvmRoute;
- private boolean isEnabled;
-
- public Context(String jvmRoute, String host, String path) {
- this(jvmRoute, host, path, false);
- }
-
- public Context(String jvmRoute, String host, String path, boolean isEnabled) {
- this.jvmRoute = jvmRoute;
- this.host = host;
- this.path = path;
- this.isEnabled = isEnabled;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getHost() {
- return host;
- }
-
- public String getJvmRoute() {
- return jvmRoute;
- }
-
- public boolean isEnabled() {
- return isEnabled;
- }
-
- public String createKey() {
- return jvmRoute + ":" + host + ":" + path;
- }
-
- public String createName() {
- return host + ":" + path;
- }
-
- @Override
- public String toString() {
- return createKey();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((host == null) ? 0 : host.hashCode());
- result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Context other = (Context) obj;
- if (host == null) {
- if (other.host != null)
- return false;
- } else if (!host.equals(other.host))
- return false;
- if (jvmRoute == null) {
- if (other.jvmRoute != null)
- return false;
- } else if (!jvmRoute.equals(other.jvmRoute))
- return false;
- if (path == null) {
- if (other.path != null)
- return false;
- } else if (!path.equals(other.path))
- return false;
- return true;
- }
-
- public static Context fromString(String stringRepresentation) throws Exception {
- String parts[] = stringRepresentation.trim().split(":");
- if (parts.length < 3) {
- throw new Exception("Parsing error. Not enough information to create
a context.");
- }
-
- return new Context(parts[0], parts[1], parts[2]);
- }
- }
-}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java
new file mode 100644
index 0000000..6131578
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java
@@ -0,0 +1,117 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
+
+/**
+ * Manages a mod_cluster context entity.
+ *
+ * @author Stefan Negrea
+ */
+@SuppressWarnings({ "rawtypes", "deprecation" })
+public class WebappContextComponent extends
MBeanResourceComponent<MBeanResourceComponent> {
+
+ private static final Log log = LogFactory.getLog(WebappContextComponent.class);
+
+ @Override
+ protected EmsBean loadBean() {
+ return getResourceContext().getParentResourceComponent().getEmsBean();
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
+
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+
+ int indexOfCurrentContext =
proxyInfo.getAvailableContexts().indexOf(context);
+
+ if (indexOfCurrentContext != -1) {
+ ProxyInfo.Context currentContext =
proxyInfo.getAvailableContexts().get(indexOfCurrentContext);
+
+ if (currentContext.isEnabled()) {
+ return AvailabilityType.UP;
+ }
+ }
+
+ return AvailabilityType.DOWN;
+ } catch (Exception e) {
+ log.info(e);
+ return AvailabilityType.DOWN;
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
+ if ("enableContext".equals(name) ||
"disableContext".equals(name) || "stopContext".equals(name)) {
+
+ ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+
+ Object[] configuration = null;
+ if ("stopContext".equals(name)) {
+ configuration = new Object[] { context.getHost(), context.getPath(),
+ parameters.getSimple("timeout").getLongValue(),
+
TimeUnit.valueOf(parameters.getSimple("unit").getStringValue()) };
+ } else {
+ configuration = new Object[] { context.getHost(), context.getPath() };
+ }
+
+ if (context.getPath().equals("/")) {
+ configuration[1] = "ROOT";
+ }
+
+ log.info(name + " - " + context.getHost() + " " +
context.getPath());
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ Object resultObject =
getEmsBean().getOperation(name).invoke(configuration);
+
+ if (resultObject instanceof OperationResult) {
+ return (OperationResult) resultObject;
+ } else {
+ return new OperationResult(String.valueOf(resultObject));
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ throw new Exception("Operation " + name + " not available
mod_cluster WebApp service.");
+ }
+}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java
new file mode 100644
index 0000000..559e1b6
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java
@@ -0,0 +1,105 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
+
+/**
+ * Discovers mod_cluster contexts from the proxyInfo mbean property.
+ *
+ * @author Stefan Negrea
+ */
+@SuppressWarnings("rawtypes")
+public class WebappContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBeanResourceComponent> {
+
+ private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
+ private static final String ENGINE_OBJECT_NAME = "engineObjectName";
+
+ /* (non-Javadoc)
+ * @see
org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
+ */
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ String jvmRoute = this.getJvmRoute(context);
+
+ EmsBean configBean = context.getParentResourceComponent().getEmsBean();
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(configBean);
+
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ Set<DiscoveredResourceDetails> entities = new
HashSet<DiscoveredResourceDetails>();
+
+ for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
+ if (availableContext.getJvmRoute().equals(jvmRoute)) {
+ DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(context.getResourceType(),
+ availableContext.createKey(), availableContext.createName(), null,
"Webapp Context", null, null);
+ entities.add(detail);
+ }
+ }
+
+ return entities;
+ }
+
+ /**
+ * Retrieves the jvm route for the node from the parent context.
+ *
+ * @param context the discovery context
+ * @return node's jvm route
+ */
+ private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent>
context) {
+ Configuration pluginConfig =
context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
+ String engineObjectName =
pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue();
+ EmsBean engineBean = this.loadBean(engineObjectName,
context.getParentResourceComponent());
+
+ return (String)
engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(String objectName, MBeanResourceComponent context) {
+ EmsConnection emsConnection = context.getEmsConnection();
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some
means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
+}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/model/ProxyInfo.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/model/ProxyInfo.java
new file mode 100644
index 0000000..9cedad5
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/model/ProxyInfo.java
@@ -0,0 +1,310 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Simple parser for the raw proxy information provided by mod_cluster.
+ *
+ * @author Stefan Negrea
+ */
+public class ProxyInfo {
+
+ private Map<String, Node> availableNodes = new HashMap<String, Node>();
+ private Map<String, Vhost> availableVhosts = new HashMap<String,
Vhost>();
+ private List<Context> availableContexts = new
ArrayList<ProxyInfo.Context>();
+
+ public ProxyInfo(String rawProxyInfo) {
+ parseNodes(rawProxyInfo);
+ parseVhosts(rawProxyInfo);
+ parseContexts(rawProxyInfo);
+ }
+
+ private void parseNodes(String rawProxyInfo) {
+ Pattern nodePattern = Pattern.compile("Node:.*\n");
+ Matcher nodeMatcher = nodePattern.matcher(rawProxyInfo);
+ while (nodeMatcher.find()) {
+ String rawNode = nodeMatcher.group();
+ String[] nodePieces = rawNode.split(",");
+
+ String identifier = nodePieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
+
+ String jvmRoute = nodePieces[1];
+ jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':') + 1).trim();
+
+ availableNodes.put(identifier, new Node(jvmRoute, identifier));
+ }
+ }
+
+ private void parseVhosts(String rawProxyInfo) {
+ Pattern vhostPattern = Pattern.compile("Vhost:.*\n");
+ Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
+ while (vhostMatcher.find()) {
+ String rawVhost = vhostMatcher.group();
+ String[] vhostPieces = rawVhost.split(",");
+
+ String identifier = vhostPieces[0].trim();
+ identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String host = vhostPieces[1].trim();
+ host = host.substring(host.indexOf(":") + 1).trim();
+
+ availableVhosts.put(identifier, new Vhost(identifier, host));
+ }
+ }
+
+ private void parseContexts(String rawProxyInfo) {
+ Pattern contextPattern = Pattern.compile("Context:.*[\n|}]");
+ Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
+ while (contextMatcher.find()) {
+ String rawContext = contextMatcher.group();
+ String[] contextPieces = rawContext.split(",");
+ String actualContext =
contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
+
+ String identifier = contextPieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String nodeIdentifier = contextPieces[0];
+ nodeIdentifier =
nodeIdentifier.substring(nodeIdentifier.indexOf("[") + 1,
nodeIdentifier.indexOf("]"));
+ nodeIdentifier = nodeIdentifier.substring(0,
nodeIdentifier.indexOf(":"));
+ String jvmRoute = availableNodes.get(nodeIdentifier).getJvmRoute();
+
+ String rawIsEnabled = contextPieces[2];
+ rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') +
1).trim();
+ boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
+
+ Vhost relatedVhost = availableVhosts.get(identifier);
+
+ availableContexts.add(new Context(jvmRoute, relatedVhost.getHost(),
actualContext, isEnabled));
+ }
+ }
+
+ public List<Context> getAvailableContexts() {
+ return Collections.unmodifiableList(availableContexts);
+ }
+
+ public List<Vhost> getAvailableVhosts() {
+ return Collections.unmodifiableList(new
ArrayList<Vhost>(availableVhosts.values()));
+ }
+
+ public List<Node> getAvailableNodes() {
+ return Collections.unmodifiableList(new
ArrayList<Node>(availableNodes.values()));
+ }
+
+ public static class Node {
+ private String jvmRoute;
+ private String nodeId;
+
+ public Node(String jvmRoute, String nodeId) {
+ this.jvmRoute = jvmRoute;
+ this.nodeId = nodeId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
+ result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Node other = (Node) obj;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
+ if (nodeId == null) {
+ if (other.nodeId != null)
+ return false;
+ } else if (!nodeId.equals(other.nodeId))
+ return false;
+ return true;
+ }
+ }
+
+ public static class Vhost {
+ private String identifier;
+ private String host;
+
+ public Vhost(String identifier, String host) {
+ this.identifier = identifier;
+ this.host = host;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((identifier == null) ? 0 :
identifier.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Vhost other = (Vhost) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (identifier == null) {
+ if (other.identifier != null)
+ return false;
+ } else if (!identifier.equals(other.identifier))
+ return false;
+ return true;
+ }
+ }
+
+ public static class Context {
+ private String path;
+ private String host;
+ private String jvmRoute;
+ private boolean isEnabled;
+
+ public Context(String jvmRoute, String host, String path) {
+ this(jvmRoute, host, path, false);
+ }
+
+ public Context(String jvmRoute, String host, String path, boolean isEnabled) {
+ this.jvmRoute = jvmRoute;
+ this.host = host;
+ this.path = path;
+ this.isEnabled = isEnabled;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ public String createKey() {
+ return jvmRoute + ":" + host + ":" + path;
+ }
+
+ public String createName() {
+ return host + ":" + path;
+ }
+
+ @Override
+ public String toString() {
+ return createKey();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Context other = (Context) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
+ if (path == null) {
+ if (other.path != null)
+ return false;
+ } else if (!path.equals(other.path))
+ return false;
+ return true;
+ }
+
+ public static Context fromString(String stringRepresentation) throws Exception {
+ String parts[] = stringRepresentation.trim().split(":");
+ if (parts.length < 3) {
+ throw new Exception("Parsing error. Not enough information to create
a context.");
+ }
+
+ return new Context(parts[0], parts[1], parts[2]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 7e1a79f..6f46849 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -440,7 +440,7 @@
</resource-configuration>
</service>
- <service name="Webapp Context"
discovery="ContextDiscoveryComponent" class="ContextComponent"
description="Webapp Context">
+ <service name="Webapp Context"
discovery="WebappContextDiscoveryComponent"
class="WebappContextComponent" description="Webapp Context">
<operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
<results>
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index 625d8d4..ebadd86 100644
---
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -23,7 +23,7 @@ import java.io.InputStream;
import org.testng.annotations.Test;
-import org.rhq.plugins.modcluster.ProxyInfo;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
/**
* @author Stefan Negrea
commit bf99abb7942ffafbd7aad728698105f8f0fc3a63
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 23 16:12:11 2011 -0500
Renaming mod_cluster components to match their explicit purpose.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
index 0a0a570..b87bfcd 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -30,14 +30,16 @@ import
org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
/**
* @author Stefan Negrea
*
*/
-@SuppressWarnings({ "deprecation" })
-public class FileConfiguredMBeanResourceComponent extends TimeUnitParamResourceComponent
{
+@SuppressWarnings({ "deprecation", "rawtypes" })
+public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent<JMXComponent> {
private static final Log log =
LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServiceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServiceComponent.java
new file mode 100644
index 0000000..d9da81c
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServiceComponent.java
@@ -0,0 +1,52 @@
+package org.rhq.plugins.modcluster;
+
+import java.util.concurrent.TimeUnit;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/**
+ *
+ * @author Stefan Negrea
+ */
+public class ModClusterServiceComponent extends FileConfiguredMBeanResourceComponent {
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
+ if (name.toLowerCase().startsWith("ping")) {
+ name = "ping";
+ }
+
+ return super.invokeOperation(name, parameters);
+ }
+
+ @Override
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
+ System.out.println(typeName);
+ if (typeName.equals(TimeUnit.class.getName())) {
+ return TimeUnit.valueOf(propSimple.getStringValue());
+ }
+
+ return super.getPropertyValueAsType(propSimple, typeName);
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
deleted file mode 100644
index c67bf61..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.rhq.plugins.modcluster;
-
-import java.util.concurrent.TimeUnit;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/**
- *
- * @author Stefan Negrea
- */
-public class PolyPingMBeanResourceComponent extends FileConfiguredMBeanResourceComponent
{
-
- @Override
- public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
- if (name.toLowerCase().startsWith("ping")) {
- name = "ping";
- }
-
- return super.invokeOperation(name, parameters);
- }
-
- @Override
- protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
- System.out.println(typeName);
- if (typeName.equals(TimeUnit.class.getName())) {
- return TimeUnit.valueOf(propSimple.getStringValue());
- }
-
- return super.getPropertyValueAsType(propSimple, typeName);
- }
-}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
deleted file mode 100644
index 0296eaf..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.concurrent.TimeUnit;
-
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-
-/**
- * @author Stefan Negrea
- *
- */
-@SuppressWarnings("rawtypes")
-public class TimeUnitParamResourceComponent extends MBeanResourceComponent {
-
- @Override
- protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
- System.out.println(typeName);
- if (typeName.equals(TimeUnit.class.getName())) {
- return TimeUnit.valueOf(propSimple.getStringValue());
- }
-
- return super.getPropertyValueAsType(propSimple, typeName);
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index ed82f7c..7e1a79f 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -27,7 +27,7 @@
<!-- Start - Configuration for HAModClusterService -->
<service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
- class="PolyPingMBeanResourceComponent"
+ class="ModClusterServiceComponent"
supportsManualAdd="true"
description="HA Service Listener" singleton="true">
@@ -199,7 +199,7 @@
<!-- End - Configuration for HAModClusterService -->
<!-- Start - Configuration for ModClusterService -->
- <service name="Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+ <service name="Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="ModClusterServiceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
commit 0218f0b41bfb7e1ae6e6ddb12565c396c7ef813d
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 23 15:39:58 2011 -0500
Updates to support integration with JBoss' mod_cluster module for AS6 and
EAP5.1.x
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index b642573..f27b153 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -112,6 +112,7 @@ public class ModclusterPluginTest {
add(PLUGIN_NAME);
add("Webapp Context");
add("HA Service Configuration");
+ add("HA Service");
}
};
@@ -132,6 +133,15 @@ public class ModclusterPluginTest {
ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
.getResourceComponent(resource);
((ConfigurationFacet)
resourceComponent).loadResourceConfiguration();
+ } else if (resource.getResourceType().getName().equals("HA
Service")) {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("p1", "1"));
+ config.put(new PropertySimple("p2",
java.util.concurrent.TimeUnit.SECONDS));
+ OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("stop", config);
+ log.info("Result of operation stopContext was: " +
result.getSimpleResult());
}
}
}
diff --git
a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
index 6a60a93..8da6a2d 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
@@ -561,15 +561,15 @@ public class MBeanResourceComponent<T extends JMXComponent>
implements Measureme
paramIndex =
Integer.valueOf(propName.substring(propName.indexOf('[') + 1,
propName.indexOf(']')));
if (paramIndex < 0 || paramIndex >= emsParams.size()) {
throw new IllegalStateException("Index [" + paramIndex +
"] specified for parameter of operation ["
- + name + "] on MBean [" + emsBean.getBeanName() +
"] is invalid. The MBean operation takes "
- + emsParams.size() + " parameters.");
+ + name + "] on MBean [" + emsBean.getBeanName() +
"] is invalid. The MBean operation takes "
+ + emsParams.size() + " parameters.");
}
} else {
paramIndex = emsParamIndexesByName.get(propName);
if (paramIndex == null) {
throw new IllegalStateException("Name [" + propName +
"] specified for parameter of operation ["
- + name + "] on MBean [" + emsBean.getBeanName()
- + "] is invalid. The MBean operation does not take a
parameter by that name.");
+ + name + "] on MBean [" + emsBean.getBeanName()
+ + "] is invalid. The MBean operation does not take a
parameter by that name.");
}
}
EmsParameter emsParam = emsParams.get(paramIndex);
@@ -611,7 +611,7 @@ public class MBeanResourceComponent<T extends JMXComponent>
implements Measureme
return resultToReturn;
}
- private Object getPropertyValueAsType(PropertySimple propSimple, String typeName) {
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
Object value;
if (typeName.equals(String.class.getName())) {
value = (propSimple == null) ? null : propSimple.getStringValue();
@@ -626,7 +626,8 @@ public class MBeanResourceComponent<T extends JMXComponent>
implements Measureme
} else if (typeName.equals(Double.class.getName()) ||
typeName.equals(double.class.getName())) {
value = (propSimple == null) ? null : propSimple.getDoubleValue();
} else {
- throw new IllegalStateException("Operation parameter maps to MBean
parameter with an unsupported type (" + typeName + ").");
+ throw new IllegalStateException("Operation parameter maps to MBean
parameter with an unsupported type ("
+ + typeName + ").");
}
// TODO GH: Handle rest of types. (I think i have a mapper for this in mc4j
return value;
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index 35c5b28..3a6deaa 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -31,6 +31,11 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-plugin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index c5343d0..4c8b437 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -90,6 +90,10 @@ public class ContextComponent extends
MBeanResourceComponent<MBeanResourceCompon
configuration = new Object[] { context.getHost(), context.getPath() };
}
+ if (context.getPath().equals("/")) {
+ configuration[1] = "ROOT";
+ }
+
log.info(name + " - " + context.getHost() + " " +
context.getPath());
ClassLoader cl = Thread.currentThread().getContextClassLoader();
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
index ee0369c..0a0a570 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -30,21 +30,20 @@ import
org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.util.exception.ThrowableUtil;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
/**
* @author Stefan Negrea
*
*/
-@SuppressWarnings({ "rawtypes", "deprecation" })
-public class FileConfiguredMBeanResourceComponent extends MBeanResourceComponent {
+@SuppressWarnings({ "deprecation" })
+public class FileConfiguredMBeanResourceComponent extends TimeUnitParamResourceComponent
{
private static final Log log =
LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
private static final String BEAN_CLASS_NAME_PROPERTY = "className";
private static final String DEPENDENCY_BEAN_CLASS_NAME_PROPERTY =
"dependencyClassName";
- private static final String SERVER_HOME_DIR = "jboss.server.home.dir";
+ private static final String SERVER_HOME_DIR = "serverHomeDir";
private static final String CONFIGURATION_FILE_RELATIVE_PATH =
"/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml";
/**
@@ -105,7 +104,7 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
}
private String getServerHomeDirectory() {
- ModclusterServerComponent modClusterComponent = (ModclusterServerComponent)
this.resourceContext
+ ModClusterServerComponent modClusterComponent = (ModClusterServerComponent)
this.resourceContext
.getParentResourceComponent();
PropertySimple property =
modClusterComponent.getResourceContext().getPluginConfiguration()
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
index 496068c..3eb7cbe 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
@@ -36,9 +36,6 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
@SuppressWarnings("rawtypes")
public class LoadMetricDiscoveryComponent extends
MBeanResourceDiscoveryComponent<JMXComponent> {
- /* (non-Javadoc)
- * @see
org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext,
boolean)
- */
@Override
public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<JMXComponent> context,
boolean skipUnknownProps) {
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterDiscoveryComponent.java
new file mode 100644
index 0000000..b9a73b5
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterDiscoveryComponent.java
@@ -0,0 +1,70 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas.JBossASServerComponent;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class ModClusterDiscoveryComponent extends MBeanResourceDiscoveryComponent {
+
+ private final static String JBOSS_SERVER_HOME_DIR = "serverHomeDir";
+
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext context) {
+ Set<DiscoveredResourceDetails> tempSet = super.discoverResources(context);
+
+ for (DiscoveredResourceDetails detail : tempSet) {
+ String serverHomeDirectory =
findServerHomeDirectory(context.getParentResourceComponent());
+ detail.getPluginConfiguration().put(new PropertySimple(JBOSS_SERVER_HOME_DIR,
serverHomeDirectory));
+ }
+
+ return tempSet;
+ }
+
+ @SuppressWarnings("static-access")
+ public String findServerHomeDirectory(ResourceComponent parentResourceComponent) {
+ if (parentResourceComponent instanceof ApplicationServerComponent) {
+ ApplicationServerComponent parentComponent = (ApplicationServerComponent)
parentResourceComponent;
+
+ return
parentComponent.getResourceContext().getPluginConfiguration().getSimple("serverHomeDir")
+ .getStringValue();
+
+ } else if (parentResourceComponent instanceof JBossASServerComponent) {
+ JBossASServerComponent parentComponent = (JBossASServerComponent)
parentResourceComponent;
+
+ return
parentComponent.getPluginConfiguration().getSimple(parentComponent.JBOSS_HOME_DIR_CONFIG_PROP)
+ .getStringValue();
+ }
+
+ return null;
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
new file mode 100644
index 0000000..7d5f0dc
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings({ "rawtypes" })
+public class ModClusterServerComponent extends MBeanResourceComponent {
+
+ @Override
+ public AvailabilityType getAvailability() {
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
+
+ if (rawProxyInfo == null) {
+ return AvailabilityType.DOWN;
+ }
+
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ if (proxyInfo.getAvailableNodes().size() == 0) {
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability();
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
deleted file mode 100644
index 03598e9..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.plugins.jbossas.JBossASServerComponent;
-import org.rhq.plugins.jbossas5.ApplicationServerComponent;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-import org.rhq.plugins.modcluster.helper.JBossHelper;
-
-/**
- * @author Stefan Negrea
- *
- */
-@SuppressWarnings({ "rawtypes" })
-public class ModclusterServerComponent extends MBeanResourceComponent {
-
- private final static String JBOSS_SERVER_HOME_DIR =
"jboss.server.home.dir";
-
- @SuppressWarnings({ "unchecked", "deprecation",
"static-access" })
- @Override
- public void start(ResourceContext context) {
- super.start(context);
-
- String serverHomeDirectory = null;
- if (this.resourceContext.getParentResourceComponent() instanceof
ApplicationServerComponent) {
- ApplicationServerComponent parentComponent = (ApplicationServerComponent)
this.resourceContext
- .getParentResourceComponent();
-
- serverHomeDirectory =
parentComponent.getResourceContext().getPluginConfiguration()
- .getSimple("serverHomeDir").getStringValue();
-
- } else if (this.resourceContext.getParentResourceComponent() instanceof
JBossASServerComponent) {
- JBossASServerComponent parentComponent = (JBossASServerComponent)
this.resourceContext
- .getParentResourceComponent();
-
- serverHomeDirectory = parentComponent.getPluginConfiguration()
- .getSimple(parentComponent.JBOSS_HOME_DIR_CONFIG_PROP).getStringValue();
- }
-
- if (serverHomeDirectory != null) {
- PropertySimple serverHomeDirectoryProperty = null;
- serverHomeDirectoryProperty = new PropertySimple();
- serverHomeDirectoryProperty.setName(JBOSS_SERVER_HOME_DIR);
- serverHomeDirectoryProperty.setStringValue(serverHomeDirectory);
-
this.resourceContext.getPluginConfiguration().put(serverHomeDirectoryProperty);
- }
- };
-
- //private final static String PROXY_INFO_PROPERTY_NAME
-
- /* (non-Javadoc)
- * @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
- */
- @Override
- public AvailabilityType getAvailability() {
- String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
-
- if (rawProxyInfo == null) {
- return AvailabilityType.DOWN;
- }
-
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
- if (proxyInfo.getAvailableNodes().size() == 0) {
- return AvailabilityType.DOWN;
- }
-
- return super.getAvailability();
- }
-}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
index bc54267..c67bf61 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
@@ -1,6 +1,9 @@
package org.rhq.plugins.modcluster;
+import java.util.concurrent.TimeUnit;
+
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.operation.OperationResult;
/*
@@ -36,4 +39,14 @@ public class PolyPingMBeanResourceComponent extends
FileConfiguredMBeanResourceC
return super.invokeOperation(name, parameters);
}
+
+ @Override
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
+ System.out.println(typeName);
+ if (typeName.equals(TimeUnit.class.getName())) {
+ return TimeUnit.valueOf(propSimple.getStringValue());
+ }
+
+ return super.getPropertyValueAsType(propSimple, typeName);
+ }
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
new file mode 100644
index 0000000..0296eaf
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
@@ -0,0 +1,42 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.concurrent.TimeUnit;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings("rawtypes")
+public class TimeUnitParamResourceComponent extends MBeanResourceComponent {
+
+ @Override
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
+ System.out.println(typeName);
+ if (typeName.equals(TimeUnit.class.getName())) {
+ return TimeUnit.valueOf(propSimple.getStringValue());
+ }
+
+ return super.getPropertyValueAsType(propSimple, typeName);
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
index 6c00130..dee2f81 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
@@ -18,11 +18,18 @@
*/
package org.rhq.plugins.modcluster.config;
+import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -38,11 +45,13 @@ public abstract class AbstractConfigurationFile {
public AbstractConfigurationFile(String fileName) throws
ParserConfigurationException, SAXException, IOException {
this.fileName = fileName;
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- this.document = docBuilder.parse(this.getFileName());
+ loadConfiguratonFile();
}
+ abstract void setPropertyValue(String propertyName, String value);
+
+ abstract String getPropertyValue(String propertyName);
+
/**
* @return the fileName
*/
@@ -57,9 +66,19 @@ public abstract class AbstractConfigurationFile {
return document;
}
- abstract void setPropertyValue(String propertyName, String value);
+ public void saveConfigurationFile() throws Exception {
+ File file = new File(this.getFileName());
+ StreamResult result = new StreamResult(file);
+ Source source = new DOMSource(this.getDocument());
- abstract String getPropertyValue(String propertyName);
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.transform(source, result);
+ }
- abstract void saveConfigurationFile() throws Exception;
+ private void loadConfiguratonFile() throws ParserConfigurationException,
SAXException, IOException {
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ this.document = docBuilder.parse(this.getFileName());
+ }
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
index 1d008ee..354fa99 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
@@ -47,11 +47,4 @@ public class JBossWebServerFile extends AbstractConfigurationFile {
// TODO Auto-generated method stub
return null;
}
-
- @Override
- void saveConfigurationFile() throws Exception {
- // TODO Auto-generated method stub
-
- }
-
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
index 45053f7..6abf955 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -19,17 +19,10 @@
package org.rhq.plugins.modcluster.config;
import java.io.IOException;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
@@ -129,22 +122,6 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
}
/**
- * @throws TransformerException
- */
- public void saveConfigurationFile() throws TransformerException {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "no");
-
- //initialize StreamResult with File object to save to file
- StreamResult result = new StreamResult(new StringWriter());
- DOMSource source = new DOMSource(this.getDocument());
- transformer.transform(source, result);
-
- String xmlString = result.getWriter().toString();
- System.out.println(xmlString);
- }
-
- /**
* @param className
* @return
*/
@@ -155,7 +132,6 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
Node node = result.item(i);
if (node.getAttributes().getNamedItem("class") != null
&&
className.equals(node.getAttributes().getNamedItem("class").getTextContent()))
{
-
System.out.println(node.getAttributes().getNamedItem("class").getTextContent());
return node;
}
}
@@ -174,7 +150,6 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
Node node = result.item(i);
if (node.getAttributes().getNamedItem("name") != null
&&
beanName.equals(node.getAttributes().getNamedItem("name").getTextContent())) {
-
System.out.println(node.getAttributes().getNamedItem("name").getTextContent());
return node;
}
}
@@ -243,5 +218,4 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return listOfNodes;
}
-
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 4f3010f..ed82f7c 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -6,7 +6,9 @@
<depends plugin="JMX" />
<service name="mod_cluster"
- discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
+ discovery="ModClusterDiscoveryComponent"
+ class="ModClusterServerComponent"
+ supportsManualAdd="true" description="mod_cluster plugin"
singleton="true">
<runs-inside>
<parent-resource-type name="JBossAS Server"
plugin="JBossAS" />
@@ -17,13 +19,17 @@
<c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*|jboss.web:service=ModCluster" />
<c:simple-property name="engineObjectName"
readOnly="true" default="jboss.web:type=Engine" />
<c:simple-property name="nameTemplate"
default="mod_cluster" />
+ <c:simple-property name="serverHomeDir"/>
</plugin-configuration>
<operation name="reset" displayName="Reset the node"
description="Move this application server out of an error state." />
<operation name="refresh" displayName="Refresh
configuration" description="Refresh configuration for this application
server." />
<!-- Start - Configuration for HAModClusterService -->
- <service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+ <service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
+ class="PolyPingMBeanResourceComponent"
+ supportsManualAdd="true"
+ description="HA Service Listener" singleton="true">
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
@@ -35,18 +41,18 @@
<!-- HA Operations -->
<operation name="disableDomain" displayName="Disable
domain" description="Disables all contexts on each node within the current
domain. If the current domain is null, then all nodes are stopped.">
<results>
- <c:simple-property name="result" description="The result
of the operation" />
+ <c:simple-property name="operationResult"
description="The result of the operation" />
</results>
</operation>
<operation name="enableDomain" displayName="Enable
domain" description="Enable all contexts on each node within the current domain.
If the current domain is null, then all nodes are stopped.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="stopDomain" displayName="Stop domain"
description="Gracefully stops all contexts on each node within the current domain. If
the current domain is null, then all nodes are stopped.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="The number of units of time for which to wait
for all sessions to drain on a given node." />
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:simple-property required="true" name="p1"
type="string" displayName="The number of units of time for which to wait
for all sessions to drain on a given node." />
+ <c:simple-property required="true" name="p2"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
<c:property-options allowCustomValue="false">
<c:option value="MICROSECONDS"
name="MICROSECONDS" />
<c:option value="MILLISECONDS"
name="MILLISECONDS" />
@@ -58,7 +64,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -66,59 +72,60 @@
<operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
<results>
- <c:simple-property name="result" description="Map of
PING_RPS response, grouped by proxy.">
+ <c:simple-property name="operationResult"
description="Map of PING_RPS response, grouped by proxy.">
</c:simple-property>
</results>
</operation>
<operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ <c:simple-property required="true" name="p1"
type="string" displayName="JVM Route of node to ping." />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="pingNodeByAddress" displayName="Ping node by
address"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
- <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
- <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="p2"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="p3"
type="integer" displayName="Port" />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
<operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
+
<operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
<results>
- <c:simple-property name="result" description="The result
of the operation">
+ <c:simple-property name="operationResult"
description="The result of the operation">
</c:simple-property>
</results>
</operation>
<operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
<results>
- <c:simple-property name="result" description="The result
of the operation">
+ <c:simple-property name="operationResult"
description="The result of the operation">
</c:simple-property>
</results>
</operation>
<operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:simple-property required="true" name="p1"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="p2"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
<c:property-options allowCustomValue="false">
<c:option value="MICROSECONDS"
name="MICROSECONDS" />
<c:option value="MILLISECONDS"
name="MILLISECONDS" />
@@ -130,7 +137,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -139,7 +146,7 @@
<metric property="ProxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="processStatusFrequency"
type="integer" description="Process status frequency." />
+ <c:simple-property name="processStatusFrequency"
type="integer" required="false" description="Process status
frequency." />
</resource-configuration>
</service>
@@ -203,56 +210,57 @@
<operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ <c:simple-property required="true" name="p1"
type="string" displayName="JVM Route of node to ping." />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="pingNodeByAddress" displayName="Ping node by
address"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
- <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
- <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="p2"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="p3"
type="integer" displayName="Port" />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
<operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
+
<operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:simple-property required="true" name="p1"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="p2"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
<c:property-options allowCustomValue="false">
<c:option value="MICROSECONDS"
name="MICROSECONDS" />
<c:option value="MILLISECONDS"
name="MILLISECONDS" />
@@ -264,7 +272,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -338,12 +346,12 @@
</operation>
<operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
@@ -361,7 +369,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -396,11 +404,9 @@
<c:simple-property name="nameTemplate" default="Dynamic
Load Balancer Factor" />
</plugin-configuration>
- <metric property="Metrics" displayName="Collected
Metrics" displayType="summary" dataType="trait" />
-
<resource-configuration>
- <c:simple-property name="DecayFactor" type="integer"
description="The number of historical load values used to determine load
factor." />
- <c:simple-property name="History" type="integer"
description="The exponential decay factor for historical load values." />
+ <c:simple-property name="decayFactor" type="integer"
required="false" description="The number of historical load values used to
determine load factor." />
+ <c:simple-property name="history" type="integer"
required="false" description="The exponential decay factor for historical
load values." />
</resource-configuration>
</service>
@@ -424,11 +430,13 @@
<c:simple-property name="nameTemplate" default="Load
Metric" />
</plugin-configuration>
- <metric property="Load" displayName="Load"
category="utilization" description="The current load of this metric as a
percent of the metric's capacity." dataType="measurement" />
+ <metric property="Load" displayName="Load"
category="utilization"
+ description="The current load of this metric as a percent of the
metric's capacity." dataType="measurement"
+ defaultOn="true" displayType="summary"/>
<resource-configuration>
- <c:simple-property name="Weight" type="integer"
description="The significance of this load metric compared to the other
metrics." />
- <c:simple-property name="Capacity" type="double"
description="Used to normalize the value returned by load expressed as a percentage
of the capacity, such that: 0 < (load/capacity) < 1" />
+ <c:simple-property name="weight" type="integer"
description="The significance of this load metric compared to the other
metrics." />
+ <c:simple-property name="capacity" type="double"
description="Used to normalize the value returned by load expressed as a percentage
of the capacity, such that: 0 < (load/capacity) < 1" />
</resource-configuration>
</service>
@@ -436,7 +444,7 @@
<operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation." />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation." />
</results>
</operation>
<operation name="stopContext" displayName="Stop webapp"
description="Gracefully stops this webapp.">
@@ -454,12 +462,12 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="enableContext" displayName="Enable
webapp" description="Enable this webapp.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
index c50b0e6..cba5672 100644
---
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
@@ -28,16 +28,19 @@ public class ServerConfigTest {
public void TestConfig() {
try {
+ //Test simple bean configuration
ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
- System.out.println(config.getPropertyValue("test"));
+ config.setPropertyValue("test", null);
+ config.setPropertyValue("processStatusFrequency", null);
config.saveConfigurationFile();
+ //Test bean configuration with constructor dependency
config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
"org.jboss.modcluster.config.ha.HAModClusterConfig",
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
@@ -45,11 +48,8 @@ public class ServerConfigTest {
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
- System.out.println(config.getPropertyValue("test"));
-
- config.saveConfigurationFile();
-
config.setPropertyValue("test", null);
+ config.setPropertyValue("processStatusFrequency", null);
config.saveConfigurationFile();
} catch (Exception e) {
// TODO Auto-generated catch block
commit 8a35caa7f9b3d2093e7cdd495cf65f4572bca065
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 15 14:59:16 2011 -0500
The JBoss server home directory is now correctly retrieved from the parent resource
component. Included some other minor code tweaks and refactorings.
diff --git a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
index 77a81b2..ba94746 100644
--- a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
+++ b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
@@ -42,7 +42,13 @@
</dependencyManagement>
<dependencies>
-
+ <dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 0a39eab..b642573 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -45,6 +45,7 @@ import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.plugin.FileSystemPluginFinder;
import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
@@ -109,7 +110,8 @@ public class ModclusterPluginTest {
{
add(PLUGIN_NAME);
- add(PLUGIN_NAME + " Webapp Context");
+ add("Webapp Context");
+ add("HA Service Configuration");
}
};
@@ -124,8 +126,12 @@ public class ModclusterPluginTest {
Resource resource = (Resource) objectResource;
if (resource.getResourceType().getName().equals("mod_cluster"))
{
testResourceMeasurement(resource);
- } else {
+ } else if (resource.getResourceType().getName().equals("Webapp
Context")) {
testContextOperations(resource);
+ } else if (resource.getResourceType().getName().equals("HA Service
Configuration")) {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+ ((ConfigurationFacet)
resourceComponent).loadResourceConfiguration();
}
}
}
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index fdc4f37..35c5b28 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -23,6 +23,14 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>log4j</groupId>
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 8e14f9b..c5343d0 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -20,6 +20,8 @@ package org.rhq.plugins.modcluster;
import java.util.concurrent.TimeUnit;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.mc4j.ems.connection.bean.EmsBean;
import org.rhq.core.domain.configuration.Configuration;
@@ -35,6 +37,9 @@ import org.rhq.plugins.modcluster.helper.JBossHelper;
*/
@SuppressWarnings({ "rawtypes", "deprecation" })
public class ContextComponent extends
MBeanResourceComponent<MBeanResourceComponent> {
+
+ private static final Log log = LogFactory.getLog(ContextComponent.class);
+
@Override
protected EmsBean loadBean() {
return getResourceContext().getParentResourceComponent().getEmsBean();
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
index 9b511b3..ee0369c 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -19,6 +19,9 @@
package org.rhq.plugins.modcluster;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -34,11 +37,15 @@ import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
* @author Stefan Negrea
*
*/
-@SuppressWarnings("rawtypes")
+@SuppressWarnings({ "rawtypes", "deprecation" })
public class FileConfiguredMBeanResourceComponent extends MBeanResourceComponent {
+ private static final Log log =
LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
+
private static final String BEAN_CLASS_NAME_PROPERTY = "className";
private static final String DEPENDENCY_BEAN_CLASS_NAME_PROPERTY =
"dependencyClassName";
+ private static final String SERVER_HOME_DIR = "jboss.server.home.dir";
+ private static final String CONFIGURATION_FILE_RELATIVE_PATH =
"/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml";
/**
* This default setup of configuration properties can map to mbean attributes
@@ -46,15 +53,14 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
* @return the configuration of the component
*/
@Override
- @SuppressWarnings("deprecation")
public Configuration loadResourceConfiguration() {
+
Configuration configuration = new Configuration();
ConfigurationDefinition configurationDefinition =
this.resourceContext.getResourceType()
.getResourceConfigurationDefinition();
try {
- ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
- .getPluginConfiguration());
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance();
for (PropertyDefinition property :
configurationDefinition.getPropertyDefinitions().values()) {
if (property instanceof PropertyDefinitionSimple) {
@@ -69,8 +75,7 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
}
}
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.debug("Unable to load mod_cluster configuration file.", e);
}
return configuration;
@@ -84,19 +89,35 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
updateResourceConfiguration(report, false);
}
- private ModClusterBeanFile getModClusterBeanFileInstance(Configuration pluginConfig)
throws Exception {
+ private ModClusterBeanFile getModClusterBeanFileInstance() throws Exception {
+ Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
String beanClassName =
pluginConfig.getSimple(BEAN_CLASS_NAME_PROPERTY).getStringValue();
+ String fileName = this.getServerHomeDirectory() +
CONFIGURATION_FILE_RELATIVE_PATH;
+
if (pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY) != null) {
String dependencyBeanClassName =
pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY)
.getStringValue();
- return new ModClusterBeanFile(dependencyBeanClassName);
+ return new ModClusterBeanFile(beanClassName, dependencyBeanClassName,
fileName);
+ }
+
+ return new ModClusterBeanFile(beanClassName, fileName);
+ }
+
+ private String getServerHomeDirectory() {
+ ModclusterServerComponent modClusterComponent = (ModclusterServerComponent)
this.resourceContext
+ .getParentResourceComponent();
+
+ PropertySimple property =
modClusterComponent.getResourceContext().getPluginConfiguration()
+ .getSimple(SERVER_HOME_DIR);
+
+ if (property != null) {
+ return property.getStringValue();
}
- return new ModClusterBeanFile(beanClassName);
+ return null;
}
- @SuppressWarnings("deprecation")
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report, boolean
ignoreReadOnly) {
ConfigurationDefinition configurationDefinition =
this.getResourceContext().getResourceType()
@@ -106,8 +127,7 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
- .getPluginConfiguration());
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance();
for (String key : report.getConfiguration().getSimpleProperties().keySet())
{
PropertySimple property = report.getConfiguration().getSimple(key);
@@ -127,10 +147,9 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
}
}
- modClusterBeanFile.saveConfigFile();
+ modClusterBeanFile.saveConfigurationFile();
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.debug("Unable to save mod_cluster configuration file.", e);
}
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
index fb944c8..496068c 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
@@ -30,7 +30,7 @@ import org.rhq.plugins.jmx.JMXComponent;
import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
/**
- * @author snegrea
+ * @author Stefan Negrea
*
*/
@SuppressWarnings("rawtypes")
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 2c964c0..03598e9 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,7 +18,11 @@
*/
package org.rhq.plugins.modcluster;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.plugins.jbossas.JBossASServerComponent;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.helper.JBossHelper;
@@ -29,6 +33,38 @@ import org.rhq.plugins.modcluster.helper.JBossHelper;
@SuppressWarnings({ "rawtypes" })
public class ModclusterServerComponent extends MBeanResourceComponent {
+ private final static String JBOSS_SERVER_HOME_DIR =
"jboss.server.home.dir";
+
+ @SuppressWarnings({ "unchecked", "deprecation",
"static-access" })
+ @Override
+ public void start(ResourceContext context) {
+ super.start(context);
+
+ String serverHomeDirectory = null;
+ if (this.resourceContext.getParentResourceComponent() instanceof
ApplicationServerComponent) {
+ ApplicationServerComponent parentComponent = (ApplicationServerComponent)
this.resourceContext
+ .getParentResourceComponent();
+
+ serverHomeDirectory =
parentComponent.getResourceContext().getPluginConfiguration()
+ .getSimple("serverHomeDir").getStringValue();
+
+ } else if (this.resourceContext.getParentResourceComponent() instanceof
JBossASServerComponent) {
+ JBossASServerComponent parentComponent = (JBossASServerComponent)
this.resourceContext
+ .getParentResourceComponent();
+
+ serverHomeDirectory = parentComponent.getPluginConfiguration()
+ .getSimple(parentComponent.JBOSS_HOME_DIR_CONFIG_PROP).getStringValue();
+ }
+
+ if (serverHomeDirectory != null) {
+ PropertySimple serverHomeDirectoryProperty = null;
+ serverHomeDirectoryProperty = new PropertySimple();
+ serverHomeDirectoryProperty.setName(JBOSS_SERVER_HOME_DIR);
+ serverHomeDirectoryProperty.setStringValue(serverHomeDirectory);
+
this.resourceContext.getPluginConfiguration().put(serverHomeDirectoryProperty);
+ }
+ };
+
//private final static String PROXY_INFO_PROPERTY_NAME
/* (non-Javadoc)
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
index 8f5d08b..bc54267 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
@@ -22,6 +22,10 @@ import org.rhq.core.pluginapi.operation.OperationResult;
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/**
+ *
+ * @author Stefan Negrea
+ */
public class PolyPingMBeanResourceComponent extends FileConfiguredMBeanResourceComponent
{
@Override
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
index 4fe5788..6c00130 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
@@ -32,9 +32,6 @@ import org.xml.sax.SAXException;
* @author Stefan Negrea
*/
public abstract class AbstractConfigurationFile {
-
- public static final String SERVER_HOME_DIR = "jboss.server.home.dir";
-
private String fileName;
private Document document;
@@ -60,4 +57,9 @@ public abstract class AbstractConfigurationFile {
return document;
}
+ abstract void setPropertyValue(String propertyName, String value);
+
+ abstract String getPropertyValue(String propertyName);
+
+ abstract void saveConfigurationFile() throws Exception;
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
index 602e52b..1d008ee 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
@@ -36,4 +36,22 @@ public class JBossWebServerFile extends AbstractConfigurationFile {
// TODO Auto-generated constructor stub
}
+ @Override
+ void setPropertyValue(String propertyName, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ String getPropertyValue(String propertyName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ void saveConfigurationFile() throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
index 0e25f26..45053f7 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.modcluster.config;
import java.io.IOException;
@@ -38,24 +37,38 @@ import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
- * @author snegrea
+ * @author Stefan Negrea
*
*/
public class ModClusterBeanFile extends AbstractConfigurationFile {
private Node beanNode;
- public ModClusterBeanFile(String className) throws ParserConfigurationException,
SAXException, IOException {
- super(
-
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+ /**
+ * @param className
+ * @param configurationFile
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public ModClusterBeanFile(String className, String configurationFile) throws
ParserConfigurationException,
+ SAXException, IOException {
+ super(configurationFile);
beanNode = this.getBeanNodeByClass(className);
}
- public ModClusterBeanFile(String className, String constructorArgumentClassName)
+ /**
+ * @param className
+ * @param constructorArgumentClassName
+ * @param configurationFile
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public ModClusterBeanFile(String className, String constructorArgumentClassName,
String configurationFile)
throws ParserConfigurationException, SAXException, IOException {
- super(
-
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+ super(configurationFile);
Node primaryBeanNode = this.getBeanNodeByClass(className);
String dependencyName = this.getBeanFromConstructorArgument(primaryBeanNode,
constructorArgumentClassName);
@@ -63,58 +76,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
beanNode = this.getBeanNodeByName(dependencyName);
}
- private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
- List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
-
- if (tempNodeList.size() > 0) {
- Node constructorNode = tempNodeList.get(0);
-
- tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
-
- if (tempNodeList.size() > 0) {
- Node parameterNode = null;
-
- for (Node currentNode : tempNodeList) {
- if (currentNode.getAttributes().getNamedItem("class") !=
null
- &&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
- .getTextContent())) {
- parameterNode = currentNode;
- break;
- }
- }
-
- if (parameterNode != null) {
- tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
-
- if (tempNodeList.size() > 0) {
- Node injectNode = tempNodeList.get(0);
- Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
-
- if (beanAttribute != null) {
- return beanAttribute.getTextContent();
- }
- }
- }
- }
- }
-
- return null;
- }
-
- private List<Node> getChildNodesByName(Node node, String nodeName) {
- List<Node> listOfNodes = new ArrayList<Node>();
-
- for (int i = 0; i < node.getChildNodes().getLength(); i++) {
- Node currentNode = node.getChildNodes().item(i);
-
- if (nodeName.equals(currentNode.getNodeName())) {
- listOfNodes.add(currentNode);
- }
- }
-
- return listOfNodes;
- }
-
+ /**
+ * @param propertyName
+ * @param value
+ */
public void setPropertyValue(String propertyName, String value) {
boolean propertyFound = false;
for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
@@ -144,6 +109,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
}
}
+ /**
+ * @param propertyName
+ * @return
+ */
public String getPropertyValue(String propertyName) {
for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
Node currentNode = beanNode.getChildNodes().item(i);
@@ -159,7 +128,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return null;
}
- public void saveConfigFile() throws TransformerException {
+ /**
+ * @throws TransformerException
+ */
+ public void saveConfigurationFile() throws TransformerException {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "no");
@@ -172,7 +144,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
System.out.println(xmlString);
}
- public Node getBeanNodeByClass(String className) {
+ /**
+ * @param className
+ * @return
+ */
+ private Node getBeanNodeByClass(String className) {
NodeList result = this.getDocument().getElementsByTagName("bean");
for (int i = 1; i < result.getLength(); i++) {
@@ -187,7 +163,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return null;
}
- public Node getBeanNodeByName(String beanName) {
+ /**
+ * @param beanName
+ * @return
+ */
+ private Node getBeanNodeByName(String beanName) {
NodeList result = this.getDocument().getElementsByTagName("bean");
for (int i = 1; i < result.getLength(); i++) {
@@ -202,4 +182,66 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return null;
}
+ /**
+ * @param beanNode
+ * @param constructorArgumentClassName
+ * @return
+ */
+ private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
+ List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
+
+ if (tempNodeList.size() > 0) {
+ Node constructorNode = tempNodeList.get(0);
+
+ tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
+
+ if (tempNodeList.size() > 0) {
+ Node parameterNode = null;
+
+ for (Node currentNode : tempNodeList) {
+ if (currentNode.getAttributes().getNamedItem("class") !=
null
+ &&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
+ .getTextContent())) {
+ parameterNode = currentNode;
+ break;
+ }
+ }
+
+ if (parameterNode != null) {
+ tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
+
+ if (tempNodeList.size() > 0) {
+ Node injectNode = tempNodeList.get(0);
+ Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
+
+ if (beanAttribute != null) {
+ return beanAttribute.getTextContent();
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param node
+ * @param nodeName
+ * @return
+ */
+ private List<Node> getChildNodesByName(Node node, String nodeName) {
+ List<Node> listOfNodes = new ArrayList<Node>();
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++) {
+ Node currentNode = node.getChildNodes().item(i);
+
+ if (nodeName.equals(currentNode.getNodeName())) {
+ listOfNodes.add(currentNode);
+ }
+ }
+
+ return listOfNodes;
+ }
+
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index fe4ac7d..4f3010f 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -5,7 +5,8 @@
<depends plugin="JMX" />
- <service name="mod_cluster"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
+ <service name="mod_cluster"
+ discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
<runs-inside>
<parent-resource-type name="JBossAS Server"
plugin="JBossAS" />
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
index 4e4aac1..c50b0e6 100644
---
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
@@ -28,27 +28,29 @@ public class ServerConfigTest {
public void TestConfig() {
try {
- ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService");
+ ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
System.out.println(config.getPropertyValue("test"));
- config.saveConfigFile();
+ config.saveConfigurationFile();
config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
- "org.jboss.modcluster.config.ha.HAModClusterConfig");
+ "org.jboss.modcluster.config.ha.HAModClusterConfig",
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
System.out.println(config.getPropertyValue("test"));
- config.saveConfigFile();
+ config.saveConfigurationFile();
config.setPropertyValue("test", null);
- config.saveConfigFile();
+ config.saveConfigurationFile();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
commit eb9e67e2c2115a941044fe5e03782ac524d60550
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Sun Aug 14 12:06:26 2011 -0500
Enable mod_cluster support for JBoss 5&6 with simple and HA configuration
listeners. Also, added metric collections and configuration save to bean file.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
new file mode 100644
index 0000000..b9ce25e
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * Discovers mod_cluster contexts from the proxyInfo mbean property.
+ *
+ * @author Stefan Negrea
+ */
+@SuppressWarnings("rawtypes")
+public class ClassNameMBeanDiscoveryComponent<T extends JMXComponent> extends
MBeanResourceDiscoveryComponent<T> {
+
+ private static final String CLASS_NAME = "className";
+
+ /* (non-Javadoc)
+ * @see
org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext,
boolean)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<T> context,
+ boolean skipUnknownProps) {
+
+ Set<DiscoveredResourceDetails> results = super.discoverResources(context,
skipUnknownProps);
+
+ for (DiscoveredResourceDetails discoveredResource : results) {
+ if (!isBeanConfiguredClassName(context, discoveredResource.getResourceKey()))
{
+ results.remove(discoveredResource);
+ }
+ }
+
+ return results;
+ }
+
+ /**
+ * @param context
+ * @param objectName
+ * @return
+ */
+ public boolean isBeanConfiguredClassName(ResourceDiscoveryContext<T> context,
String objectName) {
+ String className =
context.getDefaultPluginConfiguration().getSimple(CLASS_NAME).getStringValue();
+
+ EmsConnection connection =
context.getParentResourceComponent().getEmsConnection();
+ EmsBean emsBean = loadBean(connection, objectName);
+
+ return className.equals(emsBean.getClassTypeName());
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(EmsConnection emsConnection, String objectName) {
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some
means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
+
+}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 3545fa5..8e14f9b 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -26,6 +26,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
/**
* Manages a mod_cluster context entity.
@@ -44,7 +45,7 @@ public class ContextComponent extends
MBeanResourceComponent<MBeanResourceCompon
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- String rawProxyInfo = (String)
getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
@@ -91,12 +92,16 @@ public class ContextComponent extends
MBeanResourceComponent<MBeanResourceCompon
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
Object resultObject =
getEmsBean().getOperation(name).invoke(configuration);
- return new OperationResult(String.valueOf(resultObject));
+ if (resultObject instanceof OperationResult) {
+ return (OperationResult) resultObject;
+ } else {
+ return new OperationResult(String.valueOf(resultObject));
+ }
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
- throw new Exception("Operation " + name + " not available
mod_cluster_context service");
+ throw new Exception("Operation " + name + " not available
mod_cluster WebApp service.");
}
}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 3d03715..788cbce 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
+ * RHQ Management Platform
* Copyright (C) 2005-2008 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.rhq.plugins.modcluster;
@@ -33,6 +29,7 @@ import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
/**
* Discovers mod_cluster contexts from the proxyInfo mbean property.
@@ -43,7 +40,6 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBeanResourceComponent> {
private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
- private static final String PROXY_INFO_PROPERTY = "proxyInfo";
private static final String ENGINE_OBJECT_NAME = "engineObjectName";
/* (non-Javadoc)
@@ -51,7 +47,9 @@ public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBe
*/
public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
String jvmRoute = this.getJvmRoute(context);
- String rawProxyInfo = this.getRawProxyInfo(context);
+
+ EmsBean configBean = context.getParentResourceComponent().getEmsBean();
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(configBean);
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
Set<DiscoveredResourceDetails> entities = new
HashSet<DiscoveredResourceDetails>();
@@ -59,8 +57,7 @@ public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBe
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
if (availableContext.getJvmRoute().equals(jvmRoute)) {
DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(context.getResourceType(),
- availableContext.createKey(), availableContext.createName(), null,
"mod_cluster Webapp Context",
- null, null);
+ availableContext.createKey(), availableContext.createName(), null,
"Webapp Context", null, null);
entities.add(detail);
}
}
@@ -83,17 +80,6 @@ public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBe
}
/**
- * Retrieves raw proxy configuration from the parent context.
- *
- * @param context the discovery context
- * @return raw proxy configuration
- */
- private String getRawProxyInfo(ResourceDiscoveryContext<MBeanResourceComponent>
context) {
- EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
- return (String)
statsBean.getAttribute(PROXY_INFO_PROPERTY).refresh().toString();
- }
-
- /**
* Loads the bean with the given object name.
*
* Subclasses are free to override this method in order to load the bean.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
new file mode 100644
index 0000000..9b511b3
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -0,0 +1,137 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings("rawtypes")
+public class FileConfiguredMBeanResourceComponent extends MBeanResourceComponent {
+
+ private static final String BEAN_CLASS_NAME_PROPERTY = "className";
+ private static final String DEPENDENCY_BEAN_CLASS_NAME_PROPERTY =
"dependencyClassName";
+
+ /**
+ * This default setup of configuration properties can map to mbean attributes
+ *
+ * @return the configuration of the component
+ */
+ @Override
+ @SuppressWarnings("deprecation")
+ public Configuration loadResourceConfiguration() {
+ Configuration configuration = new Configuration();
+ ConfigurationDefinition configurationDefinition =
this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ try {
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
+ .getPluginConfiguration());
+
+ for (PropertyDefinition property :
configurationDefinition.getPropertyDefinitions().values()) {
+ if (property instanceof PropertyDefinitionSimple) {
+ String value =
modClusterBeanFile.getPropertyValue(property.getName());
+ if (value != null) {
+ configuration.put(new PropertySimple(property.getName(),
value));
+ } else {
+ PropertyDefinitionSimple propertyDefinitionSimple =
(PropertyDefinitionSimple) property;
+ configuration.put(new PropertySimple(property.getName(),
propertyDefinitionSimple
+ .getDefaultValue()));
+ }
+ }
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return configuration;
+ }
+
+ /**
+ * Equivalent to updateResourceConfiguration(report, false);
+ */
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ updateResourceConfiguration(report, false);
+ }
+
+ private ModClusterBeanFile getModClusterBeanFileInstance(Configuration pluginConfig)
throws Exception {
+ String beanClassName =
pluginConfig.getSimple(BEAN_CLASS_NAME_PROPERTY).getStringValue();
+
+ if (pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY) != null) {
+ String dependencyBeanClassName =
pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY)
+ .getStringValue();
+ return new ModClusterBeanFile(dependencyBeanClassName);
+ }
+
+ return new ModClusterBeanFile(beanClassName);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport report, boolean
ignoreReadOnly) {
+ ConfigurationDefinition configurationDefinition =
this.getResourceContext().getResourceType()
+ .getResourceConfigurationDefinition();
+
+ // assume we succeed - we'll set to failure if we can't set all
properties
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+
+ try {
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
+ .getPluginConfiguration());
+
+ for (String key : report.getConfiguration().getSimpleProperties().keySet())
{
+ PropertySimple property = report.getConfiguration().getSimple(key);
+ if (property != null) {
+ try {
+ PropertyDefinitionSimple def =
configurationDefinition.getPropertyDefinitionSimple(property
+ .getName());
+ if (!(ignoreReadOnly && def.isReadOnly())) {
+ modClusterBeanFile.setPropertyValue(property.getName(),
property.getStringValue());
+ }
+ } catch (Exception e) {
+ property.setErrorMessage(ThrowableUtil.getStackAsString(e));
+ report
+ .setErrorMessage("Failed setting resource configuration
- see property error messages for details");
+ log.info("Failure setting MBean Resource configuration value
for " + key, e);
+ }
+ }
+ }
+
+ modClusterBeanFile.saveConfigFile();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
new file mode 100644
index 0000000..fb944c8
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * @author snegrea
+ *
+ */
+@SuppressWarnings("rawtypes")
+public class LoadMetricDiscoveryComponent extends
MBeanResourceDiscoveryComponent<JMXComponent> {
+
+ /* (non-Javadoc)
+ * @see
org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext,
boolean)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<JMXComponent> context,
+ boolean skipUnknownProps) {
+
+ Set<DiscoveredResourceDetails> results = super.discoverResources(context,
skipUnknownProps);
+
+ for (DiscoveredResourceDetails discoveredResource : results) {
+
+ String name = getBeanConfiguredClassName(context,
discoveredResource.getResourceKey());
+
+ name = name.substring(name.lastIndexOf(".") + 1);
+ name = name.substring(0, name.lastIndexOf("LoadMetric"));
+
+ discoveredResource.setResourceName(name);
+ discoveredResource.setResourceDescription("Load Metric");
+ }
+
+ return results;
+ }
+
+ /**
+ * @param context
+ * @param objectName
+ * @return
+ */
+ public String getBeanConfiguredClassName(ResourceDiscoveryContext<JMXComponent>
context, String objectName) {
+ EmsConnection connection =
context.getParentResourceComponent().getEmsConnection();
+ EmsBean emsBean = loadBean(connection, objectName);
+
+ return emsBean.getClassTypeName();
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(EmsConnection emsConnection, String objectName) {
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some
means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 70898ef..2c964c0 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -20,6 +20,7 @@ package org.rhq.plugins.modcluster;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
/**
* @author Stefan Negrea
@@ -28,15 +29,21 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
@SuppressWarnings({ "rawtypes" })
public class ModclusterServerComponent extends MBeanResourceComponent {
+ //private final static String PROXY_INFO_PROPERTY_NAME
+
/* (non-Javadoc)
* @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
*/
@Override
public AvailabilityType getAvailability() {
- String rawProxyInfo = (String)
getEmsBean().getAttribute("proxyInfo").refresh().toString();
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
+
+ if (rawProxyInfo == null) {
+ return AvailabilityType.DOWN;
+ }
- if (proxyInfo.getAvailableContexts().size() == 0) {
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ if (proxyInfo.getAvailableNodes().size() == 0) {
return AvailabilityType.DOWN;
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
new file mode 100644
index 0000000..8f5d08b
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
@@ -0,0 +1,35 @@
+package org.rhq.plugins.modcluster;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+public class PolyPingMBeanResourceComponent extends FileConfiguredMBeanResourceComponent
{
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
+ if (name.toLowerCase().startsWith("ping")) {
+ name = "ping";
+ }
+
+ return super.invokeOperation(name, parameters);
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
new file mode 100644
index 0000000..4fe5788
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.config;
+
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author Stefan Negrea
+ */
+public abstract class AbstractConfigurationFile {
+
+ public static final String SERVER_HOME_DIR = "jboss.server.home.dir";
+
+ private String fileName;
+ private Document document;
+
+ public AbstractConfigurationFile(String fileName) throws
ParserConfigurationException, SAXException, IOException {
+ this.fileName = fileName;
+
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ this.document = docBuilder.parse(this.getFileName());
+ }
+
+ /**
+ * @return the fileName
+ */
+ public String getFileName() {
+ return fileName;
+ }
+
+ /**
+ * @return the doc
+ */
+ public Document getDocument() {
+ return document;
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
new file mode 100644
index 0000000..602e52b
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
@@ -0,0 +1,39 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster.config;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXException;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class JBossWebServerFile extends AbstractConfigurationFile {
+
+ public JBossWebServerFile(String fileName) throws ParserConfigurationException,
SAXException, IOException {
+ super(fileName);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
new file mode 100644
index 0000000..0e25f26
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -0,0 +1,205 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster.config;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @author snegrea
+ *
+ */
+public class ModClusterBeanFile extends AbstractConfigurationFile {
+
+ private Node beanNode;
+
+ public ModClusterBeanFile(String className) throws ParserConfigurationException,
SAXException, IOException {
+ super(
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+
+ beanNode = this.getBeanNodeByClass(className);
+ }
+
+ public ModClusterBeanFile(String className, String constructorArgumentClassName)
+ throws ParserConfigurationException, SAXException, IOException {
+ super(
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+
+ Node primaryBeanNode = this.getBeanNodeByClass(className);
+ String dependencyName = this.getBeanFromConstructorArgument(primaryBeanNode,
constructorArgumentClassName);
+
+ beanNode = this.getBeanNodeByName(dependencyName);
+ }
+
+ private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
+ List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
+
+ if (tempNodeList.size() > 0) {
+ Node constructorNode = tempNodeList.get(0);
+
+ tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
+
+ if (tempNodeList.size() > 0) {
+ Node parameterNode = null;
+
+ for (Node currentNode : tempNodeList) {
+ if (currentNode.getAttributes().getNamedItem("class") !=
null
+ &&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
+ .getTextContent())) {
+ parameterNode = currentNode;
+ break;
+ }
+ }
+
+ if (parameterNode != null) {
+ tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
+
+ if (tempNodeList.size() > 0) {
+ Node injectNode = tempNodeList.get(0);
+ Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
+
+ if (beanAttribute != null) {
+ return beanAttribute.getTextContent();
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private List<Node> getChildNodesByName(Node node, String nodeName) {
+ List<Node> listOfNodes = new ArrayList<Node>();
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++) {
+ Node currentNode = node.getChildNodes().item(i);
+
+ if (nodeName.equals(currentNode.getNodeName())) {
+ listOfNodes.add(currentNode);
+ }
+ }
+
+ return listOfNodes;
+ }
+
+ public void setPropertyValue(String propertyName, String value) {
+ boolean propertyFound = false;
+ for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
+ Node currentNode = beanNode.getChildNodes().item(i);
+
+ if (currentNode.getNodeName().equals("property")
+ && currentNode.getAttributes().getNamedItem("name") !=
null
+ &&
propertyName.equals(currentNode.getAttributes().getNamedItem("name").getTextContent()))
{
+
+ if (value != null) {
+ currentNode.setTextContent(value);
+ } else {
+ beanNode.removeChild(currentNode);
+ }
+
+ propertyFound = true;
+ }
+ }
+
+ if (value != null && !propertyFound) {
+ Node propertyChild = this.getDocument().createElement("property");
+ Attr nameProperty = this.getDocument().createAttribute("name");
+ nameProperty.setValue(propertyName);
+ propertyChild.setTextContent(value);
+ propertyChild.getAttributes().setNamedItem(nameProperty);
+ beanNode.appendChild(propertyChild);
+ }
+ }
+
+ public String getPropertyValue(String propertyName) {
+ for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
+ Node currentNode = beanNode.getChildNodes().item(i);
+
+ if (currentNode.getNodeName().equals("property")
+ && currentNode.getAttributes().getNamedItem("name") !=
null
+ &&
propertyName.equals(currentNode.getAttributes().getNamedItem("name").getTextContent()))
{
+
+ return currentNode.getTextContent();
+ }
+ }
+
+ return null;
+ }
+
+ public void saveConfigFile() throws TransformerException {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "no");
+
+ //initialize StreamResult with File object to save to file
+ StreamResult result = new StreamResult(new StringWriter());
+ DOMSource source = new DOMSource(this.getDocument());
+ transformer.transform(source, result);
+
+ String xmlString = result.getWriter().toString();
+ System.out.println(xmlString);
+ }
+
+ public Node getBeanNodeByClass(String className) {
+ NodeList result = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < result.getLength(); i++) {
+ Node node = result.item(i);
+ if (node.getAttributes().getNamedItem("class") != null
+ &&
className.equals(node.getAttributes().getNamedItem("class").getTextContent()))
{
+
System.out.println(node.getAttributes().getNamedItem("class").getTextContent());
+ return node;
+ }
+ }
+
+ return null;
+ }
+
+ public Node getBeanNodeByName(String beanName) {
+ NodeList result = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < result.getLength(); i++) {
+ Node node = result.item(i);
+ if (node.getAttributes().getNamedItem("name") != null
+ &&
beanName.equals(node.getAttributes().getNamedItem("name").getTextContent())) {
+
System.out.println(node.getAttributes().getNamedItem("name").getTextContent());
+ return node;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/helper/JBossHelper.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/helper/JBossHelper.java
new file mode 100644
index 0000000..364f3ef
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/helper/JBossHelper.java
@@ -0,0 +1,49 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster.helper;
+
+import org.mc4j.ems.connection.bean.EmsBean;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class JBossHelper {
+
+ public static String getRawProxyInfo(EmsBean emsBean) {
+ String rawProxyInfo = null;
+
+ //try first to get the value for JBoss EAP5.x or AS6
+ try {
+ rawProxyInfo = (String)
emsBean.getAttribute("ProxyInfo").refresh().toString();
+ } catch (Exception e) {
+ }
+
+ //if not able to get the value after the first attempt try to get the value for
JBoss 4.2/4.3
+ if (rawProxyInfo == null) {
+ try {
+ rawProxyInfo = (String)
emsBean.getAttribute("proxyInfo").refresh().toString();
+ } catch (Exception e) {
+ }
+ }
+
+ return rawProxyInfo;
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 4846490..fe4ac7d 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,132 +1,466 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<plugin name="mod_cluster"
- displayName="mod_cluster"
- description="Monitoring and management of mod_cluster plugin."
- version="1.0"
- package="org.rhq.plugins.modcluster"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:c="urn:xmlns:rhq-configuration">
+<plugin name="mod_cluster" displayName="mod_cluster"
description="Monitoring and management of mod_cluster plugin."
version="1.0" package="org.rhq.plugins.modcluster"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
<depends plugin="JMX" />
- <service name="mod_cluster"
- discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
- class="ModclusterServerComponent"
- supportsManualAdd="true"
- description="mod_cluster plugin"
- singleton="true">
-
+ <service name="mod_cluster"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
+
<runs-inside>
- <parent-resource-type name="JBossAS Server"
plugin="JBossAS"/>
- <parent-resource-type name="JBossAS5 Server"
plugin="JBossAS5"/>
+ <parent-resource-type name="JBossAS Server"
plugin="JBossAS" />
+ <parent-resource-type name="JBossAS Server"
plugin="JBossAS5" />
</runs-inside>
-
+
<plugin-configuration>
- <c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="engineObjectName"
readOnly="true" default="jboss.web:type=Engine"/>
- <c:simple-property name="nameTemplate"
default="mod_cluster"/>
+ <c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*|jboss.web:service=ModCluster" />
+ <c:simple-property name="engineObjectName"
readOnly="true" default="jboss.web:type=Engine" />
+ <c:simple-property name="nameTemplate"
default="mod_cluster" />
</plugin-configuration>
-
- <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
- <parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout"/>
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
- <c:property-options allowCustomValue="false">
- <c:option value="MICROSECONDS"
name="MICROSECONDS"/>
- <c:option value="MILLISECONDS"
name="MILLISECONDS"/>
- <c:option value="NANOSECONDS"
name="NANOSECONDS"/>
- <c:option value="SECONDS"
name="SECONDS"/>
- <c:option value="HOURS" name="HOURS"/>
- <c:option value="DAYS" name="DAYS"/>
- </c:property-options>
- </c:simple-property>
- </parameters>
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
- <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
- <parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address"/>
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port"/>
- </parameters>
- </operation>
- <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
+
<operation name="reset" displayName="Reset the node"
description="Move this application server out of an error state." />
- <operation name="disable" displayName="Disable all webpapps"
description="Disable all webapps for all virtual hosts of this application
server.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
- <operation name="removeProxy" displayName="Remove a proxy"
description="Remove a proxy.">
- <parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address"/>
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port"/>
- </parameters>
- </operation>
<operation name="refresh" displayName="Refresh
configuration" description="Refresh configuration for this application
server." />
-
- <metric property="proxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
- <metric property="modelerType" displayName="Type of the modeled
resource" displayType="summary" dataType="trait" />
- <metric property="className" displayName="Fully qualified class
name of the managed object" displayType="summary"
dataType="trait" />
- <metric property="advertise" displayName="Enable autodiscovery of
httpd servers." displayType="summary" dataType="trait" />
-
- <resource-configuration>
- <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
- <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the cluster."/>
- <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster."/>
- <c:simple-property name="smax" type="integer"
description="Maximum time on seconds for idle connections above smax."/>
- <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server."/>
- <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery."/>
- <c:simple-property name="stickySessionForce" type="boolean"
description="Return an error when the request cannot be routed to the right
node."/>
- <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer."/>
- <c:simple-property name="flushPackets" type="boolean"
description="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="integer"
description="Connection timeout for communication with the proxy." />
- <c:simple-property name="advertisePort" type="integer"
required="false" description="Multicast port for discovery" />
- <c:simple-property name="advertiseGroupAddress"
type="string" required="false" description="Multicast address for
discovery."/>
- <c:simple-property name="flushWait" type="integer"
description="Time in ms to wait before flushing packets."/>
- <c:simple-property name="ping" type="integer"
description="Time in s to wait for a pong answer to a ping."/>
- </resource-configuration>
-
- <service name="mod_cluster Webapp Context"
- discovery="ContextDiscoveryComponent"
- class="ContextComponent"
- description="mod_cluster webapp context">
-
- <operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation."/>
- </results>
- </operation>
- <operation name="stopContext" displayName="Stop webapp"
description="Gracefully stops this webapp.">
+
+ <!-- Start - Configuration for HAModClusterService -->
+ <service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA
Service" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ha.HAModClusterService" />
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <!-- HA Operations -->
+ <operation name="disableDomain" displayName="Disable
domain" description="Disables all contexts on each node within the current
domain. If the current domain is null, then all nodes are stopped.">
+ <results>
+ <c:simple-property name="result" description="The result
of the operation" />
+ </results>
+ </operation>
+ <operation name="enableDomain" displayName="Enable
domain" description="Enable all contexts on each node within the current domain.
If the current domain is null, then all nodes are stopped.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stopDomain" displayName="Stop domain"
description="Gracefully stops all contexts on each node within the current domain. If
the current domain is null, then all nodes are stopped.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="The number of units of time for which to wait
for all sessions to drain on a given node." />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <!-- Regular Operations -->
+
+ <operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
+ <results>
+ <c:simple-property name="result" description="Map of
PING_RPS response, grouped by proxy.">
+ </c:simple-property>
+ </results>
+ </operation>
+ <operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+ <operation name="pingNodeByAddress" displayName="Ping node by
address"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+
+ <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
+ <results>
+ <c:simple-property name="result" description="The result
of the operation">
+ </c:simple-property>
+ </results>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
+ <results>
+ <c:simple-property name="result" description="The result
of the operation">
+ </c:simple-property>
+ </results>
+ </operation>
+ <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <metric property="MasterNode" displayName="Master Node"
displayType="summary" dataType="trait" />
+ <metric property="ProxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="ProxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
+
+ <resource-configuration>
+ <c:simple-property name="processStatusFrequency"
type="integer" description="Process status frequency." />
+ </resource-configuration>
+ </service>
+
+ <service name="HA Service Configuration"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Configuration" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA Service
Configuration" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ha.HAModClusterService" />
+ <c:simple-property name="dependencyClassName"
readOnly="true"
default="org.jboss.modcluster.config.ha.HAModClusterConfig" />
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <resource-configuration>
+
+ <!-- HA Configuration -->
+ <c:simple-property name="masterPerLoadBalancingGroup"
type="boolean" required="false" description="Enable current node
to be master in the load balancing group." />
+
+ <!-- Handler Configuration -->
+ <c:simple-property name="advertise" type="boolean"
required="false" default="false" description="Enable
autodiscovery of httpd servers." />
+ <c:simple-property name="advertiseGroupAddress"
type="string" description="Multicast address on which to listen for
advertisements." />
+ <c:simple-property name="advertisePort" type="string"
required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseInterface"
type="string" required="false" description="Multicast interface
for discovery" />
+ <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery." />
+ <c:simple-property name="proxyList" type="string"
required="false" description="Comma separated list of address:port listing
the httpd servers where mod_cluster is running." />
+ <c:simple-property name="proxyURL" type="string"
required="false" description="URL prefix to send with commands to
mod_cluster. Default is no prefix." />
+ <c:simple-property name="socketTimeout" type="integer"
required="false" description="Connection timeout for communication with the
proxy." />
+ <c:simple-property name="ssl" type="boolean"
description="Whether to use SSL to communicate with mod_cluster. Note this has
nothing to do with handling of https requests by JBoss Web" />
+ <c:simple-property name="excludedContexts"
type="string" required="false" description="Comma delimited list
of contexts that should *not* be auto-registered with httpd. Contexts may be qualified by
host using a colon, e.g. host1:context1. If no host is defined, localhost is
assumed." />
+ <c:simple-property name="autoEnableContexts"
type="boolean" required="false" default="true"
description="Toggle for context auto-enable during mod_cluster startup." />
+
+ <!-- Node Configuration -->
+ <c:simple-property name="loadBalancingGroup"
type="string" required="false" description="Load balancing
group." />
+ <c:simple-property name="flushPackets" type="boolean"
required="false" description="Allows controlling flusing of packets."
/>
+ <c:simple-property name="flushWait" type="integer"
required="false" description="Time in ms to wait before flushing
packets." />
+ <c:simple-property name="ping" type="integer"
required="false" description="Time in s to wait for a pong answer to a
ping." />
+ <c:simple-property name="smax" type="integer"
required="false" description="Maximum time on seconds for idle connections
above smax." />
+ <c:simple-property name="ttl" type="integer"
required="false" description="TTL" />
+ <c:simple-property name="nodeTimeout" type="integer"
required="false" description="Node timeout" />
+ <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer" />
+
+ <!-- Balancer Configuration -->
+ <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the node." />
+ <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster." />
+ <c:simple-property name="stickySessionForce"
type="boolean" description="Return an error when the request cannot be
routed to the right node." />
+ <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
+ <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server." />
+ </resource-configuration>
+ </service>
+ <!-- End - Configuration for HAModClusterService -->
+
+ <!-- Start - Configuration for ModClusterService -->
+ <service name="Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA
Service" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ModClusterService" />
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+ <operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+ <operation name="pingNodeByAddress" displayName="Ping node by
address"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+
+ <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <metric property="ProxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="ProxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
+ </service>
+
+ <service name="Service Configuration"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Configuration" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA Service
Configuration" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ModClusterService" />
+ <c:simple-property name="dependencyClassName"
readOnly="true" default="org.jboss.modcluster.config.ModClusterConfig"
/>
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <resource-configuration>
+ <!-- Handler Configuration -->
+ <c:simple-property name="advertise" type="boolean"
required="false" default="false" description="Enable
autodiscovery of httpd servers." />
+ <c:simple-property name="advertiseGroupAddress"
type="string" description="Multicast address on which to listen for
advertisements." />
+ <c:simple-property name="advertisePort" type="string"
required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseInterface"
type="string" required="false" description="Multicast interface
for discovery" />
+ <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery." />
+ <c:simple-property name="proxyList" type="string"
required="false" description="Comma separated list of address:port listing
the httpd servers where mod_cluster is running." />
+ <c:simple-property name="proxyURL" type="string"
required="false" description="URL prefix to send with commands to
mod_cluster. Default is no prefix." />
+ <c:simple-property name="socketTimeout" type="integer"
required="false" description="Connection timeout for communication with the
proxy." />
+ <c:simple-property name="ssl" type="boolean"
description="Whether to use SSL to communicate with mod_cluster. Note this has
nothing to do with handling of https requests by JBoss Web" />
+ <c:simple-property name="excludedContexts"
type="string" required="false"
+ description="Comma delimited list of contexts that should *not* be
auto-registered with httpd. Contexts may be qualified by host using a colon, e.g.
host1:context1. If no host is defined, localhost is assumed." />
+ <c:simple-property name="autoEnableContexts"
type="boolean" required="false" default="true"
description="Toggle for context auto-enable during mod_cluster startup." />
+
+ <!-- Node Configuration -->
+ <c:simple-property name="loadBalancingGroup"
type="string" required="false" description="Load balancing
group." />
+ <c:simple-property name="flushPackets" type="boolean"
required="false" description="Allows controlling flusing of packets."
/>
+ <c:simple-property name="flushWait" type="integer"
required="false" description="Time in ms to wait before flushing
packets." />
+ <c:simple-property name="ping" type="integer"
required="false" description="Time in s to wait for a pong answer to a
ping." />
+ <c:simple-property name="smax" type="integer"
required="false" description="Maximum time on seconds for idle connections
above smax." />
+ <c:simple-property name="ttl" type="integer"
required="false" description="TTL" />
+ <c:simple-property name="nodeTimeout" type="integer"
required="false" description="Node timeout" />
+ <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer" />
+
+ <!-- Balancer Configuration -->
+ <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the node." />
+ <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster." />
+ <c:simple-property name="stickySessionForce"
type="boolean" description="Return an error when the request cannot be
routed to the right node." />
+ <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
+ <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server." />
+ </resource-configuration>
+ </service>
+ <!-- End - Configuration for ModClusterService -->
+
+ <service name="Catalina Service"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="Catalina Service Listener" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*" />
+ <c:simple-property name="nameTemplate" default="mod_cluster
Catalina Listener" />
+ </plugin-configuration>
+
+ <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <metric property="proxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="modelerType" displayName="Type of the
modeled resource" displayType="summary" dataType="trait" />
+ <metric property="className" displayName="Fully qualified
class name of the managed object" displayType="summary"
dataType="trait" />
+ <metric property="advertise" displayName="Enable autodiscovery
of httpd servers." displayType="summary" dataType="trait" />
+
+ <resource-configuration>
+ <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
+ <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the cluster." />
+ <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster." />
+ <c:simple-property name="smax" type="integer"
description="Maximum time on seconds for idle connections above smax." />
+ <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server." />
+ <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery." />
+ <c:simple-property name="stickySessionForce"
type="boolean" description="Return an error when the request cannot be
routed to the right node." />
+ <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer." />
+ <c:simple-property name="flushPackets" type="boolean"
description="Allows controlling flusing of packets." />
+ <c:simple-property name="socketTimeout" type="integer"
description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="advertisePort" type="integer"
required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseGroupAddress"
type="string" required="false" description="Multicast address for
discovery." />
+ <c:simple-property name="flushWait" type="integer"
description="Time in ms to wait before flushing packets." />
+ <c:simple-property name="ping" type="integer"
description="Time in s to wait for a pong answer to a ping." />
+ </resource-configuration>
+ </service>
+
+ <service name="Dynamic Load Balancer Factor"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="Dynamic Load balancer factor for mod_cluster"
singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:provider=LoadBalanceFactor,service=ModCluster,*" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProvider" />
+ <c:simple-property name="nameTemplate" default="Dynamic
Load Balancer Factor" />
+ </plugin-configuration>
+
+ <metric property="Metrics" displayName="Collected
Metrics" displayType="summary" dataType="trait" />
+
+ <resource-configuration>
+ <c:simple-property name="DecayFactor" type="integer"
description="The number of historical load values used to determine load
factor." />
+ <c:simple-property name="History" type="integer"
description="The exponential decay factor for historical load values." />
+ </resource-configuration>
+ </service>
+
+ <service name="Simple Load Balancer Factor"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="Simple load balancer factor for mod_cluster"
singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:provider=LoadBalanceFactor,service=ModCluster,*" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider" />
+ <c:simple-property name="nameTemplate" default="Simple Load
Balancer Factor" />
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="loadBalanceFactor"
type="integer" description="The load balance factor." />
+ </resource-configuration>
+ </service>
+
+ <service name="Load Metric"
discovery="LoadMetricDiscoveryComponent"
class="org.rhq.plugins.jmx.MBeanResourceComponent" description="Load
Metric">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:provider=LoadBalanceFactor,service=ModCluster,metric=*,*"
/>
+ <c:simple-property name="nameTemplate" default="Load
Metric" />
+ </plugin-configuration>
+
+ <metric property="Load" displayName="Load"
category="utilization" description="The current load of this metric as a
percent of the metric's capacity." dataType="measurement" />
+
+ <resource-configuration>
+ <c:simple-property name="Weight" type="integer"
description="The significance of this load metric compared to the other
metrics." />
+ <c:simple-property name="Capacity" type="double"
description="Used to normalize the value returned by load expressed as a percentage
of the capacity, such that: 0 < (load/capacity) < 1" />
+ </resource-configuration>
+ </service>
+
+ <service name="Webapp Context"
discovery="ContextDiscoveryComponent" class="ContextComponent"
description="Webapp Context">
+
+ <operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation." />
+ </results>
+ </operation>
+ <operation name="stopContext" displayName="Stop webapp"
description="Gracefully stops this webapp.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="integer" displayName="Session draining timeout"/>
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
- <c:property-options allowCustomValue="false">
- <c:option value="MICROSECONDS"
name="MICROSECONDS"/>
- <c:option value="MILLISECONDS"
name="MILLISECONDS"/>
- <c:option value="NANOSECONDS"
name="NANOSECONDS"/>
- <c:option value="SECONDS"
name="SECONDS"/>
- <c:option value="HOURS" name="HOURS"/>
- <c:option value="DAYS" name="DAYS"/>
- </c:property-options>
- </c:simple-property>
+ <c:simple-property required="true" name="timeout"
type="integer" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
</parameters>
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
- <operation name="enableContext" displayName="Enable webapp"
description="Enable this webapp.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="enableContext" displayName="Enable
webapp" description="Enable this webapp.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
</service>
</service>
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
new file mode 100644
index 0000000..4e4aac1
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import org.testng.annotations.Test;
+
+import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
+
+public class ServerConfigTest {
+
+ @Test
+ public void TestConfig() {
+
+ try {
+ ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService");
+ config.setPropertyValue("processStatusFrequency", "4");
+ config.setPropertyValue("test", "5");
+ config.setPropertyValue("test", "123");
+
+ System.out.println(config.getPropertyValue("test"));
+
+ config.saveConfigFile();
+
+ config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
+ "org.jboss.modcluster.config.ha.HAModClusterConfig");
+ config.setPropertyValue("processStatusFrequency", "4");
+ config.setPropertyValue("test", "5");
+ config.setPropertyValue("test", "123");
+
+ System.out.println(config.getPropertyValue("test"));
+
+ config.saveConfigFile();
+
+ config.setPropertyValue("test", null);
+ config.saveConfigFile();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
commit 9b57c3ef1e1bc0ee5f88968f4ee32693be048eb3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Sun Aug 14 12:03:44 2011 -0500
With JBoss 5, the timeout is blocking the operation call for the period set. Reduce
this period for these integration tests.
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index dc98d78..0a39eab 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -168,7 +168,7 @@ public class ModclusterPluginTest {
log.info("Result of operation " + "enableContext" +
" was: " + result.getSimpleResult());
Configuration config = new Configuration();
- config.put(new PropertySimple("timeout", "1000"));
+ config.put(new PropertySimple("timeout", "1"));
config.put(new PropertySimple("unit",
java.util.concurrent.TimeUnit.SECONDS));
result = ((OperationFacet)
resourceComponent).invokeOperation("stopContext", config);
log.info("Result of operation stopContext was: " +
result.getSimpleResult());
commit 273a8701e0e62f907a3c92fbf9bc47aa5d02c51d
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Sun Aug 14 12:02:34 2011 -0500
Add jar dependencies for testing with JBoss 5&6.
diff --git a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
index 0cc3f4f..77a81b2 100644
--- a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
+++ b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
@@ -17,9 +17,37 @@
<properties>
<scm.module.path>modules/integration-tests/mod_cluster-plugin-test</scm.module.path>
+ <!-- jbossas.version>6.0.0.20100429-M3</jbossas.version-->
+ <jbossas.version>6.0.0.M1</jbossas.version>
+
</properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-parent</artifactId>
+ <version>${jbossas.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-component-matrix</artifactId>
+ <version>${jbossas.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<dependencies>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>${rhq.groupId}</groupId>
@@ -41,6 +69,213 @@
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jnp-client</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-aspects</artifactId>
+ <version>5.1.0.CR1</version>
+ <classifier>jboss-aspect-jdk50-client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>trove</groupId>
+ <artifactId>trove</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-security-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-javaee</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4-jboss</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <!-- dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-security</artifactId>
+ <version>5.1.0.CR1</version>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-transaction-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-common</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-core</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-proxy-spi</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-proxy-impl</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-security</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <!-- dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-client</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.jboss.aspects</groupId>
+ <artifactId>jboss-security-aspects</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.aop</groupId>
+ <artifactId>jboss-aop</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-serialization</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-core-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-client-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-profileservice</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <classifier>jmx-invoker-adaptor-client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>jboss.messaging</groupId>
+ <artifactId>jboss-messaging-client</artifactId>
+ <scope>test</scope>
+ </dependency-->
</dependencies>
commit 324454e90750968aeaee52480f10cef156ac3178
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 10 18:04:02 2011 -0500
Get the integration tests to compile and run again by creating the maven module and
deploying the correct resources to target folder.
diff --git a/.classpath b/.classpath
index cb9d57f..93a80cc 100644
--- a/.classpath
+++ b/.classpath
@@ -282,5 +282,6 @@
<classpathentry kind="src"
path="modules/plugins/jboss-as-7/src/main/java"/>
<classpathentry kind="src"
path="modules/plugins/jboss-as-7/src/test/java"/>
<classpathentry kind="src"
path="modules/integration-tests/jboss-as-7-plugin-test/src/test/java"/>
+ <classpathentry kind="src"
path="modules/integration-tests/mod_cluster-plugin-test/src/test/java"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --git a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
new file mode 100644
index 0000000..0cc3f4f
--- /dev/null
+++ b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
@@ -0,0 +1,155 @@
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>modcluster-plugin-test</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ mod_cluster Plugin Integration Test</name>
+ <description>Integration tests for mod_cluster RHQ Agent
plugin</description>
+
+ <properties>
+
<scm.module.path>modules/integration-tests/mod_cluster-plugin-test</scm.module.path>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>modcluster-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+
+ <profile>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+
<rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+
<rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <tasks>
+ <echo>Setting up plugin dependencies...</echo>
+ <property name="settings.localRepository"
location="${user.home}/.m2/repository" />
+ <mkdir dir="target/testsetup" />
+
+ <mkdir dir="target/testsetup/plugins" />
+ <copy toDir="target/testsetup/plugins"
flatten="true">
+ <fileset
dir="${settings.localRepository}/">
+ <include
name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar"
/>
+ <include
name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar"
/>
+ <include
name="org/jboss/on/jopr-jboss-as-plugin/${project.version}/jopr-jboss-as-plugin-${project.version}.jar"
/>
+ <include
name="org/jboss/on/jopr-jboss-as-5-plugin/${project.version}/jopr-jboss-as-5-plugin-${project.version}.jar"
/>
+ <include
name="org/rhq/modcluster-plugin/${project.version}/modcluster-plugin-${project.version}.jar"
/>
+ </fileset>
+ <fileset dir="${rhq.deploymentDir}">
+ <include
name="${project.artifactId}-${project.version}.jar" />
+ </fileset>
+ </copy>
+
+ <mkdir dir="target/testsetup/lib" />
+ <unzip dest="target/testsetup/lib">
+ <fileset
dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}"
includes="*.zip" />
+ <patternset>
+ <include name="**/lib/sigar.jar" />
+ <include name="**/lib/bcel*.jar" />
+ <include name="**/lib/*.so" />
+ <include name="**/lib/*.sl" />
+ <include name="**/lib/*.dll" />
+ <include name="**/lib/*.dylib" />
+ </patternset>
+ </unzip>
+ <move todir="target/testsetup/lib"
flatten="true">
+ <fileset dir="target/testsetup/lib">
+ <include name="**/lib/*" />
+ </fileset>
+ </move>
+ <delete
dir="target/testsetup/lib/hyperic-sigar-${sigar.version}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+
<useSystemClassLoader>false</useSystemClassLoader>
+
<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/testsetup/lib</argLine>
+ <systemProperties>
+ <property>
+ <name>project.artifactId</name>
+ <value>${project.artifactId}</value>
+ </property>
+ <property>
+ <name>project.version</name>
+ <value>${project.version}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 0f644fc..dc98d78 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -148,10 +148,12 @@ public class ModclusterPluginTest {
}
if (resourceComponent instanceof OperationFacet) {
- OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("reset", null);
+ OperationResult result = null;
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("reset", new Configuration());
log.info("Result of operation test was: " + result);
- result = ((OperationFacet)
resourceComponent).invokeOperation("disable", null);
+ result = ((OperationFacet)
resourceComponent).invokeOperation("disable", new Configuration());
log.info("Result of operation test was: " +
result.getSimpleResult());
}
}
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index ab52e84..fdc4f37 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -56,51 +56,6 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
- <execution>
- <phase>process-test-resources</phase>
- <configuration>
- <tasks>
- <echo>Setting up plugin dependencies...</echo>
- <property name="settings.localRepository"
location="${user.home}/.m2/repository" />
- <mkdir dir="target/testsetup" />
-
- <mkdir dir="target/testsetup/plugins" />
- <copy toDir="target/testsetup/plugins"
flatten="true">
- <fileset
dir="${settings.localRepository}/">
- <include
name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar"
/>
- <include
name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar"
/>
- <include
name="org/jboss/on/jopr-jboss-as-plugin/${project.version}/jopr-jboss-as-plugin-${project.version}.jar"
/>
- <include
name="org/jboss/on/jopr-jboss-as-5-plugin/${project.version}/jopr-jboss-as-5-plugin-${project.version}.jar"
/>
- </fileset>
- <fileset dir="${rhq.deploymentDir}">
- <include
name="${project.artifactId}-${project.version}.jar" />
- </fileset>
- </copy>
-
- <mkdir dir="target/testsetup/lib" />
- <unzip dest="target/testsetup/lib">
- <fileset
dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}"
includes="*.zip" />
- <patternset>
- <include name="**/lib/sigar.jar" />
- <include name="**/lib/bcel*.jar" />
- <include name="**/lib/*.so" />
- <include name="**/lib/*.sl" />
- <include name="**/lib/*.dll" />
- <include name="**/lib/*.dylib" />
- </patternset>
- </unzip>
- <move todir="target/testsetup/lib"
flatten="true">
- <fileset dir="target/testsetup/lib">
- <include name="**/lib/*" />
- </fileset>
- </move>
- <delete
dir="target/testsetup/lib/hyperic-sigar-${sigar.version}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
<execution>
<id>deploy</id>
@@ -203,12 +158,10 @@
<build>
<plugins>
-
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
-
<execution>
<id>deploy</id>
<phase>compile</phase>
@@ -258,14 +211,10 @@
<goal>run</goal>
</goals>
</execution>
-
</executions>
</plugin>
-
</plugins>
</build>
</profile>
-
</profiles>
-
</project>
commit 0b63dbefbc9f88145a8012a3677af665b41b13f7
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 00:14:01 2011 -0500
Small refactoring and code formating change to make the class easier to read and
understand.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
index 6abf955..8cff302 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -75,6 +75,7 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
*/
public void setPropertyValue(String propertyName, String value) {
boolean propertyFound = false;
+
for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
Node currentNode = beanNode.getChildNodes().item(i);
@@ -107,8 +108,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
public String getPropertyValue(String propertyName) {
- for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
- Node currentNode = beanNode.getChildNodes().item(i);
+ NodeList nodeList = beanNode.getChildNodes();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node currentNode = nodeList.item(i);
if (currentNode.getNodeName().equals("property")
&& currentNode.getAttributes().getNamedItem("name") !=
null
@@ -126,10 +129,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
private Node getBeanNodeByClass(String className) {
- NodeList result = this.getDocument().getElementsByTagName("bean");
+ NodeList nodeList = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
- for (int i = 1; i < result.getLength(); i++) {
- Node node = result.item(i);
if (node.getAttributes().getNamedItem("class") != null
&&
className.equals(node.getAttributes().getNamedItem("class").getTextContent()))
{
return node;
@@ -144,10 +148,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
private Node getBeanNodeByName(String beanName) {
- NodeList result = this.getDocument().getElementsByTagName("bean");
+ NodeList nodeList = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
- for (int i = 1; i < result.getLength(); i++) {
- Node node = result.item(i);
if (node.getAttributes().getNamedItem("name") != null
&&
beanName.equals(node.getAttributes().getNamedItem("name").getTextContent())) {
return node;
@@ -163,17 +168,17 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @return
*/
private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
- List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
+ List<Node> nodeList = this.getChildrenNodesByName(beanNode,
"constructor");
- if (tempNodeList.size() > 0) {
- Node constructorNode = tempNodeList.get(0);
+ if (nodeList.size() > 0) {
+ Node constructorNode = nodeList.get(0);
- tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
+ nodeList = this.getChildrenNodesByName(constructorNode,
"parameter");
- if (tempNodeList.size() > 0) {
+ if (nodeList.size() > 0) {
Node parameterNode = null;
- for (Node currentNode : tempNodeList) {
+ for (Node currentNode : nodeList) {
if (currentNode.getAttributes().getNamedItem("class") !=
null
&&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
.getTextContent())) {
@@ -183,10 +188,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
}
if (parameterNode != null) {
- tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
+ nodeList = this.getChildrenNodesByName(parameterNode,
"inject");
- if (tempNodeList.size() > 0) {
- Node injectNode = tempNodeList.get(0);
+ if (nodeList.size() > 0) {
+ Node injectNode = nodeList.get(0);
Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
if (beanAttribute != null) {
@@ -205,17 +210,17 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @param nodeName
* @return
*/
- private List<Node> getChildNodesByName(Node node, String nodeName) {
- List<Node> listOfNodes = new ArrayList<Node>();
+ private List<Node> getChildrenNodesByName(Node node, String nodeName) {
+ List<Node> nodeList = new ArrayList<Node>();
for (int i = 0; i < node.getChildNodes().getLength(); i++) {
Node currentNode = node.getChildNodes().item(i);
if (nodeName.equals(currentNode.getNodeName())) {
- listOfNodes.add(currentNode);
+ nodeList.add(currentNode);
}
}
- return listOfNodes;
+ return nodeList;
}
}
commit 7d543559bf07e87dd707fac16e0d1dc8f63b2815
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 00:12:49 2011 -0500
Added the proxyInfo metric back to Catalina service context since it is readly
available.
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 6f46849..3e523f7 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -374,6 +374,7 @@
</operation>
<metric property="proxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="proxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
<metric property="modelerType" displayName="Type of the
modeled resource" displayType="summary" dataType="trait" />
<metric property="className" displayName="Fully qualified
class name of the managed object" displayType="summary"
dataType="trait" />
<metric property="advertise" displayName="Enable autodiscovery
of httpd servers." displayType="summary" dataType="trait" />
commit 676fc23804ccf42d8eb2ce236400bc08a4025f89
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 24 11:18:01 2011 -0500
More updates to the naming of each plugin component to match the intent and purpose.
Also updated the integration tests to test each resource type.
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModClusterPluginIntegrationTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModClusterPluginIntegrationTest.java
new file mode 100644
index 0000000..625163b
--- /dev/null
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModClusterPluginIntegrationTest.java
@@ -0,0 +1,229 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.plugin.FileSystemPluginFinder;
+import org.rhq.core.pc.plugin.PluginEnvironment;
+import org.rhq.core.pc.plugin.PluginManager;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/**
+ * @author Stefan Negrea
+ */
+@SuppressWarnings("rawtypes")
+@Test(groups = "modcluster-plugin")
+public class ModClusterPluginIntegrationTest {
+ private Log log = LogFactory.getLog(this.getClass());
+ private static final String PLUGIN_NAME = "mod_cluster";
+
+ @BeforeSuite
+ public void start() {
+ try {
+ File pluginDir = new File("target/testsetup/plugins");
+ PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
+ pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
+ pcConfig.setPluginDirectory(pluginDir);
+
+ pcConfig.setInsideAgent(false);
+ PluginContainer.getInstance().setConfiguration(pcConfig);
+ PluginContainer.getInstance().initialize();
+ log.info("PC started.");
+ for (String plugin :
PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
+ log.info("...Loaded plugin: " + plugin);
+ }
+ } catch (Exception e) {
+ log.info("Error initializing the context", e);
+ }
+ }
+
+ @AfterSuite
+ public void stop() {
+ PluginContainer.getInstance().shutdown();
+ }
+
+ @Test
+ public void testPluginLoad() {
+ PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
+ PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
+ assert (pluginEnvironment != null) : "Null environment, plugin not
loaded";
+ assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
+ }
+
+ @Test(dependsOnMethods = "testPluginLoad")
+ public void testDiscovery() throws Exception {
+ InventoryReport report =
PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
+
+ Thread.sleep(1000);
+
+ report =
PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
+ assert report != null;
+ log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
+
+ Set<Resource> resources =
findResource(PluginContainer.getInstance().getInventoryManager().getPlatform());
+ log.info("Found " + resources.size() + " mod_cluster and
mod_cluster_context instance(s).");
+
+ assert (resources.size() != 0) : "No mod_cluster or related instances
found.";
+
+ if (resources.size() != 0) {
+ for (Object objectResource : resources.toArray()) {
+ Resource resource = (Resource) objectResource;
+ if (resource.getResourceType().getName().equals("mod_cluster"))
{
+ testMainResource(resource);
+ } else if (resource.getResourceType().getName().equals("Webapp
Context")) {
+ testWebappContext(resource);
+ } else if (resource.getResourceType().getName().equals("HA Service
Configuration")) {
+ testLoadServiceConfiguration(resource);
+ } else if (resource.getResourceType().getName().equals("HA
Service")) {
+ testServiceMeasurement(resource);
+ testServiceMethodInvocation(resource);
+ }
+ }
+ }
+ }
+
+ private void testServiceMethodInvocation(Resource resource) throws
InterruptedException, Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("p1", "1"));
+ config.put(new PropertySimple("p2",
java.util.concurrent.TimeUnit.SECONDS));
+ OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("stop", config);
+ log.info("Result of operation stopContext was: " +
result.getSimpleResult());
+ }
+
+ private void testLoadServiceConfiguration(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+ ((ConfigurationFacet) resourceComponent).loadResourceConfiguration();
+ }
+
+ private void testServiceMeasurement(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof MeasurementFacet) {
+ for (MeasurementDefinition def :
resource.getResourceType().getMetricDefinitions()) {
+ Set<MeasurementScheduleRequest> metricList = new
HashSet<MeasurementScheduleRequest>();
+ metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000,
true, def.getDataType(), null));
+ MeasurementReport report = new MeasurementReport();
+ ((MeasurementFacet) resourceComponent).getValues(report, metricList);
+
+ MeasurementData data = report.getTraitData().iterator().next();
+ assert data != null : "Unable to collect trait [" +
def.getName() + "] on " + resource;
+ log.info("Measurement: " + def.getName() + "=" +
data.getValue());
+ }
+ }
+ }
+
+ private void testMainResource(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof OperationFacet) {
+ OperationResult result = null;
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("reset", new Configuration());
+ log.info("Result of operation test was: " + result);
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("refresh", new Configuration());
+ log.info("Result of operation test was: " + result);
+ }
+ }
+
+ private void testWebappContext(Resource resource) throws Exception {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ if (resourceComponent instanceof OperationFacet) {
+ try {
+ OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation " + "enableContext" +
" was: " + result.getSimpleResult());
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("timeout", "1"));
+ config.put(new PropertySimple("unit",
java.util.concurrent.TimeUnit.SECONDS));
+ result = ((OperationFacet)
resourceComponent).invokeOperation("stopContext", config);
+ log.info("Result of operation stopContext was: " +
result.getSimpleResult());
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
+ log.info("Result of operation enableContext was: " +
result.getSimpleResult());
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("disableContext", null);
+ log.info("Result of operation disableContext was: " +
result.getSimpleResult());
+
+ } catch (Exception e) {
+ log.info("Operation failed. ", e);
+ }
+
+ }
+ }
+
+ private Set<Resource> findResource(Resource parent) {
+ Set<Resource> found = new HashSet<Resource>();
+
+ Queue<Resource> discoveryQueue = new LinkedList<Resource>();
+ discoveryQueue.add(parent);
+
+ while (!discoveryQueue.isEmpty()) {
+ Resource currentResource = discoveryQueue.poll();
+
+ log.info("Discovered resource of type: " +
currentResource.getResourceType().getName());
+ if (currentResource.getResourceType().getPlugin().equals(PLUGIN_NAME)) {
+ found.add(currentResource);
+ }
+
+ if (currentResource.getChildResources() != null) {
+ for (Resource child : currentResource.getChildResources()) {
+ discoveryQueue.add(child);
+ }
+ }
+ }
+
+ return found;
+ }
+}
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
deleted file mode 100644
index f27b153..0000000
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster.test;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-
-import org.rhq.core.clientapi.server.discovery.InventoryReport;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.MeasurementData;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.pc.PluginContainer;
-import org.rhq.core.pc.PluginContainerConfiguration;
-import org.rhq.core.pc.plugin.FileSystemPluginFinder;
-import org.rhq.core.pc.plugin.PluginEnvironment;
-import org.rhq.core.pc.plugin.PluginManager;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-/**
- * @author Stefan Negrea
- */
-@SuppressWarnings("rawtypes")
-@Test(groups = "modcluster-plugin")
-public class ModclusterPluginTest {
- private Log log = LogFactory.getLog(this.getClass());
- private static final String PLUGIN_NAME = "mod_cluster";
-
- @BeforeSuite
- public void start() {
- try {
- File pluginDir = new File("target/testsetup/plugins");
- PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
- pcConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
- pcConfig.setPluginDirectory(pluginDir);
-
- pcConfig.setInsideAgent(false);
- PluginContainer.getInstance().setConfiguration(pcConfig);
- PluginContainer.getInstance().initialize();
- log.info("PC started.");
- for (String plugin :
PluginContainer.getInstance().getPluginManager().getMetadataManager().getPluginNames()) {
- log.info("...Loaded plugin: " + plugin);
- }
- } catch (Exception e) {
- log.info("Error initializing the context", e);
- }
- }
-
- @AfterSuite
- public void stop() {
- PluginContainer.getInstance().shutdown();
- }
-
- @Test
- public void testPluginLoad() {
- PluginManager pluginManager = PluginContainer.getInstance().getPluginManager();
- PluginEnvironment pluginEnvironment = pluginManager.getPlugin(PLUGIN_NAME);
- assert (pluginEnvironment != null) : "Null environment, plugin not
loaded";
- assert (pluginEnvironment.getPluginName().equals(PLUGIN_NAME));
- }
-
- @Test(dependsOnMethods = "testPluginLoad")
- public void testDiscovery() throws Exception {
- InventoryReport report =
PluginContainer.getInstance().getInventoryManager().executeServerScanImmediately();
- assert report != null;
- log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
-
- Thread.sleep(1000);
-
- report =
PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
- assert report != null;
- log.info("Discovery took: " + (report.getEndTime() -
report.getStartTime()) + "ms");
-
- List<String> typeNames = new ArrayList<String>() {
- private static final long serialVersionUID = 1L;
-
- {
- add(PLUGIN_NAME);
- add("Webapp Context");
- add("HA Service Configuration");
- add("HA Service");
- }
- };
-
- Set<Resource> resources =
findResource(PluginContainer.getInstance().getInventoryManager().getPlatform(),
- typeNames);
- log.info("Found " + resources.size() + " mod_cluster and
mod_cluster_context instance(s).");
-
- assert (resources.size() != 0) : "No mod_cluster or related instances
found.";
-
- if (resources.size() != 0) {
- for (Object objectResource : resources.toArray()) {
- Resource resource = (Resource) objectResource;
- if (resource.getResourceType().getName().equals("mod_cluster"))
{
- testResourceMeasurement(resource);
- } else if (resource.getResourceType().getName().equals("Webapp
Context")) {
- testContextOperations(resource);
- } else if (resource.getResourceType().getName().equals("HA Service
Configuration")) {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
- ((ConfigurationFacet)
resourceComponent).loadResourceConfiguration();
- } else if (resource.getResourceType().getName().equals("HA
Service")) {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
-
- Configuration config = new Configuration();
- config.put(new PropertySimple("p1", "1"));
- config.put(new PropertySimple("p2",
java.util.concurrent.TimeUnit.SECONDS));
- OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("stop", config);
- log.info("Result of operation stopContext was: " +
result.getSimpleResult());
- }
- }
- }
- }
-
- private void testResourceMeasurement(Resource resource) throws Exception {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
- if (resourceComponent instanceof MeasurementFacet) {
- for (MeasurementDefinition def :
resource.getResourceType().getMetricDefinitions()) {
- Set<MeasurementScheduleRequest> metricList = new
HashSet<MeasurementScheduleRequest>();
- metricList.add(new MeasurementScheduleRequest(1, def.getName(), 1000,
true, def.getDataType(), null));
- MeasurementReport report = new MeasurementReport();
- ((MeasurementFacet) resourceComponent).getValues(report, metricList);
-
- MeasurementData data = report.getTraitData().iterator().next();
- assert data != null : "Unable to collect trait [" +
def.getName() + "] on " + resource;
- log.info("Measurement: " + def.getName() + "=" +
data.getValue());
- }
- }
-
- if (resourceComponent instanceof OperationFacet) {
- OperationResult result = null;
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("reset", new Configuration());
- log.info("Result of operation test was: " + result);
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("disable", new Configuration());
- log.info("Result of operation test was: " +
result.getSimpleResult());
- }
- }
-
- private void testContextOperations(Resource resource) throws Exception {
- ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
- .getResourceComponent(resource);
-
- if (resourceComponent instanceof OperationFacet) {
- try {
- OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation " + "enableContext" +
" was: " + result.getSimpleResult());
-
- Configuration config = new Configuration();
- config.put(new PropertySimple("timeout", "1"));
- config.put(new PropertySimple("unit",
java.util.concurrent.TimeUnit.SECONDS));
- result = ((OperationFacet)
resourceComponent).invokeOperation("stopContext", config);
- log.info("Result of operation stopContext was: " +
result.getSimpleResult());
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("enableContext", null);
- log.info("Result of operation enableContext was: " +
result.getSimpleResult());
-
- result = ((OperationFacet)
resourceComponent).invokeOperation("disableContext", null);
- log.info("Result of operation disableContext was: " +
result.getSimpleResult());
-
- } catch (Exception e) {
- log.info("Operation failed. ", e);
- }
-
- }
- }
-
- private Set<Resource> findResource(Resource parent, List<String>
typeNames) {
- Set<Resource> found = new HashSet<Resource>();
-
- Queue<Resource> discoveryQueue = new LinkedList<Resource>();
- discoveryQueue.add(parent);
-
- while (!discoveryQueue.isEmpty()) {
- Resource currentResource = discoveryQueue.poll();
-
- log.info("Discovered resource of type: " +
currentResource.getResourceType().getName());
- if (typeNames.contains(currentResource.getResourceType().getName())) {
- found.add(currentResource);
- }
-
- if (currentResource.getChildResources() != null) {
- for (Resource child : currentResource.getChildResources()) {
- discoveryQueue.add(child);
- }
- }
- }
-
- return found;
- }
-}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
index b9ce25e..b854398 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
@@ -89,7 +89,7 @@ public class ClassNameMBeanDiscoveryComponent<T extends
JMXComponent> extends MB
emsConnection.queryBeans(objectName);
bean = emsConnection.getBean(objectName);
}
+
return bean;
}
-
-}
\ No newline at end of file
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
deleted file mode 100644
index 4c8b437..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.bean.EmsBean;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-import org.rhq.plugins.modcluster.helper.JBossHelper;
-
-/**
- * Manages a mod_cluster context entity.
- *
- * @author Stefan Negrea
- */
-@SuppressWarnings({ "rawtypes", "deprecation" })
-public class ContextComponent extends
MBeanResourceComponent<MBeanResourceComponent> {
-
- private static final Log log = LogFactory.getLog(ContextComponent.class);
-
- @Override
- protected EmsBean loadBean() {
- return getResourceContext().getParentResourceComponent().getEmsBean();
- }
-
- @Override
- public AvailabilityType getAvailability() {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
-
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
-
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
-
- ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
-
- int indexOfCurrentContext =
proxyInfo.getAvailableContexts().indexOf(context);
-
- if (indexOfCurrentContext != -1) {
- ProxyInfo.Context currentContext =
proxyInfo.getAvailableContexts().get(indexOfCurrentContext);
-
- if (currentContext.isEnabled()) {
- return AvailabilityType.UP;
- }
- }
-
- return AvailabilityType.DOWN;
- } catch (Exception e) {
- log.info(e);
- return AvailabilityType.DOWN;
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- }
-
- @Override
- public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
- if ("enableContext".equals(name) ||
"disableContext".equals(name) || "stopContext".equals(name)) {
-
- ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
-
- Object[] configuration = null;
- if ("stopContext".equals(name)) {
- configuration = new Object[] { context.getHost(), context.getPath(),
- parameters.getSimple("timeout").getLongValue(),
-
TimeUnit.valueOf(parameters.getSimple("unit").getStringValue()) };
- } else {
- configuration = new Object[] { context.getHost(), context.getPath() };
- }
-
- if (context.getPath().equals("/")) {
- configuration[1] = "ROOT";
- }
-
- log.info(name + " - " + context.getHost() + " " +
context.getPath());
-
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try {
-
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- Object resultObject =
getEmsBean().getOperation(name).invoke(configuration);
-
- if (resultObject instanceof OperationResult) {
- return (OperationResult) resultObject;
- } else {
- return new OperationResult(String.valueOf(resultObject));
- }
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
- }
- }
-
- throw new Exception("Operation " + name + " not available
mod_cluster WebApp service.");
- }
-}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
deleted file mode 100644
index 788cbce..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.mc4j.ems.connection.EmsConnection;
-import org.mc4j.ems.connection.bean.EmsBean;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-import org.rhq.plugins.modcluster.helper.JBossHelper;
-
-/**
- * Discovers mod_cluster contexts from the proxyInfo mbean property.
- *
- * @author Stefan Negrea
- */
-@SuppressWarnings("rawtypes")
-public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBeanResourceComponent> {
-
- private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
- private static final String ENGINE_OBJECT_NAME = "engineObjectName";
-
- /* (non-Javadoc)
- * @see
org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
- */
- public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
- String jvmRoute = this.getJvmRoute(context);
-
- EmsBean configBean = context.getParentResourceComponent().getEmsBean();
- String rawProxyInfo = JBossHelper.getRawProxyInfo(configBean);
-
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
- Set<DiscoveredResourceDetails> entities = new
HashSet<DiscoveredResourceDetails>();
-
- for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
- if (availableContext.getJvmRoute().equals(jvmRoute)) {
- DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(context.getResourceType(),
- availableContext.createKey(), availableContext.createName(), null,
"Webapp Context", null, null);
- entities.add(detail);
- }
- }
-
- return entities;
- }
-
- /**
- * Retrieves the jvm route for the node from the parent context.
- *
- * @param context the discovery context
- * @return node's jvm route
- */
- private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent>
context) {
- Configuration pluginConfig =
context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
- String engineObjectName =
pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue();
- EmsBean engineBean = this.loadBean(engineObjectName,
context.getParentResourceComponent());
-
- return (String)
engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
- }
-
- /**
- * Loads the bean with the given object name.
- *
- * Subclasses are free to override this method in order to load the bean.
- *
- * @param objectName the name of the bean to load
- * @return the bean that is loaded
- */
- protected EmsBean loadBean(String objectName, MBeanResourceComponent context) {
- EmsConnection emsConnection = context.getEmsConnection();
- EmsBean bean = emsConnection.getBean(objectName);
- if (bean == null) {
- // In some cases, this resource component may have been discovered by some
means other than querying its
- // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
- // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
- // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
- // bean before giving up.
- emsConnection.queryBeans(objectName);
- bean = emsConnection.getBean(objectName);
- }
- return bean;
- }
-}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
index 7d5f0dc..0db722e 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
@@ -21,6 +21,7 @@ package org.rhq.plugins.modcluster;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.helper.JBossHelper;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
/**
* @author Stefan Negrea
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
deleted file mode 100644
index 8614402..0000000
--- a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ProxyInfo.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Simple parser for the raw proxy information provided by mod_cluster.
- *
- * @author Stefan Negrea
- */
-public class ProxyInfo {
-
- private Map<String, Node> availableNodes = new HashMap<String, Node>();
- private Map<String, Vhost> availableVhosts = new HashMap<String,
Vhost>();
- private List<Context> availableContexts = new
ArrayList<ProxyInfo.Context>();
-
- public ProxyInfo(String rawProxyInfo) {
- parseNodes(rawProxyInfo);
- parseVhosts(rawProxyInfo);
- parseContexts(rawProxyInfo);
- }
-
- private void parseNodes(String rawProxyInfo) {
- Pattern nodePattern = Pattern.compile("Node:.*\n");
- Matcher nodeMatcher = nodePattern.matcher(rawProxyInfo);
- while (nodeMatcher.find()) {
- String rawNode = nodeMatcher.group();
- String[] nodePieces = rawNode.split(",");
-
- String identifier = nodePieces[0];
- identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
-
- String jvmRoute = nodePieces[1];
- jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':') + 1).trim();
-
- availableNodes.put(identifier, new Node(jvmRoute, identifier));
- }
- }
-
- private void parseVhosts(String rawProxyInfo) {
- Pattern vhostPattern = Pattern.compile("Vhost:.*\n");
- Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
- while (vhostMatcher.find()) {
- String rawVhost = vhostMatcher.group();
- String[] vhostPieces = rawVhost.split(",");
-
- String identifier = vhostPieces[0].trim();
- identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
- identifier = identifier.substring(0, identifier.lastIndexOf(":"));
-
- String host = vhostPieces[1].trim();
- host = host.substring(host.indexOf(":") + 1).trim();
-
- availableVhosts.put(identifier, new Vhost(identifier, host));
- }
- }
-
- private void parseContexts(String rawProxyInfo) {
- Pattern contextPattern = Pattern.compile("Context:.*[\n|}]");
- Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
- while (contextMatcher.find()) {
- String rawContext = contextMatcher.group();
- String[] contextPieces = rawContext.split(",");
- String actualContext =
contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
-
- String identifier = contextPieces[0];
- identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
- identifier = identifier.substring(0, identifier.lastIndexOf(":"));
-
- String nodeIdentifier = contextPieces[0];
- nodeIdentifier =
nodeIdentifier.substring(nodeIdentifier.indexOf("[") + 1,
nodeIdentifier.indexOf("]"));
- nodeIdentifier = nodeIdentifier.substring(0,
nodeIdentifier.indexOf(":"));
- String jvmRoute = availableNodes.get(nodeIdentifier).getJvmRoute();
-
- String rawIsEnabled = contextPieces[2];
- rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') +
1).trim();
- boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
-
- Vhost relatedVhost = availableVhosts.get(identifier);
-
- availableContexts.add(new Context(jvmRoute, relatedVhost.getHost(),
actualContext, isEnabled));
- }
- }
-
- public List<Context> getAvailableContexts() {
- return Collections.unmodifiableList(availableContexts);
- }
-
- public List<Vhost> getAvailableVhosts() {
- return Collections.unmodifiableList(new
ArrayList<Vhost>(availableVhosts.values()));
- }
-
- public List<Node> getAvailableNodes() {
- return Collections.unmodifiableList(new
ArrayList<Node>(availableNodes.values()));
- }
-
- public static class Node {
- private String jvmRoute;
- private String nodeId;
-
- public Node(String jvmRoute, String nodeId) {
- this.jvmRoute = jvmRoute;
- this.nodeId = nodeId;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public String getJvmRoute() {
- return jvmRoute;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
- result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Node other = (Node) obj;
- if (jvmRoute == null) {
- if (other.jvmRoute != null)
- return false;
- } else if (!jvmRoute.equals(other.jvmRoute))
- return false;
- if (nodeId == null) {
- if (other.nodeId != null)
- return false;
- } else if (!nodeId.equals(other.nodeId))
- return false;
- return true;
- }
- }
-
- public static class Vhost {
- private String identifier;
- private String host;
-
- public Vhost(String identifier, String host) {
- this.identifier = identifier;
- this.host = host;
- }
-
- public String getIdentifier() {
- return identifier;
- }
-
- public String getHost() {
- return host;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((host == null) ? 0 : host.hashCode());
- result = prime * result + ((identifier == null) ? 0 :
identifier.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Vhost other = (Vhost) obj;
- if (host == null) {
- if (other.host != null)
- return false;
- } else if (!host.equals(other.host))
- return false;
- if (identifier == null) {
- if (other.identifier != null)
- return false;
- } else if (!identifier.equals(other.identifier))
- return false;
- return true;
- }
- }
-
- public static class Context {
- private String path;
- private String host;
- private String jvmRoute;
- private boolean isEnabled;
-
- public Context(String jvmRoute, String host, String path) {
- this(jvmRoute, host, path, false);
- }
-
- public Context(String jvmRoute, String host, String path, boolean isEnabled) {
- this.jvmRoute = jvmRoute;
- this.host = host;
- this.path = path;
- this.isEnabled = isEnabled;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getHost() {
- return host;
- }
-
- public String getJvmRoute() {
- return jvmRoute;
- }
-
- public boolean isEnabled() {
- return isEnabled;
- }
-
- public String createKey() {
- return jvmRoute + ":" + host + ":" + path;
- }
-
- public String createName() {
- return host + ":" + path;
- }
-
- @Override
- public String toString() {
- return createKey();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((host == null) ? 0 : host.hashCode());
- result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Context other = (Context) obj;
- if (host == null) {
- if (other.host != null)
- return false;
- } else if (!host.equals(other.host))
- return false;
- if (jvmRoute == null) {
- if (other.jvmRoute != null)
- return false;
- } else if (!jvmRoute.equals(other.jvmRoute))
- return false;
- if (path == null) {
- if (other.path != null)
- return false;
- } else if (!path.equals(other.path))
- return false;
- return true;
- }
-
- public static Context fromString(String stringRepresentation) throws Exception {
- String parts[] = stringRepresentation.trim().split(":");
- if (parts.length < 3) {
- throw new Exception("Parsing error. Not enough information to create
a context.");
- }
-
- return new Context(parts[0], parts[1], parts[2]);
- }
- }
-}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java
new file mode 100644
index 0000000..6131578
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextComponent.java
@@ -0,0 +1,117 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
+
+/**
+ * Manages a mod_cluster context entity.
+ *
+ * @author Stefan Negrea
+ */
+@SuppressWarnings({ "rawtypes", "deprecation" })
+public class WebappContextComponent extends
MBeanResourceComponent<MBeanResourceComponent> {
+
+ private static final Log log = LogFactory.getLog(WebappContextComponent.class);
+
+ @Override
+ protected EmsBean loadBean() {
+ return getResourceContext().getParentResourceComponent().getEmsBean();
+ }
+
+ @Override
+ public AvailabilityType getAvailability() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
+
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+
+ ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+
+ int indexOfCurrentContext =
proxyInfo.getAvailableContexts().indexOf(context);
+
+ if (indexOfCurrentContext != -1) {
+ ProxyInfo.Context currentContext =
proxyInfo.getAvailableContexts().get(indexOfCurrentContext);
+
+ if (currentContext.isEnabled()) {
+ return AvailabilityType.UP;
+ }
+ }
+
+ return AvailabilityType.DOWN;
+ } catch (Exception e) {
+ log.info(e);
+ return AvailabilityType.DOWN;
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
+ if ("enableContext".equals(name) ||
"disableContext".equals(name) || "stopContext".equals(name)) {
+
+ ProxyInfo.Context context =
ProxyInfo.Context.fromString(resourceContext.getResourceKey());
+
+ Object[] configuration = null;
+ if ("stopContext".equals(name)) {
+ configuration = new Object[] { context.getHost(), context.getPath(),
+ parameters.getSimple("timeout").getLongValue(),
+
TimeUnit.valueOf(parameters.getSimple("unit").getStringValue()) };
+ } else {
+ configuration = new Object[] { context.getHost(), context.getPath() };
+ }
+
+ if (context.getPath().equals("/")) {
+ configuration[1] = "ROOT";
+ }
+
+ log.info(name + " - " + context.getHost() + " " +
context.getPath());
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
+ Object resultObject =
getEmsBean().getOperation(name).invoke(configuration);
+
+ if (resultObject instanceof OperationResult) {
+ return (OperationResult) resultObject;
+ } else {
+ return new OperationResult(String.valueOf(resultObject));
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ throw new Exception("Operation " + name + " not available
mod_cluster WebApp service.");
+ }
+}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java
new file mode 100644
index 0000000..559e1b6
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/WebappContextDiscoveryComponent.java
@@ -0,0 +1,105 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
+
+/**
+ * Discovers mod_cluster contexts from the proxyInfo mbean property.
+ *
+ * @author Stefan Negrea
+ */
+@SuppressWarnings("rawtypes")
+public class WebappContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBeanResourceComponent> {
+
+ private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
+ private static final String ENGINE_OBJECT_NAME = "engineObjectName";
+
+ /* (non-Javadoc)
+ * @see
org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
+ */
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
+ String jvmRoute = this.getJvmRoute(context);
+
+ EmsBean configBean = context.getParentResourceComponent().getEmsBean();
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(configBean);
+
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ Set<DiscoveredResourceDetails> entities = new
HashSet<DiscoveredResourceDetails>();
+
+ for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
+ if (availableContext.getJvmRoute().equals(jvmRoute)) {
+ DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(context.getResourceType(),
+ availableContext.createKey(), availableContext.createName(), null,
"Webapp Context", null, null);
+ entities.add(detail);
+ }
+ }
+
+ return entities;
+ }
+
+ /**
+ * Retrieves the jvm route for the node from the parent context.
+ *
+ * @param context the discovery context
+ * @return node's jvm route
+ */
+ private String getJvmRoute(ResourceDiscoveryContext<MBeanResourceComponent>
context) {
+ Configuration pluginConfig =
context.getParentResourceComponent().getResourceContext().getPluginConfiguration();
+ String engineObjectName =
pluginConfig.getSimple(ENGINE_OBJECT_NAME).getStringValue();
+ EmsBean engineBean = this.loadBean(engineObjectName,
context.getParentResourceComponent());
+
+ return (String)
engineBean.getAttribute(JVM_ROUTE_PROPERTY).refresh().toString();
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(String objectName, MBeanResourceComponent context) {
+ EmsConnection emsConnection = context.getEmsConnection();
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some
means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
+}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/model/ProxyInfo.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/model/ProxyInfo.java
new file mode 100644
index 0000000..9cedad5
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/model/ProxyInfo.java
@@ -0,0 +1,310 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Simple parser for the raw proxy information provided by mod_cluster.
+ *
+ * @author Stefan Negrea
+ */
+public class ProxyInfo {
+
+ private Map<String, Node> availableNodes = new HashMap<String, Node>();
+ private Map<String, Vhost> availableVhosts = new HashMap<String,
Vhost>();
+ private List<Context> availableContexts = new
ArrayList<ProxyInfo.Context>();
+
+ public ProxyInfo(String rawProxyInfo) {
+ parseNodes(rawProxyInfo);
+ parseVhosts(rawProxyInfo);
+ parseContexts(rawProxyInfo);
+ }
+
+ private void parseNodes(String rawProxyInfo) {
+ Pattern nodePattern = Pattern.compile("Node:.*\n");
+ Matcher nodeMatcher = nodePattern.matcher(rawProxyInfo);
+ while (nodeMatcher.find()) {
+ String rawNode = nodeMatcher.group();
+ String[] nodePieces = rawNode.split(",");
+
+ String identifier = nodePieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
+
+ String jvmRoute = nodePieces[1];
+ jvmRoute = jvmRoute.substring(jvmRoute.indexOf(':') + 1).trim();
+
+ availableNodes.put(identifier, new Node(jvmRoute, identifier));
+ }
+ }
+
+ private void parseVhosts(String rawProxyInfo) {
+ Pattern vhostPattern = Pattern.compile("Vhost:.*\n");
+ Matcher vhostMatcher = vhostPattern.matcher(rawProxyInfo);
+ while (vhostMatcher.find()) {
+ String rawVhost = vhostMatcher.group();
+ String[] vhostPieces = rawVhost.split(",");
+
+ String identifier = vhostPieces[0].trim();
+ identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String host = vhostPieces[1].trim();
+ host = host.substring(host.indexOf(":") + 1).trim();
+
+ availableVhosts.put(identifier, new Vhost(identifier, host));
+ }
+ }
+
+ private void parseContexts(String rawProxyInfo) {
+ Pattern contextPattern = Pattern.compile("Context:.*[\n|}]");
+ Matcher contextMatcher = contextPattern.matcher(rawProxyInfo);
+ while (contextMatcher.find()) {
+ String rawContext = contextMatcher.group();
+ String[] contextPieces = rawContext.split(",");
+ String actualContext =
contextPieces[1].substring(contextPieces[1].indexOf("/")).trim();
+
+ String identifier = contextPieces[0];
+ identifier = identifier.substring(identifier.indexOf("[") + 1,
identifier.indexOf("]"));
+ identifier = identifier.substring(0, identifier.lastIndexOf(":"));
+
+ String nodeIdentifier = contextPieces[0];
+ nodeIdentifier =
nodeIdentifier.substring(nodeIdentifier.indexOf("[") + 1,
nodeIdentifier.indexOf("]"));
+ nodeIdentifier = nodeIdentifier.substring(0,
nodeIdentifier.indexOf(":"));
+ String jvmRoute = availableNodes.get(nodeIdentifier).getJvmRoute();
+
+ String rawIsEnabled = contextPieces[2];
+ rawIsEnabled = rawIsEnabled.substring(rawIsEnabled.indexOf(':') +
1).trim();
+ boolean isEnabled = rawIsEnabled.equals("ENABLED") ? true : false;
+
+ Vhost relatedVhost = availableVhosts.get(identifier);
+
+ availableContexts.add(new Context(jvmRoute, relatedVhost.getHost(),
actualContext, isEnabled));
+ }
+ }
+
+ public List<Context> getAvailableContexts() {
+ return Collections.unmodifiableList(availableContexts);
+ }
+
+ public List<Vhost> getAvailableVhosts() {
+ return Collections.unmodifiableList(new
ArrayList<Vhost>(availableVhosts.values()));
+ }
+
+ public List<Node> getAvailableNodes() {
+ return Collections.unmodifiableList(new
ArrayList<Node>(availableNodes.values()));
+ }
+
+ public static class Node {
+ private String jvmRoute;
+ private String nodeId;
+
+ public Node(String jvmRoute, String nodeId) {
+ this.jvmRoute = jvmRoute;
+ this.nodeId = nodeId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
+ result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Node other = (Node) obj;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
+ if (nodeId == null) {
+ if (other.nodeId != null)
+ return false;
+ } else if (!nodeId.equals(other.nodeId))
+ return false;
+ return true;
+ }
+ }
+
+ public static class Vhost {
+ private String identifier;
+ private String host;
+
+ public Vhost(String identifier, String host) {
+ this.identifier = identifier;
+ this.host = host;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((identifier == null) ? 0 :
identifier.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Vhost other = (Vhost) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (identifier == null) {
+ if (other.identifier != null)
+ return false;
+ } else if (!identifier.equals(other.identifier))
+ return false;
+ return true;
+ }
+ }
+
+ public static class Context {
+ private String path;
+ private String host;
+ private String jvmRoute;
+ private boolean isEnabled;
+
+ public Context(String jvmRoute, String host, String path) {
+ this(jvmRoute, host, path, false);
+ }
+
+ public Context(String jvmRoute, String host, String path, boolean isEnabled) {
+ this.jvmRoute = jvmRoute;
+ this.host = host;
+ this.path = path;
+ this.isEnabled = isEnabled;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public String getJvmRoute() {
+ return jvmRoute;
+ }
+
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ public String createKey() {
+ return jvmRoute + ":" + host + ":" + path;
+ }
+
+ public String createName() {
+ return host + ":" + path;
+ }
+
+ @Override
+ public String toString() {
+ return createKey();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + ((jvmRoute == null) ? 0 : jvmRoute.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Context other = (Context) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (jvmRoute == null) {
+ if (other.jvmRoute != null)
+ return false;
+ } else if (!jvmRoute.equals(other.jvmRoute))
+ return false;
+ if (path == null) {
+ if (other.path != null)
+ return false;
+ } else if (!path.equals(other.path))
+ return false;
+ return true;
+ }
+
+ public static Context fromString(String stringRepresentation) throws Exception {
+ String parts[] = stringRepresentation.trim().split(":");
+ if (parts.length < 3) {
+ throw new Exception("Parsing error. Not enough information to create
a context.");
+ }
+
+ return new Context(parts[0], parts[1], parts[2]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 7e1a79f..6f46849 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -440,7 +440,7 @@
</resource-configuration>
</service>
- <service name="Webapp Context"
discovery="ContextDiscoveryComponent" class="ContextComponent"
description="Webapp Context">
+ <service name="Webapp Context"
discovery="WebappContextDiscoveryComponent"
class="WebappContextComponent" description="Webapp Context">
<operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
<results>
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
index 625d8d4..ebadd86 100644
---
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ProxyInfoTest.java
@@ -23,7 +23,7 @@ import java.io.InputStream;
import org.testng.annotations.Test;
-import org.rhq.plugins.modcluster.ProxyInfo;
+import org.rhq.plugins.modcluster.model.ProxyInfo;
/**
* @author Stefan Negrea
commit dee21cbe94b5d5befc5a087a74cc5884bea96ee4
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 23 16:12:11 2011 -0500
Renaming mod_cluster components to match their explicit purpose.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
index 0a0a570..b87bfcd 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -30,14 +30,16 @@ import
org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
/**
* @author Stefan Negrea
*
*/
-@SuppressWarnings({ "deprecation" })
-public class FileConfiguredMBeanResourceComponent extends TimeUnitParamResourceComponent
{
+@SuppressWarnings({ "deprecation", "rawtypes" })
+public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent<JMXComponent> {
private static final Log log =
LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServiceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServiceComponent.java
new file mode 100644
index 0000000..d9da81c
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServiceComponent.java
@@ -0,0 +1,52 @@
+package org.rhq.plugins.modcluster;
+
+import java.util.concurrent.TimeUnit;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/**
+ *
+ * @author Stefan Negrea
+ */
+public class ModClusterServiceComponent extends FileConfiguredMBeanResourceComponent {
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
+ if (name.toLowerCase().startsWith("ping")) {
+ name = "ping";
+ }
+
+ return super.invokeOperation(name, parameters);
+ }
+
+ @Override
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
+ System.out.println(typeName);
+ if (typeName.equals(TimeUnit.class.getName())) {
+ return TimeUnit.valueOf(propSimple.getStringValue());
+ }
+
+ return super.getPropertyValueAsType(propSimple, typeName);
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
deleted file mode 100644
index c67bf61..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.rhq.plugins.modcluster;
-
-import java.util.concurrent.TimeUnit;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/**
- *
- * @author Stefan Negrea
- */
-public class PolyPingMBeanResourceComponent extends FileConfiguredMBeanResourceComponent
{
-
- @Override
- public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
- if (name.toLowerCase().startsWith("ping")) {
- name = "ping";
- }
-
- return super.invokeOperation(name, parameters);
- }
-
- @Override
- protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
- System.out.println(typeName);
- if (typeName.equals(TimeUnit.class.getName())) {
- return TimeUnit.valueOf(propSimple.getStringValue());
- }
-
- return super.getPropertyValueAsType(propSimple, typeName);
- }
-}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
deleted file mode 100644
index 0296eaf..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import java.util.concurrent.TimeUnit;
-
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-
-/**
- * @author Stefan Negrea
- *
- */
-@SuppressWarnings("rawtypes")
-public class TimeUnitParamResourceComponent extends MBeanResourceComponent {
-
- @Override
- protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
- System.out.println(typeName);
- if (typeName.equals(TimeUnit.class.getName())) {
- return TimeUnit.valueOf(propSimple.getStringValue());
- }
-
- return super.getPropertyValueAsType(propSimple, typeName);
- }
-}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index ed82f7c..7e1a79f 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -27,7 +27,7 @@
<!-- Start - Configuration for HAModClusterService -->
<service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
- class="PolyPingMBeanResourceComponent"
+ class="ModClusterServiceComponent"
supportsManualAdd="true"
description="HA Service Listener" singleton="true">
@@ -199,7 +199,7 @@
<!-- End - Configuration for HAModClusterService -->
<!-- Start - Configuration for ModClusterService -->
- <service name="Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+ <service name="Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="ModClusterServiceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
commit 35d73023552f4b83976705e88f14e6fecf0eed6f
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Aug 23 15:39:58 2011 -0500
Updates to support integration with JBoss' mod_cluster module for AS6 and
EAP5.1.x
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index b642573..f27b153 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -112,6 +112,7 @@ public class ModclusterPluginTest {
add(PLUGIN_NAME);
add("Webapp Context");
add("HA Service Configuration");
+ add("HA Service");
}
};
@@ -132,6 +133,15 @@ public class ModclusterPluginTest {
ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
.getResourceComponent(resource);
((ConfigurationFacet)
resourceComponent).loadResourceConfiguration();
+ } else if (resource.getResourceType().getName().equals("HA
Service")) {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("p1", "1"));
+ config.put(new PropertySimple("p2",
java.util.concurrent.TimeUnit.SECONDS));
+ OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("stop", config);
+ log.info("Result of operation stopContext was: " +
result.getSimpleResult());
}
}
}
diff --git
a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
index 6a60a93..8da6a2d 100644
--- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
+++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/MBeanResourceComponent.java
@@ -561,15 +561,15 @@ public class MBeanResourceComponent<T extends JMXComponent>
implements Measureme
paramIndex =
Integer.valueOf(propName.substring(propName.indexOf('[') + 1,
propName.indexOf(']')));
if (paramIndex < 0 || paramIndex >= emsParams.size()) {
throw new IllegalStateException("Index [" + paramIndex +
"] specified for parameter of operation ["
- + name + "] on MBean [" + emsBean.getBeanName() +
"] is invalid. The MBean operation takes "
- + emsParams.size() + " parameters.");
+ + name + "] on MBean [" + emsBean.getBeanName() +
"] is invalid. The MBean operation takes "
+ + emsParams.size() + " parameters.");
}
} else {
paramIndex = emsParamIndexesByName.get(propName);
if (paramIndex == null) {
throw new IllegalStateException("Name [" + propName +
"] specified for parameter of operation ["
- + name + "] on MBean [" + emsBean.getBeanName()
- + "] is invalid. The MBean operation does not take a
parameter by that name.");
+ + name + "] on MBean [" + emsBean.getBeanName()
+ + "] is invalid. The MBean operation does not take a
parameter by that name.");
}
}
EmsParameter emsParam = emsParams.get(paramIndex);
@@ -611,7 +611,7 @@ public class MBeanResourceComponent<T extends JMXComponent>
implements Measureme
return resultToReturn;
}
- private Object getPropertyValueAsType(PropertySimple propSimple, String typeName) {
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
Object value;
if (typeName.equals(String.class.getName())) {
value = (propSimple == null) ? null : propSimple.getStringValue();
@@ -626,7 +626,8 @@ public class MBeanResourceComponent<T extends JMXComponent>
implements Measureme
} else if (typeName.equals(Double.class.getName()) ||
typeName.equals(double.class.getName())) {
value = (propSimple == null) ? null : propSimple.getDoubleValue();
} else {
- throw new IllegalStateException("Operation parameter maps to MBean
parameter with an unsupported type (" + typeName + ").");
+ throw new IllegalStateException("Operation parameter maps to MBean
parameter with an unsupported type ("
+ + typeName + ").");
}
// TODO GH: Handle rest of types. (I think i have a mapper for this in mc4j
return value;
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index 35c5b28..3a6deaa 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -31,6 +31,11 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-plugin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index c5343d0..4c8b437 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -90,6 +90,10 @@ public class ContextComponent extends
MBeanResourceComponent<MBeanResourceCompon
configuration = new Object[] { context.getHost(), context.getPath() };
}
+ if (context.getPath().equals("/")) {
+ configuration[1] = "ROOT";
+ }
+
log.info(name + " - " + context.getHost() + " " +
context.getPath());
ClassLoader cl = Thread.currentThread().getContextClassLoader();
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
index ee0369c..0a0a570 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -30,21 +30,20 @@ import
org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.util.exception.ThrowableUtil;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
/**
* @author Stefan Negrea
*
*/
-@SuppressWarnings({ "rawtypes", "deprecation" })
-public class FileConfiguredMBeanResourceComponent extends MBeanResourceComponent {
+@SuppressWarnings({ "deprecation" })
+public class FileConfiguredMBeanResourceComponent extends TimeUnitParamResourceComponent
{
private static final Log log =
LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
private static final String BEAN_CLASS_NAME_PROPERTY = "className";
private static final String DEPENDENCY_BEAN_CLASS_NAME_PROPERTY =
"dependencyClassName";
- private static final String SERVER_HOME_DIR = "jboss.server.home.dir";
+ private static final String SERVER_HOME_DIR = "serverHomeDir";
private static final String CONFIGURATION_FILE_RELATIVE_PATH =
"/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml";
/**
@@ -105,7 +104,7 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
}
private String getServerHomeDirectory() {
- ModclusterServerComponent modClusterComponent = (ModclusterServerComponent)
this.resourceContext
+ ModClusterServerComponent modClusterComponent = (ModClusterServerComponent)
this.resourceContext
.getParentResourceComponent();
PropertySimple property =
modClusterComponent.getResourceContext().getPluginConfiguration()
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
index 496068c..3eb7cbe 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
@@ -36,9 +36,6 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
@SuppressWarnings("rawtypes")
public class LoadMetricDiscoveryComponent extends
MBeanResourceDiscoveryComponent<JMXComponent> {
- /* (non-Javadoc)
- * @see
org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext,
boolean)
- */
@Override
public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<JMXComponent> context,
boolean skipUnknownProps) {
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterDiscoveryComponent.java
new file mode 100644
index 0000000..b9a73b5
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterDiscoveryComponent.java
@@ -0,0 +1,70 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jbossas.JBossASServerComponent;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class ModClusterDiscoveryComponent extends MBeanResourceDiscoveryComponent {
+
+ private final static String JBOSS_SERVER_HOME_DIR = "serverHomeDir";
+
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext context) {
+ Set<DiscoveredResourceDetails> tempSet = super.discoverResources(context);
+
+ for (DiscoveredResourceDetails detail : tempSet) {
+ String serverHomeDirectory =
findServerHomeDirectory(context.getParentResourceComponent());
+ detail.getPluginConfiguration().put(new PropertySimple(JBOSS_SERVER_HOME_DIR,
serverHomeDirectory));
+ }
+
+ return tempSet;
+ }
+
+ @SuppressWarnings("static-access")
+ public String findServerHomeDirectory(ResourceComponent parentResourceComponent) {
+ if (parentResourceComponent instanceof ApplicationServerComponent) {
+ ApplicationServerComponent parentComponent = (ApplicationServerComponent)
parentResourceComponent;
+
+ return
parentComponent.getResourceContext().getPluginConfiguration().getSimple("serverHomeDir")
+ .getStringValue();
+
+ } else if (parentResourceComponent instanceof JBossASServerComponent) {
+ JBossASServerComponent parentComponent = (JBossASServerComponent)
parentResourceComponent;
+
+ return
parentComponent.getPluginConfiguration().getSimple(parentComponent.JBOSS_HOME_DIR_CONFIG_PROP)
+ .getStringValue();
+ }
+
+ return null;
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
new file mode 100644
index 0000000..7d5f0dc
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModClusterServerComponent.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings({ "rawtypes" })
+public class ModClusterServerComponent extends MBeanResourceComponent {
+
+ @Override
+ public AvailabilityType getAvailability() {
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
+
+ if (rawProxyInfo == null) {
+ return AvailabilityType.DOWN;
+ }
+
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ if (proxyInfo.getAvailableNodes().size() == 0) {
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability();
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
deleted file mode 100644
index 03598e9..0000000
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.plugins.modcluster;
-
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.plugins.jbossas.JBossASServerComponent;
-import org.rhq.plugins.jbossas5.ApplicationServerComponent;
-import org.rhq.plugins.jmx.MBeanResourceComponent;
-import org.rhq.plugins.modcluster.helper.JBossHelper;
-
-/**
- * @author Stefan Negrea
- *
- */
-@SuppressWarnings({ "rawtypes" })
-public class ModclusterServerComponent extends MBeanResourceComponent {
-
- private final static String JBOSS_SERVER_HOME_DIR =
"jboss.server.home.dir";
-
- @SuppressWarnings({ "unchecked", "deprecation",
"static-access" })
- @Override
- public void start(ResourceContext context) {
- super.start(context);
-
- String serverHomeDirectory = null;
- if (this.resourceContext.getParentResourceComponent() instanceof
ApplicationServerComponent) {
- ApplicationServerComponent parentComponent = (ApplicationServerComponent)
this.resourceContext
- .getParentResourceComponent();
-
- serverHomeDirectory =
parentComponent.getResourceContext().getPluginConfiguration()
- .getSimple("serverHomeDir").getStringValue();
-
- } else if (this.resourceContext.getParentResourceComponent() instanceof
JBossASServerComponent) {
- JBossASServerComponent parentComponent = (JBossASServerComponent)
this.resourceContext
- .getParentResourceComponent();
-
- serverHomeDirectory = parentComponent.getPluginConfiguration()
- .getSimple(parentComponent.JBOSS_HOME_DIR_CONFIG_PROP).getStringValue();
- }
-
- if (serverHomeDirectory != null) {
- PropertySimple serverHomeDirectoryProperty = null;
- serverHomeDirectoryProperty = new PropertySimple();
- serverHomeDirectoryProperty.setName(JBOSS_SERVER_HOME_DIR);
- serverHomeDirectoryProperty.setStringValue(serverHomeDirectory);
-
this.resourceContext.getPluginConfiguration().put(serverHomeDirectoryProperty);
- }
- };
-
- //private final static String PROXY_INFO_PROPERTY_NAME
-
- /* (non-Javadoc)
- * @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
- */
- @Override
- public AvailabilityType getAvailability() {
- String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
-
- if (rawProxyInfo == null) {
- return AvailabilityType.DOWN;
- }
-
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
- if (proxyInfo.getAvailableNodes().size() == 0) {
- return AvailabilityType.DOWN;
- }
-
- return super.getAvailability();
- }
-}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
index bc54267..c67bf61 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
@@ -1,6 +1,9 @@
package org.rhq.plugins.modcluster;
+import java.util.concurrent.TimeUnit;
+
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.operation.OperationResult;
/*
@@ -36,4 +39,14 @@ public class PolyPingMBeanResourceComponent extends
FileConfiguredMBeanResourceC
return super.invokeOperation(name, parameters);
}
+
+ @Override
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
+ System.out.println(typeName);
+ if (typeName.equals(TimeUnit.class.getName())) {
+ return TimeUnit.valueOf(propSimple.getStringValue());
+ }
+
+ return super.getPropertyValueAsType(propSimple, typeName);
+ }
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
new file mode 100644
index 0000000..0296eaf
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/TimeUnitParamResourceComponent.java
@@ -0,0 +1,42 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.concurrent.TimeUnit;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings("rawtypes")
+public class TimeUnitParamResourceComponent extends MBeanResourceComponent {
+
+ @Override
+ protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName)
{
+ System.out.println(typeName);
+ if (typeName.equals(TimeUnit.class.getName())) {
+ return TimeUnit.valueOf(propSimple.getStringValue());
+ }
+
+ return super.getPropertyValueAsType(propSimple, typeName);
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
index 6c00130..dee2f81 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
@@ -18,11 +18,18 @@
*/
package org.rhq.plugins.modcluster.config;
+import java.io.File;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -38,11 +45,13 @@ public abstract class AbstractConfigurationFile {
public AbstractConfigurationFile(String fileName) throws
ParserConfigurationException, SAXException, IOException {
this.fileName = fileName;
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- this.document = docBuilder.parse(this.getFileName());
+ loadConfiguratonFile();
}
+ abstract void setPropertyValue(String propertyName, String value);
+
+ abstract String getPropertyValue(String propertyName);
+
/**
* @return the fileName
*/
@@ -57,9 +66,19 @@ public abstract class AbstractConfigurationFile {
return document;
}
- abstract void setPropertyValue(String propertyName, String value);
+ public void saveConfigurationFile() throws Exception {
+ File file = new File(this.getFileName());
+ StreamResult result = new StreamResult(file);
+ Source source = new DOMSource(this.getDocument());
- abstract String getPropertyValue(String propertyName);
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.transform(source, result);
+ }
- abstract void saveConfigurationFile() throws Exception;
+ private void loadConfiguratonFile() throws ParserConfigurationException,
SAXException, IOException {
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ this.document = docBuilder.parse(this.getFileName());
+ }
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
index 1d008ee..354fa99 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
@@ -47,11 +47,4 @@ public class JBossWebServerFile extends AbstractConfigurationFile {
// TODO Auto-generated method stub
return null;
}
-
- @Override
- void saveConfigurationFile() throws Exception {
- // TODO Auto-generated method stub
-
- }
-
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
index 45053f7..6abf955 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -19,17 +19,10 @@
package org.rhq.plugins.modcluster.config;
import java.io.IOException;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
@@ -129,22 +122,6 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
}
/**
- * @throws TransformerException
- */
- public void saveConfigurationFile() throws TransformerException {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "no");
-
- //initialize StreamResult with File object to save to file
- StreamResult result = new StreamResult(new StringWriter());
- DOMSource source = new DOMSource(this.getDocument());
- transformer.transform(source, result);
-
- String xmlString = result.getWriter().toString();
- System.out.println(xmlString);
- }
-
- /**
* @param className
* @return
*/
@@ -155,7 +132,6 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
Node node = result.item(i);
if (node.getAttributes().getNamedItem("class") != null
&&
className.equals(node.getAttributes().getNamedItem("class").getTextContent()))
{
-
System.out.println(node.getAttributes().getNamedItem("class").getTextContent());
return node;
}
}
@@ -174,7 +150,6 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
Node node = result.item(i);
if (node.getAttributes().getNamedItem("name") != null
&&
beanName.equals(node.getAttributes().getNamedItem("name").getTextContent())) {
-
System.out.println(node.getAttributes().getNamedItem("name").getTextContent());
return node;
}
}
@@ -243,5 +218,4 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return listOfNodes;
}
-
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 4f3010f..ed82f7c 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -6,7 +6,9 @@
<depends plugin="JMX" />
<service name="mod_cluster"
- discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
+ discovery="ModClusterDiscoveryComponent"
+ class="ModClusterServerComponent"
+ supportsManualAdd="true" description="mod_cluster plugin"
singleton="true">
<runs-inside>
<parent-resource-type name="JBossAS Server"
plugin="JBossAS" />
@@ -17,13 +19,17 @@
<c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*|jboss.web:service=ModCluster" />
<c:simple-property name="engineObjectName"
readOnly="true" default="jboss.web:type=Engine" />
<c:simple-property name="nameTemplate"
default="mod_cluster" />
+ <c:simple-property name="serverHomeDir"/>
</plugin-configuration>
<operation name="reset" displayName="Reset the node"
description="Move this application server out of an error state." />
<operation name="refresh" displayName="Refresh
configuration" description="Refresh configuration for this application
server." />
<!-- Start - Configuration for HAModClusterService -->
- <service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+ <service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
+ class="PolyPingMBeanResourceComponent"
+ supportsManualAdd="true"
+ description="HA Service Listener" singleton="true">
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
@@ -35,18 +41,18 @@
<!-- HA Operations -->
<operation name="disableDomain" displayName="Disable
domain" description="Disables all contexts on each node within the current
domain. If the current domain is null, then all nodes are stopped.">
<results>
- <c:simple-property name="result" description="The result
of the operation" />
+ <c:simple-property name="operationResult"
description="The result of the operation" />
</results>
</operation>
<operation name="enableDomain" displayName="Enable
domain" description="Enable all contexts on each node within the current domain.
If the current domain is null, then all nodes are stopped.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="stopDomain" displayName="Stop domain"
description="Gracefully stops all contexts on each node within the current domain. If
the current domain is null, then all nodes are stopped.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="The number of units of time for which to wait
for all sessions to drain on a given node." />
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:simple-property required="true" name="p1"
type="string" displayName="The number of units of time for which to wait
for all sessions to drain on a given node." />
+ <c:simple-property required="true" name="p2"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
<c:property-options allowCustomValue="false">
<c:option value="MICROSECONDS"
name="MICROSECONDS" />
<c:option value="MILLISECONDS"
name="MILLISECONDS" />
@@ -58,7 +64,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -66,59 +72,60 @@
<operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
<results>
- <c:simple-property name="result" description="Map of
PING_RPS response, grouped by proxy.">
+ <c:simple-property name="operationResult"
description="Map of PING_RPS response, grouped by proxy.">
</c:simple-property>
</results>
</operation>
<operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ <c:simple-property required="true" name="p1"
type="string" displayName="JVM Route of node to ping." />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="pingNodeByAddress" displayName="Ping node by
address"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
- <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
- <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="p2"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="p3"
type="integer" displayName="Port" />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
<operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
+
<operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
<results>
- <c:simple-property name="result" description="The result
of the operation">
+ <c:simple-property name="operationResult"
description="The result of the operation">
</c:simple-property>
</results>
</operation>
<operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
<results>
- <c:simple-property name="result" description="The result
of the operation">
+ <c:simple-property name="operationResult"
description="The result of the operation">
</c:simple-property>
</results>
</operation>
<operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:simple-property required="true" name="p1"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="p2"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
<c:property-options allowCustomValue="false">
<c:option value="MICROSECONDS"
name="MICROSECONDS" />
<c:option value="MILLISECONDS"
name="MILLISECONDS" />
@@ -130,7 +137,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -139,7 +146,7 @@
<metric property="ProxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
<resource-configuration>
- <c:simple-property name="processStatusFrequency"
type="integer" description="Process status frequency." />
+ <c:simple-property name="processStatusFrequency"
type="integer" required="false" description="Process status
frequency." />
</resource-configuration>
</service>
@@ -203,56 +210,57 @@
<operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ <c:simple-property required="true" name="p1"
type="string" displayName="JVM Route of node to ping." />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="pingNodeByAddress" displayName="Ping node by
address"
description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
<parameters>
- <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
- <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
- <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="p2"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="p3"
type="integer" displayName="Port" />
</parameters>
<results>
- <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ <c:simple-property name="operationResult"
type="string" description="Map of PING_RPS response, grouped by
proxy." />
</results>
</operation>
<operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
<operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
<parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ <c:simple-property required="true" name="p1"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="p2"
type="integer" displayName="Proxy port" />
</parameters>
</operation>
+
<operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:simple-property required="true" name="p1"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="p2"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
<c:property-options allowCustomValue="false">
<c:option value="MICROSECONDS"
name="MICROSECONDS" />
<c:option value="MILLISECONDS"
name="MILLISECONDS" />
@@ -264,7 +272,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -338,12 +346,12 @@
</operation>
<operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
@@ -361,7 +369,7 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
@@ -396,11 +404,9 @@
<c:simple-property name="nameTemplate" default="Dynamic
Load Balancer Factor" />
</plugin-configuration>
- <metric property="Metrics" displayName="Collected
Metrics" displayType="summary" dataType="trait" />
-
<resource-configuration>
- <c:simple-property name="DecayFactor" type="integer"
description="The number of historical load values used to determine load
factor." />
- <c:simple-property name="History" type="integer"
description="The exponential decay factor for historical load values." />
+ <c:simple-property name="decayFactor" type="integer"
required="false" description="The number of historical load values used to
determine load factor." />
+ <c:simple-property name="history" type="integer"
required="false" description="The exponential decay factor for historical
load values." />
</resource-configuration>
</service>
@@ -424,11 +430,13 @@
<c:simple-property name="nameTemplate" default="Load
Metric" />
</plugin-configuration>
- <metric property="Load" displayName="Load"
category="utilization" description="The current load of this metric as a
percent of the metric's capacity." dataType="measurement" />
+ <metric property="Load" displayName="Load"
category="utilization"
+ description="The current load of this metric as a percent of the
metric's capacity." dataType="measurement"
+ defaultOn="true" displayType="summary"/>
<resource-configuration>
- <c:simple-property name="Weight" type="integer"
description="The significance of this load metric compared to the other
metrics." />
- <c:simple-property name="Capacity" type="double"
description="Used to normalize the value returned by load expressed as a percentage
of the capacity, such that: 0 < (load/capacity) < 1" />
+ <c:simple-property name="weight" type="integer"
description="The significance of this load metric compared to the other
metrics." />
+ <c:simple-property name="capacity" type="double"
description="Used to normalize the value returned by load expressed as a percentage
of the capacity, such that: 0 < (load/capacity) < 1" />
</resource-configuration>
</service>
@@ -436,7 +444,7 @@
<operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation." />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation." />
</results>
</operation>
<operation name="stopContext" displayName="Stop webapp"
description="Gracefully stops this webapp.">
@@ -454,12 +462,12 @@
</c:simple-property>
</parameters>
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
<operation name="enableContext" displayName="Enable
webapp" description="Enable this webapp.">
<results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ <c:simple-property name="operationResult"
type="boolean" description="The result of the operation" />
</results>
</operation>
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
index c50b0e6..cba5672 100644
---
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
@@ -28,16 +28,19 @@ public class ServerConfigTest {
public void TestConfig() {
try {
+ //Test simple bean configuration
ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
- System.out.println(config.getPropertyValue("test"));
+ config.setPropertyValue("test", null);
+ config.setPropertyValue("processStatusFrequency", null);
config.saveConfigurationFile();
+ //Test bean configuration with constructor dependency
config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
"org.jboss.modcluster.config.ha.HAModClusterConfig",
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
@@ -45,11 +48,8 @@ public class ServerConfigTest {
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
- System.out.println(config.getPropertyValue("test"));
-
- config.saveConfigurationFile();
-
config.setPropertyValue("test", null);
+ config.setPropertyValue("processStatusFrequency", null);
config.saveConfigurationFile();
} catch (Exception e) {
// TODO Auto-generated catch block
commit 7b57da38ba1b16241e06480cf0b95a22c3508999
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Aug 15 14:59:16 2011 -0500
The JBoss server home directory is now correctly retrieved from the parent resource
component. Included some other minor code tweaks and refactorings.
diff --git a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
index 77a81b2..ba94746 100644
--- a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
+++ b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
@@ -42,7 +42,13 @@
</dependencyManagement>
<dependencies>
-
+ <dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 0a39eab..b642573 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -45,6 +45,7 @@ import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.plugin.FileSystemPluginFinder;
import org.rhq.core.pc.plugin.PluginEnvironment;
import org.rhq.core.pc.plugin.PluginManager;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
@@ -109,7 +110,8 @@ public class ModclusterPluginTest {
{
add(PLUGIN_NAME);
- add(PLUGIN_NAME + " Webapp Context");
+ add("Webapp Context");
+ add("HA Service Configuration");
}
};
@@ -124,8 +126,12 @@ public class ModclusterPluginTest {
Resource resource = (Resource) objectResource;
if (resource.getResourceType().getName().equals("mod_cluster"))
{
testResourceMeasurement(resource);
- } else {
+ } else if (resource.getResourceType().getName().equals("Webapp
Context")) {
testContextOperations(resource);
+ } else if (resource.getResourceType().getName().equals("HA Service
Configuration")) {
+ ResourceComponent resourceComponent =
PluginContainer.getInstance().getInventoryManager()
+ .getResourceComponent(resource);
+ ((ConfigurationFacet)
resourceComponent).loadResourceConfiguration();
}
}
}
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index fdc4f37..35c5b28 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -23,6 +23,14 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.on</groupId>
+ <artifactId>jopr-jboss-as-5-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>log4j</groupId>
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 8e14f9b..c5343d0 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -20,6 +20,8 @@ package org.rhq.plugins.modcluster;
import java.util.concurrent.TimeUnit;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.mc4j.ems.connection.bean.EmsBean;
import org.rhq.core.domain.configuration.Configuration;
@@ -35,6 +37,9 @@ import org.rhq.plugins.modcluster.helper.JBossHelper;
*/
@SuppressWarnings({ "rawtypes", "deprecation" })
public class ContextComponent extends
MBeanResourceComponent<MBeanResourceComponent> {
+
+ private static final Log log = LogFactory.getLog(ContextComponent.class);
+
@Override
protected EmsBean loadBean() {
return getResourceContext().getParentResourceComponent().getEmsBean();
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
index 9b511b3..ee0369c 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -19,6 +19,9 @@
package org.rhq.plugins.modcluster;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -34,11 +37,15 @@ import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
* @author Stefan Negrea
*
*/
-@SuppressWarnings("rawtypes")
+@SuppressWarnings({ "rawtypes", "deprecation" })
public class FileConfiguredMBeanResourceComponent extends MBeanResourceComponent {
+ private static final Log log =
LogFactory.getLog(FileConfiguredMBeanResourceComponent.class);
+
private static final String BEAN_CLASS_NAME_PROPERTY = "className";
private static final String DEPENDENCY_BEAN_CLASS_NAME_PROPERTY =
"dependencyClassName";
+ private static final String SERVER_HOME_DIR = "jboss.server.home.dir";
+ private static final String CONFIGURATION_FILE_RELATIVE_PATH =
"/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml";
/**
* This default setup of configuration properties can map to mbean attributes
@@ -46,15 +53,14 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
* @return the configuration of the component
*/
@Override
- @SuppressWarnings("deprecation")
public Configuration loadResourceConfiguration() {
+
Configuration configuration = new Configuration();
ConfigurationDefinition configurationDefinition =
this.resourceContext.getResourceType()
.getResourceConfigurationDefinition();
try {
- ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
- .getPluginConfiguration());
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance();
for (PropertyDefinition property :
configurationDefinition.getPropertyDefinitions().values()) {
if (property instanceof PropertyDefinitionSimple) {
@@ -69,8 +75,7 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
}
}
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.debug("Unable to load mod_cluster configuration file.", e);
}
return configuration;
@@ -84,19 +89,35 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
updateResourceConfiguration(report, false);
}
- private ModClusterBeanFile getModClusterBeanFileInstance(Configuration pluginConfig)
throws Exception {
+ private ModClusterBeanFile getModClusterBeanFileInstance() throws Exception {
+ Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
String beanClassName =
pluginConfig.getSimple(BEAN_CLASS_NAME_PROPERTY).getStringValue();
+ String fileName = this.getServerHomeDirectory() +
CONFIGURATION_FILE_RELATIVE_PATH;
+
if (pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY) != null) {
String dependencyBeanClassName =
pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY)
.getStringValue();
- return new ModClusterBeanFile(dependencyBeanClassName);
+ return new ModClusterBeanFile(beanClassName, dependencyBeanClassName,
fileName);
+ }
+
+ return new ModClusterBeanFile(beanClassName, fileName);
+ }
+
+ private String getServerHomeDirectory() {
+ ModclusterServerComponent modClusterComponent = (ModclusterServerComponent)
this.resourceContext
+ .getParentResourceComponent();
+
+ PropertySimple property =
modClusterComponent.getResourceContext().getPluginConfiguration()
+ .getSimple(SERVER_HOME_DIR);
+
+ if (property != null) {
+ return property.getStringValue();
}
- return new ModClusterBeanFile(beanClassName);
+ return null;
}
- @SuppressWarnings("deprecation")
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report, boolean
ignoreReadOnly) {
ConfigurationDefinition configurationDefinition =
this.getResourceContext().getResourceType()
@@ -106,8 +127,7 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
try {
- ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
- .getPluginConfiguration());
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance();
for (String key : report.getConfiguration().getSimpleProperties().keySet())
{
PropertySimple property = report.getConfiguration().getSimple(key);
@@ -127,10 +147,9 @@ public class FileConfiguredMBeanResourceComponent extends
MBeanResourceComponent
}
}
- modClusterBeanFile.saveConfigFile();
+ modClusterBeanFile.saveConfigurationFile();
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.debug("Unable to save mod_cluster configuration file.", e);
}
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
index fb944c8..496068c 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
@@ -30,7 +30,7 @@ import org.rhq.plugins.jmx.JMXComponent;
import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
/**
- * @author snegrea
+ * @author Stefan Negrea
*
*/
@SuppressWarnings("rawtypes")
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 2c964c0..03598e9 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -18,7 +18,11 @@
*/
package org.rhq.plugins.modcluster;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.plugins.jbossas.JBossASServerComponent;
+import org.rhq.plugins.jbossas5.ApplicationServerComponent;
import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.modcluster.helper.JBossHelper;
@@ -29,6 +33,38 @@ import org.rhq.plugins.modcluster.helper.JBossHelper;
@SuppressWarnings({ "rawtypes" })
public class ModclusterServerComponent extends MBeanResourceComponent {
+ private final static String JBOSS_SERVER_HOME_DIR =
"jboss.server.home.dir";
+
+ @SuppressWarnings({ "unchecked", "deprecation",
"static-access" })
+ @Override
+ public void start(ResourceContext context) {
+ super.start(context);
+
+ String serverHomeDirectory = null;
+ if (this.resourceContext.getParentResourceComponent() instanceof
ApplicationServerComponent) {
+ ApplicationServerComponent parentComponent = (ApplicationServerComponent)
this.resourceContext
+ .getParentResourceComponent();
+
+ serverHomeDirectory =
parentComponent.getResourceContext().getPluginConfiguration()
+ .getSimple("serverHomeDir").getStringValue();
+
+ } else if (this.resourceContext.getParentResourceComponent() instanceof
JBossASServerComponent) {
+ JBossASServerComponent parentComponent = (JBossASServerComponent)
this.resourceContext
+ .getParentResourceComponent();
+
+ serverHomeDirectory = parentComponent.getPluginConfiguration()
+ .getSimple(parentComponent.JBOSS_HOME_DIR_CONFIG_PROP).getStringValue();
+ }
+
+ if (serverHomeDirectory != null) {
+ PropertySimple serverHomeDirectoryProperty = null;
+ serverHomeDirectoryProperty = new PropertySimple();
+ serverHomeDirectoryProperty.setName(JBOSS_SERVER_HOME_DIR);
+ serverHomeDirectoryProperty.setStringValue(serverHomeDirectory);
+
this.resourceContext.getPluginConfiguration().put(serverHomeDirectoryProperty);
+ }
+ };
+
//private final static String PROXY_INFO_PROPERTY_NAME
/* (non-Javadoc)
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
index 8f5d08b..bc54267 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
@@ -22,6 +22,10 @@ import org.rhq.core.pluginapi.operation.OperationResult;
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/**
+ *
+ * @author Stefan Negrea
+ */
public class PolyPingMBeanResourceComponent extends FileConfiguredMBeanResourceComponent
{
@Override
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
index 4fe5788..6c00130 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
@@ -32,9 +32,6 @@ import org.xml.sax.SAXException;
* @author Stefan Negrea
*/
public abstract class AbstractConfigurationFile {
-
- public static final String SERVER_HOME_DIR = "jboss.server.home.dir";
-
private String fileName;
private Document document;
@@ -60,4 +57,9 @@ public abstract class AbstractConfigurationFile {
return document;
}
+ abstract void setPropertyValue(String propertyName, String value);
+
+ abstract String getPropertyValue(String propertyName);
+
+ abstract void saveConfigurationFile() throws Exception;
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
index 602e52b..1d008ee 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
@@ -36,4 +36,22 @@ public class JBossWebServerFile extends AbstractConfigurationFile {
// TODO Auto-generated constructor stub
}
+ @Override
+ void setPropertyValue(String propertyName, String value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ String getPropertyValue(String propertyName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ void saveConfigurationFile() throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
index 0e25f26..45053f7 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.modcluster.config;
import java.io.IOException;
@@ -38,24 +37,38 @@ import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
- * @author snegrea
+ * @author Stefan Negrea
*
*/
public class ModClusterBeanFile extends AbstractConfigurationFile {
private Node beanNode;
- public ModClusterBeanFile(String className) throws ParserConfigurationException,
SAXException, IOException {
- super(
-
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+ /**
+ * @param className
+ * @param configurationFile
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public ModClusterBeanFile(String className, String configurationFile) throws
ParserConfigurationException,
+ SAXException, IOException {
+ super(configurationFile);
beanNode = this.getBeanNodeByClass(className);
}
- public ModClusterBeanFile(String className, String constructorArgumentClassName)
+ /**
+ * @param className
+ * @param constructorArgumentClassName
+ * @param configurationFile
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public ModClusterBeanFile(String className, String constructorArgumentClassName,
String configurationFile)
throws ParserConfigurationException, SAXException, IOException {
- super(
-
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+ super(configurationFile);
Node primaryBeanNode = this.getBeanNodeByClass(className);
String dependencyName = this.getBeanFromConstructorArgument(primaryBeanNode,
constructorArgumentClassName);
@@ -63,58 +76,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
beanNode = this.getBeanNodeByName(dependencyName);
}
- private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
- List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
-
- if (tempNodeList.size() > 0) {
- Node constructorNode = tempNodeList.get(0);
-
- tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
-
- if (tempNodeList.size() > 0) {
- Node parameterNode = null;
-
- for (Node currentNode : tempNodeList) {
- if (currentNode.getAttributes().getNamedItem("class") !=
null
- &&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
- .getTextContent())) {
- parameterNode = currentNode;
- break;
- }
- }
-
- if (parameterNode != null) {
- tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
-
- if (tempNodeList.size() > 0) {
- Node injectNode = tempNodeList.get(0);
- Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
-
- if (beanAttribute != null) {
- return beanAttribute.getTextContent();
- }
- }
- }
- }
- }
-
- return null;
- }
-
- private List<Node> getChildNodesByName(Node node, String nodeName) {
- List<Node> listOfNodes = new ArrayList<Node>();
-
- for (int i = 0; i < node.getChildNodes().getLength(); i++) {
- Node currentNode = node.getChildNodes().item(i);
-
- if (nodeName.equals(currentNode.getNodeName())) {
- listOfNodes.add(currentNode);
- }
- }
-
- return listOfNodes;
- }
-
+ /**
+ * @param propertyName
+ * @param value
+ */
public void setPropertyValue(String propertyName, String value) {
boolean propertyFound = false;
for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
@@ -144,6 +109,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
}
}
+ /**
+ * @param propertyName
+ * @return
+ */
public String getPropertyValue(String propertyName) {
for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
Node currentNode = beanNode.getChildNodes().item(i);
@@ -159,7 +128,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return null;
}
- public void saveConfigFile() throws TransformerException {
+ /**
+ * @throws TransformerException
+ */
+ public void saveConfigurationFile() throws TransformerException {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "no");
@@ -172,7 +144,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
System.out.println(xmlString);
}
- public Node getBeanNodeByClass(String className) {
+ /**
+ * @param className
+ * @return
+ */
+ private Node getBeanNodeByClass(String className) {
NodeList result = this.getDocument().getElementsByTagName("bean");
for (int i = 1; i < result.getLength(); i++) {
@@ -187,7 +163,11 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return null;
}
- public Node getBeanNodeByName(String beanName) {
+ /**
+ * @param beanName
+ * @return
+ */
+ private Node getBeanNodeByName(String beanName) {
NodeList result = this.getDocument().getElementsByTagName("bean");
for (int i = 1; i < result.getLength(); i++) {
@@ -202,4 +182,66 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
return null;
}
+ /**
+ * @param beanNode
+ * @param constructorArgumentClassName
+ * @return
+ */
+ private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
+ List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
+
+ if (tempNodeList.size() > 0) {
+ Node constructorNode = tempNodeList.get(0);
+
+ tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
+
+ if (tempNodeList.size() > 0) {
+ Node parameterNode = null;
+
+ for (Node currentNode : tempNodeList) {
+ if (currentNode.getAttributes().getNamedItem("class") !=
null
+ &&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
+ .getTextContent())) {
+ parameterNode = currentNode;
+ break;
+ }
+ }
+
+ if (parameterNode != null) {
+ tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
+
+ if (tempNodeList.size() > 0) {
+ Node injectNode = tempNodeList.get(0);
+ Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
+
+ if (beanAttribute != null) {
+ return beanAttribute.getTextContent();
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param node
+ * @param nodeName
+ * @return
+ */
+ private List<Node> getChildNodesByName(Node node, String nodeName) {
+ List<Node> listOfNodes = new ArrayList<Node>();
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++) {
+ Node currentNode = node.getChildNodes().item(i);
+
+ if (nodeName.equals(currentNode.getNodeName())) {
+ listOfNodes.add(currentNode);
+ }
+ }
+
+ return listOfNodes;
+ }
+
}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index fe4ac7d..4f3010f 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -5,7 +5,8 @@
<depends plugin="JMX" />
- <service name="mod_cluster"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
+ <service name="mod_cluster"
+ discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
<runs-inside>
<parent-resource-type name="JBossAS Server"
plugin="JBossAS" />
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
index 4e4aac1..c50b0e6 100644
---
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
@@ -28,27 +28,29 @@ public class ServerConfigTest {
public void TestConfig() {
try {
- ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService");
+ ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
System.out.println(config.getPropertyValue("test"));
- config.saveConfigFile();
+ config.saveConfigurationFile();
config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
- "org.jboss.modcluster.config.ha.HAModClusterConfig");
+ "org.jboss.modcluster.config.ha.HAModClusterConfig",
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
System.out.println(config.getPropertyValue("test"));
- config.saveConfigFile();
+ config.saveConfigurationFile();
config.setPropertyValue("test", null);
- config.saveConfigFile();
+ config.saveConfigurationFile();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
commit c166ad34f0490dea2ea9c95ff6c1d2c1c8d9e0fc
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Sun Aug 14 12:06:26 2011 -0500
Enable mod_cluster support for JBoss 5&6 with simple and HA configuration
listeners. Also, added metric collections and configuration save to bean file.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
new file mode 100644
index 0000000..b9ce25e
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ClassNameMBeanDiscoveryComponent.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * Discovers mod_cluster contexts from the proxyInfo mbean property.
+ *
+ * @author Stefan Negrea
+ */
+@SuppressWarnings("rawtypes")
+public class ClassNameMBeanDiscoveryComponent<T extends JMXComponent> extends
MBeanResourceDiscoveryComponent<T> {
+
+ private static final String CLASS_NAME = "className";
+
+ /* (non-Javadoc)
+ * @see
org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext,
boolean)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<T> context,
+ boolean skipUnknownProps) {
+
+ Set<DiscoveredResourceDetails> results = super.discoverResources(context,
skipUnknownProps);
+
+ for (DiscoveredResourceDetails discoveredResource : results) {
+ if (!isBeanConfiguredClassName(context, discoveredResource.getResourceKey()))
{
+ results.remove(discoveredResource);
+ }
+ }
+
+ return results;
+ }
+
+ /**
+ * @param context
+ * @param objectName
+ * @return
+ */
+ public boolean isBeanConfiguredClassName(ResourceDiscoveryContext<T> context,
String objectName) {
+ String className =
context.getDefaultPluginConfiguration().getSimple(CLASS_NAME).getStringValue();
+
+ EmsConnection connection =
context.getParentResourceComponent().getEmsConnection();
+ EmsBean emsBean = loadBean(connection, objectName);
+
+ return className.equals(emsBean.getClassTypeName());
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(EmsConnection emsConnection, String objectName) {
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some
means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
+
+}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
index 3545fa5..8e14f9b 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextComponent.java
@@ -26,6 +26,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
/**
* Manages a mod_cluster context entity.
@@ -44,7 +45,7 @@ public class ContextComponent extends
MBeanResourceComponent<MBeanResourceCompon
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
- String rawProxyInfo = (String)
getEmsBean().getAttribute("proxyInfo").refresh().toString();
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
@@ -91,12 +92,16 @@ public class ContextComponent extends
MBeanResourceComponent<MBeanResourceCompon
Thread.currentThread().setContextClassLoader(getEmsBean().getClass().getClassLoader());
Object resultObject =
getEmsBean().getOperation(name).invoke(configuration);
- return new OperationResult(String.valueOf(resultObject));
+ if (resultObject instanceof OperationResult) {
+ return (OperationResult) resultObject;
+ } else {
+ return new OperationResult(String.valueOf(resultObject));
+ }
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
- throw new Exception("Operation " + name + " not available
mod_cluster_context service");
+ throw new Exception("Operation " + name + " not available
mod_cluster WebApp service.");
}
}
\ No newline at end of file
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
index 3d03715..788cbce 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ContextDiscoveryComponent.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
+ * RHQ Management Platform
* Copyright (C) 2005-2008 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.rhq.plugins.modcluster;
@@ -33,6 +29,7 @@ import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
/**
* Discovers mod_cluster contexts from the proxyInfo mbean property.
@@ -43,7 +40,6 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBeanResourceComponent> {
private static final String JVM_ROUTE_PROPERTY = "jvmRoute";
- private static final String PROXY_INFO_PROPERTY = "proxyInfo";
private static final String ENGINE_OBJECT_NAME = "engineObjectName";
/* (non-Javadoc)
@@ -51,7 +47,9 @@ public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBe
*/
public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<MBeanResourceComponent> context) {
String jvmRoute = this.getJvmRoute(context);
- String rawProxyInfo = this.getRawProxyInfo(context);
+
+ EmsBean configBean = context.getParentResourceComponent().getEmsBean();
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(configBean);
ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
Set<DiscoveredResourceDetails> entities = new
HashSet<DiscoveredResourceDetails>();
@@ -59,8 +57,7 @@ public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBe
for (ProxyInfo.Context availableContext : proxyInfo.getAvailableContexts()) {
if (availableContext.getJvmRoute().equals(jvmRoute)) {
DiscoveredResourceDetails detail = new
DiscoveredResourceDetails(context.getResourceType(),
- availableContext.createKey(), availableContext.createName(), null,
"mod_cluster Webapp Context",
- null, null);
+ availableContext.createKey(), availableContext.createName(), null,
"Webapp Context", null, null);
entities.add(detail);
}
}
@@ -83,17 +80,6 @@ public class ContextDiscoveryComponent implements
ResourceDiscoveryComponent<MBe
}
/**
- * Retrieves raw proxy configuration from the parent context.
- *
- * @param context the discovery context
- * @return raw proxy configuration
- */
- private String getRawProxyInfo(ResourceDiscoveryContext<MBeanResourceComponent>
context) {
- EmsBean statsBean = context.getParentResourceComponent().getEmsBean();
- return (String)
statsBean.getAttribute(PROXY_INFO_PROPERTY).refresh().toString();
- }
-
- /**
* Loads the bean with the given object name.
*
* Subclasses are free to override this method in order to load the bean.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
new file mode 100644
index 0000000..9b511b3
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/FileConfiguredMBeanResourceComponent.java
@@ -0,0 +1,137 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+@SuppressWarnings("rawtypes")
+public class FileConfiguredMBeanResourceComponent extends MBeanResourceComponent {
+
+ private static final String BEAN_CLASS_NAME_PROPERTY = "className";
+ private static final String DEPENDENCY_BEAN_CLASS_NAME_PROPERTY =
"dependencyClassName";
+
+ /**
+ * This default setup of configuration properties can map to mbean attributes
+ *
+ * @return the configuration of the component
+ */
+ @Override
+ @SuppressWarnings("deprecation")
+ public Configuration loadResourceConfiguration() {
+ Configuration configuration = new Configuration();
+ ConfigurationDefinition configurationDefinition =
this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ try {
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
+ .getPluginConfiguration());
+
+ for (PropertyDefinition property :
configurationDefinition.getPropertyDefinitions().values()) {
+ if (property instanceof PropertyDefinitionSimple) {
+ String value =
modClusterBeanFile.getPropertyValue(property.getName());
+ if (value != null) {
+ configuration.put(new PropertySimple(property.getName(),
value));
+ } else {
+ PropertyDefinitionSimple propertyDefinitionSimple =
(PropertyDefinitionSimple) property;
+ configuration.put(new PropertySimple(property.getName(),
propertyDefinitionSimple
+ .getDefaultValue()));
+ }
+ }
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return configuration;
+ }
+
+ /**
+ * Equivalent to updateResourceConfiguration(report, false);
+ */
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ updateResourceConfiguration(report, false);
+ }
+
+ private ModClusterBeanFile getModClusterBeanFileInstance(Configuration pluginConfig)
throws Exception {
+ String beanClassName =
pluginConfig.getSimple(BEAN_CLASS_NAME_PROPERTY).getStringValue();
+
+ if (pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY) != null) {
+ String dependencyBeanClassName =
pluginConfig.getSimple(DEPENDENCY_BEAN_CLASS_NAME_PROPERTY)
+ .getStringValue();
+ return new ModClusterBeanFile(dependencyBeanClassName);
+ }
+
+ return new ModClusterBeanFile(beanClassName);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport report, boolean
ignoreReadOnly) {
+ ConfigurationDefinition configurationDefinition =
this.getResourceContext().getResourceType()
+ .getResourceConfigurationDefinition();
+
+ // assume we succeed - we'll set to failure if we can't set all
properties
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+
+ try {
+ ModClusterBeanFile modClusterBeanFile =
this.getModClusterBeanFileInstance(this.resourceContext
+ .getPluginConfiguration());
+
+ for (String key : report.getConfiguration().getSimpleProperties().keySet())
{
+ PropertySimple property = report.getConfiguration().getSimple(key);
+ if (property != null) {
+ try {
+ PropertyDefinitionSimple def =
configurationDefinition.getPropertyDefinitionSimple(property
+ .getName());
+ if (!(ignoreReadOnly && def.isReadOnly())) {
+ modClusterBeanFile.setPropertyValue(property.getName(),
property.getStringValue());
+ }
+ } catch (Exception e) {
+ property.setErrorMessage(ThrowableUtil.getStackAsString(e));
+ report
+ .setErrorMessage("Failed setting resource configuration
- see property error messages for details");
+ log.info("Failure setting MBean Resource configuration value
for " + key, e);
+ }
+ }
+ }
+
+ modClusterBeanFile.saveConfigFile();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
new file mode 100644
index 0000000..fb944c8
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster;
+
+import java.util.Set;
+
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
+
+/**
+ * @author snegrea
+ *
+ */
+@SuppressWarnings("rawtypes")
+public class LoadMetricDiscoveryComponent extends
MBeanResourceDiscoveryComponent<JMXComponent> {
+
+ /* (non-Javadoc)
+ * @see
org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext,
boolean)
+ */
+ @Override
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<JMXComponent> context,
+ boolean skipUnknownProps) {
+
+ Set<DiscoveredResourceDetails> results = super.discoverResources(context,
skipUnknownProps);
+
+ for (DiscoveredResourceDetails discoveredResource : results) {
+
+ String name = getBeanConfiguredClassName(context,
discoveredResource.getResourceKey());
+
+ name = name.substring(name.lastIndexOf(".") + 1);
+ name = name.substring(0, name.lastIndexOf("LoadMetric"));
+
+ discoveredResource.setResourceName(name);
+ discoveredResource.setResourceDescription("Load Metric");
+ }
+
+ return results;
+ }
+
+ /**
+ * @param context
+ * @param objectName
+ * @return
+ */
+ public String getBeanConfiguredClassName(ResourceDiscoveryContext<JMXComponent>
context, String objectName) {
+ EmsConnection connection =
context.getParentResourceComponent().getEmsConnection();
+ EmsBean emsBean = loadBean(connection, objectName);
+
+ return emsBean.getClassTypeName();
+ }
+
+ /**
+ * Loads the bean with the given object name.
+ *
+ * Subclasses are free to override this method in order to load the bean.
+ *
+ * @param objectName the name of the bean to load
+ * @return the bean that is loaded
+ */
+ protected EmsBean loadBean(EmsConnection emsConnection, String objectName) {
+ EmsBean bean = emsConnection.getBean(objectName);
+ if (bean == null) {
+ // In some cases, this resource component may have been discovered by some
means other than querying its
+ // parent's EMSConnection (e.g. ApplicationDiscoveryComponent uses a
filesystem to discover EARs and
+ // WARs that are not yet deployed). In such cases, getBean() will return
null, since EMS won't have the
+ // bean in its cache. To cover such cases, make an attempt to query the
underlying MBeanServer for the
+ // bean before giving up.
+ emsConnection.queryBeans(objectName);
+ bean = emsConnection.getBean(objectName);
+ }
+ return bean;
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
index 70898ef..2c964c0 100644
---
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/ModclusterServerComponent.java
@@ -20,6 +20,7 @@ package org.rhq.plugins.modcluster;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.plugins.jmx.MBeanResourceComponent;
+import org.rhq.plugins.modcluster.helper.JBossHelper;
/**
* @author Stefan Negrea
@@ -28,15 +29,21 @@ import org.rhq.plugins.jmx.MBeanResourceComponent;
@SuppressWarnings({ "rawtypes" })
public class ModclusterServerComponent extends MBeanResourceComponent {
+ //private final static String PROXY_INFO_PROPERTY_NAME
+
/* (non-Javadoc)
* @see org.rhq.plugins.jmx.MBeanResourceComponent#getAvailability()
*/
@Override
public AvailabilityType getAvailability() {
- String rawProxyInfo = (String)
getEmsBean().getAttribute("proxyInfo").refresh().toString();
- ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ String rawProxyInfo = JBossHelper.getRawProxyInfo(getEmsBean());
+
+ if (rawProxyInfo == null) {
+ return AvailabilityType.DOWN;
+ }
- if (proxyInfo.getAvailableContexts().size() == 0) {
+ ProxyInfo proxyInfo = new ProxyInfo(rawProxyInfo);
+ if (proxyInfo.getAvailableNodes().size() == 0) {
return AvailabilityType.DOWN;
}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
new file mode 100644
index 0000000..8f5d08b
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/PolyPingMBeanResourceComponent.java
@@ -0,0 +1,35 @@
+package org.rhq.plugins.modcluster;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+public class PolyPingMBeanResourceComponent extends FileConfiguredMBeanResourceComponent
{
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws
Exception {
+ if (name.toLowerCase().startsWith("ping")) {
+ name = "ping";
+ }
+
+ return super.invokeOperation(name, parameters);
+ }
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
new file mode 100644
index 0000000..4fe5788
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.config;
+
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ * @author Stefan Negrea
+ */
+public abstract class AbstractConfigurationFile {
+
+ public static final String SERVER_HOME_DIR = "jboss.server.home.dir";
+
+ private String fileName;
+ private Document document;
+
+ public AbstractConfigurationFile(String fileName) throws
ParserConfigurationException, SAXException, IOException {
+ this.fileName = fileName;
+
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ this.document = docBuilder.parse(this.getFileName());
+ }
+
+ /**
+ * @return the fileName
+ */
+ public String getFileName() {
+ return fileName;
+ }
+
+ /**
+ * @return the doc
+ */
+ public Document getDocument() {
+ return document;
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
new file mode 100644
index 0000000..602e52b
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
@@ -0,0 +1,39 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster.config;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXException;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class JBossWebServerFile extends AbstractConfigurationFile {
+
+ public JBossWebServerFile(String fileName) throws ParserConfigurationException,
SAXException, IOException {
+ super(fileName);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
new file mode 100644
index 0000000..0e25f26
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
@@ -0,0 +1,205 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster.config;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @author snegrea
+ *
+ */
+public class ModClusterBeanFile extends AbstractConfigurationFile {
+
+ private Node beanNode;
+
+ public ModClusterBeanFile(String className) throws ParserConfigurationException,
SAXException, IOException {
+ super(
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+
+ beanNode = this.getBeanNodeByClass(className);
+ }
+
+ public ModClusterBeanFile(String className, String constructorArgumentClassName)
+ throws ParserConfigurationException, SAXException, IOException {
+ super(
+
"/home/snegrea/Downloads/jboss51eap/jboss-as/server/all/deploy/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml");
+
+ Node primaryBeanNode = this.getBeanNodeByClass(className);
+ String dependencyName = this.getBeanFromConstructorArgument(primaryBeanNode,
constructorArgumentClassName);
+
+ beanNode = this.getBeanNodeByName(dependencyName);
+ }
+
+ private String getBeanFromConstructorArgument(Node beanNode, String
constructorArgumentClassName) {
+ List<Node> tempNodeList = this.getChildNodesByName(beanNode,
"constructor");
+
+ if (tempNodeList.size() > 0) {
+ Node constructorNode = tempNodeList.get(0);
+
+ tempNodeList = this.getChildNodesByName(constructorNode,
"parameter");
+
+ if (tempNodeList.size() > 0) {
+ Node parameterNode = null;
+
+ for (Node currentNode : tempNodeList) {
+ if (currentNode.getAttributes().getNamedItem("class") !=
null
+ &&
constructorArgumentClassName.equals(currentNode.getAttributes().getNamedItem("class")
+ .getTextContent())) {
+ parameterNode = currentNode;
+ break;
+ }
+ }
+
+ if (parameterNode != null) {
+ tempNodeList = this.getChildNodesByName(parameterNode,
"inject");
+
+ if (tempNodeList.size() > 0) {
+ Node injectNode = tempNodeList.get(0);
+ Node beanAttribute =
injectNode.getAttributes().getNamedItem("bean");
+
+ if (beanAttribute != null) {
+ return beanAttribute.getTextContent();
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private List<Node> getChildNodesByName(Node node, String nodeName) {
+ List<Node> listOfNodes = new ArrayList<Node>();
+
+ for (int i = 0; i < node.getChildNodes().getLength(); i++) {
+ Node currentNode = node.getChildNodes().item(i);
+
+ if (nodeName.equals(currentNode.getNodeName())) {
+ listOfNodes.add(currentNode);
+ }
+ }
+
+ return listOfNodes;
+ }
+
+ public void setPropertyValue(String propertyName, String value) {
+ boolean propertyFound = false;
+ for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
+ Node currentNode = beanNode.getChildNodes().item(i);
+
+ if (currentNode.getNodeName().equals("property")
+ && currentNode.getAttributes().getNamedItem("name") !=
null
+ &&
propertyName.equals(currentNode.getAttributes().getNamedItem("name").getTextContent()))
{
+
+ if (value != null) {
+ currentNode.setTextContent(value);
+ } else {
+ beanNode.removeChild(currentNode);
+ }
+
+ propertyFound = true;
+ }
+ }
+
+ if (value != null && !propertyFound) {
+ Node propertyChild = this.getDocument().createElement("property");
+ Attr nameProperty = this.getDocument().createAttribute("name");
+ nameProperty.setValue(propertyName);
+ propertyChild.setTextContent(value);
+ propertyChild.getAttributes().setNamedItem(nameProperty);
+ beanNode.appendChild(propertyChild);
+ }
+ }
+
+ public String getPropertyValue(String propertyName) {
+ for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
+ Node currentNode = beanNode.getChildNodes().item(i);
+
+ if (currentNode.getNodeName().equals("property")
+ && currentNode.getAttributes().getNamedItem("name") !=
null
+ &&
propertyName.equals(currentNode.getAttributes().getNamedItem("name").getTextContent()))
{
+
+ return currentNode.getTextContent();
+ }
+ }
+
+ return null;
+ }
+
+ public void saveConfigFile() throws TransformerException {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "no");
+
+ //initialize StreamResult with File object to save to file
+ StreamResult result = new StreamResult(new StringWriter());
+ DOMSource source = new DOMSource(this.getDocument());
+ transformer.transform(source, result);
+
+ String xmlString = result.getWriter().toString();
+ System.out.println(xmlString);
+ }
+
+ public Node getBeanNodeByClass(String className) {
+ NodeList result = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < result.getLength(); i++) {
+ Node node = result.item(i);
+ if (node.getAttributes().getNamedItem("class") != null
+ &&
className.equals(node.getAttributes().getNamedItem("class").getTextContent()))
{
+
System.out.println(node.getAttributes().getNamedItem("class").getTextContent());
+ return node;
+ }
+ }
+
+ return null;
+ }
+
+ public Node getBeanNodeByName(String beanName) {
+ NodeList result = this.getDocument().getElementsByTagName("bean");
+
+ for (int i = 1; i < result.getLength(); i++) {
+ Node node = result.item(i);
+ if (node.getAttributes().getNamedItem("name") != null
+ &&
beanName.equals(node.getAttributes().getNamedItem("name").getTextContent())) {
+
System.out.println(node.getAttributes().getNamedItem("name").getTextContent());
+ return node;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/helper/JBossHelper.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/helper/JBossHelper.java
new file mode 100644
index 0000000..364f3ef
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/helper/JBossHelper.java
@@ -0,0 +1,49 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.modcluster.helper;
+
+import org.mc4j.ems.connection.bean.EmsBean;
+
+/**
+ * @author Stefan Negrea
+ *
+ */
+public class JBossHelper {
+
+ public static String getRawProxyInfo(EmsBean emsBean) {
+ String rawProxyInfo = null;
+
+ //try first to get the value for JBoss EAP5.x or AS6
+ try {
+ rawProxyInfo = (String)
emsBean.getAttribute("ProxyInfo").refresh().toString();
+ } catch (Exception e) {
+ }
+
+ //if not able to get the value after the first attempt try to get the value for
JBoss 4.2/4.3
+ if (rawProxyInfo == null) {
+ try {
+ rawProxyInfo = (String)
emsBean.getAttribute("proxyInfo").refresh().toString();
+ } catch (Exception e) {
+ }
+ }
+
+ return rawProxyInfo;
+ }
+}
diff --git a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
index 4846490..fe4ac7d 100644
--- a/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,132 +1,466 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<plugin name="mod_cluster"
- displayName="mod_cluster"
- description="Monitoring and management of mod_cluster plugin."
- version="1.0"
- package="org.rhq.plugins.modcluster"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-plugin"
- xmlns:c="urn:xmlns:rhq-configuration">
+<plugin name="mod_cluster" displayName="mod_cluster"
description="Monitoring and management of mod_cluster plugin."
version="1.0" package="org.rhq.plugins.modcluster"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
<depends plugin="JMX" />
- <service name="mod_cluster"
- discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
- class="ModclusterServerComponent"
- supportsManualAdd="true"
- description="mod_cluster plugin"
- singleton="true">
-
+ <service name="mod_cluster"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="mod_cluster plugin" singleton="true">
+
<runs-inside>
- <parent-resource-type name="JBossAS Server"
plugin="JBossAS"/>
- <parent-resource-type name="JBossAS5 Server"
plugin="JBossAS5"/>
+ <parent-resource-type name="JBossAS Server"
plugin="JBossAS" />
+ <parent-resource-type name="JBossAS Server"
plugin="JBossAS5" />
</runs-inside>
-
+
<plugin-configuration>
- <c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*"/>
- <c:simple-property name="engineObjectName"
readOnly="true" default="jboss.web:type=Engine"/>
- <c:simple-property name="nameTemplate"
default="mod_cluster"/>
+ <c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*|jboss.web:service=ModCluster" />
+ <c:simple-property name="engineObjectName"
readOnly="true" default="jboss.web:type=Engine" />
+ <c:simple-property name="nameTemplate"
default="mod_cluster" />
</plugin-configuration>
-
- <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
- <parameters>
- <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout"/>
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
- <c:property-options allowCustomValue="false">
- <c:option value="MICROSECONDS"
name="MICROSECONDS"/>
- <c:option value="MILLISECONDS"
name="MILLISECONDS"/>
- <c:option value="NANOSECONDS"
name="NANOSECONDS"/>
- <c:option value="SECONDS"
name="SECONDS"/>
- <c:option value="HOURS" name="HOURS"/>
- <c:option value="DAYS" name="DAYS"/>
- </c:property-options>
- </c:simple-property>
- </parameters>
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
- <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
- <parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address"/>
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port"/>
- </parameters>
- </operation>
- <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
+
<operation name="reset" displayName="Reset the node"
description="Move this application server out of an error state." />
- <operation name="disable" displayName="Disable all webpapps"
description="Disable all webapps for all virtual hosts of this application
server.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
- <operation name="removeProxy" displayName="Remove a proxy"
description="Remove a proxy.">
- <parameters>
- <c:simple-property required="true" name="host"
type="string" displayName="Proxy address"/>
- <c:simple-property required="true" name="port"
type="string" displayName="Proxy port"/>
- </parameters>
- </operation>
<operation name="refresh" displayName="Refresh
configuration" description="Refresh configuration for this application
server." />
-
- <metric property="proxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
- <metric property="modelerType" displayName="Type of the modeled
resource" displayType="summary" dataType="trait" />
- <metric property="className" displayName="Fully qualified class
name of the managed object" displayType="summary"
dataType="trait" />
- <metric property="advertise" displayName="Enable autodiscovery of
httpd servers." displayType="summary" dataType="trait" />
-
- <resource-configuration>
- <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
- <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the cluster."/>
- <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster."/>
- <c:simple-property name="smax" type="integer"
description="Maximum time on seconds for idle connections above smax."/>
- <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server."/>
- <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery."/>
- <c:simple-property name="stickySessionForce" type="boolean"
description="Return an error when the request cannot be routed to the right
node."/>
- <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer."/>
- <c:simple-property name="flushPackets" type="boolean"
description="Allows controlling flusing of packets."/>
- <c:simple-property name="socketTimeout" type="integer"
description="Connection timeout for communication with the proxy." />
- <c:simple-property name="advertisePort" type="integer"
required="false" description="Multicast port for discovery" />
- <c:simple-property name="advertiseGroupAddress"
type="string" required="false" description="Multicast address for
discovery."/>
- <c:simple-property name="flushWait" type="integer"
description="Time in ms to wait before flushing packets."/>
- <c:simple-property name="ping" type="integer"
description="Time in s to wait for a pong answer to a ping."/>
- </resource-configuration>
-
- <service name="mod_cluster Webapp Context"
- discovery="ContextDiscoveryComponent"
- class="ContextComponent"
- description="mod_cluster webapp context">
-
- <operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation."/>
- </results>
- </operation>
- <operation name="stopContext" displayName="Stop webapp"
description="Gracefully stops this webapp.">
+
+ <!-- Start - Configuration for HAModClusterService -->
+ <service name="HA Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA
Service" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ha.HAModClusterService" />
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <!-- HA Operations -->
+ <operation name="disableDomain" displayName="Disable
domain" description="Disables all contexts on each node within the current
domain. If the current domain is null, then all nodes are stopped.">
+ <results>
+ <c:simple-property name="result" description="The result
of the operation" />
+ </results>
+ </operation>
+ <operation name="enableDomain" displayName="Enable
domain" description="Enable all contexts on each node within the current domain.
If the current domain is null, then all nodes are stopped.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stopDomain" displayName="Stop domain"
description="Gracefully stops all contexts on each node within the current domain. If
the current domain is null, then all nodes are stopped.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="The number of units of time for which to wait
for all sessions to drain on a given node." />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <!-- Regular Operations -->
+
+ <operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
+ <results>
+ <c:simple-property name="result" description="Map of
PING_RPS response, grouped by proxy.">
+ </c:simple-property>
+ </results>
+ </operation>
+ <operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+ <operation name="pingNodeByAddress" displayName="Ping node by
address"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+
+ <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
+ <results>
+ <c:simple-property name="result" description="The result
of the operation">
+ </c:simple-property>
+ </results>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
+ <results>
+ <c:simple-property name="result" description="The result
of the operation">
+ </c:simple-property>
+ </results>
+ </operation>
+ <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <metric property="MasterNode" displayName="Master Node"
displayType="summary" dataType="trait" />
+ <metric property="ProxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="ProxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
+
+ <resource-configuration>
+ <c:simple-property name="processStatusFrequency"
type="integer" description="Process status frequency." />
+ </resource-configuration>
+ </service>
+
+ <service name="HA Service Configuration"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Configuration" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA Service
Configuration" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ha.HAModClusterService" />
+ <c:simple-property name="dependencyClassName"
readOnly="true"
default="org.jboss.modcluster.config.ha.HAModClusterConfig" />
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <resource-configuration>
+
+ <!-- HA Configuration -->
+ <c:simple-property name="masterPerLoadBalancingGroup"
type="boolean" required="false" description="Enable current node
to be master in the load balancing group." />
+
+ <!-- Handler Configuration -->
+ <c:simple-property name="advertise" type="boolean"
required="false" default="false" description="Enable
autodiscovery of httpd servers." />
+ <c:simple-property name="advertiseGroupAddress"
type="string" description="Multicast address on which to listen for
advertisements." />
+ <c:simple-property name="advertisePort" type="string"
required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseInterface"
type="string" required="false" description="Multicast interface
for discovery" />
+ <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery." />
+ <c:simple-property name="proxyList" type="string"
required="false" description="Comma separated list of address:port listing
the httpd servers where mod_cluster is running." />
+ <c:simple-property name="proxyURL" type="string"
required="false" description="URL prefix to send with commands to
mod_cluster. Default is no prefix." />
+ <c:simple-property name="socketTimeout" type="integer"
required="false" description="Connection timeout for communication with the
proxy." />
+ <c:simple-property name="ssl" type="boolean"
description="Whether to use SSL to communicate with mod_cluster. Note this has
nothing to do with handling of https requests by JBoss Web" />
+ <c:simple-property name="excludedContexts"
type="string" required="false" description="Comma delimited list
of contexts that should *not* be auto-registered with httpd. Contexts may be qualified by
host using a colon, e.g. host1:context1. If no host is defined, localhost is
assumed." />
+ <c:simple-property name="autoEnableContexts"
type="boolean" required="false" default="true"
description="Toggle for context auto-enable during mod_cluster startup." />
+
+ <!-- Node Configuration -->
+ <c:simple-property name="loadBalancingGroup"
type="string" required="false" description="Load balancing
group." />
+ <c:simple-property name="flushPackets" type="boolean"
required="false" description="Allows controlling flusing of packets."
/>
+ <c:simple-property name="flushWait" type="integer"
required="false" description="Time in ms to wait before flushing
packets." />
+ <c:simple-property name="ping" type="integer"
required="false" description="Time in s to wait for a pong answer to a
ping." />
+ <c:simple-property name="smax" type="integer"
required="false" description="Maximum time on seconds for idle connections
above smax." />
+ <c:simple-property name="ttl" type="integer"
required="false" description="TTL" />
+ <c:simple-property name="nodeTimeout" type="integer"
required="false" description="Node timeout" />
+ <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer" />
+
+ <!-- Balancer Configuration -->
+ <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the node." />
+ <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster." />
+ <c:simple-property name="stickySessionForce"
type="boolean" description="Return an error when the request cannot be
routed to the right node." />
+ <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
+ <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server." />
+ </resource-configuration>
+ </service>
+ <!-- End - Configuration for HAModClusterService -->
+
+ <!-- Start - Configuration for ModClusterService -->
+ <service name="Service"
discovery="ClassNameMBeanDiscoveryComponent"
class="PolyPingMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Listener" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA
Service" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ModClusterService" />
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <operation name="pingHTTPD" displayName="Ping httpd"
description="Ping httpd and determine whether each proxy is accessible and healthy.
Returns the PING_RSP grouped by proxy address.">
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+ <operation name="pingNodeByJVMRoute" displayName="Ping node by
JVM Route"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Dtermines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="jvmRoute"
type="string" displayName="JVM Route of node to ping." />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+ <operation name="pingNodeByAddress" displayName="Ping node by
address"
+ description="Ping a node from httpd and returns the PING_RSP grouped by
proxy address. Determines whether the node configured with the specified jvm route is
accessible from each proxy returning the PING_RSP grouped by proxy address.">
+ <parameters>
+ <c:simple-property required="true" name="scheme"
type="string" displayName="Scheme (ajp, http, https)" />
+ <c:simple-property required="true" name="hostname"
type="string" displayName="Name or ip address of a node." />
+ <c:simple-property required="true" name="port"
type="string" displayName="Port" />
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="string"
description="Map of PING_RPS response, grouped by proxy." />
+ </results>
+ </operation>
+
+ <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <metric property="ProxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="ProxyInfo" displayName="Proxy Info"
displayType="summary" dataType="trait" />
+ </service>
+
+ <service name="Service Configuration"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="HA Service Configuration" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:service=ModCluster" />
+ <c:simple-property name="nameTemplate" default="HA Service
Configuration" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.ModClusterService" />
+ <c:simple-property name="dependencyClassName"
readOnly="true" default="org.jboss.modcluster.config.ModClusterConfig"
/>
+ <c:simple-property name="proxyInfoProperty"
readOnly="true" default="ProxyInfo" />
+ </plugin-configuration>
+
+ <resource-configuration>
+ <!-- Handler Configuration -->
+ <c:simple-property name="advertise" type="boolean"
required="false" default="false" description="Enable
autodiscovery of httpd servers." />
+ <c:simple-property name="advertiseGroupAddress"
type="string" description="Multicast address on which to listen for
advertisements." />
+ <c:simple-property name="advertisePort" type="string"
required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseInterface"
type="string" required="false" description="Multicast interface
for discovery" />
+ <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery." />
+ <c:simple-property name="proxyList" type="string"
required="false" description="Comma separated list of address:port listing
the httpd servers where mod_cluster is running." />
+ <c:simple-property name="proxyURL" type="string"
required="false" description="URL prefix to send with commands to
mod_cluster. Default is no prefix." />
+ <c:simple-property name="socketTimeout" type="integer"
required="false" description="Connection timeout for communication with the
proxy." />
+ <c:simple-property name="ssl" type="boolean"
description="Whether to use SSL to communicate with mod_cluster. Note this has
nothing to do with handling of https requests by JBoss Web" />
+ <c:simple-property name="excludedContexts"
type="string" required="false"
+ description="Comma delimited list of contexts that should *not* be
auto-registered with httpd. Contexts may be qualified by host using a colon, e.g.
host1:context1. If no host is defined, localhost is assumed." />
+ <c:simple-property name="autoEnableContexts"
type="boolean" required="false" default="true"
description="Toggle for context auto-enable during mod_cluster startup." />
+
+ <!-- Node Configuration -->
+ <c:simple-property name="loadBalancingGroup"
type="string" required="false" description="Load balancing
group." />
+ <c:simple-property name="flushPackets" type="boolean"
required="false" description="Allows controlling flusing of packets."
/>
+ <c:simple-property name="flushWait" type="integer"
required="false" description="Time in ms to wait before flushing
packets." />
+ <c:simple-property name="ping" type="integer"
required="false" description="Time in s to wait for a pong answer to a
ping." />
+ <c:simple-property name="smax" type="integer"
required="false" description="Maximum time on seconds for idle connections
above smax." />
+ <c:simple-property name="ttl" type="integer"
required="false" description="TTL" />
+ <c:simple-property name="nodeTimeout" type="integer"
required="false" description="Node timeout" />
+ <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer" />
+
+ <!-- Balancer Configuration -->
+ <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the node." />
+ <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster." />
+ <c:simple-property name="stickySessionForce"
type="boolean" description="Return an error when the request cannot be
routed to the right node." />
+ <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
+ <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server." />
+ </resource-configuration>
+ </service>
+ <!-- End - Configuration for ModClusterService -->
+
+ <service name="Catalina Service"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="ModclusterServerComponent" supportsManualAdd="true"
description="Catalina Service Listener" singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*" />
+ <c:simple-property name="nameTemplate" default="mod_cluster
Catalina Listener" />
+ </plugin-configuration>
+
+ <operation name="addProxy" displayName="Add a proxy"
description="Add a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="removeProxy" displayName="Remove a
proxy" description="Remove a proxy.">
+ <parameters>
+ <c:simple-property required="true" name="host"
type="string" displayName="Proxy address" />
+ <c:simple-property required="true" name="port"
type="string" displayName="Proxy port" />
+ </parameters>
+ </operation>
+ <operation name="disable" displayName="Disable all
webpapps" description="Disable all webapps for all virtual hosts of this
application server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="enable" displayName="Enable all webapps"
description="Enable all webapps for all virtual hosts of this application
server.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="stop" displayName="Stop all webapps"
description="Gracefully stops all webapps for all virtual hosts of this application
server.">
+ <parameters>
+ <c:simple-property required="true" name="timeout"
type="string" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+
+ <metric property="proxyConfiguration" displayName="Proxy
Configuration" displayType="summary" dataType="trait" />
+ <metric property="modelerType" displayName="Type of the
modeled resource" displayType="summary" dataType="trait" />
+ <metric property="className" displayName="Fully qualified
class name of the managed object" displayType="summary"
dataType="trait" />
+ <metric property="advertise" displayName="Enable autodiscovery
of httpd servers." displayType="summary" dataType="trait" />
+
+ <resource-configuration>
+ <c:simple-property name="workerTimeout" type="integer"
description="Timeout to wait for an available worker (default is no wait)."
/>
+ <c:simple-property name="stickySession" type="boolean"
description="Enables sticky session for the cluster." />
+ <c:simple-property name="stickySessionRemove"
type="boolean" description="Remove session when the request cannot be
routed to the right node for this cluster." />
+ <c:simple-property name="smax" type="integer"
description="Maximum time on seconds for idle connections above smax." />
+ <c:simple-property name="maxAttempts" type="integer"
description="Maximum number of attempts to send the request to the backend
server." />
+ <c:simple-property name="advertiseSecurityKey"
type="string" required="false" description="Security key for
discovery." />
+ <c:simple-property name="stickySessionForce"
type="boolean" description="Return an error when the request cannot be
routed to the right node." />
+ <c:simple-property name="balancer" type="string"
required="false" description="Name of the balancer." />
+ <c:simple-property name="flushPackets" type="boolean"
description="Allows controlling flusing of packets." />
+ <c:simple-property name="socketTimeout" type="integer"
description="Connection timeout for communication with the proxy." />
+ <c:simple-property name="advertisePort" type="integer"
required="false" description="Multicast port for discovery" />
+ <c:simple-property name="advertiseGroupAddress"
type="string" required="false" description="Multicast address for
discovery." />
+ <c:simple-property name="flushWait" type="integer"
description="Time in ms to wait before flushing packets." />
+ <c:simple-property name="ping" type="integer"
description="Time in s to wait for a pong answer to a ping." />
+ </resource-configuration>
+ </service>
+
+ <service name="Dynamic Load Balancer Factor"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="Dynamic Load balancer factor for mod_cluster"
singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:provider=LoadBalanceFactor,service=ModCluster,*" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProvider" />
+ <c:simple-property name="nameTemplate" default="Dynamic
Load Balancer Factor" />
+ </plugin-configuration>
+
+ <metric property="Metrics" displayName="Collected
Metrics" displayType="summary" dataType="trait" />
+
+ <resource-configuration>
+ <c:simple-property name="DecayFactor" type="integer"
description="The number of historical load values used to determine load
factor." />
+ <c:simple-property name="History" type="integer"
description="The exponential decay factor for historical load values." />
+ </resource-configuration>
+ </service>
+
+ <service name="Simple Load Balancer Factor"
discovery="ClassNameMBeanDiscoveryComponent"
class="FileConfiguredMBeanResourceComponent" supportsManualAdd="true"
description="Simple load balancer factor for mod_cluster"
singleton="true">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:provider=LoadBalanceFactor,service=ModCluster,*" />
+ <c:simple-property name="className" readOnly="true"
default="org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider" />
+ <c:simple-property name="nameTemplate" default="Simple Load
Balancer Factor" />
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="loadBalanceFactor"
type="integer" description="The load balance factor." />
+ </resource-configuration>
+ </service>
+
+ <service name="Load Metric"
discovery="LoadMetricDiscoveryComponent"
class="org.rhq.plugins.jmx.MBeanResourceComponent" description="Load
Metric">
+
+ <plugin-configuration>
+ <c:simple-property name="objectName" readOnly="true"
default="jboss.web:provider=LoadBalanceFactor,service=ModCluster,metric=*,*"
/>
+ <c:simple-property name="nameTemplate" default="Load
Metric" />
+ </plugin-configuration>
+
+ <metric property="Load" displayName="Load"
category="utilization" description="The current load of this metric as a
percent of the metric's capacity." dataType="measurement" />
+
+ <resource-configuration>
+ <c:simple-property name="Weight" type="integer"
description="The significance of this load metric compared to the other
metrics." />
+ <c:simple-property name="Capacity" type="double"
description="Used to normalize the value returned by load expressed as a percentage
of the capacity, such that: 0 < (load/capacity) < 1" />
+ </resource-configuration>
+ </service>
+
+ <service name="Webapp Context"
discovery="ContextDiscoveryComponent" class="ContextComponent"
description="Webapp Context">
+
+ <operation name="disableContext" displayName="Disable
webapp" description="Disable this webapp.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation." />
+ </results>
+ </operation>
+ <operation name="stopContext" displayName="Stop webapp"
description="Gracefully stops this webapp.">
<parameters>
- <c:simple-property required="true" name="timeout"
type="integer" displayName="Session draining timeout"/>
- <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
- <c:property-options allowCustomValue="false">
- <c:option value="MICROSECONDS"
name="MICROSECONDS"/>
- <c:option value="MILLISECONDS"
name="MILLISECONDS"/>
- <c:option value="NANOSECONDS"
name="NANOSECONDS"/>
- <c:option value="SECONDS"
name="SECONDS"/>
- <c:option value="HOURS" name="HOURS"/>
- <c:option value="DAYS" name="DAYS"/>
- </c:property-options>
- </c:simple-property>
+ <c:simple-property required="true" name="timeout"
type="integer" displayName="Session draining timeout" />
+ <c:simple-property required="true" name="unit"
default="MILLISECONDS" displayName="Time unit of the timeout
parameter">
+ <c:property-options allowCustomValue="false">
+ <c:option value="MICROSECONDS"
name="MICROSECONDS" />
+ <c:option value="MILLISECONDS"
name="MILLISECONDS" />
+ <c:option value="NANOSECONDS"
name="NANOSECONDS" />
+ <c:option value="SECONDS" name="SECONDS"
/>
+ <c:option value="HOURS" name="HOURS" />
+ <c:option value="DAYS" name="DAYS" />
+ </c:property-options>
+ </c:simple-property>
</parameters>
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
- <operation name="enableContext" displayName="Enable webapp"
description="Enable this webapp.">
- <results>
- <c:simple-property name="result" type="boolean"
description="The result of the operation" />
- </results>
- </operation>
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
+ <operation name="enableContext" displayName="Enable
webapp" description="Enable this webapp.">
+ <results>
+ <c:simple-property name="result" type="boolean"
description="The result of the operation" />
+ </results>
+ </operation>
</service>
</service>
diff --git
a/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
new file mode 100644
index 0000000..4e4aac1
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.modcluster.test;
+
+import org.testng.annotations.Test;
+
+import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
+
+public class ServerConfigTest {
+
+ @Test
+ public void TestConfig() {
+
+ try {
+ ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService");
+ config.setPropertyValue("processStatusFrequency", "4");
+ config.setPropertyValue("test", "5");
+ config.setPropertyValue("test", "123");
+
+ System.out.println(config.getPropertyValue("test"));
+
+ config.saveConfigFile();
+
+ config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
+ "org.jboss.modcluster.config.ha.HAModClusterConfig");
+ config.setPropertyValue("processStatusFrequency", "4");
+ config.setPropertyValue("test", "5");
+ config.setPropertyValue("test", "123");
+
+ System.out.println(config.getPropertyValue("test"));
+
+ config.saveConfigFile();
+
+ config.setPropertyValue("test", null);
+ config.saveConfigFile();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
commit f9107f719e5fa14265be4e4f6e2ed4c4d7f8a509
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Sun Aug 14 12:03:44 2011 -0500
With JBoss 5, the timeout is blocking the operation call for the period set. Reduce
this period for these integration tests.
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index dc98d78..0a39eab 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -168,7 +168,7 @@ public class ModclusterPluginTest {
log.info("Result of operation " + "enableContext" +
" was: " + result.getSimpleResult());
Configuration config = new Configuration();
- config.put(new PropertySimple("timeout", "1000"));
+ config.put(new PropertySimple("timeout", "1"));
config.put(new PropertySimple("unit",
java.util.concurrent.TimeUnit.SECONDS));
result = ((OperationFacet)
resourceComponent).invokeOperation("stopContext", config);
log.info("Result of operation stopContext was: " +
result.getSimpleResult());
commit 47ccc7a36d1dbce6c2e99ef5a83ec1bfcd250988
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Sun Aug 14 12:02:34 2011 -0500
Add jar dependencies for testing with JBoss 5&6.
diff --git a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
index 0cc3f4f..77a81b2 100644
--- a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
+++ b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
@@ -17,9 +17,37 @@
<properties>
<scm.module.path>modules/integration-tests/mod_cluster-plugin-test</scm.module.path>
+ <!-- jbossas.version>6.0.0.20100429-M3</jbossas.version-->
+ <jbossas.version>6.0.0.M1</jbossas.version>
+
</properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-parent</artifactId>
+ <version>${jbossas.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-component-matrix</artifactId>
+ <version>${jbossas.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<dependencies>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>${rhq.groupId}</groupId>
@@ -41,6 +69,213 @@
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jnp-client</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-aspects</artifactId>
+ <version>5.1.0.CR1</version>
+ <classifier>jboss-aspect-jdk50-client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>trove</groupId>
+ <artifactId>trove</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-security-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.jboss.javaee</groupId>
+ <artifactId>jboss-javaee</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4-jboss</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-mdr</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <!-- dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-security</artifactId>
+ <version>5.1.0.CR1</version>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-transaction-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-common</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-core</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-proxy-spi</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-proxy-impl</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-security</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-dependency</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <!-- dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jbosssx-client</artifactId>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.jboss.aspects</groupId>
+ <artifactId>jboss-security-aspects</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.aop</groupId>
+ <artifactId>jboss-aop</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-serialization</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-core-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-client-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-profileservice</artifactId>
+ <classifier>client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <classifier>jmx-invoker-adaptor-client</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>jboss.messaging</groupId>
+ <artifactId>jboss-messaging-client</artifactId>
+ <scope>test</scope>
+ </dependency-->
</dependencies>
commit 58bcfd2f5c502b59f4a362f05daa20e6a3c4ac0b
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Aug 10 18:04:02 2011 -0500
Get the integration tests to compile and run again by creating the maven module and
deploying the correct resources to target folder.
diff --git a/.classpath b/.classpath
index a46eaf4..e5225db 100644
--- a/.classpath
+++ b/.classpath
@@ -280,5 +280,6 @@
<classpathentry kind="src"
path="modules/plugins/jboss-as-7/src/main/java"/>
<classpathentry kind="src"
path="modules/plugins/jboss-as-7/src/test/java"/>
<classpathentry kind="src"
path="modules/integration-tests/jboss-as-7-plugin-test/src/test/java"/>
+ <classpathentry kind="src"
path="modules/integration-tests/mod_cluster-plugin-test/src/test/java"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --git a/modules/integration-tests/mod_cluster-plugin-test/pom.xml
b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
new file mode 100644
index 0000000..0cc3f4f
--- /dev/null
+++ b/modules/integration-tests/mod_cluster-plugin-test/pom.xml
@@ -0,0 +1,155 @@
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>modcluster-plugin-test</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ mod_cluster Plugin Integration Test</name>
+ <description>Integration tests for mod_cluster RHQ Agent
plugin</description>
+
+ <properties>
+
<scm.module.path>modules/integration-tests/mod_cluster-plugin-test</scm.module.path>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>modcluster-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+
+ <profile>
+ <id>integration-tests</id>
+ <activation>
+ <property>
+ <name>maven.test.skip</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+
<rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+
<rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <tasks>
+ <echo>Setting up plugin dependencies...</echo>
+ <property name="settings.localRepository"
location="${user.home}/.m2/repository" />
+ <mkdir dir="target/testsetup" />
+
+ <mkdir dir="target/testsetup/plugins" />
+ <copy toDir="target/testsetup/plugins"
flatten="true">
+ <fileset
dir="${settings.localRepository}/">
+ <include
name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar"
/>
+ <include
name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar"
/>
+ <include
name="org/jboss/on/jopr-jboss-as-plugin/${project.version}/jopr-jboss-as-plugin-${project.version}.jar"
/>
+ <include
name="org/jboss/on/jopr-jboss-as-5-plugin/${project.version}/jopr-jboss-as-5-plugin-${project.version}.jar"
/>
+ <include
name="org/rhq/modcluster-plugin/${project.version}/modcluster-plugin-${project.version}.jar"
/>
+ </fileset>
+ <fileset dir="${rhq.deploymentDir}">
+ <include
name="${project.artifactId}-${project.version}.jar" />
+ </fileset>
+ </copy>
+
+ <mkdir dir="target/testsetup/lib" />
+ <unzip dest="target/testsetup/lib">
+ <fileset
dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}"
includes="*.zip" />
+ <patternset>
+ <include name="**/lib/sigar.jar" />
+ <include name="**/lib/bcel*.jar" />
+ <include name="**/lib/*.so" />
+ <include name="**/lib/*.sl" />
+ <include name="**/lib/*.dll" />
+ <include name="**/lib/*.dylib" />
+ </patternset>
+ </unzip>
+ <move todir="target/testsetup/lib"
flatten="true">
+ <fileset dir="target/testsetup/lib">
+ <include name="**/lib/*" />
+ </fileset>
+ </move>
+ <delete
dir="target/testsetup/lib/hyperic-sigar-${sigar.version}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+
<useSystemClassLoader>false</useSystemClassLoader>
+
<argLine>-Dorg.hyperic.sigar.path=${basedir}/target/testsetup/lib</argLine>
+ <systemProperties>
+ <property>
+ <name>project.artifactId</name>
+ <value>${project.artifactId}</value>
+ </property>
+ <property>
+ <name>project.version</name>
+ <value>${project.version}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
index 0f644fc..dc98d78 100644
---
a/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
+++
b/modules/integration-tests/mod_cluster-plugin-test/src/test/java/org/rhq/plugins/modcluster/test/ModclusterPluginTest.java
@@ -148,10 +148,12 @@ public class ModclusterPluginTest {
}
if (resourceComponent instanceof OperationFacet) {
- OperationResult result = ((OperationFacet)
resourceComponent).invokeOperation("reset", null);
+ OperationResult result = null;
+
+ result = ((OperationFacet)
resourceComponent).invokeOperation("reset", new Configuration());
log.info("Result of operation test was: " + result);
- result = ((OperationFacet)
resourceComponent).invokeOperation("disable", null);
+ result = ((OperationFacet)
resourceComponent).invokeOperation("disable", new Configuration());
log.info("Result of operation test was: " +
result.getSimpleResult());
}
}
diff --git a/modules/plugins/mod-cluster/pom.xml b/modules/plugins/mod-cluster/pom.xml
index ab52e84..fdc4f37 100644
--- a/modules/plugins/mod-cluster/pom.xml
+++ b/modules/plugins/mod-cluster/pom.xml
@@ -56,51 +56,6 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
- <execution>
- <phase>process-test-resources</phase>
- <configuration>
- <tasks>
- <echo>Setting up plugin dependencies...</echo>
- <property name="settings.localRepository"
location="${user.home}/.m2/repository" />
- <mkdir dir="target/testsetup" />
-
- <mkdir dir="target/testsetup/plugins" />
- <copy toDir="target/testsetup/plugins"
flatten="true">
- <fileset
dir="${settings.localRepository}/">
- <include
name="org/rhq/rhq-platform-plugin/${project.version}/rhq-platform-plugin-${project.version}.jar"
/>
- <include
name="org/rhq/rhq-jmx-plugin/${project.version}/rhq-jmx-plugin-${project.version}.jar"
/>
- <include
name="org/jboss/on/jopr-jboss-as-plugin/${project.version}/jopr-jboss-as-plugin-${project.version}.jar"
/>
- <include
name="org/jboss/on/jopr-jboss-as-5-plugin/${project.version}/jopr-jboss-as-5-plugin-${project.version}.jar"
/>
- </fileset>
- <fileset dir="${rhq.deploymentDir}">
- <include
name="${project.artifactId}-${project.version}.jar" />
- </fileset>
- </copy>
-
- <mkdir dir="target/testsetup/lib" />
- <unzip dest="target/testsetup/lib">
- <fileset
dir="${settings.localRepository}/org/hyperic/sigar-dist/${sigar.version}"
includes="*.zip" />
- <patternset>
- <include name="**/lib/sigar.jar" />
- <include name="**/lib/bcel*.jar" />
- <include name="**/lib/*.so" />
- <include name="**/lib/*.sl" />
- <include name="**/lib/*.dll" />
- <include name="**/lib/*.dylib" />
- </patternset>
- </unzip>
- <move todir="target/testsetup/lib"
flatten="true">
- <fileset dir="target/testsetup/lib">
- <include name="**/lib/*" />
- </fileset>
- </move>
- <delete
dir="target/testsetup/lib/hyperic-sigar-${sigar.version}" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
<execution>
<id>deploy</id>
@@ -203,12 +158,10 @@
<build>
<plugins>
-
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
-
<execution>
<id>deploy</id>
<phase>compile</phase>
@@ -258,14 +211,10 @@
<goal>run</goal>
</goals>
</execution>
-
</executions>
</plugin>
-
</plugins>
</build>
</profile>
-
</profiles>
-
</project>