[exo-jcr-commits] exo-jcr SVN: r1493 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 19 19:45:17 EST 2010


Author: pnedonosko
Date: 2010-01-19 19:45:17 -0500 (Tue, 19 Jan 2010)
New Revision: 1493

Modified:
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
   jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
Log:
EXOJCR-405 rollback rework for storage transaction (don't call rollback after failed commit - it's not actual)

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2010-01-19 23:30:39 UTC (rev 1492)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2010-01-20 00:45:17 UTC (rev 1493)
@@ -295,8 +295,7 @@
       }
 
       @Override
-      protected void txAction() throws RepositoryException, NotSupportedException, SystemException, SecurityException,
-         IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+      protected void txAction() throws RepositoryException
       {
          super.txAction();
 

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java	2010-01-19 23:30:39 UTC (rev 1492)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java	2010-01-20 00:45:17 UTC (rev 1493)
@@ -62,16 +62,16 @@
     * Action will runs in dedicated XA transaction, i.e. only JCR storage stuff will be involved to.
     * But if it's a nested isolated operation it will run the action assuming the same (current, active) transaction.
     * 
-    * @throws SystemException if XA unexpected error
-    * @throws NotSupportedException if unsupported XA operation
-    * @throws HeuristicRollbackException if all relevant updates have been rolled back on commit
-    * @throws HeuristicMixedException if some relevant updates have been committed and others have been rolled back on commit
-    * @throws RollbackException rollback error
-    * @throws IllegalStateException if thread is not associated with a transaction
-    * @throws SecurityException if thread is not allowed to commit the transaction
+    * @throws RepositoryException if error occurs 
     */
-   protected void txAction() throws RepositoryException, NotSupportedException, SystemException, SecurityException,
-      IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+   //   * @throws SystemException if XA unexpected error
+   //   * @throws NotSupportedException if unsupported XA operation
+   //   * @throws HeuristicRollbackException if all relevant updates have been rolled back on commit
+   //   * @throws HeuristicMixedException if some relevant updates have been committed and others have been rolled back on commit
+   //   * @throws RollbackException rollback performed
+   //   * @throws IllegalStateException if thread is not associated with a transaction
+   //   * @throws SecurityException if thread is not allowed to commit the transaction   
+   protected void txAction() throws RepositoryException
    {
       final boolean actInTx = currentIsolated.get() == null;
       if (actInTx)
@@ -91,9 +91,67 @@
 
             action();
 
-            commitTx();
+            try
+            {
+               commitTx();
+            }
+            catch (RollbackException e)
+            {
+               // Indicate that the transaction has been rolled back rather than committed.
+               throw new RepositoryException(e);
+            }
+            catch (HeuristicRollbackException e)
+            {
+               // if all relevant updates have been rolled back on commit
+               throw new RepositoryException(e);
+            }
+            catch (HeuristicMixedException e)
+            {
+               // if some relevant updates have been committed and others have been rolled back on commit
+               // TODO partial commit - got inconsistency. rollback not possible?
+               // doRollback();
+               throw new RepositoryException(e);
+            }
+            catch (IllegalStateException e)
+            {
+               // if thread is not associated with a transaction
+               // TODO can we do rollback if not in the tx thread?
+               // doRollback();
+               throw new RepositoryException(e);
+            }
+            catch (SecurityException e)
+            {
+               // if thread is not allowed to commit the transaction
+               // TODO can we do the rollback, will it have a rights?
+               // doRollback();               
+               throw new RepositoryException(e);
+            }
+            catch (SystemException e)
+            {
+               // if XA unexpected error
+               // TODO rollback not possible?
+               // doRollback();
+               throw new RepositoryException(e);
+            }
+            finally
+            {
+               rollback = false;
+            }
+         }
+         catch (NotSupportedException e)
+         {
+            // if unsupported XA operation: nested transaction
             rollback = false;
+            doRollback();
+            throw new RepositoryException(e);
          }
+         catch (SystemException e)
+         {
+            // if XA unexpected error on begin or get transaction
+            rollback = false;
+            doRollback();
+            throw new RepositoryException("Unexpected error on begin or get of a transaction", e);
+         }
          finally
          {
             if (rollback)
@@ -145,11 +203,11 @@
          {
             txAction();
          }
-         catch (RollbackException e)
-         {
-            // Indicate that the transaction has been rolled back rather than committed.
-            throw new RepositoryException(actionError = e);
-         }
+         //         catch (RollbackException e)
+         //         {
+         //            // Indicate that the transaction has been rolled back rather than committed.
+         //            throw new RepositoryException(actionError = e);
+         //         }
          catch (JCRInvalidItemStateException e)
          {
             throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), actionError = e);
@@ -222,67 +280,5 @@
       {
          throw new RepositoryException("Error of Transaction suspend", e);
       }
-
-      // TODO to do not commit in curr thread (i.e. curr tx)
-      //         try
-      //         {
-      //            if (transactionManager.getStatus() == Status.STATUS_COMMITTING)
-      //            {
-      //               // The JCR session has been enrolled into a XA Transaction, the method applyChanges must be called in another thread since the operations
-      //               // that we do into the cache are not allowed within the current Transaction, so to do it in another Transaction we need to call the method
-      //               // from another Thread
-      //               final AtomicReference<Exception> exception = new AtomicReference<Exception>();
-      //               final CountDownLatch doneSignal = new CountDownLatch(1);
-      //               Thread t = new Thread()
-      //               {
-      //                  public void run()
-      //                  {
-      //                     try
-      //                     {
-      //                        applyChanges(changesLog);
-      //                     }
-      //                     catch (Exception e)
-      //                     {
-      //                        exception.set(e);
-      //                     }
-      //                     finally
-      //                     {
-      //                        doneSignal.countDown();
-      //                     }
-      //                  }
-      //               };
-      //               t.start();
-      //               doneSignal.await();
-      //               Exception e = exception.get();
-      //               if (e != null)
-      //               {
-      //                  if (e instanceof RepositoryException)
-      //                  {
-      //                     throw (RepositoryException)e;                     
-      //                  }
-      //                  else
-      //                  {
-      //                     throw new RuntimeException(e);
-      //                  }
-      //               }
-      //            }
-      //            else
-      //            {
-      //               // Normal Transaction
-      //               applyChanges(changesLog);
-      //            }
-      //         }
-      //         catch (RepositoryException e)
-      //         {
-      //            throw e;
-      //         }
-      //         catch (InterruptedException e)
-      //         {
-      //            throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
-      //         }
-      //         catch (SystemException e)
-      //         {
-      //            throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
-      //         }
    }
 }



More information about the exo-jcr-commits mailing list