From 4ad1b74f9d6cf909a92f705570b3cc834a7dca7e Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Thu, 16 Feb 2006 16:09:47 +0000 Subject: [PATCH] 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 --- .../alfresco/repo/cache/EhCacheTracerJob.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java b/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java index 2c20afb092..165f293328 100644 --- a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java +++ b/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java @@ -115,7 +115,17 @@ public class EhCacheTracerJob implements Job public CacheAnalysis(Cache cache) throws CacheException { this.cache = cache; - calculateSize(); + if (this.cache.getStatus() == Cache.STATUS_ALIVE) + { + try + { + calculateSize(); + } + catch (Throwable e) + { + // just ignore + } + } } public synchronized long getSize() @@ -176,15 +186,21 @@ public class EhCacheTracerJob implements Job double sizeMB = (double)getSize()/1024.0/1024.0; long maxSize = cache.getMaxElementsInMemory(); long currentSize = cache.getMemoryStoreSize(); + long hitCount = cache.getHitCount(); + long missCount = cache.getMissCountNotFound(); double percentageFull = (double)currentSize / (double)maxSize * 100.0; double estMaxSize = sizeMB / (double) currentSize * (double) maxSize; StringBuilder sb = new StringBuilder(512); sb.append(" Analyzing EHCache: \n") - .append("===> ").append(cache).append("\n") - .append(" Deep Size: ").append(String.format("%5.2f MB", sizeMB)).append("\n") - .append(" Percentage used: ").append(String.format("%5.2f percent", percentageFull)).append("\n") - .append(" Estimated maximum size: ").append(String.format("%5.2f MB", estMaxSize)); + .append("===> ").append(cache.getName()).append("\n") + .append(" Hit Count: ").append(String.format("%10d hits ", hitCount )) + .append(" | Miss Count: ").append(String.format("%10d misses ", missCount )).append("\n") + .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(); } }