[jboss-cvs] JBossAS SVN: r111233 - 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
Thu Apr 21 09:50:26 EDT 2011
Author: jesper.pedersen
Date: 2011-04-21 09:50:26 -0400 (Thu, 21 Apr 2011)
New Revision: 111233
Added:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/Semaphore.java
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-557] MaxWaitCount 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-21 13:12:06 UTC (rev 111232)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/pool/PoolStatistics.java 2011-04-21 13:50:26 UTC (rev 111233)
@@ -79,6 +79,12 @@
public int getMaxUsedCount();
/**
+ * Get max wait count
+ * @return The value
+ */
+ public int getMaxWaitCount();
+
+ /**
* Get max wait time (milliseconds)
* @return The value
*/
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-21 13:12:06 UTC (rev 111232)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SubPoolStatistics.java 2011-04-21 13:50:26 UTC (rev 111233)
@@ -49,6 +49,7 @@
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_COUNT = "MaxWaitCount";
private static final String MAX_WAIT_TIME = "MaxWaitTime";
private static final String TIMED_OUT = "TimedOut";
private static final String TOTAL_BLOCKING_TIME = "TotalBlockingTime";
@@ -210,6 +211,10 @@
{
return getMaxUsedCount();
}
+ else if (MAX_WAIT_COUNT.equals(name))
+ {
+ return getMaxWaitCount();
+ }
else if (MAX_WAIT_TIME.equals(name))
{
return getMaxWaitTime();
@@ -407,6 +412,29 @@
}
/**
+ * Get max wait count
+ * @return The value
+ */
+ public int getMaxWaitCount()
+ {
+ if (isEnabled())
+ {
+ int result = Integer.MIN_VALUE;
+
+ for (SubPoolContext spc : subPools.values())
+ {
+ int v = spc.getSubPool().getStatistics().getMaxWaitCount();
+ if (v > result)
+ result = v;
+ }
+
+ return result != Integer.MIN_VALUE ? result : 0;
+ }
+
+ return 0;
+ }
+
+ /**
* {@inheritDoc}
*/
public long getMaxWaitTime()
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-21 13:12:06 UTC (rev 111232)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPoolStatisticsImpl.java 2011-04-21 13:50:26 UTC (rev 111233)
@@ -48,6 +48,7 @@
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_COUNT = "MaxWaitCount";
private static final String MAX_WAIT_TIME = "MaxWaitTime";
private static final String TIMED_OUT = "TimedOut";
private static final String TOTAL_BLOCKING_TIME = "TotalBlockingTime";
@@ -64,6 +65,7 @@
private AtomicInteger destroyedCount;
private AtomicInteger maxUsedCount;
private AtomicLong maxCreationTime;
+ private AtomicInteger maxWaitCount;
private AtomicLong maxWaitTime;
private AtomicInteger timedOut;
private AtomicLong totalBlockingTime;
@@ -104,6 +106,9 @@
n.add(MAX_USED_COUNT);
t.put(MAX_USED_COUNT, int.class);
+ n.add(MAX_WAIT_COUNT);
+ t.put(MAX_WAIT_COUNT, int.class);
+
n.add(MAX_WAIT_TIME);
t.put(MAX_WAIT_TIME, long.class);
@@ -130,6 +135,7 @@
this.destroyedCount = new AtomicInteger(0);
this.maxCreationTime = new AtomicLong(Long.MIN_VALUE);
this.maxUsedCount = new AtomicInteger(Integer.MIN_VALUE);
+ this.maxWaitCount = new AtomicInteger(Integer.MIN_VALUE);
this.maxWaitTime = new AtomicLong(Long.MIN_VALUE);
this.timedOut = new AtomicInteger(0);
this.totalBlockingTime = new AtomicLong(0);
@@ -221,6 +227,14 @@
{
return getMaxCreationTime();
}
+ else if (MAX_USED_COUNT.equals(name))
+ {
+ return getMaxUsedCount();
+ }
+ else if (MAX_WAIT_COUNT.equals(name))
+ {
+ return getMaxWaitCount();
+ }
else if (MAX_WAIT_TIME.equals(name))
{
return getMaxWaitTime();
@@ -367,6 +381,31 @@
}
/**
+ * Get max wait count
+ * @return The value
+ */
+ public int getMaxWaitCount()
+ {
+ if (isEnabled())
+ return maxWaitCount.get() != Integer.MIN_VALUE ? maxWaitCount.get() : 0;
+
+ return 0;
+ }
+
+ /**
+ * Set max wait count
+ * @param v The value
+ */
+ public void setMaxWaitCount(int v)
+ {
+ if (isEnabled())
+ {
+ if (v > maxWaitCount.get())
+ maxWaitCount.set(v);
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public long getMaxCreationTime()
Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/Semaphore.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/Semaphore.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/Semaphore.java 2011-04-21 13:50:26 UTC (rev 111233)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.jca.core.connectionmanager.pool.mcp;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A semaphore implementation that supports statistics
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Semaphore extends java.util.concurrent.Semaphore
+{
+ /** Statistics */
+ private ManagedConnectionPoolStatisticsImpl statistics;
+
+ /**
+ * Constructor
+ * @param maxSize The maxumum size
+ * @param fairness The fairness
+ * @param statistics The statistics module
+ */
+ public Semaphore(int maxSize, boolean fairness, ManagedConnectionPoolStatisticsImpl statistics)
+ {
+ super(maxSize, fairness);
+ this.statistics = statistics;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean tryAcquire(long timeout, TimeUnit unit) throws InterruptedException
+ {
+ statistics.setMaxWaitCount(getQueueLength());
+ return super.tryAcquire(timeout, unit);
+ }
+}
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-21 13:12:06 UTC (rev 111232)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java 2011-04-21 13:50:26 UTC (rev 111233)
@@ -40,7 +40,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -162,8 +161,8 @@
this.log = log;
this.trace = log.isTraceEnabled();
this.cls = new ArrayList<ConnectionListener>(this.maxSize);
- this.permits = new Semaphore(this.maxSize, true);
this.statistics = new ManagedConnectionPoolStatisticsImpl(maxSize);
+ this.permits = new Semaphore(maxSize, true, statistics);
// Schedule managed connection pool for prefill
if (pc.isPrefill() && p instanceof PrefillPool)
Modified: projects/jboss-jca/trunk/core/src/main/resources/poolstatistics.properties
===================================================================
--- projects/jboss-jca/trunk/core/src/main/resources/poolstatistics.properties 2011-04-21 13:12:06 UTC (rev 111232)
+++ projects/jboss-jca/trunk/core/src/main/resources/poolstatistics.properties 2011-04-21 13:50:26 UTC (rev 111233)
@@ -6,6 +6,7 @@
DestroyedCount=The destroyed count
MaxCreationTime=The maximum time for creating a physical connection
MaxUsedCount=The maximum number of connections used
+MaxWaitCount=The maximum number of threads waiting for a connection
MaxWaitTime=The maximum wait time for a connection
TimedOut=The timed out count
TotalBlockingTime=The total blocking time
More information about the jboss-cvs-commits
mailing list