modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/CatalinaServiceComponent.java
| 93 ++
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/LoadMetricDiscoveryComponent.java
| 24
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/AbstractConfigurationFile.java
| 21
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/JBossWebServerFile.java
| 58 +
modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/config/ModClusterBeanFile.java
| 39 -
modules/plugins/mod-cluster/src/main/resources/META-INF/rhq-plugin.xml
| 2
modules/plugins/mod-cluster/src/test/java/org/rhq/plugins/modcluster/test/ServerConfigTest.java
| 49 +
modules/plugins/mod-cluster/src/test/resources/xml_config/mod_cluster-jboss-beans.xml
| 337 ++++++++++
modules/plugins/mod-cluster/src/test/resources/xml_config/server.xml
| 157 ++++
9 files changed, 733 insertions(+), 47 deletions(-)
New commits:
commit 300308759921d5cc2315dbb85b49a29e9f0983c3
Merge: 5956151 8db63e0
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 18:29:29 2011 -0500
Merge branch 'mod_cluster_plugin'
commit 8db63e00ec03b5c0257925becda0b984351b6664
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 18:27:05 2011 -0500
Refactoring configuration file classes to accept files in the constructor to allow
testing. Also, added basic configuration files for testing.
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 dee2f81..d49ce88 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
@@ -39,11 +39,16 @@ import org.xml.sax.SAXException;
* @author Stefan Negrea
*/
public abstract class AbstractConfigurationFile {
- private String fileName;
+ private File configurationFile;
private Document document;
public AbstractConfigurationFile(String fileName) throws
ParserConfigurationException, SAXException, IOException {
- this.fileName = fileName;
+ this(new File(fileName));
+ }
+
+ public AbstractConfigurationFile(File configurationFile) throws
ParserConfigurationException, SAXException,
+ IOException {
+ this.configurationFile = configurationFile;
loadConfiguratonFile();
}
@@ -53,13 +58,6 @@ public abstract class AbstractConfigurationFile {
abstract String getPropertyValue(String propertyName);
/**
- * @return the fileName
- */
- public String getFileName() {
- return fileName;
- }
-
- /**
* @return the doc
*/
public Document getDocument() {
@@ -67,8 +65,7 @@ public abstract class AbstractConfigurationFile {
}
public void saveConfigurationFile() throws Exception {
- File file = new File(this.getFileName());
- StreamResult result = new StreamResult(file);
+ StreamResult result = new StreamResult(this.configurationFile);
Source source = new DOMSource(this.getDocument());
Transformer transformer = TransformerFactory.newInstance().newTransformer();
@@ -79,6 +76,6 @@ public abstract class AbstractConfigurationFile {
private void loadConfiguratonFile() throws ParserConfigurationException,
SAXException, IOException {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- this.document = docBuilder.parse(this.getFileName());
+ this.document = docBuilder.parse(this.configurationFile);
}
}
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 45204e1..01f992e 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
@@ -19,6 +19,7 @@
package org.rhq.plugins.modcluster.config;
+import java.io.File;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
@@ -47,6 +48,12 @@ public class JBossWebServerFile extends AbstractConfigurationFile {
listenerNode = this.getListenerNode();
}
+ public JBossWebServerFile(File configurationFile) throws
ParserConfigurationException, SAXException, IOException {
+ super(configurationFile);
+
+ listenerNode = this.getListenerNode();
+ }
+
@Override
public void setPropertyValue(String propertyName, String value) {
NamedNodeMap attributeList = listenerNode.getAttributes();
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 c2cf3a8..9ff7752 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
@@ -18,6 +18,7 @@
*/
package org.rhq.plugins.modcluster.config;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -44,7 +45,19 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @throws SAXException
* @throws IOException
*/
- public ModClusterBeanFile(String className, String configurationFile) throws
ParserConfigurationException,
+ public ModClusterBeanFile(String className, String configurationFileName) throws
ParserConfigurationException,
+ SAXException, IOException {
+ this(className, new File(configurationFileName));
+ }
+
+ /**
+ * @param className
+ * @param configurationFile
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public ModClusterBeanFile(String className, File configurationFile) throws
ParserConfigurationException,
SAXException, IOException {
super(configurationFile);
@@ -59,7 +72,20 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
* @throws SAXException
* @throws IOException
*/
- public ModClusterBeanFile(String className, String constructorArgumentClassName,
String configurationFile)
+ public ModClusterBeanFile(String className, String constructorArgumentClassName,
String configurationFileName)
+ throws ParserConfigurationException, SAXException, IOException {
+ this(className, constructorArgumentClassName, new File(configurationFileName));
+ }
+
+ /**
+ * @param className
+ * @param constructorArgumentClassName
+ * @param configurationFile
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public ModClusterBeanFile(String className, String constructorArgumentClassName, File
configurationFile)
throws ParserConfigurationException, SAXException, IOException {
super(configurationFile);
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 b8fca4c..871b082 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
@@ -18,6 +18,9 @@
*/
package org.rhq.plugins.modcluster.test;
+import java.io.File;
+import java.net.URL;
+
import org.testng.annotations.Test;
import org.rhq.plugins.modcluster.config.JBossWebServerFile;
@@ -26,12 +29,12 @@ import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
public class ServerConfigTest {
@Test
- public void TestModClusterConfig() {
-
+ public void TestSimpleBeanModClusterConfig() {
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");
+ URL testConfigURL =
getClass().getResource("/xml_config/mod_cluster-jboss-beans.xml");
+ File testFile = new File(testConfigURL.toURI());
+
+ ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService", testFile);
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
@@ -40,11 +43,19 @@ public class ServerConfigTest {
config.setPropertyValue("processStatusFrequency", null);
config.saveConfigurationFile();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void TestBeanWithDependenciesModClusterConfig() {
+ try {
+ URL testConfigURL =
getClass().getResource("/xml_config/mod_cluster-jboss-beans.xml");
+ File testFile = new File(testConfigURL.toURI());
- //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");
+ ModClusterBeanFile config = new
ModClusterBeanFile("org.jboss.modcluster.ha.HAModClusterService",
+ "org.jboss.modcluster.config.ha.HAModClusterConfig",
testFile);
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
@@ -53,18 +64,17 @@ public class ServerConfigTest {
config.setPropertyValue("processStatusFrequency", null);
config.saveConfigurationFile();
} catch (Exception e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void TestJBossWebConfig() {
-
try {
- //Test simple bean configuration
- JBossWebServerFile config = new JBossWebServerFile(
-
"/home/snegrea/Downloads/jboss42/server/all/deploy/jboss-web.deployer/server.xml");
+ URL testConfigURL =
getClass().getResource("/xml_config/server.xml");
+ File testFile = new File(testConfigURL.toURI());
+
+ JBossWebServerFile config = new JBossWebServerFile(testFile);
config.setPropertyValue("processStatusFrequency", "4");
config.setPropertyValue("test", "5");
config.setPropertyValue("test", "123");
@@ -74,7 +84,6 @@ public class ServerConfigTest {
config.saveConfigurationFile();
} catch (Exception e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
diff --git
a/modules/plugins/mod-cluster/src/test/resources/xml_config/mod_cluster-jboss-beans.xml
b/modules/plugins/mod-cluster/src/test/resources/xml_config/mod_cluster-jboss-beans.xml
new file mode 100644
index 0000000..1ef344b
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/test/resources/xml_config/mod_cluster-jboss-beans.xml
@@ -0,0 +1,337 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<!--
+ Beans that provide JBoss AS-side functionality for mod_cluster. These
+ beans are all "On Demand", i.e. that are not installed unless requested.
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Entry point: catalina lifecycle listener -->
+ <bean class="org.jboss.modcluster.catalina.CatalinaEventHandlerAdapter"
name="ModClusterListener">
+ <constructor>
+ <parameter class="org.jboss.modcluster.ContainerEventHandler">
+<inject bean="HAModClusterService"/>
+</parameter>
+ <parameter class="javax.management.MBeanServer">
+<inject bean="JMXKernel" property="mbeanServer"/>
+</parameter>
+ </constructor>
+ <depends>WebServer</depends>
+ </bean>
+
+ <!-- The core mod_cluster service -->
+ <bean class="org.jboss.modcluster.ModClusterService" mode="On
Demand" name="ModClusterService">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster",exposedInterface=org.jboss.modcluster.ModClusterServiceMBean.class)</annotation>
+ <constructor>
+ <parameter class="org.jboss.modcluster.config.ModClusterConfig">
+<inject bean="ModClusterConfig"/>
+</parameter>
+ <parameter
class="org.jboss.modcluster.load.LoadBalanceFactorProvider">
+<inject bean="DynamicLoadBalanceFactorProvider"/>
+</parameter>
+ </constructor>
+ </bean>
+
+ <!-- The core mod_cluster service, implemented as an HA singleton -->
+ <bean class="org.jboss.modcluster.ha.HAModClusterService" mode="On
Demand" name="HAModClusterService">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster",exposedInterface=org.jboss.modcluster.ha.HAModClusterServiceMBean.class)</annotation>
+ <constructor>
+ <parameter
class="org.jboss.modcluster.config.ha.HAModClusterConfig">
+<inject bean="ModClusterConfig"/>
+</parameter>
+ <parameter
class="org.jboss.modcluster.load.LoadBalanceFactorProvider">
+<inject bean="DynamicLoadBalanceFactorProvider"/>
+</parameter>
+ <parameter class="org.jboss.ha.framework.interfaces.HAPartition">
+<inject bean="HAPartition"/>
+</parameter>
+ <parameter
class="org.jboss.ha.framework.interfaces.HASingletonElectionPolicy">
+<bean class="org.jboss.ha.singleton.HASingletonElectionPolicySimple"/>
+</parameter>
+ </constructor>
+
+</bean>
+
+ <!-- Configure this node's communication with the load balancer -->
+ <bean class="org.jboss.modcluster.config.ha.HAModClusterConfig"
mode="On Demand" name="ModClusterConfig">
+
+ <!-- Comma separated list of address:port listing the httpd servers
+ where mod_cluster is running. -->
+ <property
name="proxyList">${jboss.mod_cluster.proxyList,jboss.modcluster.proxyList:}</property>
+ <!-- URL prefix to send with commands to mod_cluster. Default is no prefix.
-->
+ <!--property name="proxyURL"></property-->
+
+ <!-- mod_advertise is a small httpd module that advertises the
+ availability of httpd servers via multicast, allowing
+ ModClusterService to discover the httpd front-end instead of/in
+ addition to having them defined in proxyList. -->
+ <!-- Whether to listen for advertise messages -->
+ <property
name="advertise">${jboss.mod_cluster.advertise:true}</property>
+ <!-- Multicast address on which to listen for advertisements -->
+ <property
name="advertiseGroupAddress">${jboss.mod_cluster.advertise.address,jboss.modcluster.advertise.address,jboss.partition.udpGroup:224.0.1.105}</property>
+ <!-- Port to listen to for advertisements -->
+ <property
name="advertisePort">${jboss.mod_cluster.advertise.port,jboss.modcluster.advertise.port:23364}</property>
+
+ <!-- Comma delimited list of contexts that should *not* be auto-registered with
httpd. -->
+ <!-- ROOT indicates the root context. -->
+ <!-- Context may be qualified by host using a colon, e.g. host1:context1 -->
+ <!-- If no host is defined, localhost is assumed. -->
+ <property
name="excludedContexts">${jboss.mod_cluster.excludedContexts,jboss.modcluster.excludedContexts:ROOT,admin-console,invoker,jbossws,jmx-console}</property>
+ <property
name="autoEnableContexts">${jboss.mod_cluster.autoEnableContexts:true}</property>
+
+ <!-- Security key the proxy is going to send with advertise messages.
+ Default is none. -->
+ <!--property name="advertiseSecurityKey"></property-->
+
+ <!-- Whether to use SSL to communicate with mod_cluster. Note this
+ has nothing to do with handling of https requests by JBoss Web -->
+ <property name="ssl">false</property>
+
+ <!-- Configuration values for the load balancer itself (must be the
+ same on all nodes in the cluster). These will be passed to the
+ load balancer. -->
+ <property name="stickySession">true</property>
+ <property name="stickySessionForce">false</property>
+ <property name="stickySessionRemove">false</property>
+ <property name="maxAttempts">1</property>
+ <property name="workerTimeout">-1</property>
+ </bean>
+
+ <!-- Provides information to ModClusterService informing it how much load
+ this server should take. This impl calculates load factor from a
+ number of metrics and adjusts the value periodically based on runtime
+ conditions, using to the JBossWeb engine's backgroundProcessorDelay. -->
+ <bean
class="org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProvider"
mode="On Demand" name="DynamicLoadBalanceFactorProvider">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor",exposedInterface=org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProviderMBean.class)</annotation>
+ <constructor>
+ <parameter>
+ <!-- Define the load metrics to use in your load balance factor calculation
here -->
+ <set elementClass="org.jboss.modcluster.load.metric.LoadMetric">
+ <inject bean="BusyConnectorsLoadMetric"/>
+ <inject bean="HeapMemoryUsageLoadMetric"/>
+ </set>
+ </parameter>
+ </constructor>
+ <!-- The number of historical load values used to determine load factor -->
+ <!--property name="history">9</property-->
+ <!-- The exponential decay factor for historical load values -->
+ <!--property name="decayFactor">2</property-->
+ </bean>
+
+ <!-- Default load metrics/sources -->
+ <!-- The JBossWeb connector thread pool usage as a ratio of busy threads to max
thread pool size -->
+ <!-- Analogous to method=B in mod_jk -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric"
mode="On Demand" name="BusyConnectorsLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=BusyConnectors",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter>
+<inject bean="ThreadPoolLoadMetricSource"/>
+</parameter>
+ </constructor>
+ <!-- The weight determines the significance of this metric with respect
+ to others in the overall load balance factor calculation -->
+ <property name="weight">2</property>
+ </bean>
+ <!-- Queries all JBossWeb ThreadPool mbeans -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricSource"
mode="On Demand" name="ThreadPoolLoadMetricSource">
+ <constructor>
+ <parameter class="javax.management.MBeanServer">
+<inject bean="JMXKernel" property="mbeanServer"/>
+</parameter>
+ <!-- Object name pattern for connector thread pools -->
+ <!--parameter>jboss.web:type=ThreadPool,*</parameter-->
+ </constructor>
+ </bean>
+
+ <!-- The heap memory usage as a ratio of used heap to max heap size -->
+ <!-- N.B. This load metric is its own source -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.HeapMemoryUsageLoadMetric"
mode="On Demand" name="HeapMemoryUsageLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=HeapMemoryUsage",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <!--property name="weight">1</property-->
+ </bean>
+
+
+ <!-- Alternative load balance factor providers -->
+
+ <!-- Basic impl that returns a static load balance factor.
+ This would replace the DynamicLoadBalanceFactorProvider
+ used above.
+ -->
+ <bean
class="org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider"
mode="On Demand" name="SimpleLoadBalanceFactorProvider">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor",exposedInterface=org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProviderMBean.class)</annotation>
+ <property name="loadBalanceFactor">1</property>
+ </bean>
+
+ <!--
+ Alternative load metrics, grouped by source.
+ To use these, inject them into the set passed to the
+ DynamicLoadBalanceFactorProvider bean's constructor above.
+ -->
+
+ <!-- CPU usage -->
+ <!-- Perhaps the best metric for determining system load - but only available on
Java 1.6 or later -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.AverageSystemLoadMetric"
mode="On Demand" name="AverageSystemLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=AverageSystemLoad",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter>
+<inject bean="OperatingSystemLoadMetricSource"/>
+</parameter>
+ </constructor>
+ </bean>
+ <!-- The system memory usage as ratio of used memory to total memory size -->
+ <!-- Requires com.sun.management.OperatingSystemMXBean, i.e. Sun or OpenJDK JVM
-->
+ <bean
class="org.jboss.modcluster.load.metric.impl.SystemMemoryUsageLoadMetric"
mode="On Demand" name="SystemMemoryUsageLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=SystemMemoryUsage",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter>
+<inject bean="OperatingSystemLoadMetricSource"/>
+</parameter>
+ </constructor>
+ </bean>
+ <!-- Uses the platform's OperatingSystemMXBean -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.OperatingSystemLoadMetricSource"
mode="On Demand" name="OperatingSystemLoadMetricSource">
+ </bean>
+
+
+ <!-- The number of requests/sec processed by the JBossWeb connectors, with respect
to the defined capacity -->
+ <!-- Analogous to method=R in mod_jk -->
+ <bean class="org.jboss.modcluster.load.metric.impl.RequestCountLoadMetric"
mode="On Demand" name="RequestCountLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=RequestCount",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter
class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource">
+<inject bean="RequestProcessorLoadMetricSource"/>
+</parameter>
+ <!--parameter>requestCount</parameter-->
+ </constructor>
+ <!-- This metric requires an explicit capacity, e.g. maximum capacity of 1000
requests/sec -->
+ <property name="capacity">1000</property>
+ </bean>
+ <!-- The incoming traffic received by JBossWeb connectors in KB/sec, with respect to
the defined capacity -->
+ <!-- Analogous to method=T in mod_jk -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.ReceiveTrafficLoadMetric"
mode="On Demand" name="ReceiveTrafficLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=ReceiveTraffic",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter
class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource">
+<inject bean="RequestProcessorLoadMetricSource"/>
+</parameter>
+ <!--parameter>bytesReceived</parameter-->
+ </constructor>
+ <!-- This metric requires an explicit capacity, e.g. max capacity of 1024 KB/s
-->
+ <property name="capacity">1024</property>
+ </bean>
+ <!-- The outgoing traffic sent by JBossWeb connectors in KB/sec, with respect to the
defined capacity -->
+ <bean class="org.jboss.modcluster.load.metric.impl.SendTrafficLoadMetric"
mode="On Demand" name="SendTrafficLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=SendTraffic",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter
class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource">
+<inject bean="RequestProcessorLoadMetricSource"/>
+</parameter>
+ <!--parameter>bytesSent</parameter-->
+ </constructor>
+ <!-- This metric requires an explicit capacity, e.g. max capacity of 512 KB/s
-->
+ <property name="capacity">512</property>
+ </bean>
+ <!-- Queries all JBossWeb GlobalRequestProcessor mbeans -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource"
mode="On Demand" name="RequestProcessorLoadMetricSource">
+ <constructor>
+ <parameter class="javax.management.MBeanServer">
+<inject bean="JMXKernel" property="mbeanServer"/>
+</parameter>
+ <!-- Object name pattern for request processors -->
+ <!--parameter>jboss.web:type=GlobalRequestProcessor,*</parameter-->
+ </constructor>
+ </bean>
+
+
+ <!-- The number of active sessions, with respect to the defined capacity -->
+ <!-- Analogous to method=S in mod_jk -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.ActiveSessionsLoadMetric"
mode="On Demand" name="ActiveSessionsLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=ActiveSessions",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter>
+<inject bean="SessionLoadMetricSource"/>
+</parameter>
+ <!--parameter>activeSessions</parameter-->
+ </constructor>
+ <!-- This metric requires an explicit capacity, e.g. max capacity of 1000 active
sessions -->
+ <property name="capacity">1000</property>
+ </bean>
+ <!-- Queries all JBossWeb session manager mbeans -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource"
mode="On Demand" name="SessionLoadMetricSource">
+ <constructor>
+ <parameter class="javax.management.MBeanServer">
+<inject bean="JMXKernel" property="mbeanServer"/>
+</parameter>
+ <!-- Object name pattern for session managers -->
+ <!--parameter>jboss.web:type=Manager,*</parameter-->
+ </constructor>
+ </bean>
+
+
+ <!-- Returns the connection pool usage as a ratio of used to max pool size -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.ConnectionPoolUsageLoadMetric"
mode="On Demand" name="ConnectionPoolUsageMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=ConnectionPoolUsage",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter>
+<inject bean="ConnectionPoolLoadMetricSource"/>
+</parameter>
+ <!--parameter>InUseConnectionCount</parameter-->
+ <!--parameter>MaxSize</parameter-->
+ </constructor>
+ </bean>
+ <!-- Queries all JCA connection pools -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.ConnectionPoolLoadMetricSource"
mode="On Demand" name="ConnectionPoolLoadMetricSource">
+ <constructor>
+ <parameter class="javax.management.MBeanServer">
+<inject bean="JMXKernel" property="mbeanServer"/>
+</parameter>
+ <!-- Object name pattern for connector thread pools -->
+ <!--parameter>jboss.jca:service=ManagedConnectionPool,*</parameter-->
+ </constructor>
+ </bean>
+
+ <!-- Generic load metrics/sources -->
+
+ <!-- Uses the sum of the values of the specified attribute for each
+ mbean matching the query, with respect to a defined capacity. -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric"
mode="On Demand" name="MBeanAttributeLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=MBeanAttribute",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter>
+<inject bean="MBeanQueryLoadMetricSource"/>
+</parameter>
+ <parameter>
+<!-- mbean attribute -->
+</parameter>
+ </constructor>
+ <property name="capacity">1</property>
+ </bean>
+ <!-- Uses the ratio of the sum of the values of the specified dividend attribute,
+ to the sum of the values of the specified divisor attribute for each mbean
+ matching the query. -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.MBeanAttributeRatioLoadMetric"
mode="On Demand" name="MBeanAttributeRatioLoadMetric">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster,provider=LoadBalanceFactor,metric=MBeanAttributeRatio",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter>
+<inject bean="MBeanQueryLoadMetricSource"/>
+</parameter>
+ <parameter>
+<!-- dividend attribute -->
+</parameter>
+ <parameter>
+<!-- divisor attribute -->
+</parameter>
+ </constructor>
+ </bean>
+ <!-- Queries for mbeans matching the specified pattern -->
+ <bean
class="org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource"
mode="On Demand" name="MBeanQueryLoadMetricSource">
+ <constructor>
+ <parameter>
+<!-- ObjectName pattern -->
+</parameter>
+ <parameter>
+<inject bean="JMXKernel" property="mbeanServer"/>
+</parameter>
+ </constructor>
+ </bean>
+
+</deployment>
diff --git a/modules/plugins/mod-cluster/src/test/resources/xml_config/server.xml
b/modules/plugins/mod-cluster/src/test/resources/xml_config/server.xml
new file mode 100644
index 0000000..51fb479
--- /dev/null
+++ b/modules/plugins/mod-cluster/src/test/resources/xml_config/server.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
+<Server>
+
+ <Listener advertise="true"
className="org.jboss.modcluster.catalina.ModClusterListener"
smax="124"/>
+
+ <!--APR library loader. Documentation at /docs/apr.html -->
+ <Listener SSLEngine="on"
className="org.apache.catalina.core.AprLifecycleListener"/>
+ <!--Initialize Jasper prior to webapps are loaded. Documentation at
/docs/jasper-howto.html -->
+ <Listener className="org.apache.catalina.core.JasperListener"/>
+
+ <!-- Use a custom version of StandardService that allows the
+ connectors to be started independent of the normal lifecycle
+ start to allow web apps to be deployed before starting the
+ connectors.
+ -->
+ <Service name="jboss.web">
+
+ <!-- A "Connector" represents an endpoint by which requests are
received
+ and responses are returned. Documentation at :
+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+ Java AJP Connector: /docs/config/ajp.html
+ APR (HTTP/AJP) Connector: /docs/apr.html
+ Define a non-SSL HTTP/1.1 Connector on port 8080
+ -->
+ <Connector acceptCount="100" address="${jboss.bind.address}"
connectionTimeout="20000" disableUploadTimeout="true"
emptySessionPath="true" enableLookups="false"
maxHttpHeaderSize="8192" maxThreads="250" port="8080"
protocol="HTTP/1.1" redirectPort="8443"/>
+
+ <!-- Define a SSL HTTP/1.1 Connector on port 8443
+ This connector uses the JSSE configuration, when using APR, the
+ connector should be using the OpenSSL style configuration
+ described in the APR documentation -->
+ <!--
+ <Connector port="8443" protocol="HTTP/1.1"
SSLEnabled="true"
+ maxThreads="150" scheme="https"
secure="true"
+ clientAuth="false" sslProtocol="TLS" />
+ -->
+
+ <!-- Define an AJP 1.3 Connector on port 8009 -->
+ <Connector address="${jboss.bind.address}"
emptySessionPath="true" enableLookups="false" port="8009"
protocol="AJP/1.3" redirectPort="8443"/>
+
+ <Engine defaultHost="localhost" name="jboss.web">
+
+ <!-- The JAAS based authentication and authorization realm implementation
+ that is compatible with the jboss 3.2.x realm implementation.
+ - certificatePrincipal : the class name of the
+ org.jboss.security.auth.certs.CertificatePrincipal impl
+ used for mapping X509[] cert chains to a Princpal.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ -->
+ <Realm allRolesMode="authOnly"
certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"/>
+ <!-- A subclass of JBossSecurityMgrRealm that uses the authentication
+ behavior of JBossSecurityMgrRealm, but overrides the authorization
+ checks to use JACC permissions with the current java.security.Policy
+ to determine authorized access.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ <Realm
className="org.jboss.web.tomcat.security.JaccAuthorizationRealm"
+
certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
+ allRolesMode="authOnly"
+ />
+ -->
+
+ <Host autoDeploy="false"
configClass="org.jboss.web.tomcat.security.config.JBossContextConfig"
deployOnStartup="false" deployXML="false"
name="localhost">
+
+ <!-- Uncomment to enable request dumper. This Valve "logs interesting
+ contents from the specified Request (before processing) and the
+ corresponding Response (after processing). It is especially useful
+ in debugging problems related to headers and cookies."
+ -->
+ <!--
+ <Valve className="org.apache.catalina.valves.RequestDumperValve"
/>
+ -->
+
+ <!-- Access logger -->
+ <!--
+ <Valve className="org.apache.catalina.valves.AccessLogValve"
+ prefix="localhost_access_log." suffix=".log"
+ pattern="common" directory="${jboss.server.log.dir}"
+ resolveHosts="false" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host. Does not provide SSO across a cluster.
+
+ If this valve is used, do not use the JBoss ClusteredSingleSignOn
+ valve shown below.
+
+ A new configuration attribute is available beginning with
+ release 4.0.4:
+
+ cookieDomain configures the domain to which the SSO cookie
+ will be scoped (i.e. the set of hosts to
+ which the cookie will be presented). By default
+ the cookie is scoped to "/", meaning the host
+ that presented it. Set cookieDomain to a
+ wider domain (e.g. "xyz.com") to allow an SSO
+ to span more than one hostname.
+ -->
+ <!--
+ <Valve
className="org.apache.catalina.authenticator.SingleSignOn" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host AND to all other hosts in the cluster.
+
+ If this valve is used, do not use the standard Tomcat SingleSignOn
+ valve shown above.
+
+ Valve uses a JBossCache instance to support SSO credential
+ caching and replication across the cluster. The JBossCache
+ instance must be configured separately. By default, the valve
+ shares a JBossCache with the service that supports HttpSession
+ replication. See the "jboss-web-cluster-service.xml" file in
the
+ server/all/deploy directory for cache configuration details.
+
+ Besides the attributes supported by the standard Tomcat
+ SingleSignOn valve (see the Tomcat docs), this version also
+ supports the following attributes:
+
+ cookieDomain see above
+
+ treeCacheName JMX ObjectName of the JBossCache MBean used to
+ support credential caching and replication across
+ the cluster. If not set, the default value is
+ "jboss.cache:service=TomcatClusteringCache", the
+ standard ObjectName of the JBossCache MBean used
+ to support session replication.
+ -->
+ <!--
+ <Valve
className="org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn" />
+ -->
+
+ <!-- Check for unclosed connections and transaction terminated checks
+ in servlets/jsps.
+
+ Important: The dependency on the CachedConnectionManager
+ in META-INF/jboss-service.xml must be uncommented, too
+ -->
+ <Valve
cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
transactionManagerObjectName="jboss:service=TransactionManager"/>
+
+ </Host>
+
+ </Engine>
+
+ </Service>
+
+</Server>
commit dc131685f088d8915bf2516e25a37cf916cf07e3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 17:50:23 2011 -0500
All the node lists are zero based index. Fixing for the incorrect indexing of lists.
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 8cff302..c2cf3a8 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,9 +75,10 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
*/
public void setPropertyValue(String propertyName, String value) {
boolean propertyFound = false;
+ NodeList nodeList = beanNode.getChildNodes();
- for (int i = 0; i < beanNode.getChildNodes().getLength(); i++) {
- Node currentNode = beanNode.getChildNodes().item(i);
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node currentNode = nodeList.item(i);
if (currentNode.getNodeName().equals("property")
&& currentNode.getAttributes().getNamedItem("name") !=
null
@@ -131,7 +132,7 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
private Node getBeanNodeByClass(String className) {
NodeList nodeList = this.getDocument().getElementsByTagName("bean");
- for (int i = 1; i < nodeList.getLength(); i++) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getAttributes().getNamedItem("class") != null
@@ -150,7 +151,7 @@ public class ModClusterBeanFile extends AbstractConfigurationFile {
private Node getBeanNodeByName(String beanName) {
NodeList nodeList = this.getDocument().getElementsByTagName("bean");
- for (int i = 1; i < nodeList.getLength(); i++) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getAttributes().getNamedItem("name") != null
commit d1e6d46e89fb5876446fcfe42c04cf4c48a11bce
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 17:43:08 2011 -0500
Add property persistance functionality to catalina JMX listener for mod_cluster by
saving the configuration directly into the server.xml file.
diff --git
a/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/CatalinaServiceComponent.java
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/CatalinaServiceComponent.java
new file mode 100644
index 0000000..1b390c5
--- /dev/null
+++
b/modules/plugins/mod-cluster/src/main/java/org/rhq/plugins/modcluster/CatalinaServiceComponent.java
@@ -0,0 +1,93 @@
+/*
+ * 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 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.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.JBossWebServerFile;
+
+@SuppressWarnings({ "rawtypes", "deprecation" })
+public class CatalinaServiceComponent extends MBeanResourceComponent {
+ private static final String SERVER_HOME_DIR = "serverHomeDir";
+ private static final String CONFIGURATION_FILE_RELATIVE_PATH =
"/deploy/jboss-web.deployer/server.xml";
+
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ super.updateResourceConfiguration(report);
+
+ try {
+ saveResouceConfigurationToFile(report, true);
+ } catch (Exception e) {
+ }
+ }
+
+ private void saveResouceConfigurationToFile(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 {
+ JBossWebServerFile jbossWebServerFile = getJBossWebServerFileInstance();
+
+ 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())) {
+ jbossWebServerFile.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);
+ }
+ }
+ }
+
+ jbossWebServerFile.saveConfigurationFile();
+ } catch (Exception e) {
+ log.debug("Unable to save mod_cluster configuration file.", e);
+ }
+ }
+
+ private JBossWebServerFile getJBossWebServerFileInstance() throws Exception {
+ ModClusterServerComponent modClusterComponent = (ModClusterServerComponent)
this.resourceContext
+ .getParentResourceComponent();
+
+ PropertySimple property =
modClusterComponent.getResourceContext().getPluginConfiguration()
+ .getSimple(SERVER_HOME_DIR);
+
+ if (property != null) {
+ String fileName = property.getStringValue() +
CONFIGURATION_FILE_RELATIVE_PATH;
+ return new JBossWebServerFile(fileName);
+ }
+
+ return null;
+ }
+}
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 354fa99..45204e1 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
@@ -23,6 +23,11 @@ import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.commons.lang.NotImplementedException;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
@@ -31,20 +36,52 @@ import org.xml.sax.SAXException;
*/
public class JBossWebServerFile extends AbstractConfigurationFile {
- public JBossWebServerFile(String fileName) throws ParserConfigurationException,
SAXException, IOException {
- super(fileName);
- // TODO Auto-generated constructor stub
+ private static final String CATALINA_LISTENER_CLASS_NAME =
"org.jboss.modcluster.catalina.ModClusterListener";
+
+ private Node listenerNode;
+
+ public JBossWebServerFile(String configurationFileName) throws
ParserConfigurationException, SAXException,
+ IOException {
+ super(configurationFileName);
+
+ listenerNode = this.getListenerNode();
}
@Override
- void setPropertyValue(String propertyName, String value) {
- // TODO Auto-generated method stub
+ public void setPropertyValue(String propertyName, String value) {
+ NamedNodeMap attributeList = listenerNode.getAttributes();
+ if (attributeList.getNamedItem(propertyName) != null && value != null) {
+ Node attributeNode = attributeList.getNamedItem(propertyName);
+ attributeNode.setTextContent(value);
+ } else if (attributeList.getNamedItem(propertyName) != null && value ==
null) {
+ attributeList.removeNamedItem(propertyName);
+ } else if (attributeList.getNamedItem(propertyName) == null && value !=
null) {
+ Attr property = this.getDocument().createAttribute(propertyName);
+ property.setValue(propertyName);
+ property.setTextContent(value);
+ attributeList.setNamedItem(property);
+ }
}
@Override
- String getPropertyValue(String propertyName) {
- // TODO Auto-generated method stub
+ public String getPropertyValue(String propertyName) {
+ throw new NotImplementedException(
+ "Property values should be retrieved from the JMX interface not from the
configuration file.");
+ }
+
+ private Node getListenerNode() {
+ NodeList nodeList =
this.getDocument().getElementsByTagName("Listener");
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+
+ if (node.getAttributes().getNamedItem("className") != null
+ &&
CATALINA_LISTENER_CLASS_NAME.equals(node.getAttributes().getNamedItem("className").getTextContent()))
{
+ return node;
+ }
+ }
+
return null;
}
}
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 3e523f7..dafb18f 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
@@ -325,7 +325,7 @@
</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">
+ <service name="Catalina Service"
discovery="org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent"
class="CatalinaServiceComponent" supportsManualAdd="true"
description="Catalina Service Listener" singleton="true">
<plugin-configuration>
<c:simple-property name="objectName" readOnly="true"
default="Catalina:type=ModClusterListener,*" />
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 cba5672..b8fca4c 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
@@ -20,12 +20,13 @@ package org.rhq.plugins.modcluster.test;
import org.testng.annotations.Test;
+import org.rhq.plugins.modcluster.config.JBossWebServerFile;
import org.rhq.plugins.modcluster.config.ModClusterBeanFile;
public class ServerConfigTest {
@Test
- public void TestConfig() {
+ public void TestModClusterConfig() {
try {
//Test simple bean configuration
@@ -57,4 +58,25 @@ public class ServerConfigTest {
}
}
+ @Test
+ public void TestJBossWebConfig() {
+
+ try {
+ //Test simple bean configuration
+ JBossWebServerFile config = new JBossWebServerFile(
+
"/home/snegrea/Downloads/jboss42/server/all/deploy/jboss-web.deployer/server.xml");
+ config.setPropertyValue("processStatusFrequency", "4");
+ config.setPropertyValue("test", "5");
+ config.setPropertyValue("test", "123");
+
+ config.setPropertyValue("test", null);
+ config.setPropertyValue("processStatusFrequency", null);
+
+ config.saveConfigurationFile();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
}
commit 616b14c59c03a04144e887c73e2c290a149c202d
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Aug 25 17:35:02 2011 -0500
Moved private method at the bottom fo the file to follow standard java file
structure.
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 3eb7cbe..31530d7 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
@@ -57,18 +57,6 @@ public class LoadMetricDiscoveryComponent extends
MBeanResourceDiscoveryComponen
}
/**
- * @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.
@@ -89,4 +77,16 @@ public class LoadMetricDiscoveryComponent extends
MBeanResourceDiscoveryComponen
}
return bean;
}
+
+ /**
+ * @param context
+ * @param objectName
+ * @return
+ */
+ private String
getBeanConfiguredClassName(ResourceDiscoveryContext<JMXComponent> context, String
objectName) {
+ EmsConnection connection =
context.getParentResourceComponent().getEmsConnection();
+ EmsBean emsBean = loadBean(connection, objectName);
+
+ return emsBean.getClassTypeName();
+ }
}