[jboss-cvs] JBossAS SVN: r89504 - in projects/ejb3/trunk: metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 28 18:38:40 EDT 2009


Author: ALRubinger
Date: 2009-05-28 18:38:40 -0400 (Thu, 28 May 2009)
New Revision: 89504

Added:
   projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatefulSessionInstanceMetrics.java
   projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatelessSessionInstanceMetrics.java
   projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/ManagedInvocationStatisticsWrapper.java
   projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionInstanceMetrics.java
   projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/StatefulSessionInstanceMetrics.java
Removed:
   projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicSessionMetrics.java
   projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionMetrics.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
   projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java
Log:
[EJBTHREE-1839] Make the metrics deployer expose SLSB/SFSB instance metrics, and all session invocation metrics

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java	2009-05-28 21:36:58 UTC (rev 89503)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -55,7 +55,6 @@
 import org.jboss.ejb3.javaee.JavaEEComponentHelper;
 import org.jboss.ejb3.javaee.JavaEEModule;
 import org.jboss.ejb3.metadata.JBossSessionGenericWrapper;
-import org.jboss.ejb3.metrics.spi.SessionMetrics;
 import org.jboss.ejb3.pool.PoolFactoryRegistry;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
 import org.jboss.ejb3.proxy.factory.RemoteProxyFactoryRegistry;
@@ -136,11 +135,6 @@
    private EjbReferenceResolver ejbReferenceResolver;
 
    private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
-   
-   /**
-    * Metrics used in Session Beans
-    */
-   private SessionMetrics metrics;
 
    /**
     * Do not deploy persistence unit anymore.
@@ -271,24 +265,8 @@
    {
       this.poolFactoryRegistry = poolFactoryRegistry;
    }
-   
-   /**
-    * @return the metrics
-    */
-   public SessionMetrics getMetrics()
-   {
-      return metrics;
-   }
 
    /**
-    * @param metrics the metrics to set
-    */
-   public void setMetrics(final SessionMetrics metrics)
-   {
-      this.metrics = metrics;
-   }
-
-   /**
     * @deprecated processing persistence units is no longer supported, use jpa-deployers
     * @param b
     */
@@ -409,7 +387,7 @@
       return (Container) ejbContainers.get(name);
    }
 
-   public java.util.Map getEjbContainers()
+   public java.util.Map<ObjectName,Container> getEjbContainers()
    {
       return ejbContainers;
    }

