use of net.sf.ehcache.config.TerracottaClientConfiguration in project Gemma by PavlidisLab.
the class CacheMonitorImpl method getStats.
@Override
public String getStats() {
StringBuilder buf = new StringBuilder();
String[] cacheNames = cacheManager.getCacheNames();
Arrays.sort(cacheNames);
// Terracotta clustered?
TerracottaClientConfiguration terracottaConfig = cacheManager.getConfiguration().getTerracottaConfiguration();
buf.append("Distributed caching is ");
buf.append(terracottaConfig != null ? "enabled" : "disabled");
buf.append(" in the configuration file");
buf.append(terracottaConfig != null ? ". The cache server's configuration URL is at [" + terracottaConfig.getUrl() + "]" : "");
buf.append(".<br/>");
buf.append(cacheNames.length).append(" caches; only non-empty caches listed below.");
// FIXME make these sortable.
buf.append("<br/> To clear all caches click here: <img src='" + Settings.getRootContext() + "/images/icons/arrow_rotate_anticlockwise.png' onClick=\"clearAllCaches()\" alt='Flush caches' title='Clear caches' /> ");
buf.append("<br/> To start statistics collection click here: <img src='" + Settings.getRootContext() + "/images/icons/arrow_rotate_anticlockwise.png' onClick=\"enableStatistics()\" alt='Enable stats' title='Enable stats' /> ");
buf.append("<br/> To stop statistics collection click here: <img src='" + Settings.getRootContext() + "/images/icons/arrow_rotate_anticlockwise.png' onClick=\"disableStatistics()\" alt='Disable stats' title='Disable stats' /> ");
buf.append("<table style='font-size:small' ><tr>");
String header = "<th>Name</th><th>HitRate</th><th>Hits</th><th>Misses</th><th>Count</th><th>MemHits</th><th>MemMiss</th><th>DiskHits</th><th>Evicted</th> <th>Eternal?</th><th>UseDisk?</th> <th>MaxInMem</th><th>LifeTime</th><th>IdleTime</th>";
buf.append(header);
buf.append("</tr>");
int count = 0;
for (String rawCacheName : cacheNames) {
Cache cache = cacheManager.getCache(rawCacheName);
Statistics statistics = cache.getStatistics();
long objectCount = statistics.getObjectCount();
if (objectCount == 0) {
continue;
}
// a little shorter...
String cacheName = rawCacheName.replaceFirst("ubic.gemma.model.", "u.g.m.");
buf.append("<tr><td>").append(this.getClearCacheHtml(rawCacheName)).append(cacheName).append("</td>");
long hits = statistics.getCacheHits();
long misses = statistics.getCacheMisses();
long inMemoryHits = statistics.getInMemoryHits();
long inMemoryMisses = statistics.getInMemoryMisses();
long onDiskHits = statistics.getOnDiskHits();
long evictions = statistics.getEvictionCount();
if (hits + misses > 0) {
buf.append(this.makeTableCellForStat(String.format("%.2f", (double) hits / (hits + misses))));
} else {
buf.append("<td></td>");
}
buf.append(this.makeTableCellForStat(hits));
buf.append(this.makeTableCellForStat(misses));
buf.append(this.makeTableCellForStat(objectCount));
buf.append(this.makeTableCellForStat(inMemoryHits));
buf.append(this.makeTableCellForStat(inMemoryMisses));
buf.append(this.makeTableCellForStat(onDiskHits));
buf.append(this.makeTableCellForStat(evictions));
CacheConfiguration cacheConfiguration = cache.getCacheConfiguration();
boolean eternal = cacheConfiguration.isEternal();
buf.append("<td>").append(eternal ? "•" : "").append("</td>");
Strategy strategy;
strategy = cacheConfiguration.getPersistenceConfiguration() == null ? null : cacheConfiguration.getPersistenceConfiguration().getStrategy();
buf.append("<td>").append(strategy == null || strategy.equals(Strategy.NONE) ? "" : "•").append("</td>");
buf.append("<td>").append(cacheConfiguration.getMaxEntriesLocalHeap()).append("</td>");
if (eternal) {
// timeouts are irrelevant.
buf.append("<td>-</td>");
buf.append("<td>-</td>");
} else {
buf.append("<td>").append(cacheConfiguration.getTimeToIdleSeconds()).append("</td>");
buf.append("<td>").append(cacheConfiguration.getTimeToLiveSeconds()).append("</td>");
}
buf.append("</tr>");
if (++count % 25 == 0) {
buf.append("<tr>").append(header).append("</tr>");
}
}
buf.append("</table>");
return buf.toString();
}
use of net.sf.ehcache.config.TerracottaClientConfiguration in project ff4j by ff4j.
the class FeatureStoreTerracottaTestIT method initStore.
/**
* {@inheritDoc}
*/
@Override
protected FeatureStore initStore() {
// Configuration to wirk with Terracotta
Configuration managerConfiguration = new Configuration();
managerConfiguration.name("config").terracotta(new TerracottaClientConfiguration().url(TERRACOTTA_URL)).defaultCache(new CacheConfiguration().maxBytesLocalHeap(128, MemoryUnit.MEGABYTES).terracotta(new TerracottaConfiguration())).cache(new CacheConfiguration().name(FF4jEhCacheWrapper.CACHENAME_FEATURES).maxBytesLocalHeap(128, MemoryUnit.MEGABYTES).terracotta(new TerracottaConfiguration()));
FeatureStoreEhCache ehcacheStore = new FeatureStoreEhCache(managerConfiguration);
ehcacheStore.importFeaturesFromXmlFile("ff4j.xml");
return ehcacheStore;
}
use of net.sf.ehcache.config.TerracottaClientConfiguration in project onebusaway-application-modules by camsys.
the class EhCacheConfigurationFactoryBean method afterPropertiesSet.
public void afterPropertiesSet() throws IOException, CacheException {
logger.info("Initializing EHCache CacheManager");
this.configuration = ConfigurationFactory.parseConfiguration(this.configLocation.getInputStream());
if (this.diskStorePath != null) {
logger.info("diskStorePath=" + this.diskStorePath);
DiskStoreConfiguration dsConfig = new DiskStoreConfiguration();
dsConfig.setPath(this.diskStorePath);
logger.info("diskStorePath (translated)=" + dsConfig.getPath());
configuration.addDiskStore(dsConfig);
}
if (this.terracottaUrl != null) {
logger.info("terracottaUrl=" + this.terracottaUrl);
TerracottaClientConfiguration tcConfig = new TerracottaClientConfiguration();
tcConfig.setUrl(this.terracottaUrl);
configuration.addTerracottaConfig(tcConfig);
}
}
Aggregations