本文整理汇总了Java中net.sf.ehcache.Statistics类的典型用法代码示例。如果您正苦于以下问题:Java Statistics类的具体用法?Java Statistics怎么用?Java Statistics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Statistics类属于net.sf.ehcache包,在下文中一共展示了Statistics类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStatistics
import net.sf.ehcache.Statistics; //导入依赖的package包/类
/**
* This method does nothing.
* @return always the same message
*/
@Override
public String getStatistics() {
Statistics ehcacheStats = theCache.getStatistics();
StringBuffer stats = new StringBuffer();
stats.append("---- Proxyma EhcacheProvider Plugin Statisctics ----");
stats.append("\nCache instance Name: ");
stats.append(theCache.getName());
stats.append("\nCache status: ");
stats.append(theCache.getStatus());
stats.append("\nNumber of elements currently on the cache: ");
stats.append(theCache.getSize());
stats.append("\nNumber of elements into the Memory Store: ");
stats.append(theCache.getMemoryStoreSize());
stats.append("\nNumber of elements into the Disk Store: ");
stats.append(theCache.getDiskStoreSize());
stats.append("\nNumber of Cache HITS: ");
stats.append(ehcacheStats.getCacheHits());
stats.append("\nNumber of Cache MISS: ");
stats.append(ehcacheStats.getCacheMisses());
stats.append("\n---- End of EhcacheProvider Plugin Statisctics ----\n");
return stats.toString();
}
示例2: shutdown
import net.sf.ehcache.Statistics; //导入依赖的package包/类
public static void shutdown() {
if (Boolean.getBoolean("CatalogDAO.printCacheStatistics")) {
CacheManager cm = CacheManager.getInstance();
for (String s : cm.getCacheNames()) {
if (s.matches("com.tesora.dve.*")) {
Statistics stats = cm.getCache(s).getStatistics();
System.out.println("Cache " + s + ": " + stats.getObjectCount() +
" items (" + stats.getCacheHits() + " hits, " + stats.getCacheMisses() + " misses)");
}
}
}
INSTANCE.lookupCacheMap.clear();
if (INSTANCE.emf != null)
INSTANCE.emf.close();
INSTANCE.emf = null;
}
示例3: iterateOverStatistics
import net.sf.ehcache.Statistics; //导入依赖的package包/类
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);
}
}
示例4: view
import net.sf.ehcache.Statistics; //导入依赖的package包/类
/**
* 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");
}
示例5: buildCacheResult
import net.sf.ehcache.Statistics; //导入依赖的package包/类
private Map<String, Long> buildCacheResult(Cache cache) {
Statistics cacheStatistics = cache.getStatistics();
LiveCacheStatistics liveCacheStatistics = cache.getLiveCacheStatistics();
Map<String, Long> cacheData = new LinkedHashMap<>();
cacheData.put("size", liveCacheStatistics.getSize());
cacheData.put("cacheHits", cacheStatistics.getCacheHits());
cacheData.put("cacheMisses", cacheStatistics.getCacheMisses());
cacheData.put("putCount", liveCacheStatistics.getPutCount());
cacheData.put("evictionCount", cacheStatistics.getEvictionCount());
cacheData.put("averageSearchTime", cacheStatistics.getAverageSearchTime());
cacheData.put("inMemoryHits", cacheStatistics.getInMemoryHits());
cacheData.put("inMemoryMisses", cacheStatistics.getInMemoryMisses());
cacheData.put("objectCount", cacheStatistics.getObjectCount());
cacheData.put("offHeapHits", cacheStatistics.getOffHeapHits());
cacheData.put("offHeapMisses", cacheStatistics.getOffHeapMisses());
cacheData.put("onDiskHits", cacheStatistics.getOnDiskHits());
cacheData.put("onDiskMisses", cacheStatistics.getOnDiskMisses());
cacheData.put("searchesPerSecond", cacheStatistics.getSearchesPerSecond());
cacheData.put("expiredCount", liveCacheStatistics.getExpiredCount());
cacheData.put("localHeapSize", liveCacheStatistics.getLocalHeapSize());
cacheData.put("localOffHeapSize", liveCacheStatistics.getLocalOffHeapSize());
cacheData.put("removedCount", liveCacheStatistics.getRemovedCount());
cacheData.put("updateCount", liveCacheStatistics.getUpdateCount());
cacheData.put("maxGetTimeMillis", liveCacheStatistics.getMaxGetTimeNanos() / 1000000L);
return cacheData;
}
示例6: report
import net.sf.ehcache.Statistics; //导入依赖的package包/类
private void report(final Cache cache) {
final Statistics stats = cache.getStatistics();
final long hits = stats.getCacheHits();
final long misses = stats.getCacheMisses();
final double ratio = (misses != 0) ? (double) hits / (double) misses : 0d;
_logger.info("Cache {} hits = {}, misses = {}, ratio = {}", new Object[] {cache.getName(), hits, misses, ratio});
}
示例7: printStatistics
import net.sf.ehcache.Statistics; //导入依赖的package包/类
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());
}
}
示例8: initializeCacheManager
import net.sf.ehcache.Statistics; //导入依赖的package包/类
/**
* Initialize the cache manager singleton of ecache.
* @param context the proxyma context
*/
private synchronized void initializeCacheManager(ProxymaContext context) {
try {
if (ehCacheManager == null) {
ehCacheManager = new CacheManager(new ByteArrayInputStream(forgeEhcacheConfiguration(context)));
ehCacheManager.addCache(context.getName());
Cache addedCache = ehCacheManager.getCache(context.getName());
addedCache.setStatisticsAccuracy(Statistics.STATISTICS_ACCURACY_BEST_EFFORT);
log.info("Ehcahe subsystem for context \"" + context.getName() + "\" initialized..");
}
} catch (UnsupportedEncodingException ex) {
log.log(Level.SEVERE, "Unable to initialize ehcache subsystem!", ex);
}
}
示例9: getCacheStatistics
import net.sf.ehcache.Statistics; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public CacheStatistics getCacheStatistics() {
return new JCacheStatistics(new Statistics(null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}