[jboss-cvs] JBossAS SVN: r69812 - in branches/Branch_4_2/connector/src/main/org/jboss/resource: statistic and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 13 04:39:54 EST 2008


Author: vicky.kak at jboss.com
Date: 2008-02-13 04:39:54 -0500 (Wed, 13 Feb 2008)
New Revision: 69812

Added:
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/JBossStatistics.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/StatisticsReporter.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatter.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatterException.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossDefaultSubPoolStatisticFormatter.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossManagedConnectionPoolStatistics.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossSubPoolStatistics.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossXmlSubPoolStatisticFormatter.java
   branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/ManagedConnectionPoolStatistics.java
Log:
JBAS-5210 changes.

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/JBossStatistics.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/JBossStatistics.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/JBossStatistics.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,34 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic;
+
+import java.io.Serializable;
+
+/**
+ * A JBossStatistics.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public interface JBossStatistics extends Serializable
+{
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/StatisticsReporter.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/StatisticsReporter.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/StatisticsReporter.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,45 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic;
+
+
+/**
+ * Interface to allow statistics reporting. This is primarily used as a convenience
+ * interface to avoid having to modify the ManagedConnectionPool to allow for sub pool
+ * statistic reporting.
+ * 
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public interface StatisticsReporter
+{
+   
+   /**
+    * List the statistics.
+    * 
+    * @return the statistics.
+    */
+   JBossStatistics listStatistics();
+   
+   
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatter.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatter.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatter.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,43 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic.formatter;
+
+import org.jboss.resource.statistic.JBossStatistics;
+
+/**
+ * A StatisticsFormatter that allows for the formatting of JBossStatistics.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public interface StatisticsFormatter
+{
+   
+   /**
+    * Return the formatted JBossStatistics.
+    * 
+    * @param stats the statistics
+    * @return the formatted statistics
+    */
+   public Object formatStatistics(JBossStatistics stats);
+  
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatterException.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatterException.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/formatter/StatisticsFormatterException.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,56 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic.formatter;
+
+/**
+ * A StatisticsFormatterException.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public class StatisticsFormatterException extends RuntimeException
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -6319738597224174432L;
+
+   public StatisticsFormatterException()
+   {
+      super();
+   }
+
+   public StatisticsFormatterException(String message)
+   {
+      super(message);
+   }
+
+   public StatisticsFormatterException(Throwable t)
+   {
+      super(t);
+   }
+
+   public StatisticsFormatterException(String message, Throwable t)
+   {
+      super(message, t);
+   }
+
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossDefaultSubPoolStatisticFormatter.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossDefaultSubPoolStatisticFormatter.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossDefaultSubPoolStatisticFormatter.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,93 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic.pool;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.resource.statistic.JBossStatistics;
+import org.jboss.resource.statistic.formatter.StatisticsFormatter;
+
+
+/**
+ * A DefaultStatisticsFormatter.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public class JBossDefaultSubPoolStatisticFormatter implements StatisticsFormatter
+{
+
+   private static final String POOL_SEPERATOR = "------------------------------------------------------";
+
+   public Object formatSubPoolStatistics(Collection subPoolStatistics)
+   {
+      final StringBuffer statBuff = formatHeader(subPoolStatistics.size());
+      
+      for(Iterator iter = subPoolStatistics.iterator(); iter.hasNext();){
+         
+         JBossSubPoolStatistics stat = (JBossSubPoolStatistics)iter.next();
+         statBuff.append(stat);
+         statBuff.append("\n");
+         statBuff.append(POOL_SEPERATOR);
+         statBuff.append("\n\n");
+         
+      }
+      
+      return statBuff.toString();
+   }
+   
+   
+   public Object formatSubPoolStatistics(final ManagedConnectionPoolStatistics stats)
+   {
+      return formatSubPoolStatistics(stats.getSubPools());
+      
+   }
+
+   private static StringBuffer formatHeader(int count)
+   {
+
+      StringBuffer headerBuff = new StringBuffer();
+      headerBuff.append("Sub Pool Statistics: \n");
+      headerBuff.append("Sub Pool Count: " + count + "\n");
+      headerBuff.append(POOL_SEPERATOR);
+      headerBuff.append("\n\n");
+
+      return headerBuff;
+
+   }
+
+
+   public Object formatStatistics(JBossStatistics stats)
+   {
+      if(!(stats instanceof ManagedConnectionPoolStatistics)){
+
+         throw new IllegalArgumentException("Error: invalid statistics implementaiton for formatter.");
+         
+      }
+      
+      final ManagedConnectionPoolStatistics poolStats = (ManagedConnectionPoolStatistics)stats;      
+      return formatSubPoolStatistics(poolStats);
+      
+   }
+
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossManagedConnectionPoolStatistics.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossManagedConnectionPoolStatistics.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossManagedConnectionPoolStatistics.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,254 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic.pool;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.resource.statistic.JBossStatistics;
+
+/**
+ * A JBossManagedConnectionPoolStatistics.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public class JBossManagedConnectionPoolStatistics implements ManagedConnectionPoolStatistics
+{
+   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -2962342009092796221L;
+
+   private String poolName;
+
+   private long blockingTimeout;
+   private long idleTimeout;
+   private int min;
+   private int max;
+   private String criteria;
+   private boolean noTxnSeperatePool;
+   
+   private final List subPools;
+
+   private boolean trackByTxn;
+
+   private boolean prefill;
+   
+   public JBossManagedConnectionPoolStatistics(){
+      
+      subPools = new ArrayList();
+   }
+
+   public JBossManagedConnectionPoolStatistics(int subPoolSize){
+      
+      subPools = new ArrayList(subPoolSize);
+   }
+
+   public JBossManagedConnectionPoolStatistics(String poolName){      
+      
+      this();
+      this.poolName = poolName;
+      
+   }
+   
+   public void addSubPool(final JBossSubPoolStatistics subPool){
+      subPools.add(subPool);
+   }
+   
+   public Collection getSubPools(){
+      
+      return Collections.unmodifiableCollection(subPools);
+
+   }
+   
+   public long getBlockingTimeout()
+   {
+    
+      return blockingTimeout;
+   
+   }
+   
+   public void setBlockingTimeout(long blockTime){
+      
+      this.blockingTimeout = blockTime;
+            
+   }
+   
+   public String getCriteria()
+   {
+      return this.criteria;
+   }
+   
+   
+   public long getIdleTimeout()
+   {
+      return this.idleTimeout;
+   }
+
+   public void setIdleTimeout(long idleTimeout){
+      
+      this.idleTimeout = idleTimeout;
+      
+   }
+   public int getMax()
+   {
+      return this.max;
+   }
+   
+   public void setMax(int max)
+   {
+      this.max = max;
+   }
+   public int getMin()
+   {
+      return this.min;
+   }
+
+   public void setMin(int min)
+   {
+     this.min = min;
+     
+   }   
+   
+   public boolean getNoTxnSeperatePool()
+   {
+      return this.noTxnSeperatePool;
+   }
+   
+   public void setNoTxnSeperatePool(boolean noTxnSeperatePool)
+   {
+      this.noTxnSeperatePool = noTxnSeperatePool;
+   }
+   
+   public JBossManagedConnectionPoolStatistics getStatistics()
+   {
+      
+      return null;
+   }
+
+   public int getSubPoolCount()
+   {
+      return subPools.size();
+
+   }
+
+   public int getTotalConnectionsInUseCount()
+   {
+      int statValue = 0;
+      
+      for(Iterator iter = subPools.iterator(); iter.hasNext();){
+         
+         JBossSubPoolStatistics statGroup = (JBossSubPoolStatistics)iter.next();
+         statValue += statGroup.getConnectionsInUse();
+         
+      }
+      
+      return statValue;
+      
+   }
+
+   public int getTotalMaxConnectionsInUseCount()
+   {
+      
+      int statValue = 0;
+      
+      for(Iterator iter = subPools.iterator(); iter.hasNext();){
+         
+         JBossSubPoolStatistics statGroup = (JBossSubPoolStatistics)iter.next();
+         statValue += statGroup.getMaxConnectionsInUse();
+         
+      }
+      
+      return statValue;
+     
+   }
+
+   public boolean getTrackByTxn()
+   {
+      return this.trackByTxn;
+   }
+   
+   public void setTrackByTxn(boolean trackByTxn)
+   {
+      this.trackByTxn = trackByTxn;
+   
+   }
+   
+   public boolean getPrefill()
+   {
+      // TODO Auto-generated method stub
+      return prefill;
+   }
+
+   public void setPrefill(boolean prefill)
+   {
+      this.prefill = prefill;
+   }
+
+   public String getName()
+   {
+      return this.poolName;
+   }
+
+   public void setName(String name)
+   {
+      this.poolName = name;
+   }
+
+   public void setCriteria(String criteria)
+   {
+     this.criteria = criteria;
+      
+   }
+
+   public void addSubPool(JBossStatistics subPool)
+   {
+      // TODO Auto-generated method stub
+	   subPools.add(subPool);
+   }   
+   
+   public String toString()
+   {
+	   StringBuffer poolStatBuff = new StringBuffer(); 
+	   poolStatBuff.append(" Sub Pool Statistics:");
+	   poolStatBuff.append("\n Sub Pool Count:"+subPools.size()); 
+	   poolStatBuff.append("\n\n---------------------------------------------------------------");
+	   for(Iterator iter = subPools.iterator(); iter.hasNext();)
+	   {		   
+         JBossSubPoolStatistics statGroup = (JBossSubPoolStatistics)iter.next();
+         poolStatBuff.append("\n Track By Transaction:" + statGroup.getTrackByTxn()); 
+         poolStatBuff.append("\n Available Connections Count:" + statGroup.getAvailableConnections());
+         poolStatBuff.append("\n Max Connections In Use Count:" + statGroup.getMaxConnectionsInUse());
+         poolStatBuff.append("\n Connections Destroyed Count:" + statGroup.getAvailableConnections());
+         poolStatBuff.append("\n Connections In Use Count:" + statGroup.getConnectionsInUse());
+         poolStatBuff.append("\n Total Block Time:" + statGroup.getTotalBlockTime());
+         poolStatBuff.append("\n Average Block Time For Sub Pool:" + statGroup.getAverageBlockTime());
+         poolStatBuff.append("\n Maximum Wait Time For Sub Pool:" + statGroup.getMaxWaitTime());
+         poolStatBuff.append("\n Total Timed Out Connections:" + statGroup.getTotalTimedOut());
+         poolStatBuff.append("\n\n ---------------------------------------------------------------");
+	   }
+	   return poolStatBuff.toString();
+   }
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossSubPoolStatistics.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossSubPoolStatistics.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossSubPoolStatistics.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,278 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic.pool;
+
+import org.jboss.resource.statistic.JBossStatistics;
+
+/**
+ * A SubPoolStatisticGroup.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public class JBossSubPoolStatistics implements JBossStatistics
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -5089686321382050654L;
+
+   /** The trackByTxn */
+   private Boolean trackByTxn;
+   
+   /** The availableConnections */
+   private long availableConnections;
+   
+   /** The maxConnectionsInUse */
+   private int maxConnectionsInUse;
+   
+   /** The connectionsInUse */
+   private int connectionsInUse;
+   
+   /** The connectionsDestroyed */
+   private int connectionsDestroyed;
+
+   /** The totalBlockTime */
+   private long totalBlockTime;
+   
+   /** The averageBlockTime */
+   private long averageBlockTime;
+   
+   /** The totalTimedOut */
+   private int totalTimedOut;
+   
+   /** The maxWaitTime */
+   private long maxWaitTime;
+
+   /**
+    * Get the availableConnections.
+    * 
+    * @return the availableConnections.
+    */
+   public long getAvailableConnections()
+   {
+      return availableConnections;
+   }
+
+
+   /**
+    * Set the availableConnections.
+    * 
+    * @param availableConnections The availableConnections to set.
+    */
+   public void setAvailableConnections(long availableConnections)
+   {
+      this.availableConnections = availableConnections;
+   }
+
+
+   /**
+    * Get the connectionsDestroyed.
+    * 
+    * @return the connectionsDestroyed.
+    */
+   public int getConnectionsDestroyed()
+   {
+      return connectionsDestroyed;
+   }
+
+
+   /**
+    * Set the connectionsDestroyed.
+    * 
+    * @param connectionsDestroyed The connectionsDestroyed to set.
+    */
+   public void setConnectionsDestroyed(int connectionsDestroyed)
+   {
+      this.connectionsDestroyed = connectionsDestroyed;
+   }
+
+
+   /**
+    * Get the connectionsInUse.
+    * 
+    * @return the connectionsInUse.
+    */
+   public int getConnectionsInUse()
+   {
+      return connectionsInUse;
+   }
+
+
+   /**
+    * Set the connectionsInUse.
+    * 
+    * @param connectionsInUse The connectionsInUse to set.
+    */
+   public void setConnectionsInUse(int connectionsInUse)
+   {
+      this.connectionsInUse = connectionsInUse;
+   }
+
+
+   /**
+    * Get the maxConnectionsInUse.
+    * 
+    * @return the maxConnectionsInUse.
+    */
+   public int getMaxConnectionsInUse()
+   {
+      return maxConnectionsInUse;
+   }
+
+
+   /**
+    * Set the maxConnectionsInUse.
+    * 
+    * @param maxConnectionsInUse The maxConnectionsInUse to set.
+    */
+   public void setMaxConnectionsInUse(int maxConnectionsInUse)
+   {
+      this.maxConnectionsInUse = maxConnectionsInUse;
+   }
+
+
+   /**
+    * Get the trackByTxn.
+    * 
+    * @return the trackByTxn.
+    */
+   public Boolean getTrackByTxn()
+   {
+      return trackByTxn;
+   }
+
+
+   /**
+    * Set the trackByTxn.
+    * 
+    * @param trackByTxn The trackByTxn to set.
+    */
+   public void setTrackByTxn(Boolean trackByTxn)
+   {
+      this.trackByTxn = trackByTxn;
+   }
+
+
+   public String toString()
+   {
+      final StringBuffer statBuff = new StringBuffer();      
+      statBuff.append("Track By Transaction: " + getTrackByTxn() + "\n");
+      statBuff.append("Available Connections Count: " + getAvailableConnections() + "\n");
+      statBuff.append("Max Connections In Use Count:" + getMaxConnectionsInUse() + "\n");
+      statBuff.append("Connections Destroyed Count:" + getConnectionsDestroyed() + "\n");
+      statBuff.append("Connections In Use Count:" + getConnectionsInUse() + "\n");
+      statBuff.append("Total Block Time:" + getTotalBlockTime() + "\n");
+      statBuff.append("Average Block Time For Sub Pool:" + getAverageBlockTime() + "\n");
+      statBuff.append("Maximum Wait Time For Sub Pool:" + getMaxWaitTime() + "\n");
+      
+      statBuff.append("Total Timed Out:" + getTotalTimedOut() + "\n");
+
+      return statBuff.toString();
+   }
+
+
+   /**
+    * Get the totalBlockTime.
+    * 
+    * @return the totalBlockTime.
+    */
+   public long getTotalBlockTime()
+   {
+      return totalBlockTime;
+   }
+
+
+   /**
+    * Set the totalBlockTime.
+    * 
+    * @param totalBlockTime The totalBlockTime to set.
+    */
+   public void setTotalBlockTime(long totalBlockTime)
+   {
+      this.totalBlockTime = totalBlockTime;
+   }
+
+
+   /**
+    * Get the totalTimedOut.
+    * 
+    * @return the totalTimedOut.
+    */
+   public int getTotalTimedOut()
+   {
+      return totalTimedOut;
+   }
+
+
+   /**
+    * Set the totalTimedOut.
+    * 
+    * @param totalTimedOut The totalTimedOut to set.
+    */
+   public void setTotalTimedOut(int totalTimedOut)
+   {
+      this.totalTimedOut = totalTimedOut;
+   }
+
+
+   /**
+    * Get the averageBlockTime.
+    * 
+    * @return the averageBlockTime.
+    */
+   public long getAverageBlockTime()
+   {
+      return averageBlockTime;
+   }
+
+
+   /**
+    * Set the averageBlockTime.
+    * 
+    * @param averageBlockTime The averageBlockTime to set.
+    */
+   public void setAverageBlockTime(long averageBlockTime)
+   {
+      this.averageBlockTime = averageBlockTime;
+   }
+   
+   /**
+    * Get the maxWaitTime.
+    * 
+    * @return the maxWaitTime.
+    */
+   public long getMaxWaitTime()
+   {
+      return maxWaitTime;
+   }
+
+   /**
+    * Set the maxWaitTime.
+    * 
+    * @param maxWaitTime The averageBlockTime to set.
+    */
+   public void setMaxWaitTime(long maxWaitTime)
+   {
+      this.maxWaitTime = maxWaitTime;
+   }
+   
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossXmlSubPoolStatisticFormatter.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossXmlSubPoolStatisticFormatter.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/JBossXmlSubPoolStatisticFormatter.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,139 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic.pool;
+
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.resource.statistic.JBossStatistics;
+import org.jboss.resource.statistic.formatter.StatisticsFormatter;
+import org.jboss.resource.statistic.formatter.StatisticsFormatterException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+/**
+ * A XmlStatisticsFormatter.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public class JBossXmlSubPoolStatisticFormatter implements StatisticsFormatter
+{
+
+   public Object formatSubPoolStatistics(Collection subPoolStatistics)
+   {
+      final Document doc = createDocument();
+      final Element root = doc.createElement("subpool-statistics");
+      doc.appendChild(root);
+      
+      for(Iterator iter = subPoolStatistics.iterator(); iter.hasNext();){
+         
+         JBossSubPoolStatistics stat = (JBossSubPoolStatistics)iter.next();
+         createChildNode(doc, root, stat);
+       
+      }
+      
+      return getDocumentAsString(doc);
+   }
+
+   public Object formatSubPoolStatistics(ManagedConnectionPoolStatistics stats)
+   {
+      return formatSubPoolStatistics(stats.getSubPools());
+   }
+   
+   private void createChildNode(Document doc, Element root, JBossSubPoolStatistics stat){
+    
+      root.appendChild(createTextNode(doc, "max-connections-in-use", String.valueOf(stat.getMaxConnectionsInUse())));
+      root.appendChild(createTextNode(doc, "track-by-txn", String.valueOf(stat.getTrackByTxn())));
+      root.appendChild(createTextNode(doc, "connections-in-use", String.valueOf(stat.getConnectionsInUse())));
+      root.appendChild(createTextNode(doc, "connections-destroyed", String.valueOf(stat.getConnectionsDestroyed())));
+      root.appendChild(createTextNode(doc, "available-connections", String.valueOf(stat.getAvailableConnections())));
+      
+   }
+   
+   private Element createTextNode(Document doc, String name, String value){
+      
+      Text node = doc.createTextNode(name);
+      node.setNodeValue(String.valueOf(value));
+      Element child = doc.createElement(name);
+      child.appendChild(node);
+      return child;
+      
+      
+   }
+  
+   private Document createDocument(){
+      
+      try
+      {
+         Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+         return doc; 
+      }
+      catch (ParserConfigurationException e)
+      {
+         throw new StatisticsFormatterException(e.getMessage());
+         
+      }
+      
+   }
+   
+   private String getDocumentAsString(Document doc){
+      
+      try
+      {
+         final Source source = new DOMSource(doc);
+         final StringWriter writer = new StringWriter();
+         final StreamResult result = new StreamResult(writer);
+         TransformerFactory.newInstance().newTransformer().transform(source, result);
+         return writer.toString();
+      }
+      catch (TransformerException e)
+      {
+         throw new StatisticsFormatterException(e.getMessage());
+         
+      }      
+            
+   }
+
+   public Object formatStatistics(JBossStatistics stats)
+   {
+      if(!(stats instanceof ManagedConnectionPoolStatistics)){
+
+         throw new IllegalArgumentException("Error: invalid statistics implementaiton for formatter.");
+         
+      }
+      
+      final ManagedConnectionPoolStatistics poolStats = (ManagedConnectionPoolStatistics)stats;
+      return formatSubPoolStatistics(poolStats);
+   }
+
+}

Added: branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/ManagedConnectionPoolStatistics.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/ManagedConnectionPoolStatistics.java	                        (rev 0)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/statistic/pool/ManagedConnectionPoolStatistics.java	2008-02-13 09:39:54 UTC (rev 69812)
@@ -0,0 +1,99 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * 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.resource.statistic.pool;
+
+import java.util.Collection;
+
+import org.jboss.resource.statistic.JBossStatistics;
+
+/**
+ * A ManagedConnectionPoolStatistics.
+ * 
+ * @author <a href="weston.price at jboss.com">Weston Price</a>
+ * @version $Revision: 44968 $
+ */
+public interface ManagedConnectionPoolStatistics extends JBossStatistics
+{
+  
+   /**
+    * Get the name of the managed connection pool as a string.
+    * 
+    * @return the name of the managed connection pool.
+    */
+   public String getName();
+   
+   /**
+    * Set the name of the managed connection pool
+    * 
+    * @param name the name of the managed connection pool.
+    */
+   public void setName(String name);
+   
+   /**
+    * Get the number of sub pools.
+    * 
+    * @return the number of sub pools.
+    */
+   public int getSubPoolCount();
+
+   /**
+    * Get the total maximum connections used count
+    * 
+    * @return the total maximum connections used count.
+    */
+   public int getTotalMaxConnectionsInUseCount();
+
+   /**
+    * Get the total connections in use count.
+    * 
+    * @return the total connections in use count.
+    */
+   public int getTotalConnectionsInUseCount();
+
+   
+   /**
+    * Get the minimum connections for all pools
+    * 
+    * @return the minimum connections for all pools
+    */
+   public int getMin();
+
+   public void setMin(int min);
+   public int getMax();
+   public void setMax(int max);
+   public long getBlockingTimeout();
+   public void setBlockingTimeout(long blockTime);
+   public long getIdleTimeout();
+   public void setIdleTimeout(long idleTimeout);
+   public String getCriteria();
+   public void setCriteria(String criteria);
+   public boolean getTrackByTxn();
+   public void setTrackByTxn(boolean trackByTxn);
+   public boolean getNoTxnSeperatePool();
+   public void setNoTxnSeperatePool(boolean noTxnSeperatePool);
+   public void setPrefill(boolean prefill);
+   public boolean getPrefill();
+   public JBossManagedConnectionPoolStatistics getStatistics();
+   public void addSubPool(JBossStatistics subPool);
+   public Collection getSubPools();
+   
+}




More information about the jboss-cvs-commits mailing list