[jboss-cvs] JBossAS SVN: r111171 - in projects/jboss-jca/trunk/core/src/main: java/org/jboss/jca/core/connectionmanager/pool and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 12 14:10:19 EDT 2011


Author: jesper.pedersen
Date: 2011-04-12 14:10:19 -0400 (Tue, 12 Apr 2011)
New Revision: 111171

Modified:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/pool/PoolStatistics.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolStatistics.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPoolStatisticsImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java
   projects/jboss-jca/trunk/core/src/main/resources/poolstatistics.properties
Log:
[JBJCA-546] Add creation metrics to statistics

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/pool/PoolStatistics.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/pool/PoolStatistics.java	2011-04-12 14:07:13 UTC (rev 111170)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/pool/PoolStatistics.java	2011-04-12 18:10:19 UTC (rev 111171)
@@ -43,6 +43,12 @@
    public long getAverageBlockingTime();
 
    /**
+    * Get the average time spent creating a connection (milliseconds)
+    * @return The value
+    */
+   public long getAverageCreationTime();
+
+   /**
     * Get created count
     * @return The value
     */
@@ -55,6 +61,12 @@
    public int getDestroyedCount();
 
    /**
+    * Get max creation time (milliseconds)
+    * @return The value
+    */
+   public long getMaxCreationTime();
+
+   /**
     * Get max used count
     * @return The value
     */
@@ -77,4 +89,10 @@
     * @return The value
     */
    public long getTotalBlockingTime();
