/** * {@inheritDoc} */ public long getMaxBytesLocalDisk() { return cacheManager.getConfiguration().getMaxBytesLocalDisk(); }
/** * {@inheritDoc} */ public String getMaxBytesLocalDiskAsString() { return cacheManager.getConfiguration().getMaxBytesLocalDiskAsString(); }
/** * {@inheritDoc} */ public String getMaxBytesLocalHeapAsString() { return cacheManager.getConfiguration().getMaxBytesLocalHeapAsString(); }
/** * Constructor accepting the {@link CacheManager}. This element does not have a parent and is always null. * * @param cacheManager */ public ConfigurationElement(CacheManager cacheManager) { super(null, "ehcache"); this.cacheManager = cacheManager; this.configuration = cacheManager.getConfiguration(); init(); }
/** * {@inheritDoc} */ public long getMaxBytesLocalHeap() { return cacheManager.getConfiguration().getMaxBytesLocalHeap(); }
/** * {@inheritDoc} */ public long getMaxBytesLocalOffHeap() { return cacheManager.getConfiguration().getMaxBytesLocalOffHeap(); }
/** * {@inheritDoc} */ public String getMaxBytesLocalOffHeapAsString() { return cacheManager.getConfiguration().getMaxBytesLocalOffHeapAsString(); }
private void registerCacheConfiguration(final CacheManager cacheManager) { Map<String, CacheConfiguration> configMap = cacheManager.getConfiguration().getCacheConfigurations(); if (!configMap.containsKey(getName())) { cacheManager.getConfiguration().addCache(this, false); } }
/** * {@inheritDoc} */ public void setMaxBytesLocalHeapAsString(String maxBytes) { try { cacheManager.getConfiguration().setMaxBytesLocalHeap(maxBytes); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
/** * {@inheritDoc} */ public void setMaxBytesLocalDiskAsString(String maxBytes) { try { cacheManager.getConfiguration().setMaxBytesLocalDisk(maxBytes); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
/** * {@inheritDoc} */ public void setMaxBytesLocalDisk(long maxBytes) { try { cacheManager.getConfiguration().setMaxBytesLocalDisk(maxBytes); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
/** * {@inheritDoc} */ public void setMaxBytesLocalHeap(long maxBytes) { try { cacheManager.getConfiguration().setMaxBytesLocalHeap(maxBytes); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
@Override public CacheManager getObject() { CacheManager cacheManager = super.getObject(); Map<String, CacheConfiguration> cacheConfig = cacheManager.getConfiguration().getCacheConfigurations(); List<CacheConfiguration> cacheConfigurations = CachePropertiesUtil.getCacheConfigurations(); cacheConfigurations.stream() .filter(cc -> cacheConfig.get(cc.getName()) == null) .forEach(cc -> cacheManager.addCache(new Cache(cc))); return cacheManager; } }
private void warnMaxEntriesLocalHeap(final boolean register, CacheManager cacheManager) { if (getMaxEntriesLocalHeap() == 0 && register) { if (getMaxBytesLocalHeap() == 0 && (!cacheManager.getConfiguration().isMaxBytesLocalHeapSet())) { LOG.warn("Cache: " + getName() + " has a maxElementsInMemory of 0. This might lead to performance degradation or OutOfMemoryError at Terracotta client." + "From Ehcache 2.0 onwards this has been changed to mean a store" + " with no capacity limit. Set it to 1 if you want" + " no elements cached in memory"); } } }
/** * Helper method which resolves the max depth of a cache, using the cache manager's one if none was configured * on the cache itself. * * @param cache the cache from which to resolve the max depth * @return the resolved max depth */ public static int resolveMaxDepth(Ehcache cache) { if (cache == null) { return DEFAULT_MAX_SIZEOF_DEPTH; } CacheManager cacheManager = cache.getCacheManager(); return resolvePolicy(cacheManager == null ? null : cacheManager.getConfiguration(), cache.getCacheConfiguration()).getMaxDepth(); }
/** * {@inheritDoc} */ @Override public boolean isLocalHeapCountBased() { return cache.getCacheConfiguration() .getMaxBytesLocalHeap() <= 0 && !(cache.getCacheManager() != null && cache.getCacheManager() .getConfiguration() .isMaxBytesLocalHeapSet()); }
private boolean skipUpdateAccessStatistics(Element element) { if (configuration.isFrozen()) { boolean forLifetime = element.isEternal(); boolean forHeap = configuration.getMaxEntriesLocalHeap() > 0 || configuration.getMaxBytesLocalHeap() > 0 || getCacheManager().getConfiguration().isMaxBytesLocalHeapSet(); boolean forDisk = configuration.isOverflowToDisk() && (configuration.getMaxEntriesLocalDisk() > 0 || configuration.getMaxBytesLocalDisk() > 0 || getCacheManager().getConfiguration().isMaxBytesLocalDiskSet()); return !(forLifetime || forHeap || forDisk); } else { return false; } }
void setUpWanConfig() { if (!cache.getCacheManager().getConfiguration().getTerracottaConfiguration().isWanEnabledTSA()) { toolkitInstanceFactory.markCacheWanDisabled(cache.getCacheManager().getName(), cache.getName()); } }
private synchronized ClusteredInstanceFactoryWrapper createNewClusteredInstanceFactory() { // shut down the old factory if (clusteredInstanceFactory != null) { info("Shutting down old ClusteredInstanceFactory..."); shutdownClusteredInstanceFactoryWrapper(clusteredInstanceFactory); } info("Creating new ClusteredInstanceFactory"); ClusteredInstanceFactory factory; factory = TerracottaClusteredInstanceHelper.getInstance().newClusteredInstanceFactory(terracottaClientConfiguration, cacheManager.getConfiguration().getClassLoader()); CacheCluster underlyingCacheCluster = factory.getTopology(); cacheCluster.setUnderlyingCacheCluster(underlyingCacheCluster); return new ClusteredInstanceFactoryWrapper(this, factory); }
/** * {@inheritDoc} */ @Override public void setMaxBytesLocalDiskAsString(String maxBytes) { try { cache.getCacheConfiguration().setMaxBytesLocalDisk(maxBytes); } catch (RuntimeException e) { throw Utils.newPlainException(e); } if (cache.getCacheConfiguration().isMaxBytesLocalDiskPercentageSet()) { long cacheAssignedMem = cache.getCacheManager().getConfiguration().getMaxBytesLocalDisk() * cache.getCacheConfiguration().getMaxBytesLocalDiskPercentage() / PERCENTAGE_DIVISOR; setMaxBytesLocalDisk(cacheAssignedMem); } }