[jboss-cvs] JBossAS SVN: r86282 - in trunk: profileservice/src/main/org/jboss/profileservice/management and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 24 23:50:31 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-03-24 23:50:31 -0400 (Tue, 24 Mar 2009)
New Revision: 86282
Added:
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/management/
Modified:
trunk/profileservice/.classpath
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java
trunk/tomcat/src/resources/jboss-beans.xml
Log:
JBAS-6618, proxy between the runtime component and the statistic managed property to ensure the values update
Modified: trunk/profileservice/.classpath
===================================================================
--- trunk/profileservice/.classpath 2009-03-25 03:22:10 UTC (rev 86281)
+++ trunk/profileservice/.classpath 2009-03-25 03:50:31 UTC (rev 86282)
@@ -19,5 +19,6 @@
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-security-spi/lib/jboss-security-spi.jar" sourcepath="/thirdparty/jboss/jboss-security-spi/lib/jboss-security-spi-sources.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-kernel.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-kernel-sources.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-dependency.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-dependency-sources.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/system"/>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Copied: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java (from rev 86269, branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java)
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java 2009-03-25 03:50:31 UTC (rev 86282)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A ManagedProperty delegate used as the target of the ManagedProperty
+ * proxies used for runtime managed objects statistics.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ManagedPropertyDelegate implements ManagedProperty
+{
+ private final static long serialVersionUID = 1;
+ private ManagedProperty delegate;
+ /** The dispatcher handles ManagedOperation dispatches */
+ private RuntimeComponentDispatcher dispatcher;
+ private Object componentName;
+
+
+ public ManagedPropertyDelegate(ManagedProperty delegate,
+ RuntimeComponentDispatcher dispatcher, Object componentName)
+ {
+ super();
+ this.delegate = delegate;
+ this.dispatcher = dispatcher;
+ this.componentName = componentName;
+ }
+
+ public String checkValidValue(MetaValue value)
+ {
+ return delegate.checkValidValue(value);
+ }
+
+ public ManagedProperty copy()
+ {
+ return delegate.copy();
+ }
+
+ public Map<String, Annotation> getAnnotations()
+ {
+ return delegate.getAnnotations();
+ }
+
+ public String getDescription()
+ {
+ return delegate.getDescription();
+ }
+
+ public <T> T getField(String fieldName, Class<T> expected)
+ {
+ return delegate.getField(fieldName, expected);
+ }
+
+ public Fields getFields()
+ {
+ return delegate.getFields();
+ }
+
+ public Set<MetaValue> getLegalValues()
+ {
+ return delegate.getLegalValues();
+ }
+
+ public ManagedObject getManagedObject()
+ {
+ return delegate.getManagedObject();
+ }
+
+ public String getMappedName()
+ {
+ return delegate.getMappedName();
+ }
+
+ public Comparable<? extends MetaValue> getMaximumValue()
+ {
+ return delegate.getMaximumValue();
+ }
+
+ public MetaType getMetaType()
+ {
+ return delegate.getMetaType();
+ }
+
+ public Comparable<? extends MetaValue> getMinimumValue()
+ {
+ return delegate.getMinimumValue();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public ManagedObject getTargetManagedObject()
+ {
+ return delegate.getTargetManagedObject();
+ }
+
+ public <T> T getTransientAttachment(Class<T> expectedType)
+ {
+ return delegate.getTransientAttachment(expectedType);
+ }
+
+ public Object getTransientAttachment(String name)
+ {
+ return delegate.getTransientAttachment(name);
+ }
+
+ public MetaValue getValue()
+ {
+ String propName = getMappedName();
+ MetaValue propValue = dispatcher.get(componentName, propName);
+ return propValue;
+ }
+
+ public boolean hasAnnotation(String key)
+ {
+ return delegate.hasAnnotation(key);
+ }
+
+ public boolean hasViewUse(ViewUse use)
+ {
+ return delegate.hasViewUse(use);
+ }
+
+ public boolean isMandatory()
+ {
+ return delegate.isMandatory();
+ }
+
+ public boolean isModified()
+ {
+ return delegate.isModified();
+ }
+
+ public boolean isRemoved()
+ {
+ return delegate.isRemoved();
+ }
+
+ public void setField(String fieldName, Serializable value)
+ {
+ delegate.setField(fieldName, value);
+ }
+
+ public void setManagedObject(ManagedObject managedObject)
+ {
+ delegate.setManagedObject(managedObject);
+ }
+
+ public void setRemoved(boolean flag)
+ {
+ delegate.setRemoved(flag);
+ }
+
+ public void setTargetManagedObject(ManagedObject target)
+ {
+ delegate.setTargetManagedObject(target);
+ }
+
+ public void setTransientAttachment(String name, Object attachment)
+ {
+ delegate.setTransientAttachment(name, attachment);
+ }
+
+ public void setValue(MetaValue value)
+ {
+ delegate.setValue(value);
+ }
+
+
+}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-03-25 03:22:10 UTC (rev 86281)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-03-25 03:50:31 UTC (rev 86282)
@@ -400,9 +400,12 @@
if (managementObject.isRuntime())
{
boolean merged = false;
+ ManagementComponent mc = managementObject.componentType();
+ boolean isMC = !(mc.type().length() == 0 && mc.subtype().length() == 0);
+
// Merge this with the ManagedObject
ManagedObject parentMO = moRegistry.get(key);
- if (parentMO == null)
+ if (parentMO == null && isMC == false)
{
log.debug("Deferring resolution of runtime ManagedObject: "+managementObject);
// Save the runtime mo for merging
@@ -422,8 +425,7 @@
log.debug("Updated component: "+comp+" run state to: "+state);
}
// There is no further processing of runtime ManagedObjects, unless its marked as a component
- ManagementComponent mc = managementObject.componentType();
- if (mc.type().length() == 0 && mc.subtype().length() == 0)
+ if (isMC == false)
return;
//
else if (merged == false)
@@ -1233,9 +1235,13 @@
}
/**
- * Merge the runtime props and ops
- * @param mo
- * @param runtimeMO
+ * Merge the and proxy runtime props and ops
+ *
+ * @param mo - the parent managed object to merge into. May be null if the
+ * runtimeMO is a self contained managed object as is the case for runtime
+ * components.
+ * @param runtimeMO - the managed object with isRuntime=true to merge/proxy
+ * properties and operations for.
*/
protected void mergeRuntimeMO(ManagedObject mo, ManagedObject runtimeMO)
throws Exception
@@ -1245,10 +1251,29 @@
// Get the runtime MO component name
Object componentName = runtimeMO.getComponentName();
log.debug("Merging runtime: "+runtimeMO.getName()+", compnent name: "+componentName);
- Map<String, ManagedProperty> moProps = mo.getProperties();
- Set<ManagedOperation> moOps = mo.getOperations();
- HashMap<String, ManagedProperty> props = new HashMap<String, ManagedProperty>(moProps);
- HashSet<ManagedOperation> ops = new HashSet<ManagedOperation>(moOps);
+ Map<String, ManagedProperty> moProps = null;
+ Set<ManagedOperation> moOps = null;
+ HashMap<String, ManagedProperty> props = null;
+ HashSet<ManagedOperation> ops = null;
+ // If mo is null, the merge target is the runtimeMO
+ if (mo == null)
+ {
+ // Just proxy the runtime props/ops
+ mo = runtimeMO;
+ moProps = mo.getProperties();
+ moOps = mo.getOperations();
+ // These will be updated with the proxied values, don't duplicate props/ops
+ props = new HashMap<String, ManagedProperty>();
+ ops = new HashSet<ManagedOperation>();
+ }
+ else
+ {
+ // Merge the runtime props/ops
+ moProps = mo.getProperties();
+ moOps = mo.getOperations();
+ props = new HashMap<String, ManagedProperty>(moProps);
+ ops = new HashSet<ManagedOperation>(moOps);
+ }
if (runtimeProps != null && runtimeProps.size() > 0)
{
@@ -1276,14 +1301,20 @@
{
log.debug("Failed to get stat value, "+componentName+":"+propName);
}
+ ManagedProperty proxiedProp = createPropertyProxy(prop);
+ props.put(prop.getName(), proxiedProp);
}
+ else
+ {
+ props.put(prop.getName(), prop);
+ }
}
- // Keep the property associated with the runtime MO for invocations/upddates
+ // Keep the property associated with the runtime MO for invocations/updates
if (prop.getTargetManagedObject() == null)
prop.setTargetManagedObject(runtimeMO);
}
}
- props.putAll(runtimeProps);
+
log.debug("Properties after:"+props);
}
if (runtimeOps != null && runtimeOps.size() > 0)
@@ -1299,6 +1330,31 @@
moi.setOperations(ops);
}
+ private ManagedProperty createPropertyProxy(ManagedProperty prop)
+ throws Exception
+ {
+ if (dispatcher == null)
+ throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
+
+ ClassLoader loader = getClass().getClassLoader();
+ ArrayList<Interceptor> interceptors = new ArrayList<Interceptor>();
+ interceptors.add(SecurityClientInterceptor.singleton);
+ interceptors.add(MergeMetaDataInterceptor.singleton);
+ interceptors.add(InvokeRemoteInterceptor.singleton);
+
+ // Create the ManagedProperty proxy
+ // This is just a unique name registered with the dispatcher and remoting layers
+ String dispatchName = "ProfileService.ManagedProperty@"+System.identityHashCode(prop);
+ Object componentName = prop.getManagedObject().getComponentName();
+ ManagedPropertyDelegate delegate = new ManagedPropertyDelegate(prop, dispatcher, componentName);
+ Class<?>[] ifaces = {ManagedProperty.class};
+ Dispatcher.singleton.registerTarget(dispatchName, delegate);
+ ManagedProperty proxy = (ManagedProperty) Remoting.createRemoteProxy(dispatchName,
+ loader, ifaces, locator, interceptors, "ProfileService");
+ return proxy;
+ }
+
+
/**
* Create ManagedOperation wrapper to intercept
* its invocation, pushing the actual invocation
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java 2009-03-25 03:22:10 UTC (rev 86281)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java 2009-03-25 03:50:31 UTC (rev 86282)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.profileservice.test;
+import java.net.InetAddress;
+import java.net.URL;
import java.util.Map;
import java.util.Set;
@@ -31,11 +33,14 @@
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.RunState;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.types.EnumMetaType;
import org.jboss.metatype.api.values.EnumValue;
import org.jboss.metatype.api.values.EnumValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.profileservice.management.matchers.AliasMatcher;
import org.jboss.profileservice.spi.ProfileService;
import org.jboss.test.JBossTestCase;
@@ -208,6 +213,85 @@
getLog().info(props);
}
+ public void testWebConnector()
+ throws Exception
+ {
+ // Make a request
+ InetAddress address = InetAddress.getByName(getServerHost());
+ URL root = new URL("http://"+address.getHostAddress()+":8080/");
+ // Load the
+ ManagementView mgtView = getManagementView();
+ ComponentType type = new ComponentType("MBean", "Web");
+ String name = "jboss.web:name=http-"+address.getHostAddress()+"-8080,type=GlobalRequestProcessor";
+ ManagedComponent mc = mgtView.getComponent(name, type);
+ assertNotNull(name, mc);
+ Map<String, ManagedProperty> props = mc.getProperties();
+ for(ManagedProperty mp : props.values())
+ log.info(mp.getName()+", "+mp.getValue());
+ root.openConnection().setUseCaches(false);
+ log.info(root+" content: "+root.openConnection().getContentLength());
+
+ // {errorCount, bytesReceived, bytesSent, state, requestProcessors, processingTime, requestCount, maxTime}
+ ManagedProperty bytesSent = mc.getProperty("bytesSent");
+ assertNotNull(bytesSent);
+ MetaValue bytesSentMV = bytesSent.getValue();
+ SimpleValue bytesSentSV = (SimpleValue) bytesSentMV;
+ log.debug("bytesSentSV#1: "+bytesSentSV);
+ assertTrue("bytesSent > 0", bytesSentSV.compareTo(SimpleValueSupport.wrap(0)) > 0);
+
+ // Make the request again to ensure the count increases
+ log.info(root+" content: "+root.openConnection().getContentLength());
+ MetaValue bytesSentMV2 = bytesSent.getValue();
+ SimpleValue bytesSentSV2 = (SimpleValue) bytesSentMV2;
+ log.debug("bytesSentSV#2: "+bytesSentSV2);
+ assertTrue("bytesSentSV2 > bytesSentSV", bytesSentSV2.compareTo(bytesSentSV) > 0);
+ }
+
+ public void testWebConnectorPool()
+ throws Exception
+ {
+ // Make a request
+ InetAddress address = InetAddress.getByName(getServerHost());
+ URL root = new URL("http://"+address.getHostAddress()+":8080/");
+ // Load the
+ ManagementView mgtView = getManagementView();
+ ComponentType type = new ComponentType("MBean", "Web");
+ String name = "jboss.web:name=http-"+address.getHostAddress()+"-8080,type=ThreadPool";
+ ManagedComponent mc = mgtView.getComponent(name, type);
+ assertNotNull(name, mc);
+ Map<String, ManagedProperty> props = mc.getProperties();
+ for(ManagedProperty mp : props.values())
+ log.info(mp.getName()+", "+mp.getValue());
+ log.info(root+" content: "+root.openConnection().getContentLength());
+
+ ManagedProperty threadPriority = mc.getProperty("threadPriority");
+ assertNotNull(threadPriority);
+ MetaValue threadPriorityMV = threadPriority.getValue();
+ SimpleValue threadPrioritySV = (SimpleValue) threadPriorityMV;
+ assertTrue("threadPriority > 0", threadPrioritySV.compareTo(SimpleValueSupport.wrap(0)) > 0);
+ assertEquals(mc.getRunState(), RunState.RUNNING);
+ }
+
+ public void testWebHost()
+ throws Exception
+ {
+ // Make a request
+ InetAddress address = InetAddress.getByName(getServerHost());
+ // Load the
+ ManagementView mgtView = getManagementView();
+ ComponentType type = new ComponentType("MBean", "Web");
+ String name = "jboss.web:host="+address.getHostAddress()+",type=Host";
+ ManagedComponent mc = mgtView.getComponent(name, type);
+ assertNotNull(name, mc);
+ Map<String, ManagedProperty> props = mc.getProperties();
+ for(ManagedProperty mp : props.values())
+ log.info(mp.getName()+", "+mp.getValue());
+
+ ManagedProperty currentThreadCount = mc.getProperty("aliases");
+ assertNotNull(currentThreadCount);
+ assertEquals(mc.getRunState(), RunState.RUNNING);
+ }
+
/**
* Obtain the ProfileService.ManagementView
* @return
@@ -235,3 +319,4 @@
return value.longValue();
}
}
+
Copied: trunk/tomcat/src/main/org/jboss/web/tomcat/service/management (from rev 86281, branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management)
Modified: trunk/tomcat/src/resources/jboss-beans.xml
===================================================================
--- trunk/tomcat/src/resources/jboss-beans.xml 2009-03-25 03:22:10 UTC (rev 86281)
+++ trunk/tomcat/src/resources/jboss-beans.xml 2009-03-25 03:50:31 UTC (rev 86282)
@@ -27,4 +27,75 @@
</bean>
+ <bean name="WebServerMO"
+ class="org.jboss.web.tomcat.service.management.WebServer">
+ <property name="domain">jboss.web</property>
+ <property name="nameProps">
+ <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>service</key>
+ <value>WebServer</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+ <bean name="ConnectorBean-http-${jboss.bind.address}-8080MO"
+ class="org.jboss.web.tomcat.service.management.ConnectorBean">
+ <property name="domain">jboss.web</property>
+ <property name="nameProps">
+ <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>type</key>
+ <value>GlobalRequestProcessor</value>
+ </entry>
+ </map>
+ </property>
+ <property name="port">
+ <value-factory bean="ServiceBindingManager"
+ method="getIntBinding" >
+ <parameter>jboss.web:service=WebServer</parameter>
+ </value-factory>
+ </property>
+ <property name="address">${jboss.bind.address}</property>
+ <property name="server"><inject bean="JMXKernel" property="mbeanServer"/></property>
+ </bean>
+ <bean name="ThreadPool-http-${jboss.bind.address}-8080MO"
+ class="org.jboss.web.tomcat.service.management.ThreadPool">
+ <property name="domain">jboss.web</property>
+ <property name="nameProps">
+ <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>type</key>
+ <value>ThreadPool</value>
+ </entry>
+ </map>
+ </property>
+ <property name="port">
+ <value-factory bean="ServiceBindingManager"
+ method="getIntBinding" >
+ <parameter>jboss.web:service=WebServer</parameter>
+ </value-factory>
+ </property>
+ <property name="address">${jboss.bind.address}</property>
+ <property name="server"><inject bean="JMXKernel" property="mbeanServer"/></property>
+ </bean>
+ <bean name="${jboss.bind.address}-MO"
+ class="org.jboss.web.tomcat.service.management.Host">
+ <property name="domain">jboss.web</property>
+ <property name="nameProps">
+ <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>type</key>
+ <value>Host</value>
+ </entry>
+ <entry>
+ <key>host</key>
+ <value>${jboss.bind.address}</value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+
</deployment>
More information about the jboss-cvs-commits
mailing list