Better output ant catching of transient caches

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2416 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-02-16 16:09:47 +00:00
parent e5d3193e9a
commit 4ad1b74f9d

View File

@@ -115,7 +115,17 @@ public class EhCacheTracerJob implements Job
public CacheAnalysis(Cache cache) throws CacheException public CacheAnalysis(Cache cache) throws CacheException
{ {
this.cache = cache; this.cache = cache;
calculateSize(); if (this.cache.getStatus() == Cache.STATUS_ALIVE)
{
try
{
calculateSize();
}
catch (Throwable e)
{
// just ignore
}
}
} }
public synchronized long getSize() public synchronized long getSize()
@@ -176,15 +186,21 @@ public class EhCacheTracerJob implements Job
double sizeMB = (double)getSize()/1024.0/1024.0; double sizeMB = (double)getSize()/1024.0/1024.0;
long maxSize = cache.getMaxElementsInMemory(); long maxSize = cache.getMaxElementsInMemory();
long currentSize = cache.getMemoryStoreSize(); long currentSize = cache.getMemoryStoreSize();
long hitCount = cache.getHitCount();
long missCount = cache.getMissCountNotFound();
double percentageFull = (double)currentSize / (double)maxSize * 100.0; double percentageFull = (double)currentSize / (double)maxSize * 100.0;
double estMaxSize = sizeMB / (double) currentSize * (double) maxSize; double estMaxSize = sizeMB / (double) currentSize * (double) maxSize;
StringBuilder sb = new StringBuilder(512); StringBuilder sb = new StringBuilder(512);
sb.append(" Analyzing EHCache: \n") sb.append(" Analyzing EHCache: \n")
.append("===> ").append(cache).append("\n") .append("===> ").append(cache.getName()).append("\n")
.append(" Deep Size: ").append(String.format("%5.2f MB", sizeMB)).append("\n") .append(" Hit Count: ").append(String.format("%10d hits ", hitCount ))
.append(" Percentage used: ").append(String.format("%5.2f percent", percentageFull)).append("\n") .append(" | Miss Count: ").append(String.format("%10d misses ", missCount )).append("\n")
.append(" Estimated maximum size: ").append(String.format("%5.2f MB", estMaxSize)); .append(" Deep Size: ").append(String.format("%10.2f MB ", sizeMB ))
.append(" | Current Count: ").append(String.format("%10d entries ", currentSize )).append("\n")
.append(" Percentage used: ").append(String.format("%10.2f percent", percentageFull))
.append(" | Max Count: ").append(String.format("%10d entries ", maxSize )).append("\n")
.append(" Estimated maximum size: ").append(String.format("%10.2f MB ", estMaxSize ));
return sb.toString(); return sb.toString();
} }
} }