commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1531298 - /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/AbandonedConfig.java
Date Fri, 11 Oct 2013 14:09:15 GMT
Author: markt
Date: Fri Oct 11 14:09:15 2013
New Revision: 1531298

URL: http://svn.apache.org/r1531298
Log:
POOL-211
Add a useUsageTracking option to AbandonedConfig

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/AbandonedConfig.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/AbandonedConfig.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/AbandonedConfig.java?rev=1531298&r1=1531297&r2=1531298&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/AbandonedConfig.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/AbandonedConfig.java
Fri Oct 11 14:09:15 2013
@@ -20,10 +20,11 @@ package org.apache.commons.pool2.impl;
 import java.io.PrintWriter;
 
 import org.apache.commons.pool2.TrackedUse;
+import org.apache.commons.pool2.UsageTracking;
 
 /**
  * Configuration settings for abandoned object removal.
- *                                                                     
+ *
  * @version $Revision:$
  */
 public class AbandonedConfig {
@@ -32,19 +33,13 @@ public class AbandonedConfig {
      * Whether or not borrowObject performs abandoned object removal.
      */
     private boolean removeAbandonedOnBorrow = false;
-    
-    /**
-     * Whether or not pool maintenance (evictor) performs abandoned object
-     * removal.
-     */
-    private boolean removeAbandonedOnMaintenance = false;
 
     /**
      * <p>Flag to remove abandoned objects if they exceed the
      * removeAbandonedTimeout when borrowObject is invoked.</p>
      *
      * <p>The default value is false.</p>
-     * 
+     *
      * <p>If set to true, abandoned objects are removed by borrowObject if
      * there are fewer than 2 idle objects available in the pool and
      * <code>getNumActive() > getMaxTotal() - 3</code> </p>
@@ -66,17 +61,23 @@ public class AbandonedConfig {
     public void setRemoveAbandonedOnBorrow(boolean removeAbandonedOnBorrow) {
         this.removeAbandonedOnBorrow = removeAbandonedOnBorrow;
     }
-    
+
+    /**
+     * Whether or not pool maintenance (evictor) performs abandoned object
+     * removal.
+     */
+    private boolean removeAbandonedOnMaintenance = false;
+
     /**
      * <p>Flag to remove abandoned objects if they exceed the
      * removeAbandonedTimeout when pool maintenance (the "evictor")
      * runs.</p>
      *
      * <p>The default value is false.</p>
-     * 
+     *
      * <p>If set to true, abandoned objects are removed by the pool
      * maintenance thread when it runs.  This setting has no effect
-     * unless maintenance is enabled by setting 
+     * unless maintenance is enabled by setting
      *{@link GenericObjectPool#getTimeBetweenEvictionRunsMillis() timeBetweenEvictionRunsMillis}
      * to a positive number.</p>
      *
@@ -103,15 +104,15 @@ public class AbandonedConfig {
      */
     private int removeAbandonedTimeout = 300;
 
-    /** 
+    /**
      * <p>Timeout in seconds before an abandoned object can be removed.</p>
-     * 
+     *
      * <p>The time of most recent use of an object is the maximum (latest) of
      * {@link TrackedUse#getLastUsed()} (if this class of the object implements
      * TrackedUse) and the time when the object was borrowed from the pool.</p>
-     * 
+     *
      * <p>The default value is 300 seconds.</p>
-     * 
+     *
      * @return the abandoned object timeout in seconds
      */
     public int getRemoveAbandonedTimeout() {
@@ -121,8 +122,8 @@ public class AbandonedConfig {
     /**
      * <p>Sets the timeout in seconds before an abandoned object can be
      * removed</p>
-     * 
-     * <p>Setting this property has no effect if 
+     *
+     * <p>Setting this property has no effect if
      * {@link #getRemoveAbandonedOnBorrow() removeAbandonedOnBorrow} and
      * {@link #getRemoveAbandonedOnMaintenance() removeAbandonedOnMaintenance}
      * are both false.</p>
@@ -147,7 +148,7 @@ public class AbandonedConfig {
      * Defaults to false.
      * Logging of abandoned objects adds overhead for every object created
      * because a stack trace has to be generated.
-     * 
+     *
      * @return boolean true if stack trace logging is turned on for abandoned
      * objects
      *
@@ -159,7 +160,7 @@ public class AbandonedConfig {
     /**
      * Sets the flag to log stack traces for application code which abandoned
      * an object.
-     * 
+     *
      * @param logAbandoned true turns on abandoned stack trace logging
      * @see #getLogAbandoned()
      *
@@ -172,7 +173,7 @@ public class AbandonedConfig {
      * PrintWriter to use to log information on abandoned objects.
      */
     private PrintWriter logWriter = new PrintWriter(System.out);
-    
+
     /**
      * Returns the log writer being used by this configuration to log
      * information on abandoned objects. If not set, a PrintWriter based on
@@ -183,14 +184,40 @@ public class AbandonedConfig {
     public PrintWriter getLogWriter() {
         return logWriter;
     }
-    
+
     /**
      * Sets the log writer to be used by this configuration to log
      * information on abandoned objects.
-     * 
+     *
      * @param logWriter The new log writer
      */
     public void setLogWriter(PrintWriter logWriter) {
         this.logWriter = logWriter;
     }
+
+    /**
+     * If the pool implements {@link UsageTracking}, should the pool record a
+     * stack trace every time a method is called on a pooled object and retain
+     * the most recent stack trace to aid debugging of abandoned objects?
+     */
+    private boolean useUsageTracking = false;
+
+    /**
+     * If the pool implements {@link UsageTracking}, should the pool record a
+     * stack trace every time a method is called on a pooled object and retain
+     * the most recent stack trace to aid debugging of abandoned objects?
+     */
+    public boolean getUseUsageTracking() {
+        return useUsageTracking;
+    }
+
+    /**
+     * If the pool implements {@link UsageTracking}, configure whether the pool
+     * should record a stack trace every time a method is called on a pooled
+     * object and retain the most recent stack trace to aid debugging of
+     * abandoned objects.
+     */
+    public void setUseUsageTracking(boolean useUsageTracking) {
+        this.useUsageTracking = useUsageTracking;
+    }
 }



Mime
View raw message