@Override public String getStatus() { // MIRRORS the OLD status report final StringBuilder buf = new StringBuilder(); buf.append("** Memory report\n"); buf.append("freeMemory: ").append(Runtime.getRuntime().freeMemory()); buf.append(" totalMemory: "); buf.append(Runtime.getRuntime().totalMemory()); buf.append(" maxMemory: "); buf.append(Runtime.getRuntime().maxMemory()); buf.append("\n\n"); String[] allCacheNames = cacheManager.getCacheNames(); Arrays.sort(allCacheNames); ArrayList<Ehcache> caches = new ArrayList<Ehcache>(allCacheNames.length); for (String cacheName : allCacheNames) { Ehcache cache = cacheManager.getCache(cacheName); caches.add(cache); } // summary (cache descriptions) for (Ehcache cache : caches) { Cache c = new EhcacheCache(cache); buf.append(c.getDescription()).append("\n"); } // extended report // TODO probably should remove this buf.append("\n** Extended Cache Report\n"); for (Ehcache cache : caches) { buf.append(cache.toString()); buf.append("\n"); } // config report buf.append("\n** Current Cache Configurations\n"); // determine whether to use old or new form keys boolean legacyKeys = true; // set true for a 2.9/BasicMemoryService compatible set of keys String maxKey = "maxEntries"; String ttlKey = "timeToLive"; String ttiKey = "timeToIdle"; String eteKey = "eternal"; //noinspection ConstantConditions if (legacyKeys) { maxKey = "maxElementsInMemory"; ttlKey = "timeToLiveSeconds"; ttiKey = "timeToIdleSeconds"; } // DEFAULT cache config CacheConfiguration defaults = cacheManager.getConfiguration().getDefaultCacheConfiguration(); long maxEntriesDefault = defaults.getMaxEntriesLocalHeap(); long ttlSecsDefault = defaults.getTimeToLiveSeconds(); long ttiSecsDefault = defaults.getTimeToIdleSeconds(); boolean eternalDefault = defaults.isEternal(); buf.append("# DEFAULTS: ") .append(maxKey) .append("=") .append(maxEntriesDefault) .append(",") .append(ttlKey) .append("=") .append(ttlSecsDefault) .append(",") .append(ttiKey) .append("=") .append(ttiSecsDefault) .append(",") .append(eteKey) .append("=") .append(eternalDefault) .append("\n"); // new: timeToLive=600,timeToIdle=360,maxEntries=5000,eternal=false // old: timeToLiveSeconds=3600,timeToIdleSeconds=900,maxElementsInMemory=20000,eternal=false for (Ehcache cache : caches) { long maxEntries = cache.getCacheConfiguration().getMaxEntriesLocalHeap(); long ttlSecs = cache.getCacheConfiguration().getTimeToLiveSeconds(); long ttiSecs = cache.getCacheConfiguration().getTimeToIdleSeconds(); boolean eternal = cache.getCacheConfiguration().isEternal(); if (maxEntries == maxEntriesDefault && ttlSecs == ttlSecsDefault && ttiSecs == ttiSecsDefault && eternal == eternalDefault) { // Cache ONLY uses the defaults buf.append("# memory.").append(cache.getName()).append(" *ALL DEFAULTS*\n"); } else { // NOT only defaults cache, show the settings that differ from the defaults buf.append("memory.").append(cache.getName()).append("="); boolean first = true; if (maxEntries != maxEntriesDefault) { //noinspection ConstantConditions first = addKeyValueToConfig(buf, maxKey, maxEntries, first); } if (ttlSecs != ttlSecsDefault) { first = addKeyValueToConfig(buf, ttlKey, ttlSecs, first); } if (ttiSecs != ttiSecsDefault) { first = addKeyValueToConfig(buf, ttiKey, ttiSecs, first); } if (eternal != eternalDefault) { addKeyValueToConfig(buf, eteKey, eternal, first); } buf.append("\n"); // TODO remove the overflow to disk check //noinspection deprecation if (cache.getCacheConfiguration().isOverflowToDisk()) { // overflowToDisk. maxEntriesLocalDisk buf.append("# NOTE: ") .append(cache.getName()) .append(" is configured for Overflow(disk), ") .append(cache.getCacheConfiguration().getMaxEntriesLocalDisk()) .append(" entries\n"); } } } final String rv = buf.toString(); log.info(rv); return rv; }