mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged V2.2 to HEAD
8372: Merged V2.1 to V2.2 8314: Merged V2.0 to V2.1 7750: Fix for ACT-475: ContentStoreCleaner causes OutOfMemoryError 8332: Made content URL column larger to accommodate the extra locale info present in 2.1 8334: Build fix: V2.1 tighter on authentication for getTempWriter 8376: Merged V2.1 to V2.2 8325: Fix for AWC-1089 8361: Workaround for WCM-882: All metadata extracters can now handle zero length files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8497 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,9 +24,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.content.replication;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.content.ContentStore.ContentUrlHandler;
|
||||
import org.alfresco.repo.node.index.IndexRecovery;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
@@ -149,23 +148,28 @@ public class ContentStoreReplicator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler that does the actual replication
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 2.0
|
||||
*/
|
||||
private class ReplicatingHandler implements ContentUrlHandler
|
||||
{
|
||||
public void handle(String contentUrl)
|
||||
{
|
||||
replicate(contentUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a full replication of all source to target URLs.
|
||||
*/
|
||||
private void replicate()
|
||||
{
|
||||
// get all the URLs from the source
|
||||
Set<String> sourceUrls = sourceStore.getUrls();
|
||||
// get all the URLs from the target
|
||||
Set<String> targetUrls = targetStore.getUrls();
|
||||
// remove source URLs that are present in the target
|
||||
sourceUrls.removeAll(targetUrls);
|
||||
|
||||
// ensure that each remaining source URL is present in the target
|
||||
for (String contentUrl : sourceUrls)
|
||||
{
|
||||
replicate(contentUrl);
|
||||
}
|
||||
ReplicatingHandler handler = new ReplicatingHandler();
|
||||
// Iterate over all the URLs
|
||||
sourceStore.getUrls(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,6 +25,7 @@
|
||||
package org.alfresco.repo.content.replication;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -32,6 +33,7 @@ import junit.framework.TestCase;
|
||||
import org.alfresco.repo.content.AbstractContentStore;
|
||||
import org.alfresco.repo.content.ContentContext;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.content.ContentStore.ContentUrlHandler;
|
||||
import org.alfresco.repo.content.filestore.FileContentStore;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.util.GUID;
|
||||
@@ -106,6 +108,21 @@ public class ContentStoreReplicatorTest extends TestCase
|
||||
targetStore.exists(writer.getContentUrl()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler that merely records the URL
|
||||
*
|
||||
* @author Derek Hulley
|
||||
* @since 2.0
|
||||
*/
|
||||
private class UrlRecorder implements ContentUrlHandler
|
||||
{
|
||||
public Set<String> urls = new HashSet<String>(1027);
|
||||
public void handle(String contentUrl)
|
||||
{
|
||||
urls.add(contentUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds content to the source while the replicator is going as fast as possible.
|
||||
* Just to make it more interesting, the content is sometimes put in the target
|
||||
@@ -150,11 +167,13 @@ public class ContentStoreReplicatorTest extends TestCase
|
||||
}
|
||||
|
||||
// check that we have an exact match of URLs
|
||||
Set<String> sourceUrls = sourceStore.getUrls();
|
||||
Set<String> targetUrls = targetStore.getUrls();
|
||||
UrlRecorder sourceUrls = new UrlRecorder();
|
||||
UrlRecorder targetUrls = new UrlRecorder();
|
||||
sourceStore.getUrls(sourceUrls);
|
||||
targetStore.getUrls(targetUrls);
|
||||
|
||||
sourceUrls.containsAll(targetUrls);
|
||||
targetUrls.contains(sourceUrls);
|
||||
sourceUrls.urls.containsAll(targetUrls.urls);
|
||||
targetUrls.urls.contains(sourceUrls.urls);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,9 +25,7 @@
|
||||
package org.alfresco.repo.content.replication;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
@@ -370,32 +368,26 @@ public class ReplicatingContentStore extends AbstractContentStore
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the results as given by the primary store, and if inbound
|
||||
* replication is active, merges the URLs from the secondary stores.
|
||||
* 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.
|
||||
*/
|
||||
public Set<String> getUrls(Date createdAfter, Date createdBefore) throws ContentIOException
|
||||
public void getUrls(Date createdAfter, Date createdBefore, ContentUrlHandler handler) throws ContentIOException
|
||||
{
|
||||
Set<String> urls = new HashSet<String>(1024);
|
||||
|
||||
// add in URLs from primary store
|
||||
Set<String> primaryUrls = primaryStore.getUrls(createdAfter, createdBefore);
|
||||
urls.addAll(primaryUrls);
|
||||
primaryStore.getUrls(createdAfter, createdBefore, handler);
|
||||
|
||||
// add in URLs from secondary stores (they are visible for reads)
|
||||
for (ContentStore secondaryStore : secondaryStores)
|
||||
{
|
||||
Set<String> secondaryUrls = secondaryStore.getUrls(createdAfter, createdBefore);
|
||||
// merge them
|
||||
urls.addAll(secondaryUrls);
|
||||
secondaryStore.getUrls(createdAfter, createdBefore, handler);
|
||||
}
|
||||
// done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Found " + urls.size() + " URLs, of which " + primaryUrls.size() + " are primary: \n" +
|
||||
logger.debug("Iterated over content URLs: \n" +
|
||||
" created after: " + createdAfter + "\n" +
|
||||
" created before: " + createdBefore);
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,6 +26,7 @@ package org.alfresco.repo.content.replication;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
@@ -35,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.alfresco.repo.content.AbstractWritableContentStoreTest;
|
||||
import org.alfresco.repo.content.ContentContext;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.content.ContentStore.ContentUrlHandler;
|
||||
import org.alfresco.repo.content.filestore.FileContentStore;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
@@ -135,7 +137,15 @@ public class ReplicatingContentStoreTest extends AbstractWritableContentStoreTes
|
||||
// check that the URL is present for each of the stores
|
||||
for (ContentStore store : secondaryStores)
|
||||
{
|
||||
Set<String> urls = store.getUrls();
|
||||
final Set<String> urls = new HashSet<String>(1027);
|
||||
ContentUrlHandler handler = new ContentUrlHandler()
|
||||
{
|
||||
public void handle(String contentUrl)
|
||||
{
|
||||
urls.add(contentUrl);
|
||||
}
|
||||
};
|
||||
store.getUrls(handler);
|
||||
assertTrue("URL of new content not present in store", urls.contains(contentUrl) == mustExist);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user