public int getTargetMaxInMemoryCount() { return snapshot.getTargetMaxInMemoryCount(); }
public int getTargetMaxInMemoryCount() { return snapshot.getTargetMaxInMemoryCount(); }
public int getTargetMaxInMemoryCount() { return snapshot.getTargetMaxInMemoryCount(); }
public void localSizeChanged(int delta) { if ((delta <= 0) || (config.getTargetMaxInMemoryCount() <= 0)) { return; } int overshoot = map.localSize() - config.getTargetMaxInMemoryCount(); if (overshoot <= 0) { localEvictionRatio = 1; return; } else if (overshoot > Math.max(OVERSHOOT_MINIMUM, OVERSHOOT_RATIO * config.getTargetMaxInMemoryCount())) { localEvictionRatio = MAX_EVICTION_RATIO; } int maxEvict = Math.min(delta * localEvictionRatio, overshoot); targetCapacityEvictor.evictLocalElements(maxEvict); }
public void localSizeChanged(int delta) { if ((delta <= 0) || (config.getTargetMaxInMemoryCount() <= 0)) { return; } int overshoot = map.localSize() - config.getTargetMaxInMemoryCount(); if (overshoot <= 0) { localEvictionRatio = 1; return; } else if (overshoot > Math.max(OVERSHOOT_MINIMUM, OVERSHOOT_RATIO * config.getTargetMaxInMemoryCount())) { localEvictionRatio = MAX_EVICTION_RATIO; } int maxEvict = Math.min(delta * localEvictionRatio, overshoot); targetCapacityEvictor.evictLocalElements(maxEvict); }
public void localSizeChanged(int delta) { if ((delta <= 0) || (config.getTargetMaxInMemoryCount() <= 0)) { return; } int overshoot = map.localSize() - config.getTargetMaxInMemoryCount(); if (overshoot <= 0) { localEvictionRatio = 1; return; } else if (overshoot > Math.max(OVERSHOOT_MINIMUM, OVERSHOOT_RATIO * config.getTargetMaxInMemoryCount())) { localEvictionRatio = MAX_EVICTION_RATIO; } int maxEvict = Math.min(delta * localEvictionRatio, overshoot); targetCapacityEvictor.evictLocalElements(maxEvict); }
public void localSizeChanged(int delta) { if ((delta <= 0) || (config.getTargetMaxInMemoryCount() <= 0)) { return; } int overshoot = map.localSize() - config.getTargetMaxInMemoryCount(); if (overshoot <= 0) { localEvictionRatio = 1; return; } else if (overshoot > Math.max(OVERSHOOT_MINIMUM, OVERSHOOT_RATIO * config.getTargetMaxInMemoryCount())) { localEvictionRatio = MAX_EVICTION_RATIO; } int maxEvict = Math.min(delta * localEvictionRatio, overshoot); targetCapacityEvictor.evictLocalElements(maxEvict); }
public int getRegionCacheTargetMaxInMemoryCount(String region) { return lookupTerracottaHibernateEvictorConfig(region).getTargetMaxInMemoryCount(); }
protected boolean isCapacityEvictionEnabled() { return config.getTargetMaxInMemoryCount() > 0 || config.getTargetMaxTotalCount() > 0; }
protected boolean isCapacityEvictionEnabled() { return config.getTargetMaxInMemoryCount() > 0 || config.getTargetMaxTotalCount() > 0; }
protected boolean isCapacityEvictionEnabled() { return config.getTargetMaxInMemoryCount() > 0 || config.getTargetMaxTotalCount() > 0; }
protected boolean isCapacityEvictionEnabled() { return config.getTargetMaxInMemoryCount() > 0 || config.getTargetMaxTotalCount() > 0; }
public ImmutableConfig(CacheConfig config) { this.name = config.getName(); this.loggingEnabled = config.isLoggingEnabled(); this.maxTTISeconds = config.getMaxTTISeconds(); this.maxTTLSeconds = config.getMaxTTLSeconds(); this.orphanEvictionEnabled = config.isOrphanEvictionEnabled(); this.orphanEvictionPeriod = config.getOrphanEvictionPeriod(); this.targetMaxInMemoryCount = config.getTargetMaxInMemoryCount(); this.targetMaxTotalCount = config.getTargetMaxTotalCount(); this.capacityEvictionPolicyDataFactory = config.getCapacityEvictionPolicyDataFactory(); }
/** * Constructs an immutable configuration as a value-based copy of the supplied configuration. * * @param config configuration to copy from */ public ImmutableConfig(final CacheConfig config) { this.name = config.getName(); this.loggingEnabled = config.isLoggingEnabled(); this.maxTTISeconds = config.getMaxTTISeconds(); this.maxTTLSeconds = config.getMaxTTLSeconds(); this.orphanEvictionEnabled = config.isOrphanEvictionEnabled(); this.orphanEvictionPeriod = config.getOrphanEvictionPeriod(); this.targetMaxInMemoryCount = config.getTargetMaxInMemoryCount(); this.targetMaxTotalCount = config.getTargetMaxTotalCount(); this.capacityEvictionPolicyDataFactory = config.getCapacityEvictionPolicyDataFactory(); this.serverMap = config.isServerMap(); }
/** * Constructs an immutable configuration as a value-based copy of the supplied * configuration. * * @param config configuration to copy from */ public ImmutableConfig(final CacheConfig config) { this.name = config.getName(); this.loggingEnabled = config.isLoggingEnabled(); this.maxTTISeconds = config.getMaxTTISeconds(); this.maxTTLSeconds = config.getMaxTTLSeconds(); this.orphanEvictionEnabled = config.isOrphanEvictionEnabled(); this.orphanEvictionPeriod = config.getOrphanEvictionPeriod(); this.targetMaxInMemoryCount = config.getTargetMaxInMemoryCount(); this.targetMaxTotalCount = config.getTargetMaxTotalCount(); this.capacityEvictionPolicyDataFactory = config.getCapacityEvictionPolicyDataFactory(); this.serverMap = config.isServerMap(); }
@Override protected <L> ClusteredMap<K, V> initBackend(final CacheConfig cacheConfig, final LockType lockType, final GenericLockStrategy<L, ? super K> lockStrategy, final int concurrency) { ClusteredMap<K, V> backend = null; if (Terracotta.isActive()) { if (concurrency == 1) { if (cacheConfig == null) { backend = new ConcurrentDistributedServerMapDso<K, V, L>(lockType, lockStrategy, invalidateOnChange); } else { backend = new ConcurrentDistributedServerMapDso<K, V, L>(LockingUtils.translateLockType(lockType), lockStrategy, cacheConfig.getMaxTTISeconds(), cacheConfig.getMaxTTLSeconds(), cacheConfig.getTargetMaxInMemoryCount(), cacheConfig.getTargetMaxTotalCount(), invalidateOnChange, cacheConfig.getName()); } } else { backend = new ConcurrentDistributedServerMapDsoArray<K, V, L>(cacheConfig, lockType, lockStrategy, concurrency, invalidateOnChange); } } else { backend = new ConcurrentDistributedMapNoDso<K, V>(concurrency); } return backend; }
/** * Mark this timestamp as being used and reset the idle timer (if in use). Updates <tt>lastAccessedTime</tt> of this * entry to <tt>usedAtTime</tt> * <p /> * Special case when tti=1; this will update the <tt>lastAccessedTime</tt> at <tt>usedAtTime + 1</tt> instead. This is * because as time is not continuous, the entry will expire in the next second even when the entry is accessed in the * last second continuously. This is a result of time not being continuous. Effectively specifying tti=1 is equivalent * to tti=2 * * @param usedAtTime Mark used at this time */ public final void markUsed(int usedAtTime, final ClusteredLock lock, final CacheConfig config) { final boolean capacityEviction = (config.getTargetMaxInMemoryCount() > 0) || (config.getTargetMaxTotalCount() > 0); final int configTTI = config.getMaxTTISeconds(); if (configTTI == 1) { usedAtTime += 1; } if (shouldUpdateIdleTimer(usedAtTime, configTTI)) { setLastAccessedTime(usedAtTime, lock); } if (capacityEviction) { if (!config.getCapacityEvictionPolicyDataFactory().isProductOfFactory(fastGetCapacityEvictionPolicyData())) { // reinitialize capacityEvictionPolicyData take care of CapacityEviction enabled/changed dynamically setCapacityEvictionPolicyData(config.getCapacityEvictionPolicyDataFactory().newCapacityEvictionPolicyData()); } fastGetCapacityEvictionPolicyData().markUsed(usedAtTime); } }
public boolean refresh() { // read <autolock>'d synchronized (this) { CacheConfig oldSnapshot = snapshot; // don't use the ImmutableConfig(Config) constructor; it would read the snapshot... snapshot = new ImmutableConfig(name, loggingEnabled, maxTTISeconds, maxTTLSeconds, orphanEvictionEnabled, orphanEvictionPeriod, targetMaxInMemoryCount, targetMaxTotalCount, capacityEvictionPolicyDataFactory, serverMap); if (oldSnapshot != null) { fireChangeEventIfNeeded("name", oldSnapshot.getName(), name); fireChangeEventIfNeeded("loggingEnabled", oldSnapshot.isLoggingEnabled(), loggingEnabled); fireChangeEventIfNeeded("maxTTISeconds", oldSnapshot.getMaxTTISeconds(), maxTTISeconds); fireChangeEventIfNeeded("maxTTLSeconds", oldSnapshot.getMaxTTLSeconds(), maxTTLSeconds); fireChangeEventIfNeeded("orphanEvictionEnabled", oldSnapshot.isOrphanEvictionEnabled(), orphanEvictionEnabled); fireChangeEventIfNeeded("orphanEvictionPeriod", oldSnapshot.getOrphanEvictionPeriod(), orphanEvictionPeriod); fireChangeEventIfNeeded("targetMaxInMemoryCount", oldSnapshot.getTargetMaxInMemoryCount(), targetMaxInMemoryCount); fireChangeEventIfNeeded("targetMaxTotalCount", oldSnapshot.getTargetMaxTotalCount(), targetMaxTotalCount); fireChangeEventIfNeeded("capacityEvictionPolicyDataFactory", oldSnapshot.getCapacityEvictionPolicyDataFactory(), capacityEvictionPolicyDataFactory); } return !snapshot.equals(oldSnapshot); } }
public boolean refresh() { // read <autolock>'d synchronized (this) { CacheConfig oldSnapshot = snapshot; // don't use the ImmutableConfig(Config) constructor; it would read the snapshot... snapshot = new ImmutableConfig(name, loggingEnabled, maxTTISeconds, maxTTLSeconds, orphanEvictionEnabled, orphanEvictionPeriod, targetMaxInMemoryCount, targetMaxTotalCount, capacityEvictionPolicyDataFactory); if (oldSnapshot != null) { fireChangeEventIfNeeded("name", oldSnapshot.getName(), name); fireChangeEventIfNeeded("loggingEnabled", oldSnapshot.isLoggingEnabled(), loggingEnabled); fireChangeEventIfNeeded("maxTTISeconds", oldSnapshot.getMaxTTISeconds(), maxTTISeconds); fireChangeEventIfNeeded("maxTTLSeconds", oldSnapshot.getMaxTTLSeconds(), maxTTLSeconds); fireChangeEventIfNeeded("orphanEvictionEnabled", oldSnapshot.isOrphanEvictionEnabled(), orphanEvictionEnabled); fireChangeEventIfNeeded("orphanEvictionPeriod", oldSnapshot.getOrphanEvictionPeriod(), orphanEvictionPeriod); fireChangeEventIfNeeded("targetMaxInMemoryCount", oldSnapshot.getTargetMaxInMemoryCount(), targetMaxInMemoryCount); fireChangeEventIfNeeded("targetMaxTotalCount", oldSnapshot.getTargetMaxTotalCount(), targetMaxTotalCount); fireChangeEventIfNeeded("capacityEvictionPolicyDataFactory", oldSnapshot.getCapacityEvictionPolicyDataFactory(), capacityEvictionPolicyDataFactory); } return !snapshot.equals(oldSnapshot); } }
private static void connectConfigurations(Ehcache cache, ClusteredStore store) { cache.getCacheConfiguration().addConfigurationListener(store); cache.getCacheConfiguration().internalSetDiskCapacity(store.getBackend().getConfig().getTargetMaxTotalCount()); cache.getCacheConfiguration().internalSetMemCapacity(store.getBackend().getConfig().getTargetMaxInMemoryCount()); cache.getCacheConfiguration().internalSetTimeToIdle(store.getBackend().getConfig().getMaxTTISeconds()); cache.getCacheConfiguration().internalSetTimeToLive(store.getBackend().getConfig().getMaxTTLSeconds()); cache.getCacheConfiguration().internalSetLogging(store.getBackend().getConfig().isLoggingEnabled()); }