incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1336587 - in /incubator/lcf/branches/CONNECTORS-96: ./ framework/ framework/core/src/main/java/org/apache/manifoldcf/core/database/
Date Thu, 10 May 2012 10:39:06 GMT
Author: kwright
Date: Thu May 10 10:39:06 2012
New Revision: 1336587

URL: http://svn.apache.org/viewvc?rev=1336587&view=rev
Log:
Use the new pool stuff rather than bitstream everywhere.

Modified:
    incubator/lcf/branches/CONNECTORS-96/build.xml
    incubator/lcf/branches/CONNECTORS-96/framework/build.xml
    incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java
    incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java

Modified: incubator/lcf/branches/CONNECTORS-96/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-96/build.xml?rev=1336587&r1=1336586&r2=1336587&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-96/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-96/build.xml Thu May 10 10:39:06 2012
@@ -3134,14 +3134,6 @@ Use Apache Forrest version forrest-0.9-d
         </antcall>
     </target>
     
-    <target name="download-jdbcpool">
-        <mkdir dir="lib"/>
-        <mkdir dir="build/download"/>
-        <get src="http://ftp.nerim.net/FreeBSD/ports/i386/packages/databases/jdbcpool-0.99_3.tbz"
dest="build/download/jdbcpool-0.99_3.tbz"/>
-        <untar src="build/download/jdbcpool-0.99_3.tbz" compression="bzip2" dest="build/download/jdbcpool"/>
-        <copy todir="lib" file="build/download/jdbcpool/share/java/classes/jdbcpool.jar"/>
-    </target>
-
     <target name="download-chemistry">
         <mkdir dir="lib"/>
         <property name="chemistry-version" value="0.6.0"/>
@@ -3394,7 +3386,7 @@ Use Apache Forrest version forrest-0.9-d
         </copy>
     </target>
 
-    <target name="make-core-deps" depends="download-json,download-hsqldb,download-xerces,download-commons,download-solr-plugins,download-sharepoint-plugin,download-jstl,download-xmlgraphics-commons,download-wstx-asl,download-xmlsec,download-xml-apis,download-wss4j,download-velocity,download-streambuffer,download-stax,download-servlet-api,download-xml-resolver,download-osgi,download-opensaml,download-mimepull,download-mail,download-log4j,download-junit,download-jsr181-api,download-jsr250-api,download-jaxws,download-jdbcpool,download-glassfish,download-jaxb,download-tomcat,download-h2,download-h2-support,download-geronimo-specs,download-fop,download-derby,download-postgresql,download-axis,download-saaj,download-wsdl4j,download-castor,download-jetty,download-slf4j,download-xalan,download-activation,download-avalon-framework,download-poi,download-chemistry,download-ecj">
+    <target name="make-core-deps" depends="download-json,download-hsqldb,download-xerces,download-commons,download-solr-plugins,download-sharepoint-plugin,download-jstl,download-xmlgraphics-commons,download-wstx-asl,download-xmlsec,download-xml-apis,download-wss4j,download-velocity,download-streambuffer,download-stax,download-servlet-api,download-xml-resolver,download-osgi,download-opensaml,download-mimepull,download-mail,download-log4j,download-junit,download-jsr181-api,download-jsr250-api,download-jaxws,download-glassfish,download-jaxb,download-tomcat,download-h2,download-h2-support,download-geronimo-specs,download-fop,download-derby,download-postgresql,download-axis,download-saaj,download-wsdl4j,download-castor,download-jetty,download-slf4j,download-xalan,download-activation,download-avalon-framework,download-poi,download-chemistry,download-ecj">
         <copy todir="lib">
             <fileset dir="lib-license" includes="*.txt"/>
         </copy>

Modified: incubator/lcf/branches/CONNECTORS-96/framework/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-96/framework/build.xml?rev=1336587&r1=1336586&r2=1336587&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-96/framework/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-96/framework/build.xml Thu May 10 10:39:06 2012
@@ -45,7 +45,6 @@
             <include name="jasper*.jar"/>
             <include name="jetty*.jar"/>
             <include name="slf4j*.jar"/>
-            <include name="jdbcpool*.jar"/>
             <include name="jsp-2.1*.jar"/>
             <include name="jsp-api*.jar"/>
             <include name="junit*.jar"/>
