public Factory getCapacityEvictionPolicyDataFactory() { return snapshot.getCapacityEvictionPolicyDataFactory(); }
public Factory getCapacityEvictionPolicyDataFactory() { return snapshot.getCapacityEvictionPolicyDataFactory(); }
public Factory getCapacityEvictionPolicyDataFactory() { return snapshot.getCapacityEvictionPolicyDataFactory(); }
public Policy getInMemoryEvictionPolicy() { CapacityEvictionPolicyData.Factory factory = backend.getConfig().getCapacityEvictionPolicyDataFactory(); if (factory instanceof LFUCapacityEvictionPolicyData.Factory) { return LFU_POLICY_INSTANCE; } else if (factory instanceof LRUCapacityEvictionPolicyData.Factory) { return LRU_POLICY_INSTANCE; } throw new AssertionError( "An instance of " + factory + " isn't supposed to be set in the config of the clustered store as it's not understood by Ehcache"); }
public Policy getEvictionPolicy() { CapacityEvictionPolicyData.Factory factory = backend.getConfig().getCapacityEvictionPolicyDataFactory(); if (factory instanceof LFUCapacityEvictionPolicyData.Factory) { return LFU_POLICY_INSTANCE; } else if (factory instanceof LRUCapacityEvictionPolicyData.Factory) { return LRU_POLICY_INSTANCE; } throw new AssertionError( "An instance of " + factory + " isn't supposed to be set in the config of the clustered store as it's not understood by Ehcache"); }
private void initCapacityEvictionPolicyFromConfig(final TimestampedValue timestampedValue) { if (isCapacityEvictionEnabled()) { // use CapacityEvictionPolicyData.Factory in config to create a new one if its not an instance of the config's // factory CapacityEvictionPolicyData current = timestampedValue.getCapacityEvictionPolicyData(); if (!getConfig().getCapacityEvictionPolicyDataFactory().isProductOfFactory(current)) { CapacityEvictionPolicyData cep = getConfig().getCapacityEvictionPolicyDataFactory() .newCapacityEvictionPolicyData(); timestampedValue.setCapacityEvictionPolicyData(cep); } } }
private void initCapacityEvictionPolicyFromConfig(final TimestampedValue timestampedValue) { if (isCapacityEvictionEnabled()) { // use CapacityEvictionPolicyData.Factory in config to create a new one if its not an instance of the config's // factory CapacityEvictionPolicyData current = timestampedValue.getCapacityEvictionPolicyData(); if (!getConfig().getCapacityEvictionPolicyDataFactory().isProductOfFactory(current)) { CapacityEvictionPolicyData cep = getConfig().getCapacityEvictionPolicyDataFactory() .newCapacityEvictionPolicyData(); timestampedValue.setCapacityEvictionPolicyData(cep); } } }
private void initCapacityEvictionPolicyFromConfig(final TimestampedValue timestampedValue) { if (isCapacityEvictionEnabled()) { // use CapacityEvictionPolicyData.Factory in config to create a new one if its not an instance of the config's // factory CapacityEvictionPolicyData current = timestampedValue.getCapacityEvictionPolicyData(); if (!getConfig().getCapacityEvictionPolicyDataFactory().isProductOfFactory(current)) { CapacityEvictionPolicyData cep = getConfig().getCapacityEvictionPolicyDataFactory() .newCapacityEvictionPolicyData(); timestampedValue.setCapacityEvictionPolicyData(cep); } } }
private void initCapacityEvictionPolicyFromConfig(final TimestampedValue timestampedValue) { if (isCapacityEvictionEnabled()) { // use CapacityEvictionPolicyData.Factory in config to create a new one if its not an instance of the config's // factory CapacityEvictionPolicyData current = timestampedValue.getCapacityEvictionPolicyData(); if (!getConfig().getCapacityEvictionPolicyDataFactory().isProductOfFactory(current)) { CapacityEvictionPolicyData cep = getConfig().getCapacityEvictionPolicyDataFactory() .newCapacityEvictionPolicyData(); timestampedValue.setCapacityEvictionPolicyData(cep); } } }
/** * 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 String lockId, final CacheConfig config) { boolean capacityEviction = (config.getTargetMaxInMemoryCount() > 0) || (config.getTargetMaxTotalCount() > 0); int configTTI = config.getMaxTTISeconds(); if (configTTI == 1) usedAtTime += 1; if (shouldUpdateIdleTimer(usedAtTime, configTTI)) { setLastAccessedTime(usedAtTime, lockId); } if (capacityEviction) { if (!config.getCapacityEvictionPolicyDataFactory().isProductOfFactory(fastGetCapacityEvictionPolicyData())) { // reinitialize capacityEvictionPolicyData take care of CapacityEviction enabled/changed dynamically setCapacityEvictionPolicyData(config.getCapacityEvictionPolicyDataFactory().newCapacityEvictionPolicyData()); } fastGetCapacityEvictionPolicyData().markUsed(usedAtTime); } }
/** * 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); } }
/** * 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 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(); }
/** * 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); } }
/** * 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(); }
/** * 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(); boolean enableLocalCache; if (config instanceof MutableConfig) { enableLocalCache = ((MutableConfig) config).isLocalCacheEnabled(); } else if (config instanceof ImmutableConfig) { enableLocalCache = ((ImmutableConfig) config).isLocalCacheEnabled(); } else { enableLocalCache = true; } this.localCacheEnabled = enableLocalCache; }
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); } }
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); } }