mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -37,8 +37,7 @@ import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||
import org.alfresco.repo.dictionary.M2Model;
|
||||
import org.alfresco.repo.node.integrity.IntegrityChecker;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
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.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
@@ -109,9 +108,9 @@ public class PerformanceNodeServiceTest extends TestCase
|
||||
contentService = (ContentService) applicationContext.getBean("contentService");
|
||||
|
||||
// create a first store directly
|
||||
TransactionWork<NodeRef> createStoreWork = new TransactionWork<NodeRef>()
|
||||
RetryingTransactionCallback<NodeRef> createStoreWork = new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef doWork()
|
||||
public NodeRef execute()
|
||||
{
|
||||
StoreRef storeRef = nodeService.createStore(
|
||||
StoreRef.PROTOCOL_WORKSPACE,
|
||||
@@ -119,7 +118,7 @@ public class PerformanceNodeServiceTest extends TestCase
|
||||
return nodeService.getRootNode(storeRef);
|
||||
}
|
||||
};
|
||||
rootNodeRef = TransactionUtil.executeInUserTransaction(txnService, createStoreWork);
|
||||
rootNodeRef = txnService.getRetryingTransactionHelper().doInTransaction(createStoreWork);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,16 +164,16 @@ public class PerformanceNodeServiceTest extends TestCase
|
||||
startTime = System.currentTimeMillis();
|
||||
|
||||
// ensure that we execute the node tree building in a transaction
|
||||
TransactionWork<Object> buildChildrenWork = new TransactionWork<Object>()
|
||||
RetryingTransactionCallback<Object> buildChildrenWork = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
public Object execute()
|
||||
{
|
||||
IntegrityChecker.setWarnInTransaction();
|
||||
buildNodeChildren(rootNodeRef, 1, testDepth, testChildCount);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
TransactionUtil.executeInUserTransaction(txnService, buildChildrenWork);
|
||||
txnService.getRetryingTransactionHelper().doInTransaction(buildChildrenWork);
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
@@ -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
|
||||
}
|
||||
}
|
@@ -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
|
||||
|
@@ -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())
|
||||
{
|
||||
|
Reference in New Issue
Block a user