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

@@ -42,8 +42,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.sandbox.SandboxConstants;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
@@ -170,16 +169,15 @@ public class AVMExpiredContentProcessor
{
public String doWork() throws Exception
{
TransactionWork<String> expiredContentWork = new TransactionWork<String>()
RetryingTransactionCallback<String> expiredContentWork = new RetryingTransactionCallback<String>()
{
public String doWork() throws Exception
public String execute() throws Exception
{
processExpiredContent();
return null;
}
};
return TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, expiredContentWork);
return transactionService.getRetryingTransactionHelper().doInTransaction(expiredContentWork);
}
};

View File

@@ -56,7 +56,7 @@ import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMCycleException;
import org.alfresco.service.cmr.avm.AVMException;
@@ -68,11 +68,8 @@ import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
import org.alfresco.service.cmr.avm.locking.AVMLockingException;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.remote.RepoRemote;
import org.alfresco.service.cmr.repository.ContentData;
@@ -1081,17 +1078,17 @@ public class AVMServiceTest extends AVMServiceTestBase
action.setParameterValue(AVMRevertToVersionAction.TOREVERT, toRevert);
final AVMRevertToVersionAction revert = (AVMRevertToVersionAction) fContext
.getBean("avm-revert-to-version");
class TxnWork implements TransactionUtil.TransactionWork<Object>
class TxnWork implements RetryingTransactionCallback<Object>
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
revert.execute(action, AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c/foo"));
return null;
}
}
;
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"),
new TxnWork());
};
TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
results = searchService.query(storeRef, "lucene", "TEXT:\"HEAD\"");
assertEquals(0, results.length());
results.close();
@@ -1774,17 +1771,17 @@ public class AVMServiceTest extends AVMServiceTestBase
action.setParameterValue(AVMRevertListAction.PARAM_VERSION, fService.getLatestSnapshotID("area"));
action.setParameterValue(AVMRevertListAction.PARAM_NODE_LIST, (Serializable) paths);
final AVMRevertListAction revert = (AVMRevertListAction) fContext.getBean("avm-revert-list");
class TxnWork implements TransactionUtil.TransactionWork<Object>
class TxnWork implements RetryingTransactionCallback<Object>
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
revert.execute(action, null);
return null;
}
}
;
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"),
new TxnWork());
};
TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
assertEquals(0, diffs.size());
System.out.println(recursiveList("area", -1, true));
@@ -1819,17 +1816,17 @@ public class AVMServiceTest extends AVMServiceTestBase
versionPaths.add(new Pair<Integer, String>(-1, "area:/a/b/c/bar"));
action.setParameterValue(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable) versionPaths);
final AVMUndoSandboxListAction revert = (AVMUndoSandboxListAction) fContext.getBean("avm-undo-list");
class TxnWork implements TransactionUtil.TransactionWork<Object>
class TxnWork implements RetryingTransactionCallback<Object>
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
revert.execute(action, null);
return null;
}
}
;
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"),
new TxnWork());
};
TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
assertEquals(0, diffs.size());
System.out.println(recursiveList("area", -1, true));
@@ -1862,18 +1859,18 @@ public class AVMServiceTest extends AVMServiceTestBase
+ JNDIConstants.DIR_DEFAULT_WWW + "/a"), GUID.generate(), SimpleAVMPromoteAction.NAME);
action.setParameterValue(SimpleAVMPromoteAction.PARAM_TARGET_STORE, "main");
final SimpleAVMPromoteAction promote = (SimpleAVMPromoteAction) fContext.getBean("simple-avm-promote");
class TxnWork implements TransactionUtil.TransactionWork<Object>
class TxnWork implements RetryingTransactionCallback<Object>
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
promote.execute(action, AVMNodeConverter.ToNodeRef(-1, "source:/"
+ JNDIConstants.DIR_DEFAULT_WWW + "/a"));
return null;
}
}
;
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"),
new TxnWork());
};
TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
assertEquals(0, fSyncService.compare(-1, "source:/" + JNDIConstants.DIR_DEFAULT_WWW, -1,
"main:/" + JNDIConstants.DIR_DEFAULT_WWW, null).size());
}
@@ -1935,18 +1932,17 @@ public class AVMServiceTest extends AVMServiceTestBase
"foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW, null);
assertEquals(3, diffs.size());
final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction) fContext.getBean("simple-avm-submit");
class TxnWork implements TransactionUtil.TransactionWork<Object>
class TxnWork implements RetryingTransactionCallback<Object>
{
public Object doWork() throws Exception
public Object execute() throws Exception
{
action.execute(null, AVMNodeConverter.ToNodeRef(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW));
return null;
}
}
;
TxnWork worker = new TxnWork();
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"),
worker);
};
TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
diffs = fSyncService.compare(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW, -1, "foo-staging:/"
+ JNDIConstants.DIR_DEFAULT_WWW, null);
@@ -5355,7 +5351,7 @@ public class AVMServiceTest extends AVMServiceTestBase
try
{
setupBasicTree();
class TxnCallback implements RetryingTransactionHelper.RetryingTransactionCallback
class TxnCallback implements RetryingTransactionHelper.RetryingTransactionCallback<Object>
{
public Object execute()
{
@@ -5412,8 +5408,8 @@ public class AVMServiceTest extends AVMServiceTestBase
}
}
}
RetryingTransactionHelper helper = (RetryingTransactionHelper) fContext
.getBean("retryingTransactionHelper");
TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
RetryingTransactionHelper helper = transactionService.getRetryingTransactionHelper();
helper.doInTransaction(new TxnCallback(), false);
assertNotNull(fService.lookup(-1, "main:/layer/b/c/groo"));
}

View File

@@ -23,7 +23,7 @@
package org.alfresco.repo.avm;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService;
/**
@@ -73,16 +73,14 @@ public class Issuer
*/
public void initialize()
{
class TxnWork implements TransactionUtil.TransactionWork<Long>
class TxnWork implements RetryingTransactionCallback<Long>
{
public Long doWork() throws Exception
public Long execute() throws Exception
{
return AVMDAOs.Instance().fIssuerDAO.getIssuerValue(fName);
}
}
Long result = TransactionUtil.executeInUserTransaction(fTransactionService,
new TxnWork(),
true);
Long result = fTransactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork(), true);
if (result == null)
{
fNext = 0L;

View File

@@ -27,7 +27,7 @@ import java.util.LinkedList;
import java.util.List;
import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService;
import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
@@ -242,9 +242,9 @@ public class OrphanReaper
*/
public void doBatch()
{
class TxnWork implements TransactionUtil.TransactionWork<Object>
class TxnWork implements RetryingTransactionCallback<Object>
{
public Object doWork()
public Object execute()
throws Exception
{
if (fPurgeQueue == null)
@@ -341,8 +341,7 @@ public class OrphanReaper
}
try
{
TransactionUtil.executeInUserTransaction(fTransactionService,
new TxnWork());
fTransactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
}
catch (Exception e)
{