@@ -254,7 +253,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="xalan*.jar"/>
@@ -290,7 +288,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="xalan*.jar"/>
@@ -331,7 +328,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="xalan*.jar"/>
@@ -368,7 +364,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="xalan*.jar"/>
@@ -411,7 +406,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="xalan*.jar"/>
@@ -456,7 +450,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="xalan*.jar"/>
@@ -559,7 +552,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="servlet-api*.jar"/>
@@ -598,7 +590,6 @@
                 <include name="commons-io*.jar"/>
                 <include name="commons-lang*.jar"/>
                 <include name="commons-logging*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="log4j*.jar"/>
                 <include name="serializer*.jar"/>
                 <include name="servlet-api*.jar"/>
@@ -750,7 +741,6 @@
                 <include name="commons-logging*.jar"/>
                 <include name="ecj*.jar"/>
                 <include name="jasper*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="jetty*.jar"/>
                 <include name="slf4j*.jar"/>
                 <include name="jsp-api*.jar"/>
@@ -821,8 +811,7 @@
         <property name="manifest-cp-26" value="${manifest-cp-25} lib/derbytools.jar"/>
         <property name="manifest-cp-27" value="${manifest-cp-26} lib/jasper.jar"/>
         <property name="manifest-cp-28" value="${manifest-cp-27} lib/jasper-el.jar"/>
-        <property name="manifest-cp-29" value="${manifest-cp-28} lib/jdbcpool.jar"/>
-        <property name="manifest-cp-30" value="${manifest-cp-29} lib/jetty-server.jar"/>
+        <property name="manifest-cp-30" value="${manifest-cp-28} lib/jetty-server.jar"/>
         <property name="manifest-cp-31" value="${manifest-cp-30} lib/jetty-util.jar"/>
         <property name="manifest-cp-32" value="${manifest-cp-31} lib/jsp-api-2.1-glassfish.jar"/>
         <property name="manifest-cp-33" value="${manifest-cp-32} lib/json.jar"/>
@@ -877,7 +866,6 @@
                 <include name="commons-logging*.jar"/>
                 <include name="ecj*.jar"/>
                 <include name="jasper*.jar"/>
-                <include name="jdbcpool*.jar"/>
                 <include name="jetty*.jar"/>
                 <include name="slf4j*.jar"/>
                 <include name="jsp-api*.jar"/>
@@ -953,8 +941,7 @@
         <property name="manifest-cp-proprietary-26" value="${manifest-cp-proprietary-25}
lib/derbytools.jar"/>
         <property name="manifest-cp-proprietary-27" value="${manifest-cp-proprietary-26}
lib/jasper.jar"/>
         <property name="manifest-cp-proprietary-28" value="${manifest-cp-proprietary-27}
lib/jasper-el.jar"/>
-        <property name="manifest-cp-proprietary-29" value="${manifest-cp-proprietary-28}
lib/jdbcpool.jar"/>
-        <property name="manifest-cp-proprietary-30" value="${manifest-cp-proprietary-29}
lib/jetty-server.jar"/>
+        <property name="manifest-cp-proprietary-30" value="${manifest-cp-proprietary-28}
lib/jetty-server.jar"/>
         <property name="manifest-cp-proprietary-31" value="${manifest-cp-proprietary-30}
lib/jetty-util.jar"/>
         <property name="manifest-cp-proprietary-32" value="${manifest-cp-proprietary-31}
lib/jsp-api-2.1-glassfish.jar"/>
         <property name="manifest-cp-proprietary-33" value="${manifest-cp-proprietary-32}
lib/json.jar"/>

Modified: incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java?rev=1336587&r1=1336586&r2=1336587&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java
(original)
+++ incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/ConnectionFactory.java
Thu May 10 10:39:06 2012
@@ -19,6 +19,7 @@
 package org.apache.manifoldcf.core.database;
 
 import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.core.jdbcpool.*;
 import org.apache.manifoldcf.core.system.Logging;
 import org.apache.manifoldcf.core.system.ManifoldCF;
 
@@ -27,8 +28,6 @@ import java.sql.*;
 import javax.naming.*;
 import javax.sql.*;
 
-import com.bitmechanic.sql.*;
-
 /** This class creates a connection, and may at our discretion manage
 * a connection pool someday.
 */
@@ -48,19 +47,29 @@ public class ConnectionFactory
   {
   }
 
