mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed BM client caching to be disk-persistent and specific to the working root node reference.
Subsequent startups of the client no longer incur a long warm-up period when running against a repo already populated. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6855 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
package org.alfresco.repo.model.filefolder.loader;
|
package org.alfresco.repo.model.filefolder.loader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -50,9 +51,10 @@ public class LoaderUploadThread extends AbstractLoaderThread
|
|||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
CacheManager cacheManager = new CacheManager();
|
System.setProperty(CacheManager.ENABLE_SHUTDOWN_HOOK_PROPERTY, "TRUE");
|
||||||
Cache cache = new Cache("LoaderUploadThread-PathCache", 100000, false, false, 300, 300);
|
URL url = LoaderUploadThread.class.getResource("/org/alfresco/repo/model/filefolder/loader/loader-ehcache.xml");
|
||||||
cacheManager.addCache(cache);
|
CacheManager cacheManager = new CacheManager(url);
|
||||||
|
Cache cache = cacheManager.getCache("org.alfresco.LoaderUploadThread.PathCache");
|
||||||
|
|
||||||
pathCache = new EhCacheAdapter<String, NodeRef>();
|
pathCache = new EhCacheAdapter<String, NodeRef>();
|
||||||
pathCache.setCache(cache);
|
pathCache.setCache(cache);
|
||||||
@@ -81,12 +83,13 @@ public class LoaderUploadThread extends AbstractLoaderThread
|
|||||||
// Iterate down the path, checking the cache and populating it as necessary
|
// Iterate down the path, checking the cache and populating it as necessary
|
||||||
List<String> currentPath = new ArrayList<String>();
|
List<String> currentPath = new ArrayList<String>();
|
||||||
NodeRef currentParentNodeRef = workingRootNodeRef;
|
NodeRef currentParentNodeRef = workingRootNodeRef;
|
||||||
|
String currentKey = workingRootNodeRef.toString();
|
||||||
for (String pathElement : folderPath)
|
for (String pathElement : folderPath)
|
||||||
{
|
{
|
||||||
currentPath.add(pathElement);
|
currentPath.add(pathElement);
|
||||||
String key = currentPath.toString();
|
currentKey += ("/" + pathElement);
|
||||||
// Is this there?
|
// Is this there?
|
||||||
NodeRef nodeRef = pathCache.get(key);
|
NodeRef nodeRef = pathCache.get(currentKey);
|
||||||
if (nodeRef != null)
|
if (nodeRef != null)
|
||||||
{
|
{
|
||||||
// Found it
|
// Found it
|
||||||
@@ -102,7 +105,7 @@ public class LoaderUploadThread extends AbstractLoaderThread
|
|||||||
ContentModel.TYPE_FOLDER);
|
ContentModel.TYPE_FOLDER);
|
||||||
currentParentNodeRef = folderInfo.getNodeRef();
|
currentParentNodeRef = folderInfo.getNodeRef();
|
||||||
// Cache the new node
|
// Cache the new node
|
||||||
pathCache.put(key, currentParentNodeRef);
|
pathCache.put(currentKey, currentParentNodeRef);
|
||||||
}
|
}
|
||||||
// Done
|
// Done
|
||||||
return currentParentNodeRef;
|
return currentParentNodeRef;
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<ehcache>
|
||||||
|
|
||||||
|
<diskStore
|
||||||
|
path="java.io.tmpdir"/>
|
||||||
|
|
||||||
|
<defaultCache
|
||||||
|
maxElementsInMemory="5000"
|
||||||
|
eternal="true"
|
||||||
|
timeToIdleSeconds="0"
|
||||||
|
timeToLiveSeconds="0"
|
||||||
|
overflowToDisk="false"
|
||||||
|
>
|
||||||
|
</defaultCache>
|
||||||
|
|
||||||
|
<cache
|
||||||
|
name="org.alfresco.LoaderUploadThread.PathCache"
|
||||||
|
maxElementsInMemory="100000"
|
||||||
|
eternal="true"
|
||||||
|
overflowToDisk="true"
|
||||||
|
diskPersistent="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</ehcache>
|
Reference in New Issue
Block a user