Summary of estimated VM percentage that will be used

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2906 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-05-17 12:23:27 +00:00
parent c1f6eb64cb
commit ebe8390d69

View File

@@ -82,6 +82,7 @@ public class EhCacheTracerJob implements Job
long maxHeapSize = Runtime.getRuntime().maxMemory(); long maxHeapSize = Runtime.getRuntime().maxMemory();
long totalSize = 0L; long totalSize = 0L;
double estimatedMaxSize = 0L;
// get all the caches // get all the caches
String[] cacheNames = cacheManager.getCacheNames(); String[] cacheNames = cacheManager.getCacheNames();
logger.debug("Dumping EHCache info:"); logger.debug("Dumping EHCache info:");
@@ -97,13 +98,18 @@ public class EhCacheTracerJob implements Job
logger.debug(analysis); logger.debug(analysis);
// get the size // get the size
totalSize += analysis.getSize(); totalSize += analysis.getSize();
estimatedMaxSize += Double.isNaN(analysis.getEstimatedMaxSize()) ? 0.0 : analysis.getEstimatedMaxSize();
} }
// check the size // check the size
double sizePercentage = (double)totalSize / (double)maxHeapSize * 100.0; double sizePercentage = (double)totalSize / (double)maxHeapSize * 100.0;
double maxSizePercentage = estimatedMaxSize / (double)maxHeapSize * 100.0;
String msg = String.format( String msg = String.format(
"EHCaches currently consume %5.2f MB or %3.2f percent of system VM size", "EHCaches currently consume %5.2f MB or %3.2f percent of system VM size. \n" +
"The estimated maximum size is %5.2f MB or %3.2f percent of system VM size.",
(double)totalSize / 1024.0 / 1024.0, (double)totalSize / 1024.0 / 1024.0,
sizePercentage); sizePercentage,
estimatedMaxSize / 1024.0 / 1024.0,
maxSizePercentage);
logger.debug(msg); logger.debug(msg);
} }
@@ -111,6 +117,13 @@ public class EhCacheTracerJob implements Job
{ {
private Cache cache; private Cache cache;
private long size = 0L; private long size = 0L;
double sizeMB;
long maxSize;
long currentSize;
long hitCount;
long missCount;
double percentageFull;
double estMaxSize;
public CacheAnalysis(Cache cache) throws CacheException public CacheAnalysis(Cache cache) throws CacheException
{ {
@@ -133,6 +146,11 @@ public class EhCacheTracerJob implements Job
return size; return size;
} }
public synchronized double getEstimatedMaxSize()
{
return estMaxSize;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private synchronized void calculateSize() throws CacheException private synchronized void calculateSize() throws CacheException
{ {
@@ -143,6 +161,13 @@ public class EhCacheTracerJob implements Job
Element element = cache.get(key); Element element = cache.get(key);
size += getSize(element); size += getSize(element);
} }
sizeMB = (double)size/1024.0/1024.0;
maxSize = cache.getMaxElementsInMemory();
currentSize = cache.getMemoryStoreSize();
hitCount = cache.getHitCount();
missCount = cache.getMissCountNotFound();
percentageFull = (double)currentSize / (double)maxSize * 100.0;
estMaxSize = size / (double) currentSize * (double) maxSize;
} }
private long getSize(Serializable obj) private long getSize(Serializable obj)