Deleted: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicSessionMetrics.java
===================================================================
--- projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicSessionMetrics.java	2009-05-28 21:36:58 UTC (rev 89503)
+++ projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicSessionMetrics.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -1,171 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.metrics.deployer;
-
-import org.jboss.ejb3.metrics.spi.SessionMetrics;
-import org.jboss.managed.api.annotation.ManagementComponent;
-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;
-
-/**
- * BasicSessionMetrics
- * 
- * Threadsafe implementation of a session metrics collector.
- * Additionally exposed as a management object
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
- at ManagementObject(isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "Some test", componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
-public class BasicSessionMetrics implements SessionMetrics
-{
-
-   // --------------------------------------------------------------------------------||
-   // Instance Members ---------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Number of bean instances in the underlying pool/cache
-    * available for service.  Synchronized on "this".  
-    */
-   private int availableCount;
-
-   /**
-    * Number of bean instances created for this EJB.
-    * Synchronized on "this".
-    */
-   private int createCount;
-
-   /**
-    * Number of bean instances in the underlying 
-    * pool/cache.  Synchronized on "this".
-    */
-   private int currentSize;
-
-   /**
-    * Size of the underlying instance pool/cache
-    * at its highest.  Synchronized on "this".
-    */
-   private int maxSize;
-
-   /**
-    * Number of bean instances removed from the
-    * underlying pool/cache.  Synchronized on "this".
-    */
-   private int removeCount;
-
-   // --------------------------------------------------------------------------------||
-   // Required Implementations -------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getAvailableCount()
-    */
-   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
-   public synchronized int getAvailableCount()
-   {
-      return this.availableCount;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getCreateCount()
-    */
-   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
-   public synchronized int getCreateCount()
-   {
-      return this.createCount;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getCurrentSize()
-    */
-   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
-   public synchronized int getCurrentSize()
-   {
-      return this.currentSize;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getMaxSize()
-    */
-   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
-   public synchronized int getMaxSize()
-   {
-      return this.maxSize;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getRemoveCount()
-    */
-   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
-   public synchronized int getRemoveCount()
-   {
-      return this.removeCount;
-   }
-
-   /*
-    * (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#setAvailableCount(int)
-    */
-   public synchronized void setAvailableCount(final int availableCount)
-   {
-      this.availableCount = availableCount;
-   }
-
-   /*
-    * (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#setCreateCount(int)
-    */
-   public synchronized void setCreateCount(final int createCount)
-   {
-      this.createCount = createCount;
-   }
-
-   /*
-    * (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#setCurrentSize(int)
-    */
-   public synchronized void setCurrentSize(final int currentSize)
-   {
-      this.currentSize = currentSize;
-   }
-
-   /*
-    * (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#setMaxSize(int)
-    */
-   public synchronized void setMaxSize(final int maxSize)
-   {
-      this.maxSize = maxSize;
-   }
-
-   /*
-    * (non-Javadoc)
-    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#setRemoveCount(int)
-    */
-   public synchronized void setRemoveCount(final int removeCount)
-   {
-      this.removeCount = removeCount;
-   }
-}

Added: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatefulSessionInstanceMetrics.java
===================================================================
--- projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatefulSessionInstanceMetrics.java	                        (rev 0)
+++ projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatefulSessionInstanceMetrics.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metrics.deployer;
+
+import org.jboss.ejb3.cache.StatefulCache;
+import org.jboss.ejb3.metrics.spi.StatefulSessionInstanceMetrics;
+import org.jboss.ejb3.stateful.StatefulContainer;
+import org.jboss.managed.api.annotation.ManagementComponent;
+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;
+
+/**
+ * BasicStatefulSessionInstanceMetrics
+ * 
+ * Threadsafe implementation of a SFSB instance
+ * metrics collector.  Additionally exposed as a 
+ * management object.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at ManagementObject(isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "Stateful Session Bean Instance Metrics", componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
+public class BasicStatefulSessionInstanceMetrics implements StatefulSessionInstanceMetrics
+{
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Underlying Container through which we'll get the metrics
+    */
+   private StatefulContainer sfsb;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param slsb The underlying container
+    * @throws IllegalArgumentException If the underlying container is not supplied
+    */
+   public BasicStatefulSessionInstanceMetrics(final StatefulContainer sfsb) throws IllegalArgumentException
+   {
+      // Precondition check
+      if (sfsb == null)
+      {
+         throw new IllegalArgumentException("Underlying container was null");
+      }
+
+      // Set
+      this.setSlsb(sfsb);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||   
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.StatefulSessionInstanceMetrics#getCacheSize()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getCacheSize()
+   {
+      return this.getCache().getCacheSize();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.StatefulSessionInstanceMetrics#getTotalSize()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getTotalSize()
+   {
+      return this.getCache().getTotalSize();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.StatefulSessionInstanceMetrics#getPassivatedCount()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getPassivatedCount()
+   {
+      return this.getCache().getPassivatedCount();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionInstanceMetrics#getCreateCount()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getCreateCount()
+   {
+      return this.getCache().getCreateCount();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionInstanceMetrics#getRemoveCount()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getRemoveCount()
+   {
+      return this.getCache().getRemoveCount();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionInstanceMetrics#getAvailableCount()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getAvailableCount()
+   {
+      return this.getCache().getAvailableCount();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionInstanceMetrics#getMaxSize()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getMaxSize()
+   {
+      return this.getCache().getMaxSize();
+   }
+
+   /*
+    * (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionInstanceMetrics#getCurrentSize()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getCurrentSize()
+   {
+      return this.getCache().getCurrentSize();
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the underlying cache
+    */
+   private StatefulCache getCache()
+   {
+      return this.getSfsb().getCache();
+   }
+
+   /**
+    * @return the slsb
+    */
+   private StatefulContainer getSfsb()
+   {
+      return sfsb;
+   }
+
+   /**
+    * @param sfsb the slsb to set
+    */
+   private void setSlsb(final StatefulContainer sfsb)
+   {
+      this.sfsb = sfsb;
+   }
+}

Copied: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatelessSessionInstanceMetrics.java (from rev 89479, projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicSessionMetrics.java)
===================================================================
--- projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatelessSessionInstanceMetrics.java	                        (rev 0)
+++ projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatelessSessionInstanceMetrics.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metrics.deployer;
+
+import org.jboss.ejb3.metrics.spi.SessionInstanceMetrics;
+import org.jboss.ejb3.pool.Pool;
+import org.jboss.ejb3.stateless.StatelessContainer;
+import org.jboss.managed.api.annotation.ManagementComponent;
+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;
+
+/**
+ * BasicStatelessSessionInstanceMetrics
+ * 
+ * Threadsafe implementation of a SLSB instance
+ * metrics collector.  Additionally exposed as a 
+ * management object.
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at ManagementObject(isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "Stateless Session Bean Instance Metrics", componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
+public class BasicStatelessSessionInstanceMetrics implements SessionInstanceMetrics
+{
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Underlying Container through which we'll get the metrics
+    */
+   private StatelessContainer slsb;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param slsb The underlying container
+    * @throws IllegalArgumentException If the underlying container is not supplied
+    */
+   public BasicStatelessSessionInstanceMetrics(final StatelessContainer slsb) throws IllegalArgumentException
+   {
+      // Precondition check
+      if (slsb == null)
+      {
+         throw new IllegalArgumentException("Underlying container was null");
+      }
+
+      // Set
+      this.setSlsb(slsb);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getAvailableCount()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getAvailableCount()
+   {
+      return this.getPool().getAvailableCount();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getCreateCount()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getCreateCount()
+   {
+      return this.getPool().getCreateCount();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getCurrentSize()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getCurrentSize()
+   {
+      return this.getPool().getCurrentSize();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getMaxSize()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getMaxSize()
+   {
+      return this.getPool().getMaxSize();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.ejb3.metrics.spi.SessionMetrics#getRemoveCount()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public int getRemoveCount()
+   {
+      return this.getPool().getRemoveCount();
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the underlying pool
+    */
+   private Pool getPool()
+   {
+      return this.getSlsb().getPool();
+   }
+
+   /**
+    * @return the slsb
+    */
+   private StatelessContainer getSlsb()
+   {
+      return slsb;
+   }
+
+   /**
+    * @param slsb the slsb to set
+    */
+   private void setSlsb(final StatelessContainer slsb)
+   {
+      this.slsb = slsb;
+   }
+}


Property changes on: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/BasicStatelessSessionInstanceMetrics.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java
===================================================================
--- projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java	2009-05-28 21:36:58 UTC (rev 89503)
+++ projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -21,6 +21,8 @@
  */
 package org.jboss.ejb3.metrics.deployer;
 
+import java.util.Collection;
+
 import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
 import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaData;
@@ -28,12 +30,22 @@
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.Container;
 import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.metrics.spi.SessionMetrics;
+import org.jboss.ejb3.metrics.spi.SessionInstanceMetrics;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.stateful.StatefulContainer;
+import org.jboss.ejb3.stateless.StatelessContainer;
+import org.jboss.ejb3.statistics.InvocationStatistics;
 import org.jboss.logging.Logger;
 
 /**
  * Ejb3MetricsDeployer
+ * 
+ * Creates ManagedObject attachments to the current EJB3 deployment
+ * for Session Bean metrics.
+ * 
+ * EJBTHREE-1839
  *
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
@@ -61,6 +73,18 @@
     */
    private static final String BEAN_NAME_METRICS_SUFFIX = "-metrics";
 
+   /**
+    * Suffix to append to the Deployment name in order to create a unique bind name 
+    * for the instance metrics POJO
+    */
+   private static final String BEAN_NAME_METRICS_SUFFIX_INSTANCE = BEAN_NAME_METRICS_SUFFIX + "-instance";
+
+   /**
+    * Suffix to append to the Deployment name in order to create a unique bind name 
+    * for the invocation metrics POJO
+    */
+   private static final String BEAN_NAME_METRICS_SUFFIX_INVOCATION = BEAN_NAME_METRICS_SUFFIX + "-invocation";
+
    // ------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------||
    // ------------------------------------------------------------------------------||
@@ -106,29 +130,111 @@
          log.trace("Deploying EJB3 Session metrics for : " + du);
       }
 
-      // Make a new metrics definition
-      final String metricsBeanName = deployment.getName() + BEAN_NAME_METRICS_SUFFIX;
-      final SessionMetrics metrics = new BasicSessionMetrics();
-      final BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(metricsBeanName, metrics.getClass().getName());
-      bmdb.setConstructorValue(new AlreadyInstantiated(metrics));
-      final BeanMetaData bean = bmdb.getBeanMetaData();
+      // Get out all EJB3 Containers
+      final Collection<Container> containers = deployment.getEjbContainers().values();
+      if (containers != null)
+      {
+         // For each EJB Container
+         for (final Container container : containers)
+         {
+            // Session Containers
+            if (container instanceof SessionContainer)
+            {
 
-      // Add the attachment
-      du.addAttachment(BeanMetaData.class, bean);
+               // Cast
+               final SessionContainer sessionContainer = (SessionContainer) container;
 
-      // Set metrics upon the deployment
-      deployment.setMetrics(metrics);
-      log.debug("Set EJB3 metrics upon " + du);
+               // Get the invocation stats
+               final InvocationStatistics stats = sessionContainer.getInvokeStats();
+               if (stats == null)
+               {
+                  throw new IllegalStateException("Invocation statistics was null");
+               }
+               final ManagedInvocationStatisticsWrapper wrapper = new ManagedInvocationStatisticsWrapper(stats);
 
+               // Attach to the DU
+               final String invocationBeanName = sessionContainer.getName() + BEAN_NAME_METRICS_SUFFIX_INVOCATION;
+               this.attach(wrapper, invocationBeanName, du);
+
+               // SLSB
+               if (sessionContainer instanceof StatelessContainer)
+               {
+                  // Cast
+                  final StatelessContainer slsb = (StatelessContainer) sessionContainer;
+
+                  // Make new metrics
+                  final SessionInstanceMetrics metrics = new BasicStatelessSessionInstanceMetrics(slsb);
+
+                  // Attach to the DU
+                  final String beanName = slsb.getName() + BEAN_NAME_METRICS_SUFFIX_INSTANCE;
+                  this.attach(metrics, beanName, du);
+               }
+
+               // SFSB
+               else if (sessionContainer instanceof StatefulContainer)
+               {
+                  // Cast
+                  final StatefulContainer sfsb = (StatefulContainer) sessionContainer;
+
+                  // Make new metrics
+                  final SessionInstanceMetrics metrics = new BasicStatefulSessionInstanceMetrics(sfsb);
+
+                  // Attach to the DU
+                  final String beanName = sfsb.getName() + BEAN_NAME_METRICS_SUFFIX_INSTANCE;
+                  this.attach(metrics, beanName, du);
+               }
+
+            }
+         }
+      }
+
       // Set a flag showing we were here as the output
       du.addAttachment(NAME_OUTPUT, true, Boolean.class);
    }
 
    // ------------------------------------------------------------------------------||
-   // Required Implementations -----------------------------------------------------||
+   // Internal Helper Methods -----------------------------------------------------||
    // ------------------------------------------------------------------------------||
 
    /**
+    * Attaches the specified object to the specified DeploymentUnit
+    * 
+    * @param attachment
+    * @param beanName
+    * @param du
+    * @throws IllegalArgumentException If any argument is not specified
+    */
+   private void attach(final Object attachment, final String beanName, final DeploymentUnit du)
+         throws IllegalArgumentException
+   {
+      // Precondition Checks
+      if (attachment == null)
+      {
+         throw new IllegalArgumentException("metrics is null");
+      }
+      if (du == null)
+      {
+         throw new IllegalArgumentException("Deployment Unit is null");
+      }
+
+      // Make a new metrics definition
+      final BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(beanName, attachment.getClass().getName());
+      bmdb.setConstructorValue(new AlreadyInstantiated(attachment));
+      final BeanMetaData bean = bmdb.getBeanMetaData();
+
+      // Add the attachment
+      du.addAttachment(BeanMetaData.class, bean);
+      if (log.isTraceEnabled())
+      {
+         log.trace("Added metrics attachment to " + du + ": " + bean);
+      }
+   }
+
+   // ------------------------------------------------------------------------------||
+   // Inner Classes ----------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
+
+   /**
     * Constructor metadata which uses an underlying bean already 
     * instanciated.
     * 

Added: projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/ManagedInvocationStatisticsWrapper.java
===================================================================
--- projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/ManagedInvocationStatisticsWrapper.java	                        (rev 0)
+++ projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/ManagedInvocationStatisticsWrapper.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metrics.deployer;
+
+import java.util.Map;
+
+import org.jboss.ejb3.statistics.InvocationStatistics;
+import org.jboss.managed.api.annotation.ManagementComponent;
+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;
+
+/**
+ * ManagedInvocationStatistics
+ * 
+ * Simple wrapper to delegate to the underlying invocation stats, 
+ * exposing as a managed object
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at ManagementObject(isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "Stateful Session Bean Instance Metrics", componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
+public class ManagedInvocationStatisticsWrapper
+{
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * The delegate
+    */
+   private InvocationStatistics delegate;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param delegate
+    * @throws IllegalArgumentException If the delegate was not supplied
+    */
+   public ManagedInvocationStatisticsWrapper(final InvocationStatistics delegate) throws IllegalArgumentException
+   {
+      // Precondition check
+      if (delegate == null)
+      {
+         throw new IllegalArgumentException("Supplied delegate was null");
+      }
+
+      this.setDelegate(delegate);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Delegate Methods ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * @return
+    * @see org.jboss.ejb3.statistics.InvocationStatistics#getStats()
+    */
+   @ManagementProperty(readOnly = true, use = ViewUse.STATISTIC)
+   public Map getStats()
+   {
+      return delegate.getStats();
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * @param stats the stats to set
+    */
+   private void setDelegate(final InvocationStatistics stats)
+   {
+      this.delegate = stats;
+   }
+
+}

Copied: projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionInstanceMetrics.java (from rev 89479, projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionMetrics.java)
===================================================================
--- projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionInstanceMetrics.java	                        (rev 0)
+++ projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionInstanceMetrics.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metrics.spi;
+
+/**
+ * SessionInstanceMetrics
+ * 
+ * Represents backing instance metrics of any type of 
+ * EJB 3.x Session Bean, typically targeting the underlying 
+ * instance pool or cache
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface SessionInstanceMetrics
+{
+   // --------------------------------------------------------------------------------||
+   // Contracts ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the current size of the underlying 
+    * pool/cache of bean instances
+    * 
+    * @return
+    */
+   int getCurrentSize();
+
+   /**
+    * Obtains the number of instances created for this EJB
+    * 
+    * @return
+    */
+   int getCreateCount();
+
+   /**
+    * Obtains the number of instances removed for this EJB
+    * 
+    * @return
+    */
+   int getRemoveCount();
+
+   /**
+    * Obtains the number of instances currently available for 
+    * service for this EJB
+    * 
+    * @return
+    */
+   int getAvailableCount();
+
+   /**
+    * Obtains the size of the underlying instance pool/cache
+    * at it highest 
+    * 
+    * @return
+    */
+   int getMaxSize();
+}


Property changes on: projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionInstanceMetrics.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionMetrics.java
===================================================================
--- projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionMetrics.java	2009-05-28 21:36:58 UTC (rev 89503)
+++ projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/SessionMetrics.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -1,118 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.metrics.spi;
-
-/**
- * SessionMetrics
- * 
- * Represents metrics of any type of EJB 3.x Session Bean
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public interface SessionMetrics
-{
-   // --------------------------------------------------------------------------------||
-   // Contracts ----------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Obtains the current size of the underlying 
-    * pool/cache of bean instances
-    * 
-    * @return
-    */
-   int getCurrentSize();
-
-   /**
-    * Sets the current size of the underlying 
-    * pool/cache of bean instances
-    * 
-    * @param currentSize
-    * @throws IllegalArgumentException If the count is < 0
-    */
-   void setCurrentSize(int currentSize) throws IllegalArgumentException;
-
-   /**
-    * Obtains the number of instances created for this EJB
-    * 
-    * @return
-    */
-   int getCreateCount();
-
-   /**
-    * Sets the number of instances created for this EJB
-    * 
-    * @param createCount
-    * @throws IllegalArgumentException If the count is < 0
-    */
-   void setCreateCount(int createCount) throws IllegalArgumentException;
-
-   /**
-    * Obtains the number of instances removed for this EJB
-    * 
-    * @return
-    */
-   int getRemoveCount();
-
-   /**
-    * Sets the number of instances removed for this EJB
-    * 
-    * @param removeCount
-    * @throws IllegalArgumentException If the count is < 0
-    */
-   void setRemoveCount(int removeCount) throws IllegalArgumentException;
-
-   /**
-    * Obtains the number of instances currently available for 
-    * service for this EJB
-    * 
-    * @return
-    */
-   int getAvailableCount();
-
-   /**
-    * Sets the number of instances currently available for 
-    * service for this EJB
-    * 
-    * @param availableCount
-    * @throws IllegalArgumentException If the count is < 0
-    */
-   void setAvailableCount(int availableCount) throws IllegalArgumentException;
-
-   /**
-    * Obtains the size of the underlying instance pool/cache
-    * at it highest 
-    * 
-    * @return
-    */
-   int getMaxSize();
-
-   /**
-    * Sets the size of the underlying instance pool/cache
-    * at it highest 
-    * 
-    * @param maxSize
-    * @throws IllegalArgumentException If the count is < 0
-    */
-   void setMaxSize(int maxSize) throws IllegalArgumentException;
-}

Added: projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/StatefulSessionInstanceMetrics.java
===================================================================
--- projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/StatefulSessionInstanceMetrics.java	                        (rev 0)
+++ projects/ejb3/trunk/metrics-spi/src/main/java/org/jboss/ejb3/metrics/spi/StatefulSessionInstanceMetrics.java	2009-05-28 22:38:40 UTC (rev 89504)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.metrics.spi;
+
+/**
+ * StatefulSessionInstanceMetrics
+ * 
+ * Represents backing instance metrics of EJB3 Stateful Session Beans
+ * targeting the underlying instance cache
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface StatefulSessionInstanceMetrics extends SessionInstanceMetrics
+{
+
+   // --------------------------------------------------------------------------------||
+   // Contracts ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the current number of instances in the cache
+    * 
+    * @return
+    */
+   int getCacheSize();
+
+   /**
+    * Returns the total size of the cache
+    * 
+    * @return
+    */
+   int getTotalSize();
+
+   /**
+    * Returns the number of instanes passivated
+    * 
+    * @return
+    */
+   int getPassivatedCount();
+}




More information about the jboss-cvs-commits mailing list