[jboss-cvs] JBossAS SVN: r112530 - in projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core: connectionmanager/pool and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 21 05:51:42 EST 2011
Author: jesper.pedersen
Date: 2011-12-21 05:51:40 -0500 (Wed, 21 Dec 2011)
New Revision: 112530
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java
Log:
[JBJCA-722] Too eager shutdown of pools during idle timeout
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java 2011-12-20 22:31:20 UTC (rev 112529)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java 2011-12-21 10:51:40 UTC (rev 112530)
@@ -320,10 +320,12 @@
/**
* The pool has been shutdown
+ * @param pool The pool
+ * @param mcp The managed connection pool
* @return The value
*/
- @Message(id = 653, value = "The pool has been shutdown")
- public String thePoolHasBeenShutdown();
+ @Message(id = 653, value = "The pool has been shutdown (%s,%s)")
+ public String thePoolHasBeenShutdown(String pool, String mcp);
/**
* Interrupted while requesting connection
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java 2011-12-20 22:31:20 UTC (rev 112529)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java 2011-12-21 10:51:40 UTC (rev 112530)
@@ -274,22 +274,26 @@
/**
* {@inheritDoc}
*/
- public void emptyManagedConnectionPool(ManagedConnectionPool pool)
+ public synchronized void emptyManagedConnectionPool(ManagedConnectionPool pool)
{
log.debug(poolName + ": emptyManagedConnectionPool(" + pool + ")");
if (pool != null)
{
- Iterator<ManagedConnectionPool> it = mcpPools.values().iterator();
+ // We only consider removal if there are more than 1 managed connection pool
+ if (mcpPools.size() > 1)
+ {
+ Iterator<ManagedConnectionPool> it = mcpPools.values().iterator();
- while (it.hasNext())
- {
- ManagedConnectionPool other = it.next();
- if (other == pool && pool.isEmpty())
+ while (it.hasNext())
{
- pool.shutdown();
- it.remove();
- break;
+ ManagedConnectionPool other = it.next();
+ if (other == pool && pool.isEmpty())
+ {
+ pool.shutdown();
+ it.remove();
+ break;
+ }
}
}
}
@@ -306,7 +310,7 @@
/**
* {@inheritDoc}
*/
- public void flush(boolean kill)
+ public synchronized void flush(boolean kill)
{
log.debug(poolName + ": flush(" + kill + ")");
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java 2011-12-20 22:31:20 UTC (rev 112529)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java 2011-12-21 10:51:40 UTC (rev 112530)
@@ -220,7 +220,9 @@
if (cls.size() > 0)
{
if (shutdown.get())
- throw new RetryableUnavailableException(bundle.thePoolHasBeenShutdown());
+ throw new RetryableUnavailableException(
+ bundle.thePoolHasBeenShutdown(pool.getName(),
+ Integer.toHexString(System.identityHashCode(this))));
cl = cls.peek();
if (cl != null)
@@ -264,7 +266,9 @@
statistics.deltaTotalBlockingTime(System.currentTimeMillis() - startWait);
if (shutdown.get())
- throw new RetryableUnavailableException(bundle.thePoolHasBeenShutdown());
+ throw new RetryableUnavailableException(
+ bundle.thePoolHasBeenShutdown(pool.getName(),
+ Integer.toHexString(System.identityHashCode(this))));
}
catch (InterruptedException ie)
{
@@ -568,28 +572,41 @@
// We found some connections to destroy
if (destroy != null)
{
- for (int i = 0; i < destroy.size(); ++i)
+ for (ConnectionListener cl : destroy)
{
- ConnectionListener cl = destroy.get(i);
-
if (trace)
log.trace("Destroying timedout connection " + cl);
doDestroy(cl);
}
- // We destroyed something, check the minimum.
- if (!shutdown.get() &&
- poolConfiguration.getMinSize() > 0 &&
- poolConfiguration.isPrefill() &&
- pool instanceof PrefillPool)
+ if (!shutdown.get())
{
- PoolFiller.fillPool(this);
+ if (!poolConfiguration.isStrictMin())
+ {
+ boolean emptyManagedConnectionPool = false;
+
+ if (poolConfiguration.isPrefill() && pool instanceof PrefillPool)
+ {
+ if (poolConfiguration.getMinSize() > 0)
+ {
+ PoolFiller.fillPool(this);
+ }
+ else
+ {
+ emptyManagedConnectionPool = true;
+ }
+ }
+ else
+ {
+ emptyManagedConnectionPool = true;
+ }
+
+ // Empty pool
+ if (emptyManagedConnectionPool)
+ pool.emptyManagedConnectionPool(this);
+ }
}
-
- // Empty pool
- if (pool != null)
- pool.emptyManagedConnectionPool(this);
}
}
@@ -598,6 +615,9 @@
*/
public void shutdown()
{
+ if (trace)
+ log.tracef("Shutdown - Pool: %s MCP: %s", pool.getName(), Integer.toHexString(System.identityHashCode(this)));
+
shutdown.set(true);
IdleRemover.getInstance().unregisterPool(this);
ConnectionValidator.getInstance().unregisterPool(this);
@@ -609,6 +629,15 @@
*/
public void fillToMin()
{
+ if (poolConfiguration.getMinSize() <= 0)
+ return;
+
+ if (!poolConfiguration.isPrefill())
+ return;
+
+ if (!(pool instanceof PrefillPool))
+ return;
+
while (poolConfiguration.getMinSize() - (cls.size() + checkedOut.size()) > 0)
{
if (shutdown.get())
@@ -863,4 +892,20 @@
return true;
}
+
+ /**
+ * String representation
+ * @return The string
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("ArrayBlockingQueueManagedConnectionPool@").append(Integer.toHexString(System.identityHashCode(this)));
+ sb.append("[pool=").append(pool.getName());
+ sb.append("]");
+
+ return sb.toString();
+ }
}
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-12-20 22:31:20 UTC (rev 112529)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java 2011-12-21 10:51:40 UTC (rev 112530)
@@ -159,7 +159,7 @@
this.permits = new Semaphore(maxSize, true, statistics);
// Schedule managed connection pool for prefill
- if (pc.isPrefill() && p instanceof PrefillPool)
+ if (pc.isPrefill() && p instanceof PrefillPool && pc.getMinSize() > 0)
{
PoolFiller.fillPool(this);
}
@@ -261,7 +261,9 @@
if (shutdown.get())
{
permits.release();
- throw new RetryableUnavailableException(bundle.thePoolHasBeenShutdown());
+ throw new RetryableUnavailableException(
+ bundle.thePoolHasBeenShutdown(pool.getName(),
+ Integer.toHexString(System.identityHashCode(this))));
}
int clsSize = cls.size();
@@ -608,28 +610,41 @@
// We found some connections to destroy
if (destroy != null)
{
- for (int i = 0; i < destroy.size(); ++i)
+ for (ConnectionListener cl : destroy)
{
- ConnectionListener cl = destroy.get(i);
-
if (trace)
log.trace("Destroying timedout connection " + cl);
doDestroy(cl);
}
- // We destroyed something, check the minimum.
- if (!shutdown.get() &&
- poolConfiguration.getMinSize() > 0 &&
- poolConfiguration.isPrefill() &&
- pool instanceof PrefillPool)
+ if (!shutdown.get())
{
- PoolFiller.fillPool(this);
+ if (!poolConfiguration.isStrictMin())
+ {
+ boolean emptyManagedConnectionPool = false;
+
+ if (poolConfiguration.isPrefill() && pool instanceof PrefillPool)
+ {
+ if (poolConfiguration.getMinSize() > 0)
+ {
+ PoolFiller.fillPool(this);
+ }
+ else
+ {
+ emptyManagedConnectionPool = true;
+ }
+ }
+ else
+ {
+ emptyManagedConnectionPool = true;
+ }
+
+ // Empty pool
+ if (emptyManagedConnectionPool)
+ pool.emptyManagedConnectionPool(this);
+ }
}
-
- // Empty pool
- if (pool != null)
- pool.emptyManagedConnectionPool(this);
}
}
@@ -638,6 +653,9 @@
*/
public void shutdown()
{
+ if (trace)
+ log.tracef("Shutdown - Pool: %s MCP: %s", pool.getName(), Integer.toHexString(System.identityHashCode(this)));
+
shutdown.set(true);
IdleRemover.getInstance().unregisterPool(this);
ConnectionValidator.getInstance().unregisterPool(this);
@@ -924,4 +942,20 @@
cl.setLastValidatedTime(System.currentTimeMillis());
cls.add(cl);
}
+
+ /**
+ * String representation
+ * @return The string
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("SemaphoreArrayListManagedConnectionPool@").append(Integer.toHexString(System.identityHashCode(this)));
+ sb.append("[pool=").append(pool.getName());
+ sb.append("]");
+
+ return sb.toString();
+ }
}
More information about the jboss-cvs-commits
mailing list