private void fireChangeEventIfNeeded(String configName, Object oldValue, Object newValue) { if (oldValue != null && !oldValue.equals(newValue)) { fireConfigChangeEvent(configName, oldValue, newValue); } }
@Override public boolean equals(Object o) { if (!(o instanceof MutableConfig)) { return false; } MutableConfig config = (MutableConfig) o; return getName().equals(config.getName()) && (getMaxTTISeconds() == config.getMaxTTISeconds()) && (getMaxTTLSeconds() == config.getMaxTTLSeconds()) && (isOrphanEvictionEnabled() == config.isOrphanEvictionEnabled()) && (getOrphanEvictionPeriod() == config.getOrphanEvictionPeriod()) && (isLoggingEnabled() == config.isLoggingEnabled()) && (getTargetMaxInMemoryCount() == config.getTargetMaxInMemoryCount()) && (getTargetMaxTotalCount() == config.getTargetMaxTotalCount()); }
public <K, V> DistributedCache<K, V> newCache() { final MutableConfig copyConfig = new MutableConfig(this.name, this.loggingEnabled, this.maxTTISeconds, this.maxTTLSeconds, this.orphanEvictionEnabled, this.orphanEvictionPeriod, this.targetMaxInMemoryCount, this.targetMaxTotalCount, this.capacityEvictionPolicyDataFactory); if (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
@Override public int hashCode() { return this.getName().hashCode(); }
private void registerTCLoggerIfActive() { if (Terracotta.isActive()) { addConfigChangeListener(new TCLoggerConfigChangeListener()); } }
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 <K, V> DistributedCache<K, V> newCache() { final MutableConfig copyConfig = new MutableConfig(this.name, this.loggingEnabled, this.maxTTISeconds, this.maxTTLSeconds, this.orphanEvictionEnabled, this.orphanEvictionPeriod, this.targetMaxInMemoryCount, this.targetMaxTotalCount, this.capacityEvictionPolicyDataFactory); if (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
@Override public int hashCode() { return this.getName().hashCode(); }
private void registerTCLoggerIfActive() { if (Terracotta.isActive()) { addConfigChangeListener(new TCLoggerConfigChangeListener()); } }
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); } }
@Override public boolean equals(Object o) { if (!(o instanceof MutableConfig)) { return false; } MutableConfig config = (MutableConfig) o; return getName().equals(config.getName()) && (getMaxTTISeconds() == config.getMaxTTISeconds()) && (getMaxTTLSeconds() == config.getMaxTTLSeconds()) && (isOrphanEvictionEnabled() == config.isOrphanEvictionEnabled()) && (getOrphanEvictionPeriod() == config.getOrphanEvictionPeriod()) && (isLoggingEnabled() == config.isLoggingEnabled()) && (getTargetMaxInMemoryCount() == config.getTargetMaxInMemoryCount()) && (getTargetMaxTotalCount() == config.getTargetMaxTotalCount()); }
public <K, V> DistributedCache<K, V> newCache() { final MutableConfig copyConfig = new MutableConfig(this.name, this.loggingEnabled, this.maxTTISeconds, this.maxTTLSeconds, this.orphanEvictionEnabled, this.orphanEvictionPeriod, this.targetMaxInMemoryCount, this.targetMaxTotalCount, this.capacityEvictionPolicyDataFactory); if (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
@Override public int hashCode() { return this.getName().hashCode(); }
private void registerTCLoggerIfActive() { if (Terracotta.isActive()) { addConfigChangeListener(new TCLoggerConfigChangeListener()); } }
private void fireChangeEventIfNeeded(String configName, Object oldValue, Object newValue) { if (oldValue != null && !oldValue.equals(newValue)) { fireConfigChangeEvent(configName, oldValue, newValue); } }
public boolean refresh() { // read <autolock>'d synchronized (this) { ImmutableConfig 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, localCacheEnabled); if (oldSnapshot != null) { fireChangeEventIfNeeded(NAME, oldSnapshot.getName(), name); fireChangeEventIfNeeded(LOGGING_ENABLED, oldSnapshot.isLoggingEnabled(), loggingEnabled); fireChangeEventIfNeeded(MAX_TTI_SECONDS, oldSnapshot.getMaxTTISeconds(), maxTTISeconds); fireChangeEventIfNeeded(MAX_TTL_SECONDS, oldSnapshot.getMaxTTLSeconds(), maxTTLSeconds); fireChangeEventIfNeeded(ORPHAN_EVICTION_ENABLED, oldSnapshot.isOrphanEvictionEnabled(), orphanEvictionEnabled); fireChangeEventIfNeeded(ORPHAN_EVICTION_PERIOD, oldSnapshot.getOrphanEvictionPeriod(), orphanEvictionPeriod); fireChangeEventIfNeeded(TARGET_MAX_ENTRIES_LOCAL_HEAP, oldSnapshot.getTargetMaxInMemoryCount(), targetMaxInMemoryCount); fireChangeEventIfNeeded(TARGET_MAX_TOTAL_COUNT, oldSnapshot.getTargetMaxTotalCount(), targetMaxTotalCount); fireChangeEventIfNeeded(CAPACITY_EVICTION_POLICY_DATA_FACTORY, oldSnapshot.getCapacityEvictionPolicyDataFactory(), capacityEvictionPolicyDataFactory); fireChangeEventIfNeeded(LOCAL_CACHE_ENABLED, oldSnapshot.isLocalCacheEnabled(), localCacheEnabled); } return !snapshot.equals(oldSnapshot); } }
@Override public boolean equals(Object o) { if (!(o instanceof MutableConfig)) { return false; } MutableConfig config = (MutableConfig) o; return getName().equals(config.getName()) && (getMaxTTISeconds() == config.getMaxTTISeconds()) && (getMaxTTLSeconds() == config.getMaxTTLSeconds()) && (isOrphanEvictionEnabled() == config.isOrphanEvictionEnabled()) && (getOrphanEvictionPeriod() == config.getOrphanEvictionPeriod()) && (isLoggingEnabled() == config.isLoggingEnabled()) && (getTargetMaxInMemoryCount() == config.getTargetMaxInMemoryCount()) && (getTargetMaxTotalCount() == config.getTargetMaxTotalCount()); }
/** * 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 (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }
private void fireChangeEventIfNeeded(String configName, Object oldValue, Object newValue) { if (oldValue != null && !oldValue.equals(newValue)) { fireConfigChangeEvent(configName, oldValue, newValue); } }
/** * 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 (Terracotta.isActive()) { return new TerracottaDistributedCache<K, V>(copyConfig); } else { return new LocalCache<K, V>(copyConfig); } }