-  public static Connection getConnection(String jdbcUrl, String jdbcDriver, String database,
String userName, String password)
+  public static WrappedConnection getConnection(String jdbcUrl, String jdbcDriver, String
database, String userName, String password)
     throws ManifoldCFException
   {
+    // Make sure database driver is registered
+    try
+    {
+      Class.forName(jdbcDriver);
+    }
+    catch (Exception e)
+    {
+      throw new ManifoldCFException("Unable to load database driver: "+e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
+    }
 
-    ConnectionPoolManager _pool = poolManager.ensurePoolExists(jdbcDriver);
+    ConnectionPoolManager cpm = poolManager.createPoolManager();
+    
     try
     {
       // Hope for a connection now
-      Connection rval;
+      WrappedConnection rval;
       ConnectionPool cp = null;
       try
       {
-        cp = _pool.getPool(database);
+        cp = cpm.getPool(database);
       }
       catch (Exception e)
       {
@@ -71,61 +80,37 @@ public class ConnectionFactory
         int maxDBConnections = defaultMaxDBConnections;
         if (handleMax != null && handleMax.length() > 0)
           maxDBConnections = Integer.parseInt(handleMax);
-        String timeoutValueString = ManifoldCF.getProperty(ManifoldCF.databaseHandleTimeoutProperty);
-        int timeoutValue = defaultTimeoutValue;
-        if (timeoutValueString != null && timeoutValueString.length() > 0)
-          timeoutValue = Integer.parseInt(timeoutValueString);
+        //String timeoutValueString = ManifoldCF.getProperty(ManifoldCF.databaseHandleTimeoutProperty);
+        //int timeoutValue = defaultTimeoutValue;
+        //if (timeoutValueString != null && timeoutValueString.length() > 0)
+        //  timeoutValue = Integer.parseInt(timeoutValueString);
 
         // Logging.db.debug("adding pool alias [" + database + "]");
         // I had to up the timeout from one hour to 3 due to the webconnector keeping some
connections open a very long time...
 	//System.out.println("jdbcUrl = '"+jdbcUrl+"', userName='"+userName+"', password='"+password+"'");
-        _pool.addAlias(database, jdbcDriver, jdbcUrl,
+        cpm.addAlias(database, jdbcDriver, jdbcUrl,
           userName, password,
-          maxDBConnections,
-          300,                      // Idle timeout: idle time before closing connection:
5 minutes
-          timeoutValue,         // Checkout timeout: Time a thread can have connection checked
out: 24 hours
-          30,                       // Number of times you can check out a connection before
it gets closed: 30
-          false);
-        cp = _pool.getPool(database);
-      }
-      rval = getConnectionWithRetries(ConnectionPoolManager.URL_PREFIX + database, null,
null);
-      //rval = getConnectionWithRetries(ConnectionPoolManager.URL_PREFIX + database, userName,
password);
-
-      // Enter it in the pool so we can figure out whether it closed
-      // synchronized (checkedOutConnections)
-      // {
-      //      checkedOutConnections.put(rval.toString(),new ConnectionTracker(rval));
-      // }
-      //
-      // checkConnections(System.currentTimeMillis());
-
+          maxDBConnections, 300000L);
+        cp = cpm.getPool(database);
+      }
+      rval = new WrappedConnection(cp, getConnectionWithRetries(database, null, null));
       return rval;
     }
     catch (Exception e)
     {
-      throw new ManifoldCFException("Error getting connection",e,ManifoldCFException.DATABASE_ERROR);
+      throw new ManifoldCFException("Error getting connection: "+e.getMessage(),e,ManifoldCFException.DATABASE_ERROR);
     }
   }
 
-  public static void releaseConnection(Connection c)
+  public static void releaseConnection(WrappedConnection c)
     throws ManifoldCFException
   {
-    try
-    {
-      c.close();
-      // synchronized (checkedOutConnections)
-      // {
-      //      checkedOutConnections.remove(c.toString());
-      // }
-    }
-    catch (Exception e)
-    {
-      throw new ManifoldCFException("Error releasing connection",e,ManifoldCFException.DATABASE_ERROR);
-    }
+    c.release();
   }
 
   public static void releaseAll()
   {
+    //???
     if (poolManager != null)
       poolManager.releaseAll();
   }
@@ -196,34 +181,14 @@ public class ConnectionFactory
     {
     }
 
