[jboss-cvs] JBossAS SVN: r61201 - in branches/Branch_4_2/ejb3/src: main/org/jboss/ejb3/cache and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 7 13:45:17 EST 2007
Author: bdecoste
Date: 2007-03-07 13:45:17 -0500 (Wed, 07 Mar 2007)
New Revision: 61201
Added:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapper.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapperMBean.java
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Pool.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java
Log:
[EJBTHREE-825] added EJB 2.x style metrics to EJB3.0 JMX Containers
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/AbstractPool.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/AbstractPool.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -42,6 +42,8 @@
protected Class contextClass;
protected Injector[] injectors;
protected Container container;
+ protected int createCount = 0;
+ protected int removeCount = 0;
public AbstractPool()
{
@@ -127,6 +129,9 @@
container.invokeInit(bean);
container.invokePostConstruct(ctx);
+
+ ++createCount;
+
return ctx;
}
@@ -189,6 +194,9 @@
container.invokeInit(bean, initTypes, initValues);
container.invokePostConstruct(ctx);
+
+ ++createCount;
+
return ctx;
}
@@ -201,6 +209,7 @@
finally
{
ctx.remove();
+ ++removeCount;
}
}
@@ -213,4 +222,14 @@
{
this.injectors = injectors;
}
+
+ public int getCreateCount()
+ {
+ return createCount;
+ }
+
+ public int getRemoveCount()
+ {
+ return removeCount;
+ }
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -35,6 +35,9 @@
import org.jboss.ejb3.stateful.StatefulContainer;
import org.jboss.ejb3.stateful.StatefulDelegateWrapper;
+
+import org.jboss.ejb3.mdb.MDB;
+import org.jboss.ejb3.mdb.MdbDelegateWrapper;
/**
* Comment
*
@@ -82,15 +85,19 @@
// create mbean delegate.
if (service instanceof StatelessContainer)
{
- service = new StatelessDelegateWrapper(service);
+ service = new StatelessDelegateWrapper(service);
}
else if (service instanceof StatefulContainer)
{
- service = new StatefulDelegateWrapper(service);
+ service = new StatefulDelegateWrapper(service);
}
+ else if (service instanceof MDB)
+ {
+ service = new MdbDelegateWrapper(service);
+ }
else
{
- service = new ServiceDelegateWrapper(service);
+ service = new ServiceDelegateWrapper(service);
}
}
JmxDependencyPolicy policy = (JmxDependencyPolicy)dependencies;
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Pool.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Pool.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Pool.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -66,6 +66,11 @@
int getAvailableCount();
int getMaxSize();
-
+
void setMaxSize(int maxSize);
+
+ int getCreateCount();
+
+ int getRemoveCount();
+
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ThreadlocalPool.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -88,5 +88,4 @@
public void setMaxSize(int maxSize)
{
}
-
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/NoPassivationCache.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -40,6 +40,7 @@
private Pool pool;
private HashMap cacheMap;
protected int createCount = 0;
+ protected int removeCount = 0;
public void initialize(Container container) throws Exception
{
@@ -159,7 +160,11 @@
{
ctx = (StatefulBeanContext) cacheMap.remove(key);
}
- if (ctx != null) pool.remove(ctx);
+ if (ctx != null)
+ {
+ pool.remove(ctx);
+ ++removeCount;
+ }
}
public int getCacheSize()
@@ -176,5 +181,25 @@
{
return 0;
}
+
+ public int getRemoveCount()
+ {
+ return removeCount;
+ }
+
+ public int getAvailableCount()
+ {
+ return -1;
+ }
+
+ public int getMaxSize()
+ {
+ return -1;
+ }
+
+ public int getCurrentSize()
+ {
+ return cacheMap.size();
+ }
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/StatefulCache.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -90,4 +90,12 @@
int getCreateCount();
int getPassivatedCount();
+
+ int getRemoveCount();
+
+ int getAvailableCount();
+
+ int getMaxSize();
+
+ int getCurrentSize();
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/simple/SimpleStatefulCache.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -56,6 +56,7 @@
private boolean running = true;
protected int createCount = 0;
protected int passivatedCount = 0;
+ protected int removeCount = 0;
private class CacheMap extends LinkedHashMap
{
@@ -366,6 +367,8 @@
if (!ctx.isRemoved())
pool.remove(ctx);
+ ++removeCount;
+
if (ctx.getCanRemoveFromCache())
{
synchronized (cacheMap)
@@ -390,4 +393,24 @@
{
return passivatedCount;
}
+
+ public int getRemoveCount()
+ {
+ return removeCount;
+ }
+
+ public int getAvailableCount()
+ {
+ return -1;
+ }
+
+ public int getMaxSize()
+ {
+ return maxSize;
+ }
+
+ public int getCurrentSize()
+ {
+ return cacheMap.size();
+ }
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/cache/tree/StatefulTreeCache.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -83,6 +83,7 @@
public static long MarkInUseWaitTime = 15000;
protected int createCount = 0;
protected int passivatedCount = 0;
+ protected int removeCount = 0;
public StatefulBeanContext create()
{
@@ -208,6 +209,8 @@
if (ctx.getCanRemoveFromCache())
cache.remove(id);
+
+ ++removeCount;
}
}
catch (CacheException e)
@@ -362,6 +365,26 @@
return passivatedCount;
}
+ public int getRemoveCount()
+ {
+ return removeCount;
+ }
+
+ public int getAvailableCount()
+ {
+ return -1;
+ }
+
+ public int getMaxSize()
+ {
+ return -1;
+ }
+
+ public int getCurrentSize()
+ {
+ return getCacheSize();
+ }
+
private void putInCache(StatefulBeanContext ctx) throws CacheException
{
ctx.preReplicate();
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -157,4 +157,40 @@
activationSpec.merge(md.activationConfig());
}
+
+ public int getMinPoolSize()
+ {
+ String minSession = activationSpec.get("minSession");
+ if (minSession != null)
+ return Integer.parseInt(minSession);
+ else
+ return 1;
+ }
+
+ public int getMaxPoolSize()
+ {
+ String maxSession = activationSpec.get("maxSession");
+ if (maxSession != null)
+ return Integer.parseInt(maxSession);
+ else
+ return 15;
+ }
+
+ public int getMaxMessages()
+ {
+ String maxMessages = activationSpec.get("maxMessages");
+ if (maxMessages != null)
+ return Integer.parseInt(maxMessages);
+ else
+ return 1;
+ }
+
+ public int getKeepAliveMillis()
+ {
+ String keepAlive = activationSpec.get("keepAlive");
+ if (keepAlive != null)
+ return Integer.parseInt(keepAlive);
+ else
+ return 60000;
+ }
}
Added: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapper.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapper.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapper.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.mdb;
+
+import org.jboss.ejb3.ServiceDelegateWrapper;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MdbDelegateWrapper extends ServiceDelegateWrapper implements MdbDelegateWrapperMBean
+{
+ public MdbDelegateWrapper(Object delegate)
+ {
+ super(delegate);
+ }
+
+ public int getMinPoolSize()
+ {
+ return ((MDB)delegate).getMinPoolSize();
+ }
+
+ public int getMaxPoolSize()
+ {
+ return ((MDB)delegate).getMaxPoolSize();
+ }
+
+ public int getMaxMessages()
+ {
+ return ((MDB)delegate).getMaxMessages();
+ }
+
+ public int getKeepAliveMillis()
+ {
+ return ((MDB)delegate).getKeepAliveMillis();
+ }
+}
Added: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapperMBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapperMBean.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MdbDelegateWrapperMBean.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.mdb;
+
+import org.jboss.ejb3.ServiceDelegateWrapperMBean;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface MdbDelegateWrapperMBean extends ServiceDelegateWrapperMBean
+{
+ int getMinPoolSize();
+
+ int getMaxPoolSize();
+
+ int getMaxMessages();
+
+ int getKeepAliveMillis();
+}
Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java 2007-03-07 17:58:01 UTC (rev 61200)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java 2007-03-07 18:45:17 UTC (rev 61201)
@@ -27,7 +27,7 @@
import org.jboss.test.JBossTestCase;
import junit.framework.Test;
-import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
/**
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
@@ -46,69 +46,32 @@
public void testJmxMetrics() throws Exception
{
MBeanServerConnection server = getServer();
+
+ int size = 0;
-// testJmxMetrics(server, "Stateful", "jboss.j2ee:jar=stateful-test.jar,name=StatefulBean,service=EJB3");
-// testJmxMetrics(server, "TreeCacheStateful", "jboss.j2ee:jar=stateful-test.jar,name=TreeCacheStatefulBean,service=EJB3");
- }
-
- protected void testJmxMetrics(MBeanServerConnection server, String jndiBinding, String objectName) throws Exception
- {
- /* ObjectName testerName = new ObjectName(objectName);
+ ObjectName testerName = new ObjectName("jboss.j2ee:jar=mdb-test.jar,name=QueueTestMDB,service=EJB3");
- System.out.println("testPassivation");
- Stateful stateful = (Stateful)getInitialContext().lookup(jndiBinding);
- assertNotNull(stateful);
- stateful.setState("state");
+ size = (Integer)server.getAttribute(testerName, "MinPoolSize");
+ assertEquals(1, size);
- int count = (Integer)server.getAttribute(testerName, "CreateCount");
- assertEquals(1, count);
+ size = (Integer)server.getAttribute(testerName, "MaxPoolSize");
+ assertEquals(1, size);
- int size = (Integer)server.getAttribute(testerName, "CacheSize");
+ size = (Integer)server.getAttribute(testerName, "MaxMessages");
assertEquals(1, size);
- assertEquals("state", stateful.getState());
- stateful.testSerializedState("state");
- stateful.clearPassivated();
- assertEquals(null, stateful.getInterceptorState());
- stateful.setInterceptorState("hello world");
- assertFalse(stateful.testSessionContext());
- Thread.sleep(10 * 1000);
+ size = (Integer)server.getAttribute(testerName, "KeepAliveMillis");
+ assertEquals(60000, size);
- size = (Integer)server.getAttribute(testerName, "CacheSize");
- assertEquals(0, size);
+ testerName = new ObjectName("jboss.j2ee:jar=mdb-test.jar,name=TransactionQueueTestMDB,service=EJB3");
- count = (Integer)server.getAttribute(testerName, "PassivatedCount");
- assertEquals(1, count);
- assertTrue(stateful.wasPassivated());
-
- assertEquals("state", stateful.getState());
- assertEquals("hello world", stateful.getInterceptorState());
-
- Stateful another = (Stateful)getInitialContext().lookup(jndiBinding);
- assertEquals(null, another.getInterceptorState());
- another.setInterceptorState("foo");
- assertEquals("foo", another.getInterceptorState());
- assertEquals("hello world", stateful.getInterceptorState());
-
- assertFalse(stateful.testSessionContext());
-
- // Wolf: transient re-injection is broken (EJBTHREE-883)
- //stateful.testResources();
-
- count = (Integer)server.getAttribute(testerName, "CreateCount");
- assertEquals(2, count);
-
- size = (Integer)server.getAttribute(testerName, "CacheSize");
- assertEquals(2, size);
-
- another.removeBean();
- size = (Integer)server.getAttribute(testerName, "CacheSize");
+ size = (Integer)server.getAttribute(testerName, "MaxPoolSize");
assertEquals(1, size);
- stateful.removeBean();
- size = (Integer)server.getAttribute(testerName, "CacheSize");
- assertEquals(0, size);*/
+ testerName = new ObjectName("jboss.j2ee:jar=mdb-test.jar,name=DefaultedQueueTestMDB,service=EJB3");
+ size = (Integer)server.getAttribute(testerName, "MaxPoolSize");
+ assertEquals(15, size);
}
public static Test suite() throws Exception
More information about the jboss-cvs-commits
mailing list