+
+   /**
+    * Get the total time spent creating connections (milliseconds)
+    * @return The value
+    */
+   public long getTotalCreationTime();
 }

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolStatistics.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolStatistics.java	2011-04-12 14:07:13 UTC (rev 111170)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolStatistics.java	2011-04-12 18:10:19 UTC (rev 111171)
@@ -43,12 +43,15 @@
 {
    private static final String ACTIVE_COUNT = "ActiveCount";
    private static final String AVERAGE_BLOCKING_TIME = "AverageBlockingTime";
+   private static final String AVERAGE_CREATION_TIME = "AverageCreationTime";
    private static final String CREATED_COUNT = "CreatedCount";
    private static final String DESTROYED_COUNT = "DestroyedCount";
+   private static final String MAX_CREATION_TIME = "MaxCreationTime";
    private static final String MAX_USED_COUNT = "MaxUsedCount";
    private static final String MAX_WAIT_TIME = "MaxWaitTime";
    private static final String TIMED_OUT = "TimedOut";
    private static final String TOTAL_BLOCKING_TIME = "TotalBlockingTime";
+   private static final String TOTAL_CREATION_TIME = "TotalCreationTime";
 
    private ConcurrentMap<Object, SubPoolContext> subPools;
    private Set<String> names;
@@ -73,12 +76,18 @@
       n.add(AVERAGE_BLOCKING_TIME);
       t.put(AVERAGE_BLOCKING_TIME, long.class);
 
+      n.add(AVERAGE_CREATION_TIME);
+      t.put(AVERAGE_CREATION_TIME, long.class);
+
       n.add(CREATED_COUNT);
       t.put(CREATED_COUNT, int.class);
 
       n.add(DESTROYED_COUNT);
       t.put(DESTROYED_COUNT, int.class);
 
+      n.add(MAX_CREATION_TIME);
+      t.put(MAX_CREATION_TIME, long.class);
+
       n.add(MAX_USED_COUNT);
       t.put(MAX_USED_COUNT, int.class);
 
@@ -91,6 +100,9 @@
       n.add(TOTAL_BLOCKING_TIME);
       t.put(TOTAL_BLOCKING_TIME, long.class);
 
+      n.add(TOTAL_CREATION_TIME);
+      t.put(TOTAL_CREATION_TIME, long.class);
+
       this.names = Collections.unmodifiableSet(n);
       this.types = Collections.unmodifiableMap(t);
       this.enabled = new AtomicBoolean(true);
@@ -167,6 +179,10 @@
       {
          return getAverageBlockingTime();
       }
+      else if (AVERAGE_CREATION_TIME.equals(name))
+      {
+         return getAverageCreationTime();
+      }
       else if (CREATED_COUNT.equals(name))
       {
          return getCreatedCount();
@@ -175,6 +191,10 @@
       {
          return getDestroyedCount();
       }
+      else if (MAX_CREATION_TIME.equals(name))
+      {
+         return getMaxCreationTime();
+      }
       else if (MAX_USED_COUNT.equals(name))
       {
          return getMaxUsedCount();
@@ -191,6 +211,10 @@
       {
          return getTotalBlockingTime();
       }
+      else if (TOTAL_CREATION_TIME.equals(name))
+      {
+         return getTotalCreationTime();
+      }
 
       return null;
    }
@@ -249,6 +273,17 @@
    /**
     * {@inheritDoc}
     */
+   public long getAverageCreationTime()
+   {
+      if (isEnabled())
+         return getCreatedCount() != 0 ? getTotalCreationTime() / getCreatedCount() : 0;
+
+      return 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public int getCreatedCount()
    {
       if (isEnabled())
@@ -287,6 +322,28 @@
    }
 
    /**
+    * {@inheritDoc}
+    */
+   public long getMaxCreationTime()
+   {
+      if (isEnabled())
+      {
+         long result = Long.MIN_VALUE;
+
+         for (SubPoolContext spc : subPools.values())
+         {
+            long v = spc.getSubPool().getStatistics().getMaxCreationTime();
+            if (v > result)
+               result = v;
+         }
+
+         return result != Long.MIN_VALUE ? result : 0;
+      }
+
+      return 0;
+   }
+
+   /**
     * Get max used count
     * @return The value
     */
@@ -374,6 +431,26 @@
    /**
     * {@inheritDoc}
     */
+   public long getTotalCreationTime()
+   {
+      if (isEnabled())
+      {
+         long result = 0;
+
+         for (SubPoolContext spc : subPools.values())
+         {
+            result += spc.getSubPool().getStatistics().getTotalCreationTime();
+         }
+
+         return result;
+      }
+
+      return 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public void clear()
    {
       for (SubPoolContext spc : subPools.values())

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPoolStatisticsImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPoolStatisticsImpl.java	2011-04-12 14:07:13 UTC (rev 111170)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPoolStatisticsImpl.java	2011-04-12 18:10:19 UTC (rev 111171)
@@ -42,24 +42,29 @@
 {
    private static final String ACTIVE_COUNT = "ActiveCount";
    private static final String AVERAGE_BLOCKING_TIME = "AverageBlockingTime";
+   private static final String AVERAGE_CREATION_TIME = "AverageCreationTime";
    private static final String CREATED_COUNT = "CreatedCount";
    private static final String DESTROYED_COUNT = "DestroyedCount";
+   private static final String MAX_CREATION_TIME = "MaxCreationTime";
    private static final String MAX_USED_COUNT = "MaxUsedCount";
    private static final String MAX_WAIT_TIME = "MaxWaitTime";
    private static final String TIMED_OUT = "TimedOut";
    private static final String TOTAL_BLOCKING_TIME = "TotalBlockingTime";
+   private static final String TOTAL_CREATION_TIME = "TotalCreationTime";
 
    private Set<String> names;
    private Map<String, Class> types;
    private AtomicBoolean enabled;
    private Map<Locale, ResourceBundle> rbs;
 
-   private AtomicLong totalBlockingTime;
    private AtomicInteger createdCount;
    private AtomicInteger destroyedCount;
    private AtomicInteger maxUsedCount;
+   private AtomicLong maxCreationTime;
    private AtomicLong maxWaitTime;
    private AtomicInteger timedOut;
+   private AtomicLong totalBlockingTime;
+   private AtomicLong totalCreationTime;
 
    /**
     * Constructor
@@ -75,12 +80,18 @@
       n.add(AVERAGE_BLOCKING_TIME);
       t.put(AVERAGE_BLOCKING_TIME, long.class);
 
+      n.add(AVERAGE_CREATION_TIME);
+      t.put(AVERAGE_CREATION_TIME, long.class);
+
       n.add(CREATED_COUNT);
       t.put(CREATED_COUNT, int.class);
 
       n.add(DESTROYED_COUNT);
       t.put(DESTROYED_COUNT, int.class);
 
+      n.add(MAX_CREATION_TIME);
+      t.put(MAX_CREATION_TIME, long.class);
+
       n.add(MAX_USED_COUNT);
       t.put(MAX_USED_COUNT, int.class);
 
@@ -93,6 +104,9 @@
       n.add(TOTAL_BLOCKING_TIME);
       t.put(TOTAL_BLOCKING_TIME, long.class);
 
+      n.add(TOTAL_CREATION_TIME);
+      t.put(TOTAL_CREATION_TIME, long.class);
+
       this.names = Collections.unmodifiableSet(n);
       this.types = Collections.unmodifiableMap(t);
       this.enabled = new AtomicBoolean(true);
@@ -103,12 +117,14 @@
       this.rbs = new HashMap<Locale, ResourceBundle>(1);
       this.rbs.put(Locale.US, defaultResourceBundle);
 
-      this.totalBlockingTime = new AtomicLong(0);
       this.createdCount = new AtomicInteger(0);
       this.destroyedCount = new AtomicInteger(0);
+      this.maxCreationTime = new AtomicLong(Long.MIN_VALUE);
       this.maxUsedCount = new AtomicInteger(Integer.MIN_VALUE);
       this.maxWaitTime = new AtomicLong(Long.MIN_VALUE);
       this.timedOut = new AtomicInteger(0);
+      this.totalBlockingTime = new AtomicLong(0);
+      this.totalCreationTime = new AtomicLong(0);
 
       clear();
    }
@@ -176,6 +192,10 @@
       {
          return getAverageBlockingTime();
       }
+      else if (AVERAGE_CREATION_TIME.equals(name))
+      {
+         return getAverageCreationTime();
+      }
       else if (CREATED_COUNT.equals(name))
       {
          return getCreatedCount();
@@ -184,6 +204,10 @@
       {
          return getDestroyedCount();
       }
+      else if (MAX_CREATION_TIME.equals(name))
+      {
+         return getMaxCreationTime();
+      }
       else if (MAX_WAIT_TIME.equals(name))
       {
          return getMaxWaitTime();
@@ -196,6 +220,10 @@
       {
          return getTotalBlockingTime();
       }
+      else if (TOTAL_CREATION_TIME.equals(name))
+      {
+         return getTotalCreationTime();
+      }
 
       return null;
    }
@@ -241,6 +269,17 @@
    /**
     * {@inheritDoc}
     */
+   public long getAverageCreationTime()
+   {
+      if (isEnabled())
+         return createdCount.get() != 0 ? totalCreationTime.get() / createdCount.get() : 0;
+
+      return 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public int getCreatedCount()
    {
       if (isEnabled())
@@ -306,6 +345,17 @@
    /**
     * {@inheritDoc}
     */
+   public long getMaxCreationTime()
+   {
+      if (isEnabled())
+         return maxCreationTime.get() != Long.MIN_VALUE ? maxCreationTime.get() : 0;
+
+      return 0;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public long getMaxWaitTime()
    {
       if (isEnabled())
@@ -366,6 +416,35 @@
    /**
     * {@inheritDoc}
     */
+   public long getTotalCreationTime()
+   {
+      if (isEnabled())
+         return totalCreationTime.get();
+
+      return 0;
+   }
+
+   /**
+    * Add delta to total creation time
+    * @param delta The value
+    */
+   public void deltaTotalCreationTime(long delta)
+   {
+      if (isEnabled())
+      {
+         if (delta > 0)
+         {
+            totalCreationTime.addAndGet(delta);
+
+            if (delta > maxCreationTime.get())
+               maxCreationTime.set(delta);
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public void clear()
    {
       // Do nothing

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java	2011-04-12 14:07:13 UTC (rev 111170)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java	2011-04-12 18:10:19 UTC (rev 111171)
@@ -694,8 +694,11 @@
    private ConnectionListener createConnectionEventListener(Subject subject, ConnectionRequestInfo cri)
       throws ResourceException
    {
+      long start = System.currentTimeMillis();
+
       ManagedConnection mc = mcf.createManagedConnection(subject, cri);
 
+      statistics.deltaTotalCreationTime(System.currentTimeMillis() - start);
       statistics.deltaCreatedCount();
       try
       {

Modified: projects/jboss-jca/trunk/core/src/main/resources/poolstatistics.properties
===================================================================
--- projects/jboss-jca/trunk/core/src/main/resources/poolstatistics.properties	2011-04-12 14:07:13 UTC (rev 111170)
+++ projects/jboss-jca/trunk/core/src/main/resources/poolstatistics.properties	2011-04-12 18:10:19 UTC (rev 111171)
@@ -1,8 +1,11 @@
 ActiveCount=The active count
 AverageBlockingTime=The average time spent blocking for a connection
+AverageCreationTime=The average time spent creating a physical connection
 CreatedCount=The created count
 DestroyedCount=The destroyed count
+MaxCreationTime=The maximum time for creating a physical connection
 MaxUsedCount=The maximum number of connections used
 MaxWaitTime=The maximum wait time for a connection
 TimedOut=The timed out count
 TotalBlockingTime=The total blocking time
+TotalCreationTime=The total time spent creating physical connections



More information about the jboss-cvs-commits mailing list