geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r585497 - in /geronimo/server/trunk/modules: geronimo-core/src/main/java/org/apache/geronimo/pool/ geronimo-management/src/main/java/org/apache/geronimo/management/stats/ geronimo-transaction/src/main/java/org/apache/geronimo/transaction/ma...
Date Wed, 17 Oct 2007 13:39:12 GMT
Author: akulshreshtha
Date: Wed Oct 17 06:39:11 2007
New Revision: 585497

URL: http://svn.apache.org/viewvc?rev=585497&view=rev
Log:
GERONIMO-3250 Make TransactionManager a Statistics Provider. Patch by Viet H. Nguyen

Modified:
    geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/JTAStatsImpl.java
    geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java

Modified: geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java?rev=585497&r1=585496&r2=585497&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
(original)
+++ geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
Wed Oct 17 06:39:11 2007
@@ -78,6 +78,9 @@
 
         executor = p;
         this.classLoader = classLoader;
+
+        // set pool stats start time
+        stats.setStartTime();
     }
 
     public String getName() {
@@ -118,11 +121,21 @@
         } else {
             stats.prepareConsumers(Collections.EMPTY_MAP);
         }
+        // set last sapmle time
+        stats.setLastSampleTime();
         return stats;
     }
 
+    /**
+     * Reset all statistics in PoolStatsImpl object
+     */
     public void resetStats() {
-        // TODO
+        stats.threadsInUse.setLowerBound(0);
+        stats.threadsInUse.setUpperBound(0);
+        stats.threadsInUse.setCurrent(0);
+        stats.threadsInUse.setLowWaterMark(0);
+        stats.threadsInUse.setHighWaterMark(0);
+        stats.setStartTime();
     }
 
     public static class PoolStatsImpl extends StatsImpl implements ThreadPoolStats {

Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/JTAStatsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/JTAStatsImpl.java?rev=585497&r1=585496&r2=585497&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/JTAStatsImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/JTAStatsImpl.java
Wed Oct 17 06:39:11 2007
@@ -54,4 +54,16 @@
     public CountStatistic getRolledbackCount() {
         return rolledbackCount;
     }
+
+    public CountStatisticImpl getActiveCountImpl() {
+        return activeCount;
+    }
+
+    public CountStatisticImpl getCommittedCountImpl() {
+        return committedCount;
+    }
+
+    public CountStatisticImpl getRolledbackCountImpl() {
+        return rolledbackCount;
+    }
 }

Modified: geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java?rev=585497&r1=585496&r2=585497&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java
Wed Oct 17 06:39:11 2007
@@ -17,19 +17,23 @@
 
 package org.apache.geronimo.transaction.manager;
 
+import javax.management.j2ee.statistics.Stats;
 import javax.transaction.xa.XAException;
+import org.apache.geronimo.management.stats.JTAStatsImpl;
+import org.apache.geronimo.management.StatisticsProvider;
 
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 
 /**
- * Used to provide the GBean metadata for the GeronimoTransactionManager class.  This adds
XATerminator and XAWork
- * functionality to the basic transaction manager.
+ * Used to provide the GBean metadata for the GeronimoTransactionManager class
  *
  * @version $Rev$ $Date$
  */
-public class GeronimoTransactionManagerGBean extends GeronimoTransactionManager {
+public class GeronimoTransactionManagerGBean extends GeronimoTransactionManager implements
StatisticsProvider {
+
+    JTAStatsImpl stats = new JTAStatsImpl();
 
     /**
      * TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot
enforce this restriction!
@@ -42,6 +46,34 @@
     }
 
 
+    public void resetStats() {
+        stats.setStartTime();
+        super.resetStatistics();
+    }
+
+    public Stats getStats() {
+        try {
+            stats.getActiveCountImpl().setCount(super.getActiveCount());
+        } catch(Exception e) {
+
+        }
+        stats.getCommittedCountImpl().setCount(super.getTotalCommits());
+        stats.getRolledbackCountImpl().setCount(super.getTotalRollbacks());
+        stats.setLastSampleTime();
+        return stats;
+    }
+
+    public boolean isStateManageable() {
+        return false;
+    }
+
+    public boolean isStatisticsProvider() {
+        return true;
+    }
+
+    public boolean isEventProvider() {
+        return false;
+    }
 
     public static final GBeanInfo GBEAN_INFO;
 



Mime
View raw message