More for AR-460: System concurrency

There might be a few SDK projects that still use TransactionUtil, but this checkin gets rid of
its use otherwise.
I took a glance over the areas of the code that use UserTransaction directly and didn't see any
transactionally wrapped code that desperately needed to be put into a retry loop (i.e. write
transactions in a concurrent scenario).  If you spot any that you think might qualify, let me know.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6220 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-07-12 04:15:28 +00:00
parent 32054c773c
commit 0d1bd57217
31 changed files with 230 additions and 286 deletions

View File

@@ -4,8 +4,7 @@ import java.util.List;
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.apache.commons.logging.Log;
@@ -199,9 +198,9 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
logger.debug("Reindexing avm store: " + store + " snapshot id " + id);
}
TransactionWork<Object> reindexWork = new TransactionWork<Object>()
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
if (!avmSnapShotTriggeredIndexingMethodInterceptor.isSnapshotIndexed(store, id))
{
@@ -211,7 +210,7 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
return null;
}
};
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork, true);
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
// done
}

View File

@@ -39,8 +39,7 @@ import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -210,15 +209,15 @@ public abstract class AbstractReindexComponent implements IndexRecovery
auth = AuthenticationUtil.getCurrentAuthentication();
// authenticate as the system user
authenticationComponent.setSystemUserAsCurrentUser();
TransactionWork<Object> reindexWork = new TransactionWork<Object>()
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
reindexImpl();
return null;
}
};
TransactionUtil.executeInUserTransaction(transactionService, reindexWork);
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork);
}
finally
{
@@ -426,9 +425,9 @@ public abstract class AbstractReindexComponent implements IndexRecovery
logger.debug("Reindexing transaction: " + txnId);
}
TransactionWork<Object> reindexWork = new TransactionWork<Object>()
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
// get the node references pertinent to the transaction
List<NodeRef> nodeRefs = nodeDaoService.getTxnChanges(txnId);
@@ -461,7 +460,7 @@ public abstract class AbstractReindexComponent implements IndexRecovery
return null;
}
};
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork, true);
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
// done
}
}

View File

@@ -29,8 +29,7 @@ import java.util.List;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.Transaction;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeRef.Status;
@@ -243,9 +242,9 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
logger.debug("Reindexing transaction: " + txnId);
}
TransactionWork<Object> reindexWork = new TransactionWork<Object>()
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
// get the node references pertinent to the transaction
List<NodeRef> nodeRefs = nodeDaoService.getTxnChanges(txnId);
@@ -278,7 +277,7 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
return null;
}
};
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork, true);
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
// done
}
}

View File

@@ -33,8 +33,7 @@ import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -95,9 +94,9 @@ public class IndexRemoteTransactionTrackerTest extends TestCase
authenticationComponent.setSystemUserAsCurrentUser();
// disable indexing
TransactionWork<ChildAssociationRef> createNodeWork = new TransactionWork<ChildAssociationRef>()
RetryingTransactionCallback<ChildAssociationRef> createNodeWork = new RetryingTransactionCallback<ChildAssociationRef>()
{
public ChildAssociationRef doWork() throws Exception
public ChildAssociationRef execute() throws Exception
{
StoreRef storeRef = new StoreRef("test", getName() + "-" + System.currentTimeMillis());
NodeRef rootNodeRef = null;
@@ -117,7 +116,7 @@ public class IndexRemoteTransactionTrackerTest extends TestCase
return childAssocRef;
}
};
ChildAssociationRef childAssocRef = TransactionUtil.executeInUserTransaction(transactionService, createNodeWork);
ChildAssociationRef childAssocRef = transactionService.getRetryingTransactionHelper().doInTransaction(createNodeWork);
}
public void testSetup() throws Exception

View File

@@ -27,8 +27,7 @@ package org.alfresco.repo.node.index;
import java.util.List;
import org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
@@ -113,15 +112,15 @@ public class MissingContentReindexComponent extends AbstractReindexComponent
{
final NodeRef childNodeRef = row.getNodeRef();
// prompt for a reindex - it might fail again, but we just keep plugging away
TransactionWork<Object> reindexWork = new TransactionWork<Object>()
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object doWork()
public Object execute()
{
indexer.updateNode(childNodeRef);
return null;
}
};
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork);
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork);
// check if we have to break out
if (isShuttingDown())
{