You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2011/03/02 07:31:38 UTC

svn commit: r1076114 - in /ofbiz/trunk/framework/entity: dtd/entity-config.xsd src/org/ofbiz/entity/connection/DBCPConnectionFactory.java src/org/ofbiz/entity/connection/MinervaConnectionFactory.java

Author: lektran
Date: Wed Mar  2 06:31:38 2011
New Revision: 1076114

URL: http://svn.apache.org/viewvc?rev=1076114&view=rev
Log:
Add inline-jdbc attribute idle-maxsize for greater control over the max idle connections that should remain in the pool.  Previously it was always set to half of pool-maxsize (and still defaults to this value)

Modified:
    ofbiz/trunk/framework/entity/dtd/entity-config.xsd
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java

Modified: ofbiz/trunk/framework/entity/dtd/entity-config.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/dtd/entity-config.xsd?rev=1076114&r1=1076113&r2=1076114&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/dtd/entity-config.xsd (original)
+++ ofbiz/trunk/framework/entity/dtd/entity-config.xsd Wed Mar  2 06:31:38 2011
@@ -433,6 +433,13 @@ under the License.
         </xs:attribute>
         <xs:attribute type="xs:nonNegativeInteger" name="pool-maxsize" default="50"/>
         <xs:attribute type="xs:nonNegativeInteger" name="pool-minsize" default="2"/>
+        <xs:attribute type="xs:nonNegativeInteger" name="idle-maxsize">
+            <xs:annotation>
+                <xs:documentation>
+                    Maximum number of idle connections that should remain in the pool.  Defaults to 50% of pool-maxsize.
+                </xs:documentation>
+            </xs:annotation>
+        </xs:attribute>
         <xs:attribute type="xs:nonNegativeInteger" name="time-between-eviction-runs-millis" default="600000"/>
         <xs:attribute type="xs:nonNegativeInteger" name="pool-sleeptime" default="300000"/>
         <xs:attribute type="xs:nonNegativeInteger" name="pool-lifetime" default="600000"/>

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=1076114&r1=1076113&r2=1076114&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Wed Mar  2 06:31:38 2011
@@ -90,7 +90,16 @@ public class DBCPConnectionFactory imple
                 Debug.logError("Problems with pool settings [pool-minsize], using default of 2.", module);
                 minSize = 2;
             }
+            // idle-maxsize, default to half of pool-maxsize
             int maxIdle = maxSize / 2;
+            try {
+                maxIdle = Integer.parseInt(jdbcElement.getAttribute("idle-maxsize"));
+            } catch (NumberFormatException nfe) {
+                Debug.logError("Problems with pool settings [idle-maxsize=" + jdbcElement.getAttribute("idle-maxsize") + "]; the values MUST be numbers, using calculated default of" + (maxIdle > minSize ? maxIdle : minSize) + ".", module);
+            } catch (Exception e) {
+                Debug.logError("Problems with pool settings [idle-maxsize], using calculated default of" + (maxIdle > minSize ? maxIdle : minSize) + ".", module);
+            }
+            // Don't allow a maxIdle of less than pool-minsize
             maxIdle = maxIdle > minSize ? maxIdle : minSize;
 
             try {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java?rev=1076114&r1=1076113&r2=1076114&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/MinervaConnectionFactory.java Wed Mar  2 06:31:38 2011
@@ -115,6 +115,10 @@ public class MinervaConnectionFactory im
                 pds.setMinSize(2);
             }
 
+            if (jdbcElement.hasAttribute("idle-maxsize")) {
+                Debug.logWarning("idle-maxsize is not supported by MinervaConnectionFactory, ignoring value", module);
+            }
+
             // cache the pool
             dsCache.put(helperInfo.getHelperFullName(), pds);