[jboss-cvs] JBossAS SVN: r86269 - in branches/Branch_5_x: profileservice/src/main/org/jboss/profileservice/management and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 24 14:38:35 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-03-24 14:38:35 -0400 (Tue, 24 Mar 2009)
New Revision: 86269
Added:
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
Modified:
branches/Branch_5_x/profileservice/.classpath
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java
branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ConnectorBean.java
branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ThreadPool.java
branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/WebServer.java
Log:
JBAS-6618, proxy between the runtime component and the statistic managed property to ensure the values update
Modified: branches/Branch_5_x/profileservice/.classpath
===================================================================
--- branches/Branch_5_x/profileservice/.classpath 2009-03-24 17:40:32 UTC (rev 86268)
+++ branches/Branch_5_x/profileservice/.classpath 2009-03-24 18:38:35 UTC (rev 86269)
@@ -20,5 +20,6 @@
<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 kind="lib" path="/thirdparty/jboss/jboss-ejb3-ext-api/lib/jboss-ejb3-ext-api.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-ext-api/lib/jboss-ejb3-ext-api-sources.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/system"/>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Added: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java (rev 0)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java 2009-03-24 18:38:35 UTC (rev 86269)
@@ -0,0 +1,205 @@
+/*
+ * 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);
+ System.out.println("get, "+componentName+"."+propName+": "+propValue);
+ 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);
+ }
+
+
+}
Property changes on: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-03-24 17:40:32 UTC (rev 86268)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-03-24 18:38:35 UTC (rev 86269)
@@ -399,9 +399,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
@@ -421,8 +424,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)
@@ -1196,9 +1198,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
@@ -1208,10 +1214,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)
{
@@ -1239,14 +1264,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)
@@ -1262,6 +1293,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: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java 2009-03-24 17:40:32 UTC (rev 86268)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/ServerManagedObjectsTestCase.java 2009-03-24 18:38:35 UTC (rev 86269)
@@ -228,6 +228,7 @@
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}
@@ -235,7 +236,15 @@
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()
@@ -255,11 +264,11 @@
log.info(mp.getName()+", "+mp.getValue());
log.info(root+" content: "+root.openConnection().getContentLength());
- ManagedProperty currentThreadCount = mc.getProperty("currentThreadCount");
- assertNotNull(currentThreadCount);
- MetaValue currentThreadCountMV = currentThreadCount.getValue();
- SimpleValue currentThreadCountSV = (SimpleValue) currentThreadCountMV;
- assertTrue("currentThreadCount > 0", currentThreadCountSV.compareTo(SimpleValueSupport.wrap(0)) > 0);
+ 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);
}
Modified: branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ConnectorBean.java
===================================================================
--- branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ConnectorBean.java 2009-03-24 17:40:32 UTC (rev 86268)
+++ branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ConnectorBean.java 2009-03-24 18:38:35 UTC (rev 86269)
@@ -55,7 +55,8 @@
throws Exception
{
initProxy();
- return mbeanProxy.getbytesSent();
+ long sent = mbeanProxy.getbytesSent();
+ return sent;
}
@ManagementProperty(use=ViewUse.STATISTIC)
@@ -71,7 +72,8 @@
throws Exception
{
initProxy();
- return mbeanProxy.getmaxTime();
+ long maxTime = mbeanProxy.getmaxTime();
+ return maxTime;
}
@ManagementProperty(use=ViewUse.STATISTIC)
@@ -87,7 +89,8 @@
throws Exception
{
initProxy();
- return mbeanProxy.getrequestCount();
+ int count = mbeanProxy.getrequestCount();
+ return count;
}
@ManagementProperty(use=ViewUse.STATISTIC, ignored=true)
Modified: branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ThreadPool.java
===================================================================
--- branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ThreadPool.java 2009-03-24 17:40:32 UTC (rev 86268)
+++ branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/ThreadPool.java 2009-03-24 18:38:35 UTC (rev 86269)
@@ -25,6 +25,7 @@
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
/**
* @author Scott.Stark at jboss.org
@@ -38,28 +39,28 @@
{
IThreadPool mbeanProxy;
- @ManagementProperty
+ @ManagementProperty(use=ViewUse.STATISTIC)
public int getCurrentThreadCount()
{
initProxy();
return mbeanProxy.getcurrentThreadCount();
}
- @ManagementProperty
+ @ManagementProperty(use=ViewUse.STATISTIC)
public int getCurrentThreadsBusy()
{
initProxy();
return mbeanProxy.getcurrentThreadsBusy();
}
- @ManagementProperty
+ @ManagementProperty(use=ViewUse.STATISTIC)
public int getMaxThreads()
{
initProxy();
return mbeanProxy.getmaxThreads();
}
- @ManagementProperty
+ @ManagementProperty(use=ViewUse.STATISTIC)
public int getThreadPriority()
{
initProxy();
Modified: branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/WebServer.java
===================================================================
--- branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/WebServer.java 2009-03-24 17:40:32 UTC (rev 86268)
+++ branches/Branch_5_x/tomcat/src/main/org/jboss/web/tomcat/service/management/WebServer.java 2009-03-24 18:38:35 UTC (rev 86269)
@@ -21,6 +21,8 @@
*/
package org.jboss.web.tomcat.service.management;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
/**
* @author Scott.Stark at jboss.org
* @version $Revision$
@@ -29,24 +31,25 @@
{
IWebServer mbeanProxy;
+ @ManagementProperty
public String getContextMBeanCode()
{
initProxy();
return mbeanProxy.getContextMBeanCode();
}
-
+ @ManagementProperty
public String getDefaultSecurityDomain()
{
initProxy();
return mbeanProxy.getDefaultSecurityDomain();
}
-
+ @ManagementProperty
public String[] getFilteredPackages()
{
initProxy();
return mbeanProxy.getFilteredPackages();
}
-
+ @ManagementProperty
public String getSessionIdAlphabet()
{
initProxy();
More information about the jboss-cvs-commits
mailing list