private String buildConfiguration(Object cache) { final StringBuilder sb = new StringBuilder(); // getCacheConfiguration() et getMaxElementsOnDisk() n'existent pas en ehcache 1.2 final CacheConfiguration config = ((Ehcache) cache).getCacheConfiguration(); sb.append("ehcache [maxElementsInMemory = ").append(config.getMaxElementsInMemory()); final boolean overflowToDisk = config.isOverflowToDisk(); sb.append(", overflowToDisk = ").append(overflowToDisk); if (overflowToDisk) { sb.append(", maxElementsOnDisk = ").append(config.getMaxElementsOnDisk()); } final boolean eternal = config.isEternal(); sb.append(", eternal = ").append(eternal); if (!eternal) { sb.append(", timeToLiveSeconds = ").append(config.getTimeToLiveSeconds()); sb.append(", timeToIdleSeconds = ").append(config.getTimeToIdleSeconds()); sb.append(", memoryStoreEvictionPolicy = ") .append(config.getMemoryStoreEvictionPolicy()); } sb.append(", diskPersistent = ").append(config.isDiskPersistent()); sb.append(']'); return sb.toString(); }
/** * Accessor */ public boolean isDiskPersistent() { return cacheConfiguration.isDiskPersistent(); }
/** * {@inheritDoc} */ @Override public boolean isDiskPersistent() { return cache.getCacheConfiguration().isDiskPersistent(); }
/** * Flush to disk only if the cache is diskPersistent. */ public final void flush() { if (cache.getCacheConfiguration().isDiskPersistent()) { if (LOG.isDebugEnabled()) { LOG.debug(cache.getName() + " is persistent. Spooling " + map.size() + " elements to the disk store."); } spoolAllToDisk(); } //should be emptied if clearOnFlush is true if (cache.getCacheConfiguration().isClearOnFlush()) { clear(); } }
/** * {@inheritDoc} */ public void load(final Ehcache cache) throws CacheException { if (cache.getCacheConfiguration().isDiskPersistent()) { if (asynchronous) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } } else { LOG.warn("Cache '" + cache.getName() + "' isn't disk persistent, nothing to laod from!"); } }
/** * Calculates the number of caches in the configuration that are diskPersistent */ public final int numberOfCachesThatUseDiskStorage() { int count = 0; Set cacheConfigurations = configuration.getCacheConfigurations().entrySet(); for (CacheConfiguration cacheConfig : configuration.getCacheConfigurations().values()) { if (cacheConfig.isOverflowToDisk() || cacheConfig.isDiskPersistent() || (cacheConfig.isOverflowToOffHeap() && cacheConfig.isSearchable())) { count++; } else { PersistenceConfiguration persistence = cacheConfig.getPersistenceConfiguration(); if (persistence != null) { switch (persistence.getStrategy()) { case LOCALTEMPSWAP: case LOCALRESTARTABLE: count++; break; default: break; } } } } return count; }
/** * Accessor */ public boolean isDiskPersistent() { return cacheConfiguration.isDiskPersistent(); }
/** * Accessor */ public boolean isDiskPersistent() { return cacheConfiguration.isDiskPersistent(); }
/** * Accessor */ public boolean isDiskPersistent() { return cacheConfiguration.isDiskPersistent(); }
this.diskPersistent = cache.getCacheConfiguration().isDiskPersistent();
/** * {@inheritDoc} */ public boolean isDiskPersistent() { return cache.getCacheConfiguration().isDiskPersistent(); }
/** * {@inheritDoc} */ @Override public boolean isDiskPersistent() { return cache.getCacheConfiguration().isDiskPersistent(); }
@Override public Object getConfigValue(Ehcache cache) { return cache.getCacheConfiguration().isDiskPersistent(); } },
/** * {@inheritDoc} */ @Override public boolean isDiskPersistent() { return cache.getCacheConfiguration().isDiskPersistent(); }
/** * Adds all common child elements with the "defaultCache" element in ehcache.xsd * * @param element * @param cacheConfiguration */ public static void addCommonChildElementsWithDefaultCache(NodeElement element, CacheConfiguration cacheConfiguration) { for (FactoryConfigurationElement child : getAllFactoryElements(element, "cacheEventListenerFactory", cacheConfiguration .getCacheEventListenerConfigurations())) { CacheEventListenerFactoryConfiguration factoryConfiguration = (CacheEventListenerFactoryConfiguration) child .getFactoryConfiguration(); child.addAttribute(new SimpleNodeAttribute("listenFor", factoryConfiguration.getListenFor())); element.addChildElement(child); } addAllFactoryConfigsAsChildElements(element, "cacheExtensionFactory", cacheConfiguration.getCacheExtensionConfigurations()); addAllFactoryConfigsAsChildElements(element, "cacheLoaderFactory", cacheConfiguration.getCacheLoaderConfigurations()); addBootstrapCacheLoaderFactoryConfigurationElement(element, cacheConfiguration); addCacheExceptionHandlerFactoryConfigurationElement(element, cacheConfiguration); addSizeOfPolicyConfigurationElement(element, cacheConfiguration); if (!cacheConfiguration.isOverflowToDisk() || !cacheConfiguration.isDiskPersistent()) { addPersistenceConfigurationElement(element, cacheConfiguration); } addCopyStrategyConfigurationElement(element, cacheConfiguration); addElementValueComparatorConfigurationElement(element, cacheConfiguration); addCacheWriterConfigurationElement(element, cacheConfiguration); addAllFactoryConfigsAsChildElements(element, "cacheDecoratorFactory", cacheConfiguration.getCacheDecoratorConfigurations()); addTerracottaConfigurationElement(element, cacheConfiguration); addPinningElement(element, cacheConfiguration); addSearchElement(element, cacheConfiguration); }
/** * Flush to disk only if the cache is diskPersistent. */ public final void flush() { if (cache.getCacheConfiguration().isDiskPersistent()) { if (LOG.isDebugEnabled()) { LOG.debug(cache.getName() + " is persistent. Spooling " + map.size() + " elements to the disk store."); } spoolAllToDisk(); } //should be emptied if clearOnFlush is true if (cache.getCacheConfiguration().isClearOnFlush()) { clear(); } }
/** * Flush to disk only if the cache is diskPersistent. */ public final void flush() { if (cache.getCacheConfiguration().isDiskPersistent()) { if (LOG.isDebugEnabled()) { LOG.debug(cache.getName() + " is persistent. Spooling " + map.size() + " elements to the disk store."); } spoolAllToDisk(); } //should be emptied if clearOnFlush is true if (cache.getCacheConfiguration().isClearOnFlush()) { clear(); } }
/** * {@inheritDoc} */ public void load(final Ehcache cache) throws CacheException { if (cache.getCacheConfiguration().isDiskPersistent()) { if (asynchronous) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } } else { LOG.warn("Cache '" + cache.getName() + "' isn't disk persistent, nothing to laod from!"); } }
/** * {@inheritDoc} */ public void load(final Ehcache cache) throws CacheException { if (cache.getCacheConfiguration().isDiskPersistent()) { if (asynchronous) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } } else { LOG.warn("Cache '" + cache.getName() + "' isn't disk persistent, nothing to laod from!"); } }
.toString().toUpperCase()).optional(true).defaultValue( CacheConfiguration.DEFAULT_MEMORY_STORE_EVICTION_POLICY.toString().toUpperCase())); if (cacheConfiguration.isOverflowToDisk() && cacheConfiguration.isDiskPersistent()) { element.addAttribute(new SimpleNodeAttribute("diskPersistent", "true")); element.addAttribute(new SimpleNodeAttribute("overflowToDisk", "true"));