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:
Derek Hulley
2007-09-21 15:14:25 +00:00
parent 0bf9cb4cd7
commit 76afd86b11
2 changed files with 33 additions and 6 deletions

View File

@@ -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;

View File

@@ -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>