net.sf.ehcache.Statistics Java Examples

The following examples show how to use net.sf.ehcache.Statistics. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IbisCacheManager.java    From iaf with Apache License 2.0 6 votes vote down vote up
public static void iterateOverStatistics(StatisticsKeeperIterationHandler hski, Object data, int action) throws SenderException {
	if (self==null) {
		return;
	}
	String cacheNames[]=self.cacheManager.getCacheNames();
	for (int i=0;i<cacheNames.length;i++) {
		Object subdata=hski.openGroup(data, cacheNames[i], "cache");
		Ehcache cache=self.cacheManager.getEhcache(cacheNames[i]);
		Statistics stats = cache.getStatistics();
		stats.getAverageGetTime();
		hski.handleScalar(subdata, "CacheHits", stats.getCacheHits());
		hski.handleScalar(subdata, "CacheMisses", stats.getCacheMisses());
		hski.handleScalar(subdata, "EvictionCount", stats.getEvictionCount());
		hski.handleScalar(subdata, "InMemoryHits", stats.getInMemoryHits());
		hski.handleScalar(subdata, "ObjectCount", stats.getObjectCount());
		hski.handleScalar(subdata, "OnDiskHits", stats.getOnDiskHits());
		hski.closeGroup(subdata);
	}
}
 
Example #2
Source File: CacheStatsServlet.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * View log
 */
private void view(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
	log.debug("view({}, {})", request, response);
	refresh();

	List<Map<String, String>> cacheStats = new ArrayList<Map<String, String>>();

	for (String cache : cacheStatistics.keySet()) {
		Statistics stats = cacheStatistics.get(cache);

		Map<String, String> stat = new HashMap<String, String>();
		stat.put("cache", cache);
		stat.put("cacheHits", Long.toString(stats.getCacheHits()));
		stat.put("cacheMisses", Long.toString(stats.getCacheMisses()));
		stat.put("objectCount", Long.toString(stats.getObjectCount()));
		stat.put("inMemoryHits", Long.toString(stats.getInMemoryHits()));
		stat.put("inMemoryMisses", Long.toString(stats.getInMemoryMisses()));
		stat.put("memoryStoreObjectCount", Long.toString(stats.getMemoryStoreObjectCount()));
		stat.put("onDiskHits", Long.toString(stats.getOnDiskHits()));
		stat.put("onDiskMisses", Long.toString(stats.getOnDiskMisses()));
		stat.put("diskStoreObjectCount", Long.toString(stats.getDiskStoreObjectCount()));

		cacheStats.add(stat);
	}

	ServletContext sc = getServletContext();
	sc.setAttribute("cacheStats", cacheStats);
	sc.setAttribute("statsEnabled", statsEnabled);
	sc.getRequestDispatcher("/admin/cache_stats.jsp").forward(request, response);

	// Activity log
	UserActivity.log(request.getRemoteUser(), "ADMIN_CACHE_STATS", null, null, null);

	log.debug("view: void");
}
 
Example #3
Source File: NamespaceManager.java    From rya with Apache License 2.0 5 votes vote down vote up
public void printStatistics() {
    Statistics statistics = namespaceCache.getStatistics();
    if (statistics != null) { //TODO: use a logger please
        System.out.println("Namespace Cache Statisitics: ");
        System.out.println("--Hits: \t" + statistics.getCacheHits());
        System.out.println("--Misses: \t" + statistics.getCacheMisses());
        System.out.println("--Total Count: \t" + statistics.getObjectCount());
    }
}