[JBoss-dev] CVS update: jbosspool/src/main/org/jboss/pool PoolGCThread.java
User: starksm Date: 02/04/05 12:07:38 Modified:src/main/org/jboss/pool Tag: Branch_2_4 PoolGCThread.java Log: Apply fix for Bug #525840 and reduce logging threshold to trace for per connection messages Revision ChangesPath No revision No revision 1.1.1.1.2.3 +11 -11jbosspool/src/main/org/jboss/pool/PoolGCThread.java Index: PoolGCThread.java === RCS file: /cvsroot/jboss/jbosspool/src/main/org/jboss/pool/PoolGCThread.java,v retrieving revision 1.1.1.1.2.2 retrieving revision 1.1.1.1.2.3 diff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 --- PoolGCThread.java 22 Feb 2002 12:09:09 - 1.1.1.1.2.2 +++ PoolGCThread.java 5 Apr 2002 20:07:38 - 1.1.1.1.2.3 @@ -15,7 +15,7 @@ * run on any pools which are "pretty close" to their requested time. * * @author Aaron Mulder ([EMAIL PROTECTED]) - * @version $Revision: 1.1.1.1.2.2 $ + * @version $Revision: 1.1.1.1.2.3 $ */ class PoolGCThread extends Thread { @@ -30,18 +30,18 @@ public void run() { - boolean debug = log.isDebugEnabled(); + boolean trace = log.isTraceEnabled(); while(true) { // Don't do anything while there's nothing to do waitForPools(); - if( debug ) -log.debug("gc thread waited for pools"); + if( trace ) +log.trace("gc thread waited for pools"); // Figure out how long to sleep long delay = getDelay(); - if( debug ) -log.debug("gc thread delay: " + delay); + if( trace ) +log.trace("gc thread delay: " + delay); // Sleep if(delay > 0l) @@ -92,17 +92,17 @@ private synchronized void runGC() { - boolean debug = log.isDebugEnabled(); + boolean trace = log.isTraceEnabled(); - if( debug ) - log.debug("GC thread running GC"); + if( trace ) + log.trace("GC thread running GC"); for(Iterator it = pools.iterator(); it.hasNext();) { ObjectPool pool = (ObjectPool)it.next(); - if( debug ) -log.debug("GC Thread pool: " + pool.getName() + ", isTimeToGC(): " + pool.isTimeToGC() ); + if( trace ) +log.trace("GC Thread pool: " + pool.getName() + ", isTimeToGC(): " + pool.isTimeToGC() ); if(pool.isTimeToGC()) pool.runGCandShrink(); ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
[JBoss-dev] CVS update: jbosspool/src/main/org/jboss/pool PoolGCThread.java
User: lqd Date: 02/02/22 04:09:09 Modified:src/main/org/jboss/pool Tag: Branch_2_4 PoolGCThread.java Log: - oops, a TAB slipped in Revision ChangesPath No revision No revision 1.1.1.1.2.2 +2 -2 jbosspool/src/main/org/jboss/pool/PoolGCThread.java Index: PoolGCThread.java === RCS file: /cvsroot/jboss/jbosspool/src/main/org/jboss/pool/PoolGCThread.java,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -u -r1.1.1.1.2.1 -r1.1.1.1.2.2 --- PoolGCThread.java 22 Feb 2002 11:14:31 - 1.1.1.1.2.1 +++ PoolGCThread.java 22 Feb 2002 12:09:09 - 1.1.1.1.2.2 @@ -15,12 +15,12 @@ * run on any pools which are "pretty close" to their requested time. * * @author Aaron Mulder ([EMAIL PROTECTED]) - * @version $Revision: 1.1.1.1.2.1 $ + * @version $Revision: 1.1.1.1.2.2 $ */ class PoolGCThread extends Thread { private HashSet pools = new HashSet(); - private static Logger log = Logger.getLogger( ObjectPool.class ); + private static Logger log = Logger.getLogger( ObjectPool.class ); PoolGCThread() { ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
[JBoss-dev] CVS update: jbosspool/src/main/org/jboss/pool PoolGCThread.java
User: lqd Date: 02/02/22 03:14:32 Modified:src/main/org/jboss/pool Tag: Branch_2_4 PoolGCThread.java Log: - add logging Revision ChangesPath No revision No revision 1.1.1.1.2.1 +116 -62 jbosspool/src/main/org/jboss/pool/PoolGCThread.java Index: PoolGCThread.java === RCS file: /cvsroot/jboss/jbosspool/src/main/org/jboss/pool/PoolGCThread.java,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1 -r1.1.1.1.2.1 --- PoolGCThread.java 15 May 2001 07:58:24 - 1.1.1.1 +++ PoolGCThread.java 22 Feb 2002 11:14:31 - 1.1.1.1.2.1 @@ -3,7 +3,10 @@ */ package org.jboss.pool; -import java.util.*; +import java.util.HashSet; +import java.util.Iterator; + +import org.jboss.logging.Logger; /** * Runs garbage collection on all available pools. Only one GC thread is @@ -12,68 +15,119 @@ * run on any pools which are "pretty close" to their requested time. * * @author Aaron Mulder ([EMAIL PROTECTED]) + * @version $Revision: 1.1.1.1.2.1 $ */ -class PoolGCThread extends Thread { -private HashSet pools = new HashSet(); - -PoolGCThread() { -super("Minerve ObjectPool GC Thread"); -setDaemon(true); -} - -public void run() { -while(true) { -// Don't do anything while there's nothing to do -waitForPools(); -// Figure out how long to sleep -long delay = getDelay(); -// Sleep -if(delay > 0l) { -try { -sleep(delay); -} catch(InterruptedException e) {} +class PoolGCThread extends Thread +{ + private HashSet pools = new HashSet(); + private static Logger log = Logger.getLogger( ObjectPool.class ); + + PoolGCThread() + { + super("Minerva ObjectPool GC Thread"); + setDaemon(true); + } + + public void run() + { + boolean debug = log.isDebugEnabled(); + while(true) + { + // Don't do anything while there's nothing to do + waitForPools(); + if( debug ) +log.debug("gc thread waited for pools"); + + // Figure out how long to sleep + long delay = getDelay(); + if( debug ) +log.debug("gc thread delay: " + delay); + + // Sleep + if(delay > 0l) + { +try +{ + sleep(delay); } -// Run garbage collection on eligible pools -runGC(); -} -} - -private synchronized void waitForPools() { -while(pools.size() == 0) { -try { -wait(); -} catch(InterruptedException e) { -} -} -} +catch(InterruptedException ignored) {} + } + + // Run garbage collection on eligible pools + runGC(); + } + } + + private synchronized void waitForPools() + { + while(pools.size() == 0) + { + try + { +wait(); + } + catch(InterruptedException ignored) + { +// Warning level seems appropriate; shouldn't really happen +log.warn("waitForPools interrupted"); + } + } + } + + private synchronized long getDelay() + { + long next = Long.MAX_VALUE; + long now = System.currentTimeMillis(); + long current; + + for(Iterator it = pools.iterator(); it.hasNext();) + { + ObjectPool pool = (ObjectPool)it.next(); + current = pool.getNextGCMillis(now); + if(current < next) +next = current; + } + return next >= 0l ? next : 0l; + } + + private synchronized void runGC() + { + boolean debug = log.isDebugEnabled(); + + if( debug ) + log.debug("GC thread running GC"); + + for(Iterator it = pools.iterator(); it.hasNext();) + { + ObjectPool pool = (ObjectPool)it.next(); + + if( debug ) +log.debug("GC Thread pool: " + pool.getName() + ", isTimeToGC(): " + pool.isTimeToGC() ); + + if(pool.isTimeToGC()) +pool.runGCandShrink(); + } + } + + synchronized void addPool(ObjectPool pool) + { + if( log.isDebugEnabled() ) + log.debug( "Adding pool: " + pool.getName() + ", GC enabled: " + pool.isGCEnabled() ); + + if(pool.isGCEnabled()) + pools.add(pool); + + notify(); + } + + synchronized void removePool(ObjectPool pool) + { + if( log.isDebugEnabled() ) + log.debug( "Removing pool:
[JBoss-dev] CVS update: jbosspool/src/main/org/jboss/pool PoolGCThread.java
User: ejort Date: 02/01/04 22:46:32 Modified:src/main/org/jboss/pool PoolGCThread.java Log: Guarded debug logging Revision ChangesPath 1.7 +11 -7 jbosspool/src/main/org/jboss/pool/PoolGCThread.java Index: PoolGCThread.java === RCS file: /cvsroot/jboss/jbosspool/src/main/org/jboss/pool/PoolGCThread.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- PoolGCThread.java 2001/12/07 03:40:39 1.6 +++ PoolGCThread.java 2002/01/05 06:46:32 1.7 @@ -29,24 +29,28 @@ } public void run() { - log.debug("Started gc thread"); - + boolean debug = log.isDebugEnabled(); + if (debug) + log.debug("Started gc thread"); + while ( true ) { // Don't do anything while there's nothing to do waitForPools(); - log.debug("gc thread waited for pools"); + if (debug) +log.debug("gc thread waited for pools"); // Figure out how long to sleep long delay = getDelay(); - log.debug("gc thread delay: " + delay); - + if (debug) +log.debug("gc thread delay: " + delay); + // Sleep if ( delay > 0l ) { try { sleep( delay ); } catch ( InterruptedException ignore ) {} } - + // Run garbage collection on eligible pools runGC(); } @@ -96,7 +100,7 @@ if (debug) { log.debug("gc thread running gc"); } - + for ( Iterator it = pools.iterator(); it.hasNext(); ) { ObjectPool pool = ( ObjectPool )it.next(); ___ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development