-    public ConnectionPoolManager ensurePoolExists(String jdbcDriver)
-      throws ManifoldCFException
+    public ConnectionPoolManager createPoolManager()
     {
       synchronized (poolExistenceLock)
       {
         if (_pool != null)
           return _pool;
-        try
-        {
-          Class.forName(jdbcDriver);
-        }
-        catch (Exception e)
-        {
-          throw new ManifoldCFException("Unable to load database driver: "+e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
-        }
-        try
-        {
-          String handleMax = ManifoldCF.getProperty(ManifoldCF.databaseHandleMaxcountProperty);
-          int maxDBConnections = defaultMaxDBConnections;
-          if (handleMax != null && handleMax.length() > 0)
-            maxDBConnections = Integer.parseInt(handleMax);
-          _pool = new ConnectionPoolManager(maxDBConnections);
-          return _pool;
-        }
-        catch (Exception e)
-        {
-          throw new ManifoldCFException("Unable to initialize database handle pool: "+e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
-        }
+        _pool = new ConnectionPoolManager(100);
+        return _pool;
       }
     }
 
@@ -235,6 +200,14 @@ public class ConnectionFactory
           return;
       }
 
+      // Cleanup strategy: Some connections are still in use because they are being
+      // used by non-worker threads that have been interrupted but haven't yet died.
+      // Cleaning these up is a challenge.  For now I won't address this.
+      
+      _pool.shutdown();
+    }
+      
+      /*
       // Cleanup strategy is to close everything that can easily be closed, but leave around
connections that are so busy that they will not close within a certain amount of
       // time.  To do that, we spin up a thread for each connection, which attempts to close
that connection, and then wait until either 15 seconds passes, or all the threads
       // are finished.
@@ -244,7 +217,7 @@ public class ConnectionFactory
       // This is not ideal, but is a compromise designed to permit speedy and relatively
clean shutdown even under
       // difficult conditions.
 
-
+      
       Enumeration enumeration = _pool.getPools();
       ArrayList connectionShutdownThreads = new ArrayList();
       while (enumeration.hasMoreElements())
@@ -305,7 +278,7 @@ public class ConnectionFactory
 
       // Some threads may still be running - but that can't be helped.
     }
-
+    */
 
     // Protected methods and classes
 
@@ -315,6 +288,7 @@ public class ConnectionFactory
     * will be blocked from proceeding under Tomcat 5.5.  Between the two, however,
     * there's hope that the right things will take place.
     */
+    /*
     protected void finalize()
       throws Throwable
     {
@@ -328,8 +302,10 @@ public class ConnectionFactory
         super.finalize();
       }
     }
+    */
   }
 
+  /*
   protected static class ConnectionCloseThread extends Thread
   {
     protected com.bitmechanic.sql.PooledConnection connection;
@@ -361,7 +337,8 @@ public class ConnectionFactory
     }
 
   }
-
+  */
+  
   protected static class ConnectionTracker
   {
     protected Connection theConnection;

Modified: incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java?rev=1336587&r1=1336586&r2=1336587&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
(original)
+++ incubator/lcf/branches/CONNECTORS-96/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
Thu May 10 10:39:06 2012
@@ -19,6 +19,7 @@
 package org.apache.manifoldcf.core.database;
 
 import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.core.jdbcpool.*;
 import org.apache.manifoldcf.core.system.Logging;
 import org.apache.manifoldcf.core.system.ManifoldCF;
 
@@ -45,7 +46,7 @@ public abstract class Database
   protected String userName;
   protected String password;
   protected TransactionHandle th = null;
-  protected Connection connection = null;
+  protected WrappedConnection connection = null;
   protected boolean doRollback = false;
   protected boolean commitDone = false;
   protected int delayedTransactionDepth = 0;
@@ -250,7 +251,7 @@ public abstract class Database
       try
       {
         // Initialize the connection (for HSQLDB)
-        initializeConnection(connection);
+        initializeConnection(connection.getConnection());
         // Start a transaction
         startATransaction();
       }
@@ -705,7 +706,7 @@ public abstract class Database
     {
       try
       {
-        return executeViaThread(connection,query,params,bResults,maxResults,spec,returnLimit);
+        return executeViaThread(connection.getConnection(),query,params,bResults,maxResults,spec,returnLimit);
       }
       catch (ManifoldCFException e)
       {
@@ -718,12 +719,12 @@ public abstract class Database
     else
     {
       // Grab a connection
-      Connection tempConnection = ConnectionFactory.getConnection(jdbcUrl,jdbcDriverClass,databaseName,userName,password);
+      WrappedConnection tempConnection = ConnectionFactory.getConnection(jdbcUrl,jdbcDriverClass,databaseName,userName,password);
       try
       {
         // Initialize the connection (for HSQLDB)
-        initializeConnection(tempConnection);
-        return executeViaThread(tempConnection,query,params,bResults,maxResults,spec,returnLimit);
+        initializeConnection(tempConnection.getConnection());
+        return executeViaThread(tempConnection.getConnection(),query,params,bResults,maxResults,spec,returnLimit);
       }
       catch (ManifoldCFException e)
       {



Mime
View raw message