org.alfresco.repo.content.replication
Class ReplicatingContentStore

java.lang.Object
  extended by org.alfresco.repo.content.AbstractContentStore
      extended by org.alfresco.repo.content.replication.ReplicatingContentStore
All Implemented Interfaces:
ContentStore

public class ReplicatingContentStore
extends AbstractContentStore

Replicating Content Store

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.

No Replication

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.


Nested Class Summary
static class ReplicatingContentStore.ReplicatingWriteListener
          Replicates the content upon stream closure.
 
Nested classes/interfaces inherited from interface org.alfresco.repo.content.ContentStore
ContentStore.ContentUrlHandler
 
Field Summary
 
Fields inherited from interface org.alfresco.repo.content.ContentStore
NEW_CONTENT_CONTEXT, PROTOCOL_DELIMITER
 
Constructor Summary
ReplicatingContentStore()
          Default constructor set inbound = false and outbound = true;
 
Method Summary
 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.
 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. Replaced with ReplicatingContentStore.setRetryingTransactionHelper(RetryingTransactionHelper)
 
Methods inherited from class org.alfresco.repo.content.AbstractContentStore
exists, getContentUrlParts, getRootLocation, getSpaceFree, getSpaceTotal, getSpaceUsed, getTotalSize, getUrls, getWriter, getWriterInternal, isValidContentUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicatingContentStore

public ReplicatingContentStore()
Default constructor set inbound = false and outbound = true;

Method Detail

setTransactionService

public void setTransactionService(TransactionService transactionService)
Deprecated. Replaced with ReplicatingContentStore.setRetryingTransactionHelper(RetryingTransactionHelper)


setRetryingTransactionHelper

public void setRetryingTransactionHelper(RetryingTransactionHelper helper)
Set the retrying transaction helper.

Since:
2.0

setPrimaryStore

public void setPrimaryStore(ContentStore primaryStore)
Set the primary store that content will be replicated to or from

Parameters:
primaryStore - the primary content store

setSecondaryStores

public void setSecondaryStores(java.util.List secondaryStores)
Set the secondary stores that this component will replicate to or from

Parameters:
stores - a list of stores to replicate to or from

setInbound

public void setInbound(boolean inbound)
Set whether or not this component should replicate content to the primary store if not found.

Parameters:
inbound - true to pull content onto the primary store when found on one of the other stores

setOutbound

public void setOutbound(boolean outbound)
Set whether or not this component should replicate content to all stores as it is written.

Parameters:
outbound - true to enable synchronous replication to all stores

setOutboundThreadPoolExecutor

public void setOutboundThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor outboundThreadPoolExecutor)
Set the thread pool executer

Parameters:
outboundThreadPoolExecutor - set this to have the synchronization occur in a separate thread

isWriteSupported

public boolean isWriteSupported()
Description copied from interface: ContentStore
Check if the store supports write requests.

Returns:
Returns true if the primary store supports writing

isContentUrlSupported

public boolean isContentUrlSupported(java.lang.String contentUrl)
Description copied from class: AbstractContentStore
Override this method to supply a efficient and direct check of the URL supplied. The default implementation checks whether ContentStore.getReader(String) throws the UnsupportedContentUrlException exception.

Specified by:
isContentUrlSupported in interface ContentStore
Overrides:
isContentUrlSupported in class AbstractContentStore
Parameters:
contentUrl - the content URL to check
Returns:
Returns true if the primary store supports the URL

getReader

public org.alfresco.service.cmr.repository.ContentReader getReader(java.lang.String contentUrl)
                                                            throws org.alfresco.service.cmr.repository.ContentIOException
Forwards the call directly to the first store in the list of stores.

Parameters:
contentUrl - the path to where the content is located
Returns:
Returns a read-only content accessor for the given URL. There may be no content at the given URL, but the reader must still be returned.
Throws:
org.alfresco.service.cmr.repository.ContentIOException - if an IO error occurs
See Also:
ContentStore.exists(String), ContentReader.exists(), EmptyContentReader

getWriter

public org.alfresco.service.cmr.repository.ContentWriter getWriter(ContentContext ctx)
Description copied from class: AbstractContentStore
An implementation that does some sanity checking before requesting a writer from the store. If this method is not overridden, then an implementation of AbstractContentStore.getWriterInternal(ContentReader, String) must be supplied.

Specified by:
getWriter in interface ContentStore
Overrides:
getWriter in class AbstractContentStore
Parameters:
ctx - the context of content.
Returns:
Returns a write-only content accessor
See Also:
AbstractContentStore.getWriterInternal(ContentReader, String)

delete

public boolean delete(java.lang.String contentUrl)
               throws org.alfresco.service.cmr.repository.ContentIOException
Performs a delete on the local store and if outbound replication is on, propogates the delete to the other stores too.

Specified by:
delete in interface ContentStore
Overrides:
delete in class AbstractContentStore
Parameters:
contentUrl - the URL of the content to delete
Returns:
Returns the value returned by the delete on the primary store.
Throws:
org.alfresco.service.cmr.repository.ContentIOException - if an error occurs if an IO error occurs

getUrls

public void getUrls(java.util.Date createdAfter,
                    java.util.Date createdBefore,
                    ContentStore.ContentUrlHandler handler)
             throws org.alfresco.service.cmr.repository.ContentIOException
Iterates over results as given by the primary store and all secondary stores. It is up to the handler to eliminate duplicates that will occur between the primary and secondary stores.

Specified by:
getUrls in interface ContentStore
Overrides:
getUrls in class AbstractContentStore
Parameters:
createdAfter - 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 URL
Throws:
org.alfresco.service.cmr.repository.ContentIOException - if an error occurs


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.