manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1209209 - in /incubator/lcf/trunk/framework: core/src/main/java/org/apache/manifoldcf/core/database/ core/src/main/java/org/apache/manifoldcf/core/interfaces/ pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/
Date Thu, 01 Dec 2011 19:43:05 GMT
Author: kwright
Date: Thu Dec  1 19:43:03 2011
New Revision: 1209209

URL: http://svn.apache.org/viewvc?rev=1209209&view=rev
Log:
Part of CONNECTORS-299.  Add method to allow pre-emptive commit while still in try/catch block,
which should allow for transaction abort retries from commits in the places we need that.

Modified:
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
    incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
    incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java?rev=1209209&r1=1209208&r2=1209209&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java
Thu Dec  1 19:43:03 2011
@@ -258,6 +258,17 @@ public class BaseTable
     dbInterface.beginTransaction();
   }
 
+  /** Perform the transaction commit.
+  * Calling this method does not relieve the coder of the responsibility of calling endTransaction(),
+  * as listed below.  The purpose of a separate commit operation is to allow handling of
situations where the
+  * commit generates a TRANSACTION_ABORT signal.
+  */
+  public void performCommit()
+    throws ManifoldCFException
+  {
+    dbInterface.performCommit();
+  }
+
   /** Signal that a rollback should occur on the next endTransaction().
   */
   protected void signalRollback()

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java?rev=1209209&r1=1209208&r2=1209209&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/Database.java
Thu Dec  1 19:43:03 2011
@@ -47,6 +47,7 @@ public abstract class Database
   protected TransactionHandle th = null;
   protected Connection connection = null;
   protected boolean doRollback = false;
+  protected boolean commitDone = false;
   protected int delayedTransactionDepth = 0;
   protected Map<String,Modifications> modificationsSet = new HashMap<String,Modifications>();
 
@@ -148,6 +149,9 @@ public abstract class Database
     String queryClass, boolean needResult, int maxReturn, ResultSpecification spec, ILimitChecker
returnLimits)
     throws ManifoldCFException
   {
+    if (commitDone)
+      throw new ManifoldCFException("Commit already done");
+    
     // System.out.println("Query: "+query);
     if (Logging.db.isDebugEnabled())
     {
@@ -211,6 +215,7 @@ public abstract class Database
     th = new TransactionHandle(context,th,transactionType);
     cacheManager.startTransaction(th.getTransactionID(),enclosingID);
     doRollback = false;
+    commitDone = false;
   }
 
   /** Synchronize internal transactions.
@@ -277,6 +282,22 @@ public abstract class Database
     }
   }
 
+  /** Perform the transaction commit.
+  * Calling this method does not relieve the coder of the responsibility of calling endTransaction(),
+  * as listed below.  The purpose of a separate commit operation is to allow handling of
situations where the
+  * commit generates a TRANSACTION_ABORT signal.
+  */
+  public void performCommit()
+    throws ManifoldCFException
+  {
+    Logging.db.debug("Committing transaction!");
+    if (delayedTransactionDepth == 0)
+    {
+      commitCurrentTransaction();
+      commitDone = true;
+    }
+  }
+
   /** Signal that a rollback should occur on the next endTransaction().
   */
   public void signalRollback()
@@ -318,7 +339,8 @@ public abstract class Database
           {
             // Do a commit into the database, and blow away cached queries (cached against
the
             // database transaction key).
-            commitCurrentTransaction();
+            if (!commitDone)
+              commitCurrentTransaction();
           }
         }
         catch (ManifoldCFException e)
@@ -343,9 +365,16 @@ public abstract class Database
     finally
     {
       if (doRollback)
+      {
         cacheManager.rollbackTransaction(th.getTransactionID());
+      }
       else
-        cacheManager.commitTransaction(th.getTransactionID());
+      {
+        if (!commitDone)
+          cacheManager.commitTransaction(th.getTransactionID());
+      }
+      commitDone = false;
+      doRollback = false;
       th = parentTransaction;
       if (th == null)
       {

Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java?rev=1209209&r1=1209208&r2=1209209&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
(original)
+++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java
Thu Dec  1 19:43:03 2011
@@ -360,12 +360,20 @@ public interface IDBInterface
   public void beginTransaction(int transactionType)
     throws ManifoldCFException;
 
+  /** Perform the transaction commit.
+  * Calling this method does not relieve the coder of the responsibility of calling endTransaction(),
+  * as listed below.  The purpose of a separate commit operation is to allow handling of
situations where the
+  * commit generates a TRANSACTION_ABORT signal.
+  */
+  public void performCommit()
+    throws ManifoldCFException;
+
   /** Signal that a rollback should occur on the next endTransaction().
   */
   public void signalRollback();
 
-  /** End a database transaction, either performing a commit or a rollback (depending on
whether
-  * signalRollback() was called within the transaction).
+  /** End a database transaction, either performing a commit or a rollback or nothing (depending
on whether
+  * signalRollback() was called within the transaction or performCommit() or none of the
above).
   */
   public void endTransaction()
     throws ManifoldCFException;

Modified: incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1209209&r1=1209208&r2=1209209&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
(original)
+++ incubator/lcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
Thu Dec  1 19:43:03 2011
@@ -3989,6 +3989,7 @@ public class JobManager implements IJobM
           // A certain set of carrydown records are going to be deleted by the ensuing restoreRecords
command.  Calculate that set of records!
           rval = calculateAffectedRestoreCarrydownChildren(jobID,parentIdentifierHashes);
           carryDown.restoreRecords(jobID,parentIdentifierHashes);
+          database.performCommit();
           break;
         }
         catch (ManifoldCFException e)
@@ -4043,7 +4044,8 @@ public class JobManager implements IJobM
             Integer.toString(parentIdentifierHashes.length)+" doc hopcounts for job "+jobID.toString());
 
           hopCount.finishParents(jobID,legalLinkTypes,parentIdentifierHashes,hopcountMethod);
-
+          database.performCommit();
+          
           if (Logging.perf.isDebugEnabled())
             Logging.perf.debug("Took "+new Long(System.currentTimeMillis()-startTime).toString()+"
ms to finish "+
             Integer.toString(parentIdentifierHashes.length)+" doc hopcounts for job "+jobID.toString());



Mime
View raw message