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(); }
json.put("Maximum Elements in Memory", config.getMaxEntriesLocalHeap()); json.put("Maximum Elements on Disk", config.getMaxBytesLocalDisk()); json.put("Memory Store Eviction Policy", config.getMemoryStoreEvictionPolicy().toString()); json.put("Clean or Flush", config.isClearOnFlush()); json.put("Eternal", config.isEternal());
/** * Accessor * @return a String representation of the policy */ public String getMemoryStoreEvictionPolicy() { return cacheConfiguration.getMemoryStoreEvictionPolicy().toString(); }
/** * {@inheritDoc} */ @Override public String getMemoryStoreEvictionPolicy() { return cache.getCacheConfiguration().getMemoryStoreEvictionPolicy().toString(); }
/** * Chooses the Policy from the cache configuration * @param cache the cache * @return the chosen eviction policy */ static Policy determineEvictionPolicy(Ehcache cache) { MemoryStoreEvictionPolicy policySelection = cache.getCacheConfiguration().getMemoryStoreEvictionPolicy(); if (policySelection.equals(MemoryStoreEvictionPolicy.LRU)) { return new LruPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.FIFO)) { return new FifoPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.LFU)) { return new LfuPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.CLOCK)) { return null; } throw new IllegalArgumentException(policySelection + " isn't a valid eviction policy"); }
/** * Chooses the Policy from the cache configuration * * @param cache the cache * @return the chosen eviction policy */ static Policy determineEvictionPolicy(Ehcache cache) { MemoryStoreEvictionPolicy policySelection = cache.getCacheConfiguration().getMemoryStoreEvictionPolicy(); if (policySelection.equals(MemoryStoreEvictionPolicy.LRU)) { return new LruPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.FIFO)) { return new FifoPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.LFU)) { return new LfuPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.CLOCK)) { return new LruPolicy(); } throw new IllegalArgumentException(policySelection + " isn't a valid eviction policy"); }
/** * Returns a {@link String} representation of {@link Cache}. */ @Override public String toString() { StringBuilder dump = new StringBuilder(); dump.append("[") .append(" name = ").append(configuration.getName()) .append(" status = ").append(cacheStatus.getStatus()) .append(" eternal = ").append(configuration.isEternal()) .append(" overflowToDisk = ").append(configuration.isOverflowToDisk()) .append(" maxEntriesLocalHeap = ").append(configuration.getMaxEntriesLocalHeap()) .append(" maxEntriesLocalDisk = ").append(configuration.getMaxEntriesLocalDisk()) .append(" memoryStoreEvictionPolicy = ").append(configuration.getMemoryStoreEvictionPolicy()) .append(" timeToLiveSeconds = ").append(configuration.getTimeToLiveSeconds()) .append(" timeToIdleSeconds = ").append(configuration.getTimeToIdleSeconds()) .append(" persistence = ").append(configuration.getPersistenceConfiguration() == null ? "none" : configuration.getPersistenceConfiguration().getStrategy()) .append(" diskExpiryThreadIntervalSeconds = ").append(configuration.getDiskExpiryThreadIntervalSeconds()) .append(registeredEventListeners) .append(" maxBytesLocalHeap = ").append(configuration.getMaxBytesLocalHeap()) .append(" overflowToOffHeap = ").append(configuration.isOverflowToOffHeap()) .append(" maxBytesLocalOffHeap = ").append(configuration.getMaxBytesLocalOffHeap()) .append(" maxBytesLocalDisk = ").append(configuration.getMaxBytesLocalDisk()) .append(" pinned = ") .append(configuration.getPinningConfiguration() != null ? configuration.getPinningConfiguration().getStore().name() : "false") .append(" ]"); return dump.toString(); }
private static void validateConfig(Ehcache ehcache) { CacheConfiguration cacheConfiguration = ehcache.getCacheConfiguration(); final TerracottaConfiguration terracottaConfiguration = cacheConfiguration.getTerracottaConfiguration(); List<ConfigError> errors = new ArrayList<ConfigError>(); if (terracottaConfiguration == null || !terracottaConfiguration.isClustered()) { throw new InvalidConfigurationException( "Cannot create clustered store for non-terracotta clustered caches"); } MemoryStoreEvictionPolicy policy = cacheConfiguration.getMemoryStoreEvictionPolicy(); if (policy == MemoryStoreEvictionPolicy.FIFO || policy == MemoryStoreEvictionPolicy.LFU) { errors.add(new ConfigError("Policy '" + policy + "' is not a supported memory store eviction policy.")); } if (cacheConfiguration.isOverflowToDisk()) { if (LOG.isWarnEnabled()) { LOG.warn("Persistence on disk on the local node is not supported with a Terracotta clustered ehcache store. Configure the Terracotta server array to be persistent instead."); } } boolean cachePinned = cacheConfiguration.getPinningConfiguration() != null && cacheConfiguration.getPinningConfiguration().getStore() == PinningConfiguration.Store.INCACHE; if (cachePinned && cacheConfiguration.getMaxEntriesInCache() != CacheConfiguration.DEFAULT_MAX_ENTRIES_IN_CACHE) { errors.add(new ConfigError("Cache pinning is not supported with maxEntriesInCache")); } if (errors.size() > 0) { throw new InvalidConfigurationException(errors); } }
/** * Accessor * @return a String representation of the policy */ public String getMemoryStoreEvictionPolicy() { return cacheConfiguration.getMemoryStoreEvictionPolicy().toString(); }
/** * Accessor * @return a String representation of the policy */ public String getMemoryStoreEvictionPolicy() { return cacheConfiguration.getMemoryStoreEvictionPolicy().toString(); }
/** * Accessor * @return a String representation of the policy */ public String getMemoryStoreEvictionPolicy() { return cacheConfiguration.getMemoryStoreEvictionPolicy().toString(); }
@Override public Object getConfigValue(Ehcache cache) { MemoryStoreEvictionPolicy policy = cache .getCacheConfiguration().getMemoryStoreEvictionPolicy(); return policy.toString(); } },
/** * {@inheritDoc} */ public String getMemoryStoreEvictionPolicy() { return cache.getCacheConfiguration().getMemoryStoreEvictionPolicy().toString(); }
/** * {@inheritDoc} */ @Override public String getMemoryStoreEvictionPolicy() { return cache.getCacheConfiguration().getMemoryStoreEvictionPolicy().toString(); }
/** * {@inheritDoc} */ @Override public String getMemoryStoreEvictionPolicy() { return cache.getCacheConfiguration().getMemoryStoreEvictionPolicy().toString(); }
/** * Chooses the Policy from the cache configuration * * @param cache */ protected static final Policy determineEvictionPolicy(Ehcache cache) { MemoryStoreEvictionPolicy policySelection = cache.getCacheConfiguration().getMemoryStoreEvictionPolicy(); if (policySelection.equals(MemoryStoreEvictionPolicy.LRU)) { return new LruPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.FIFO)) { return new FifoPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.LFU)) { return new LfuPolicy(); } throw new IllegalArgumentException(policySelection + " isn't a valid eviction policy"); }
/** * Chooses the Policy from the cache configuration * * @param cache */ protected final Policy determineEvictionPolicy() { MemoryStoreEvictionPolicy policySelection = cache.getCacheConfiguration().getMemoryStoreEvictionPolicy(); if (policySelection.equals(MemoryStoreEvictionPolicy.LRU)) { return new LruPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.FIFO)) { return new FifoPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.LFU)) { return new LfuPolicy(); } throw new IllegalArgumentException(policySelection + " isn't a valid eviction policy"); }
/** * Chooses the Policy from the cache configuration * @param cache the cache * @return the chosen eviction policy */ private static Policy determineEvictionPolicy(Ehcache cache) { MemoryStoreEvictionPolicy policySelection = cache.getCacheConfiguration().getMemoryStoreEvictionPolicy(); if (policySelection.equals(MemoryStoreEvictionPolicy.LRU)) { return new LruPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.FIFO)) { return new FifoPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.LFU)) { return new LfuPolicy(); } else if (policySelection.equals(MemoryStoreEvictionPolicy.CLOCK)) { return null; } throw new IllegalArgumentException(policySelection + " isn't a valid eviction policy"); }
if (useClassicLru && configuration.getMemoryStoreEvictionPolicy().equals(MemoryStoreEvictionPolicy.LRU)) { Store disk = createDiskStore(); store = new LegacyStoreWrapper(new LruMemoryStore(this, disk), disk, registeredEventListeners, configuration);
element.addAttribute(new SimpleNodeAttribute("transactionalMode", cacheConfiguration.getTransactionalMode()).optional(true) .defaultValue(CacheConfiguration.DEFAULT_TRANSACTIONAL_MODE)); element.addAttribute(new SimpleNodeAttribute("memoryStoreEvictionPolicy", cacheConfiguration.getMemoryStoreEvictionPolicy() .toString().toUpperCase()).optional(true).defaultValue( CacheConfiguration.DEFAULT_MEMORY_STORE_EVICTION_POLICY.toString().toUpperCase()));