Refinements to RetryingTransactionHelper to make it equivalent to

executeInUserTransaction().
Changed the on close callback for write listeners to use a RetryingTransaction.
The point of this exercise is to make it possible for clients of the core server
to ignore transient resource contention failures.  CIFS, for example, will be able 
to take advantage of this, since a transient error condition currently results in a dead
share.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4597 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-12-13 17:03:44 +00:00
parent 4834c89f5a
commit e76fc329b6
10 changed files with 172 additions and 68 deletions

View File

@@ -23,7 +23,6 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.ContentServicePolicies.OnContentReadPolicy;
import org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy;
@@ -34,6 +33,7 @@ import org.alfresco.repo.content.transform.magick.ImageMagickContentTransformer;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
@@ -73,6 +73,7 @@ public class RoutingContentService implements ContentService
private DictionaryService dictionaryService;
private NodeService nodeService;
private AVMService avmService;
private RetryingTransactionHelper transactionHelper;
/** a registry of all available content transformers */
private ContentTransformerRegistry transformerRegistry;
@@ -106,6 +107,11 @@ public class RoutingContentService implements ContentService
this.transactionService = transactionService;
}
public void setRetryingTransactionHelper(RetryingTransactionHelper helper)
{
this.transactionHelper = helper;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
@@ -356,9 +362,9 @@ public class RoutingContentService implements ContentService
if (update)
{
// need a listener to update the node when the stream closes
WriteStreamListener listener = new WriteStreamListener(nodeService, nodeRef, propertyQName, writer);
WriteStreamListener listener = new WriteStreamListener(nodeService, avmService, nodeRef, propertyQName, writer);
writer.addListener(listener);
writer.setTransactionService(transactionService);
writer.setRetryingTransactionHelper(transactionHelper);
}
// give back to the client
@@ -458,17 +464,20 @@ public class RoutingContentService implements ContentService
private static class WriteStreamListener implements ContentStreamListener
{
private NodeService nodeService;
private AVMService avmService;
private NodeRef nodeRef;
private QName propertyQName;
private ContentWriter writer;
public WriteStreamListener(
NodeService nodeService,
AVMService avmService,
NodeRef nodeRef,
QName propertyQName,
ContentWriter writer)
{
this.nodeService = nodeService;
this.avmService = avmService;
this.nodeRef = nodeRef;
this.propertyQName = propertyQName;
this.writer = writer;
@@ -480,10 +489,19 @@ public class RoutingContentService implements ContentService
{
// set the full content property
ContentData contentData = writer.getContentData();
nodeService.setProperty(
// Bypass NodeService for avm stores.
if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
Pair<Integer, String> versionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
avmService.setContentData(versionPath.getSecond(), contentData);
}
else
{
nodeService.setProperty(
nodeRef,
propertyQName,
contentData);
}
// done
if (logger.isDebugEnabled())
{