Make the polling fairness configurable
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 28 Oct 2008 15:00:22 +0000 (15:00 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 28 Oct 2008 15:00:22 +0000 (15:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@708592 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java

index 24cab97..7950369 100644 (file)
@@ -265,7 +265,7 @@ public class ConnectionPool {
         //make space for 10 extra in case we flow over a bit\r
         busy = new ArrayBlockingQueue<PooledConnection>(properties.getMaxActive(),false);\r
         //make space for 10 extra in case we flow over a bit\r
-        idle = new ArrayBlockingQueue<PooledConnection>(properties.getMaxActive(),false);\r
+        idle = new ArrayBlockingQueue<PooledConnection>(properties.getMaxActive(),properties.isFairQueue());\r
 \r
         //if the evictor thread is supposed to run, start it now\r
         if (properties.isPoolSweeperEnabled()) {\r
index 58265bf..5f4cbb6 100644 (file)
@@ -99,6 +99,7 @@ public class DataSourceFactory implements ObjectFactory {
     protected final static String PROP_INTERCEPTORS = "jdbcInterceptors";\r
     protected final static String PROP_VALIDATIONINTERVAL = "validationInterval";\r
     protected final static String PROP_JMX_ENABLED = "jmxEnabled";\r
+    protected final static String PROP_FAIR_QUEUE = "fairQueue";\r
     \r
     public static final int UNKNOWN_TRANSACTIONISOLATION = -1;\r
 \r
@@ -135,7 +136,8 @@ public class DataSourceFactory implements ObjectFactory {
         PROP_CONNECTIONPROPERTIES,\r
         PROP_INITSQL,\r
         PROP_INTERCEPTORS,\r
-        PROP_JMX_ENABLED\r
+        PROP_JMX_ENABLED,\r
+        PROP_FAIR_QUEUE\r
     };\r
 \r
     // -------------------------------------------------- ObjectFactory Methods\r
@@ -380,6 +382,12 @@ public class DataSourceFactory implements ObjectFactory {
         if (value != null) {\r
             dataSource.getPoolProperties().setJmxEnabled(Boolean.parseBoolean(value));\r
         }\r
+        \r
+        value = properties.getProperty(PROP_FAIR_QUEUE);\r
+        if (value != null) {\r
+            dataSource.getPoolProperties().setFairQueue(Boolean.parseBoolean(value));\r
+        }\r
+        \r
 \r
         // Return the configured DataSource instance\r
         DataSource ds = getDataSource(dataSource);\r
index 878585c..ba07230 100644 (file)
@@ -284,6 +284,10 @@ public class DataSourceProxy  {
         this.getPoolProperties().setJmxEnabled(enabled);\r
     }\r
     \r
+    public void setFairQueue(boolean fairQueue) {\r
+        this.getPoolProperties().setFairQueue(fairQueue);\r
+    }\r
+    \r
     public void setConnectionProperties(String properties) {\r
         try {\r
             java.util.Properties prop = DataSourceFactory.getProperties(properties);\r
index 6f94d36..225ca48 100644 (file)
@@ -58,6 +58,15 @@ public class PoolProperties {
     protected String initSQL;\r
     protected boolean testOnConnect =false;\r
     private String jdbcInterceptors=null;\r
+    private boolean fairQueue = false;\r
+\r
+    public boolean isFairQueue() {\r
+        return fairQueue;\r
+    }\r
+\r
+    public void setFairQueue(boolean fairQueue) {\r
+        this.fairQueue = fairQueue;\r
+    }\r
 \r
     public boolean isAccessToUnderlyingConnectionAllowed() {\r
         return accessToUnderlyingConnectionAllowed;\r