public class ReplicatingContentStore extends AbstractContentStore
A content store implementation that is able to replicate content between stores.
Content is not persisted by this store, but rather it relies on any number of
child stores to provide access to
content readers and writers.
The order in which the stores appear in the list of stores participating is important. The first store in the list is known as the primary store. When the replicator goes to fetch content, the stores are searched from first to last. The stores should therefore be arranged in order of speed.
It supports the notion of inbound and/or outbound replication, both of which can be operational at the same time. Outbound Replication
When this is enabled, then the primary store is used for writes. When the content write completes (i.e. the write channel is closed) then the content is synchronously copied to all other stores. The write is therefore slowed down, but the content replication will occur in-transaction.
The outboundThreadPoolExecutor
property to enable asynchronous replication.
With asynchronous replication, there is always a risk that a failure
occurs during the replication. Depending on the configuration of the server,
further action may need to be taken to rectify the problem manually.
Inbound Replication
This can be used to lazily replicate content onto the primary store. When
content can't be found in the primary store, the other stores are checked
in order. If content is found, then it is copied into the local store
before being returned. Subsequent accesses will use the primary store.
This should be used where the secondary stores are much slower, such as in
the case of a store against some kind of archival mechanism.
Content is written to the primary store only. The other stores are only used to retrieve content and the primary store is not updated with the content.
CachingContentStore| Modifier and Type | Class and Description |
|---|---|
static class |
ReplicatingContentStore.ReplicatingWriteListener
Replicates the content upon stream closure.
|
ContentStore.ContentUrlHandlercontentLimitProviderNEW_CONTENT_CONTEXT, PROTOCOL_DELIMITER| Constructor and Description |
|---|
ReplicatingContentStore()
Default constructor set
inbound = false and outbound = true; |
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete(java.lang.String contentUrl)
Performs a delete on the local store and if outbound replication is on, propogates
the delete to the other stores too.
|
org.alfresco.service.cmr.repository.ContentReader |
getReader(java.lang.String contentUrl)
Forwards the call directly to the first store in the list of stores.
|
java.lang.String |
getRootLocation()
Get the location where the store is rooted.
|
void |
getUrls(java.util.Date createdAfter,
java.util.Date createdBefore,
ContentStore.ContentUrlHandler handler)
Iterates over results as given by the primary store and all secondary stores.
|
org.alfresco.service.cmr.repository.ContentWriter |
getWriter(ContentContext ctx)
An implementation that does some sanity checking before requesting a writer from the
store.
|
boolean |
isContentUrlSupported(java.lang.String contentUrl)
Override this method to supply a efficient and direct check of the URL supplied.
|
boolean |
isWriteSupported()
Check if the store supports write requests.
|
void |
setInbound(boolean inbound)
Set whether or not this component should replicate content to the
primary store if not found.
|
void |
setOutbound(boolean outbound)
Set whether or not this component should replicate content to all stores
as it is written.
|
void |
setOutboundThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor outboundThreadPoolExecutor)
Set the thread pool executer
|
void |
setPrimaryStore(ContentStore primaryStore)
Set the primary store that content will be replicated to or from
|
void |
setRetryingTransactionHelper(RetryingTransactionHelper helper)
Set the retrying transaction helper.
|
void |
setSecondaryStores(java.util.List secondaryStores)
Set the secondary stores that this component will replicate to or from
|
void |
setTransactionService(TransactionService transactionService)
Deprecated.
|
exists, getContentUrlParts, getSpaceFree, getSpaceTotal, getSpaceUsed, getTotalSize, getUrls, getWriter, getWriterInternal, isValidContentUrl, setContentLimitProviderpublic ReplicatingContentStore()
inbound = false and outbound = true;public void setTransactionService(TransactionService transactionService)
ReplicatingContentStore.setRetryingTransactionHelper(RetryingTransactionHelper)public void setRetryingTransactionHelper(RetryingTransactionHelper helper)
public void setPrimaryStore(ContentStore primaryStore)
primaryStore - the primary content storepublic void setSecondaryStores(java.util.List secondaryStores)
stores - a list of stores to replicate to or frompublic void setInbound(boolean inbound)
inbound - true to pull content onto the primary store when found
on one of the other storespublic void setOutbound(boolean outbound)
outbound - true to enable synchronous replication to all storespublic void setOutboundThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor outboundThreadPoolExecutor)
outboundThreadPoolExecutor - set this to have the synchronization occur in a separate
threadpublic boolean isWriteSupported()
ContentStorepublic boolean isContentUrlSupported(java.lang.String contentUrl)
AbstractContentStoreContentStore.getReader(String)
throws the UnsupportedContentUrlException exception.isContentUrlSupported in interface ContentStoreisContentUrlSupported in class AbstractContentStorecontentUrl - the content URL to checkpublic java.lang.String getRootLocation()
AbstractContentStoregetRootLocation in interface ContentStoregetRootLocation in class AbstractContentStorepublic org.alfresco.service.cmr.repository.ContentReader getReader(java.lang.String contentUrl)
throws org.alfresco.service.cmr.repository.ContentIOException
contentUrl - the path to where the content is locatedorg.alfresco.service.cmr.repository.ContentIOException - if an IO error occursContentStore.exists(String),
ContentReader.exists(),
EmptyContentReaderpublic org.alfresco.service.cmr.repository.ContentWriter getWriter(ContentContext ctx)
AbstractContentStoreAbstractContentStore.getWriterInternal(ContentReader, String) must be supplied.getWriter in interface ContentStoregetWriter in class AbstractContentStorectx - the context of content.AbstractContentStore.getWriterInternal(ContentReader, String)public boolean delete(java.lang.String contentUrl)
throws org.alfresco.service.cmr.repository.ContentIOException
delete in interface ContentStoredelete in class AbstractContentStorecontentUrl - the URL of the content to deleteorg.alfresco.service.cmr.repository.ContentIOException - if an error occurs
if an IO error occurspublic void getUrls(java.util.Date createdAfter,
java.util.Date createdBefore,
ContentStore.ContentUrlHandler handler)
throws org.alfresco.service.cmr.repository.ContentIOException
getUrls in interface ContentStoregetUrls in class AbstractContentStorecreatedAfter - all URLs returned must have been created after this date. May be null.createdBefore - all URLs returned must have been created before this date. May be null.handler - the callback that will passed each URLorg.alfresco.service.cmr.repository.ContentIOException - if an error occursCopyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.