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(); }
protected boolean isCapacityEvictionEnabled() { return config.getTargetMaxInMemoryCount() > 0 || config.getTargetMaxTotalCount() > 0; }
protected boolean isEvictionEnabled() { return config.getMaxTTISeconds() > 0 || config.getMaxTTLSeconds() > 0; }
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()); }
/** * Perform orphan eviction */ public void endLocalEviction() { log("Local eviction finished"); if (!config.isOrphanEvictionEnabled() || !isOrphanEvictor || !(config.getMaxTTISeconds() > 0 || config.getMaxTTLSeconds() > 0)) { return; } boolean isTimeForOrphanEviction = incrementEvictionCounter(); if (isTimeForOrphanEviction) { log("Running orphan eviction (evictionCount = " + evictionCount + ", orphanEvictionPeriod = " + config.getOrphanEvictionPeriod() + ")"); // when the cluster information has been injected, there's also no sense to evict if (clusterInfo != null) { store.evictOrphanElements(clusterInfo); } } else { log("Not running orphan eviction (evictionCount = " + evictionCount + ", orphanEvictionPeriod = " + config.getOrphanEvictionPeriod() + ")"); } }
public boolean isLoggingEnabled() { return snapshot.isLoggingEnabled(); }
public Factory getCapacityEvictionPolicyDataFactory() { return snapshot.getCapacityEvictionPolicyDataFactory(); }
public boolean isOrphanEvictionEnabled() { return snapshot.isOrphanEvictionEnabled(); }
/** * Construct an orphan eviction listener with clustered state * * @param config The clustered configuration of the orphan distributed map and orphan evictor * @param store The clustered store to evict * @param orphanEvictorLock The clustered lock that is used as a token to indicate the elected orphan evictor */ public OrphanEvictionListener(CacheConfig config, Evictable<K> store, EvictorLock orphanEvictorLock) { // Copy configuration this.config = config; if (config.isOrphanEvictionEnabled()) { Assert.eval(config.getOrphanEvictionPeriod() > 0); } // Copy clustered resources this.store = store; this.orphanEvictorLock = orphanEvictorLock; }
public int getTargetMaxTotalCount() { return snapshot.getTargetMaxTotalCount(); }
public int getTargetMaxInMemoryCount() { return snapshot.getTargetMaxInMemoryCount(); }
public String getName() { return snapshot.getName(); }
private boolean incrementEvictionCounter() { evictionCount++; boolean isTimeForOrphanEviction = evictionCount >= config.getOrphanEvictionPeriod(); if (isTimeForOrphanEviction) { evictionCount = 0; } return isTimeForOrphanEviction; }
private void sleep() { long start = System.currentTimeMillis(); long wakeup = calculateWakeup(start); while (System.currentTimeMillis() < wakeup) { config.waitForChange(wakeup - System.currentTimeMillis()); wakeup = calculateWakeup(start); } }
protected boolean isEvictionEnabled() { return config.getMaxTTISeconds() > 0 || config.getMaxTTLSeconds() > 0; }
protected boolean isCapacityEvictionEnabled() { return config.getTargetMaxInMemoryCount() > 0 || config.getTargetMaxTotalCount() > 0; }
public boolean isLoggingEnabled() { return snapshot.isLoggingEnabled(); }
public Factory getCapacityEvictionPolicyDataFactory() { return snapshot.getCapacityEvictionPolicyDataFactory(); }
public boolean isOrphanEvictionEnabled() { return snapshot.isOrphanEvictionEnabled(); }
/** * Construct an orphan eviction listener with clustered state * * @param config The clustered configuration of the orphan distributed map and orphan evictor * @param store The clustered store to evict * @param orphanEvictorLock The clustered lock that is used as a token to indicate the elected orphan evictor */ public OrphanEvictionListener(CacheConfig config, Evictable<K> store, EvictorLock orphanEvictorLock) { // Copy configuration this.config = config; if (config.isOrphanEvictionEnabled()) { Assert.eval(config.getOrphanEvictionPeriod() > 0); } // Copy clustered resources this.store = store; this.orphanEvictorLock = orphanEvictorLock; }