User: user57
Date: 01/12/06 19:40:39
Modified: src/main/org/jboss/pool ObjectPool.java PoolGCThread.java
Log:
o changed log.warn to log.debug for runGC
o using two argument error methods when logging exceptions, instead of
using string concatenation
Revision Changes Path
1.9 +9 -8 jbosspool/src/main/org/jboss/pool/ObjectPool.java
Index: ObjectPool.java
===================================================================
RCS file: /cvsroot/jboss/jbosspool/src/main/org/jboss/pool/ObjectPool.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ObjectPool.java 2001/11/26 03:24:54 1.8
+++ ObjectPool.java 2001/12/07 03:40:39 1.9
@@ -38,7 +38,8 @@
*/
public class ObjectPool implements PoolEventListener
{
- private Logger log = Logger.getLogger( ObjectPool.class );
+ /** Class logger. */
+ private Logger log = Logger.getLogger(ObjectPool.class);
private PoolObjectFactory factory;
private String poolName;
@@ -182,7 +183,7 @@
minSize = size;
if ( maxSize != 0 && minSize > maxSize ) {
maxSize = minSize;
- log.warn( "WARNING: pool max size set to " + maxSize + " to stay >= min
size" );
+ log.warn( "pool max size set to " + maxSize + " to stay >= min size" );
}
}
@@ -207,7 +208,7 @@
maxSize = size;
if ( maxSize != 0 && minSize > maxSize ) {
minSize = maxSize;
- log.warn( "WARNING: pool min size set to " + minSize + " to stay <= max
size" );
+ log.warn( "pool min size set to " + minSize + " to stay <= max size" );
}
}
@@ -822,7 +823,7 @@
try {
factory.deleteObject( pooled );
} catch ( Exception e ) {
- log.error( "Pool " + this + " factory (" +
factory.getClass().getName() + " delete error: " + e );
+ log.error( "Pool " + this + " factory (" +
factory.getClass().getName() + " delete error", e);
}
rec.close();
deadObjects.remove( object );
@@ -909,7 +910,7 @@
}
void runCleanupandShrink() {
- log.warn("running gc for pool");
+ log.debug("running gc for pool");
if ( isCleanupEnabled() ) {
// Garbage collection - return any object that's been out too long with no
use
Iterator it = new HashSet( objects.values() ).iterator();
@@ -950,7 +951,7 @@
try {
factory.deleteObject( pooled );
} catch ( Exception e ) {
- log.error( "Pool " + this + " factory (" +
factory.getClass().getName() + " delete error: " + e );
+ log.error( "Pool " + this + " factory (" +
factory.getClass().getName() + " delete error", e);
}
rec.close();
++count;
@@ -1057,7 +1058,7 @@
class BeanFactory extends PoolObjectFactory
{
- private Class beanClass;
+ private Class beanClass;
private Logger log = Logger.getLogger( BeanFactory.class );
@@ -1078,7 +1079,7 @@
try {
return beanClass.newInstance();
} catch ( Exception e ) {
- log.error( "Unable to create instance of " + beanClass.getName() + ": " +
e );
+ log.error( "Unable to create instance of " + beanClass.getName(), e);
}
return null;
}
1.6 +32 -18 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PoolGCThread.java 2001/11/26 03:24:54 1.5
+++ PoolGCThread.java 2001/12/07 03:40:39 1.6
@@ -9,48 +9,54 @@
import org.jboss.logging.Logger;
/**
- * Runs garbage collection on all available pools. Only one GC thread is
- * created, no matter how many pools there are - it just tries to calculate the
- * next time it should run based on the figues for all the pools. It will run
- * on any pools which are "pretty close" to their requested time.
+ * Runs garbage collection on all available pools. Only one GC thread is
+ * created, no matter how many pools there are - it just tries to calculate the
+ * next time it should run based on the figues for all the pools. It will run
+ * on any pools which are "pretty close" to their requested time.
*
- * @author Aaron Mulder ([EMAIL PROTECTED])
+ * @author Aaron Mulder ([EMAIL PROTECTED])
*/
class PoolGCThread extends Thread
{
+ /** Class logger. */
+ private static Logger log = Logger.getLogger(PoolGCThread.class);
- static Logger category = Logger.getLogger(PoolGCThread.class.getName());
+ private HashSet pools = new HashSet();
- private HashSet pools = new HashSet();
-
PoolGCThread() {
super( "Minerva ObjectPool GC Thread" );
setDaemon( true );
}
public void run() {
- category.debug("Started gc thread");
+ log.debug("Started gc thread");
+
while ( true ) {
// Don't do anything while there's nothing to do
waitForPools();
- category.debug("gc thread waited for pools");
+ log.debug("gc thread waited for pools");
+
// Figure out how long to sleep
long delay = getDelay();
- category.debug("gc thread delay: " + delay);
+ log.debug("gc thread delay: " + delay);
+
// Sleep
if ( delay > 0l ) {
try {
sleep( delay );
- } catch ( InterruptedException e ) {
- }
+ } catch ( InterruptedException ignore ) {}
}
+
// Run garbage collection on eligible pools
runGC();
}
}
synchronized void addPool( ObjectPool pool ) {
- category.debug("Adding pool: " + pool.getName() + ", Cleanup enabled: " +
pool.isCleanupEnabled());
+ if (log.isDebugEnabled()) {
+ log.debug("Adding pool: " + pool.getName() +
+ ", Cleanup enabled: " + pool.isCleanupEnabled());
+ }
if ( pool.isCleanupEnabled() ) {
pools.add( pool );
}
@@ -79,17 +85,25 @@
while ( pools.size() == 0 ) {
try {
wait();
- } catch ( InterruptedException e ) {
- category.debug("waitForPools interrupted");
+ } catch ( InterruptedException ignore ) {
+ log.debug("waitForPools interrupted");
}
}
}
private synchronized void runGC() {
- category.debug("gc thread running gc");
+ boolean debug = log.isDebugEnabled();
+ if (debug) {
+ log.debug("gc thread running gc");
+ }
+
for ( Iterator it = pools.iterator(); it.hasNext(); ) {
ObjectPool pool = ( ObjectPool )it.next();
- category.debug("gc thread pool: " + pool.getName() + " isTimeToCleanup()"
+ pool.isTimeToCleanup());
+
+ if (debug) {
+ log.debug("gc thread pool: " + pool.getName() +
+ " isTimeToCleanup()" + pool.isTimeToCleanup());
+ }
if ( pool.isTimeToCleanup() ) {
pool.runCleanupandShrink();
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development