Only count 1000 entities

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2953 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-05-23 13:49:47 +00:00
parent 297a0d9f7c
commit 5b6bff9d97

View File

@@ -159,11 +159,22 @@ public class EhCacheTracerJob implements Job
{ {
// calculate the cache deep size - EHCache 1.1 is always returning 0L // calculate the cache deep size - EHCache 1.1 is always returning 0L
List<Serializable> keys = cache.getKeys(); List<Serializable> keys = cache.getKeys();
// only count a maximum of 1000 entities
int count = 0;
for (Serializable key : keys) for (Serializable key : keys)
{ {
Element element = cache.get(key); Element element = cache.get(key);
size += getSize(element); size += getSize(element);
count++;
if (count >= 1000)
{
break;
}
} }
// the size must be multiplied by the ratio of the count to actual size
size = count > 0L ? (long) (size * ((double)keys.size()/(double)count)) : 0L;
sizeMB = (double)size/1024.0/1024.0; sizeMB = (double)size/1024.0/1024.0;
maxSize = cache.getMaxElementsInMemory(); maxSize = cache.getMaxElementsInMemory();
currentSize = cache.getMemoryStoreSize(); currentSize = cache.getMemoryStoreSize();