mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Renamed RetryingTransaction to RetryingTransactionHelper, HibernateRetryingTransaction
to HibernateRetryingTransactionHelper. Changed propagation mode of AVM transactions to PROPAGATION_REQUIRED and tweaked to not retry in a transaction that wasn't started locally. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3389 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -44,7 +44,7 @@ class AVMServiceImpl implements AVMService
|
||||
/**
|
||||
* The RetryingTransaction.
|
||||
*/
|
||||
private RetryingTransaction fTransaction;
|
||||
private RetryingTransactionHelper fTransaction;
|
||||
|
||||
/**
|
||||
* The AVMRepository for each service thread.
|
||||
@@ -94,7 +94,7 @@ class AVMServiceImpl implements AVMService
|
||||
* Set the Retrying Transaction wrapper.
|
||||
* @param txn
|
||||
*/
|
||||
public void setRetryingTransaction(RetryingTransaction txn)
|
||||
public void setRetryingTransaction(RetryingTransactionHelper txn)
|
||||
{
|
||||
fTransaction = txn;
|
||||
}
|
||||
|
@@ -26,16 +26,15 @@ import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.orm.hibernate3.HibernateTemplate;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
/**
|
||||
* Helper for DAOs.
|
||||
* @author britt
|
||||
*/
|
||||
class HibernateRetryingTransaction extends HibernateTemplate implements RetryingTransaction
|
||||
class HibernateRetryingTransactionHelper extends HibernateTemplate implements RetryingTransactionHelper
|
||||
{
|
||||
private static Logger fgLogger = Logger.getLogger(HibernateRetryingTransaction.class);
|
||||
private static Logger fgLogger = Logger.getLogger(HibernateRetryingTransactionHelper.class);
|
||||
|
||||
/**
|
||||
* The transaction manager.
|
||||
@@ -61,7 +60,7 @@ class HibernateRetryingTransaction extends HibernateTemplate implements Retrying
|
||||
* Make one up.
|
||||
* @param sessionFactory The SessionFactory.
|
||||
*/
|
||||
HibernateRetryingTransaction()
|
||||
HibernateRetryingTransactionHelper()
|
||||
{
|
||||
fRandom = new Random();
|
||||
}
|
||||
@@ -77,12 +76,17 @@ class HibernateRetryingTransaction extends HibernateTemplate implements Retrying
|
||||
while (true)
|
||||
{
|
||||
TransactionStatus status = null;
|
||||
boolean newTxn = true;
|
||||
try
|
||||
{
|
||||
status =
|
||||
fTransactionManager.getTransaction(write ? fWriteDefinition : fReadDefinition);
|
||||
newTxn = status.isNewTransaction();
|
||||
execute(new HibernateCallbackWrapper(callback));
|
||||
fTransactionManager.commit(status);
|
||||
if (newTxn)
|
||||
{
|
||||
fTransactionManager.commit(status);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (Throwable t)
|
||||
@@ -96,6 +100,10 @@ class HibernateRetryingTransaction extends HibernateTemplate implements Retrying
|
||||
{
|
||||
fTransactionManager.rollback(status);
|
||||
}
|
||||
if (!newTxn)
|
||||
{
|
||||
throw new AVMException("Unrecoverable error.", t);
|
||||
}
|
||||
// If we've lost a race or we've deadlocked, retry.
|
||||
if (t instanceof DeadlockLoserDataAccessException)
|
||||
{
|
@@ -36,7 +36,7 @@ class Issuer
|
||||
/**
|
||||
* The transactional wrapper.
|
||||
*/
|
||||
private RetryingTransaction fTransaction;
|
||||
private RetryingTransactionHelper fTransaction;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -58,7 +58,7 @@ class Issuer
|
||||
* Set the transactional wrapper.
|
||||
* @param retryingTransaction The transactional wrapper.
|
||||
*/
|
||||
public void setRetryingTransaction(RetryingTransaction retryingTransaction)
|
||||
public void setRetryingTransaction(RetryingTransactionHelper retryingTransaction)
|
||||
{
|
||||
fTransaction = retryingTransaction;
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ class OrphanReaper implements Runnable
|
||||
/**
|
||||
* The HibernateTxn instance.
|
||||
*/
|
||||
private RetryingTransaction fTransaction;
|
||||
private RetryingTransactionHelper fTransaction;
|
||||
|
||||
/**
|
||||
* Inactive base sleep interval.
|
||||
@@ -111,7 +111,7 @@ class OrphanReaper implements Runnable
|
||||
* Set the Hibernate Transaction Wrapper.
|
||||
* @param transaction
|
||||
*/
|
||||
public void setRetryingTransaction(RetryingTransaction transaction)
|
||||
public void setRetryingTransaction(RetryingTransactionHelper transaction)
|
||||
{
|
||||
fTransaction = transaction;
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ package org.alfresco.repo.avm;
|
||||
* when a transaction fails for synchronization reasons.
|
||||
* @author britt
|
||||
*/
|
||||
interface RetryingTransaction
|
||||
interface RetryingTransactionHelper
|
||||
{
|
||||
/**
|
||||
* Perform a set of operations under a single transaction.
|
Reference in New Issue
Block a user