public Configuration newConfiguration(String cacheName, String configDeclaration, CacheType cacheType, IsolationLevel isolation, boolean keyCache, int keyMaxSize, boolean unlockedRead, boolean logging, int maxTti, int maxTtl, boolean orphanEviction, int orphanPeriod, int targetMaxInMemoryCount, int targetMaxTotalCount) { return new ImmutableConfiguration(cacheName, configDeclaration, cacheType, isolation, keyCache, keyMaxSize, unlockedRead, new MutableConfig().setName(cacheName).setLoggingEnabled(logging) .setMaxTTISeconds(maxTti).setMaxTTLSeconds(maxTtl) .setOrphanEvictionEnabled(orphanEviction) .setOrphanEvictionPeriod(orphanPeriod) .setTargetMaxInMemoryCount(targetMaxInMemoryCount) .setTargetMaxTotalCount(targetMaxTotalCount)); }
private void registerTCLoggerIfActive() { if (DSO_ACTIVE) { addConfigChangeListener(new TCLoggerConfigChangeListener()); } }
private void fireChangeEventIfNeeded(String configName, Object oldValue, Object newValue) { if (oldValue != null && !oldValue.equals(newValue)) { fireConfigChangeEvent(configName, oldValue, newValue); } }
private static CacheConfig getDefaultConfig() { MutableConfig config = new MutableConfig(); config.setMaxTTISeconds(0); config.setMaxTTLSeconds(0); config.setOrphanEvictionEnabled(false); ImmutableConfig rv = new ImmutableConfig(config); if (rv.isEvictionEnabled()) { throw new AssertionError("Eviction is enabled? " + config); } return rv; }
/** * Construct a new cache configuration. * @return A new configuration with all default values. */ public static CacheConfig newConfig() { return new MutableConfig(); } }
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 <K, V> DistributedCache<K, V> newCache() { MutableConfig copyConfig = new MutableConfig(name, loggingEnabled, maxTTISeconds, maxTTLSeconds, orphanEvictionEnabled, orphanEvictionPeriod, targetMaxInMemoryCount, targetMaxTotalCount, capacityEvictionPolicyDataFactory); if (CacheConfigFactory.DSO_ACTIVE) { return new DistributedCacheImpl<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
/** * Construct a new cache instance based on the configuration changes specified in this instance of the builder so far. * If Terracotta is not being used, a non-clustered implementation will be returned instead. * * @param <K> Key type * @param <V> Value type * @return Map constructed by this method based on previous parameters and defaults */ public <K, V> DistributedCache<K, V> newCache() { MutableConfig copyConfig = new MutableConfig(name, loggingEnabled, maxTTISeconds, maxTTLSeconds, orphanEvictionEnabled, orphanEvictionPeriod, targetMaxInMemoryCount, targetMaxTotalCount, capacityEvictionPolicyDataFactory); if (CacheConfigFactory.DSO_ACTIVE) { return new DistributedCacheImpl<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
/** * This method is used for common on-load and instantiation logic. We can't rely on the standard DSO on-load feature * since roots of ClusteredStore are explicitly created in * {@link org.terracotta.modules.ehcache.store.TerracottaClusteredInstanceFactory} through ManagerUtil call, as * opposed to the regular root declaration in DSO instrumented classes. * <p/> * This approach is needed for 'express' features since none of the application context classes can be instrumented by * Terracotta due to the lack of a boot jar. */ public void initalizeTransients(final Ehcache ehcache) { this.cache = ehcache; if (localKeyCacheMaxsize > 0) { keyLookupCache = new ConcurrentHashMap<Object, Object>(); } else { keyLookupCache = null; } this.linkedConfigurations = new CopyOnWriteArraySet<CacheConfiguration>(); ((MutableConfig) backend.getConfig()).addConfigChangeListener(this); backend.initializeTransients(cache.getCacheEventNotificationService()); if (localBufferedMap == null) { localBufferedMap = new LocalBufferedMap<Object, TimestampedValue<Object>>(backend, cacheCoherence, valueModeHandler); } CacheShutdownHook.INSTANCE.registerCache(cache); }
public ClusteredStore(final Ehcache cache) { final CacheConfig config = new MutableConfig(); final CacheConfiguration ehcacheConfig = cache.getCacheConfiguration();