Package net.sf.ehcache.config
Class TerracottaConfiguration
- java.lang.Object
-
- net.sf.ehcache.config.TerracottaConfiguration
-
- All Implemented Interfaces:
java.lang.Cloneable
public class TerracottaConfiguration extends java.lang.Object implements java.lang.CloneableClass to hold the Terracotta configuration - either a pointer to the real config or a container for embedded config.- Author:
- Alex Miller, Geert Bevin, Abhishek Sanoujam
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTerracottaConfiguration.ConsistencyEnum for various consistency settings
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_CACHE_COHERENTDeprecated.since 2.4 UseDEFAULT_CONSISTENCY_TYPEinstead.static booleanDEFAULT_CACHE_XADefault xa enabledstatic booleanDEFAULT_CLUSTEREDDefault clustered modestatic booleanDEFAULT_COHERENT_READSDefault coherent read behaviorstatic booleanDEFAULT_COMPRESSION_ENABLEDDefault compression settingstatic intDEFAULT_CONCURRENCYDefault value for concurrency of the internal Store.static TerracottaConfiguration.ConsistencyDEFAULT_CONSISTENCY_TYPEDefault cache consistency settingstatic booleanDEFAULT_COPY_ON_READDefault copy on read settingstatic booleanDEFAULT_LOCAL_CACHE_ENABLEDDefault value for whether local cache is enabled or notstatic booleanDEFAULT_LOCAL_KEY_CACHEDefault local key cache statusstatic intDEFAULT_LOCAL_KEY_CACHE_SIZEDefault local key cache sizestatic NonstopConfigurationDEFAULT_NON_STOP_CONFIGURATIONDefault value forNonstopConfigurationstatic booleanDEFAULT_ORPHAN_EVICTIONDefault orphan eviction statusstatic intDEFAULT_ORPHAN_EVICTION_PERIODDefault orphan eviction periodstatic booleanDEFAULT_SYNCHRONOUS_WRITESDefault setting for synchronous-write
-
Constructor Summary
Constructors Constructor Description TerracottaConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddNonstop(NonstopConfiguration nonstopConfiguration)Add theNonstopConfigurationTerracottaConfigurationcacheXA(boolean cacheXA)TerracottaConfigurationclone()Clones this object, following the usual contract.TerracottaConfigurationclustered(boolean clustered)TerracottaConfigurationcoherent(boolean coherent)Deprecated.since 2.4 Useconsistency(Consistency)insteadTerracottaConfigurationcoherentReads(boolean coherentReads)Deprecated.TerracottaConfigurationcompressionEnabled(boolean enabled)TerracottaConfigurationconcurrency(int concurrency)TerracottaConfigurationconsistency(TerracottaConfiguration.Consistency consistency)Setter for consistency, returns this instanceTerracottaConfigurationcopyOnRead(boolean isCopyOnRead)Deprecated.booleangetCoherentReads()Deprecated.intgetConcurrency()Get the value of concurrency.TerracottaConfiguration.ConsistencygetConsistency()Getter for consistencybooleangetLocalKeyCache()Check whether the local key cache is enabledintgetLocalKeyCacheSize()Get the size limit of the local key cache (if enabled)NonstopConfigurationgetNonstopConfiguration()Get theNonstopConfiguration, may be nullbooleangetOrphanEviction()Check whether orphan eviction is enabledintgetOrphanEvictionPeriod()Get the number of regular eviction cycles between orphan evictionsbooleanisCacheXA()Check whether the [serialized value] cache is an XA enabled cachebooleanisClustered()Check whether clustering is enabledbooleanisCoherent()Deprecated.since 2.4 UsegetConsistency()instead to query theTerracottaConfiguration.Consistencyor Ehcache#isNodeCoherent() to query if the node is coherentbooleanisCompressionEnabled()Check whether compression is enabledbooleanisCopyOnRead()Deprecated.booleanisLocalCacheEnabled()Returns true if local cache is enabled, otherwise falsebooleanisNonstopEnabled()Returns true if nonstop is enabledbooleanisSynchronousWrites()Is the cache configured for synchronous-write?TerracottaConfigurationlocalCacheEnabled(boolean localCacheEnabled)Enable or disable the local cacheTerracottaConfigurationlocalKeyCache(boolean localKeyCache)TerracottaConfigurationlocalKeyCacheSize(int localKeyCacheSize)TerracottaConfigurationnonstop(NonstopConfiguration nonstopConfiguration)Set theNonstopConfigurationTerracottaConfigurationorphanEviction(boolean orphanEviction)TerracottaConfigurationorphanEvictionPeriod(int orphanEvictionPeriod)voidsetCacheXA(boolean cacheXA)Used by BeanHandler to set the cacheXA flag during parsingvoidsetClustered(boolean clustered)Indicates whether to cluster this cache with Terracotta.voidsetCoherent(boolean coherent)Deprecated.since 2.4 UsesetConsistency(Consistency)insteadvoidsetCoherentReads(boolean coherentReads)Deprecated.voidsetCompressionEnabled(boolean enabled)Used by BeanHandler to set the compressionEnabled flag during parsingvoidsetConcurrency(int concurrency)Sets the value of concurrency.voidsetConsistency(java.lang.String consistency)Setter for consistencyvoidsetConsistency(TerracottaConfiguration.Consistency consistency)Setter for consistencyvoidsetCopyOnRead(boolean isCopyOnRead)Deprecated.voidsetLocalCacheEnabled(boolean localCacheEnabled)Enable or disable the local cachevoidsetLocalKeyCache(boolean localKeyCache)Sets whether this cache should use an unclustered local key cache (usually should be false unless optimizing for a small read-only cache)voidsetLocalKeyCacheSize(int localKeyCacheSize)Sets maximum size of the local key cache (usually the size of the key set of the cache or cache partition).voidsetOrphanEviction(boolean orphanEviction)Sets whether this cache should perform orphan eviction (usually should be true).voidsetOrphanEvictionPeriod(int orphanEvictionPeriod)Set how often this cache should perform orphan eviction (measured in regular eviction periods).voidsetSynchronousWrites(boolean synchronousWrites)Set the value for synchronous-writeTerracottaConfigurationsynchronousWrites(boolean synchronousWrites)
-
-
-
Field Detail
-
DEFAULT_CLUSTERED
public static final boolean DEFAULT_CLUSTERED
Default clustered mode- See Also:
- Constant Field Values
-
DEFAULT_COHERENT_READS
public static final boolean DEFAULT_COHERENT_READS
Default coherent read behavior- See Also:
- Constant Field Values
-
DEFAULT_CACHE_XA
public static final boolean DEFAULT_CACHE_XA
Default xa enabled- See Also:
- Constant Field Values
-
DEFAULT_ORPHAN_EVICTION
public static final boolean DEFAULT_ORPHAN_EVICTION
Default orphan eviction status- See Also:
- Constant Field Values
-
DEFAULT_ORPHAN_EVICTION_PERIOD
public static final int DEFAULT_ORPHAN_EVICTION_PERIOD
Default orphan eviction period- See Also:
- Constant Field Values
-
DEFAULT_LOCAL_KEY_CACHE
public static final boolean DEFAULT_LOCAL_KEY_CACHE
Default local key cache status- See Also:
- Constant Field Values
-
DEFAULT_LOCAL_KEY_CACHE_SIZE
public static final int DEFAULT_LOCAL_KEY_CACHE_SIZE
Default local key cache size- See Also:
- Constant Field Values
-
DEFAULT_COPY_ON_READ
public static final boolean DEFAULT_COPY_ON_READ
Default copy on read setting- See Also:
- Constant Field Values
-
DEFAULT_COMPRESSION_ENABLED
public static final boolean DEFAULT_COMPRESSION_ENABLED
Default compression setting- See Also:
- Constant Field Values
-
DEFAULT_NON_STOP_CONFIGURATION
public static final NonstopConfiguration DEFAULT_NON_STOP_CONFIGURATION
Default value forNonstopConfiguration
-
DEFAULT_CACHE_COHERENT
@Deprecated public static final boolean DEFAULT_CACHE_COHERENT
Deprecated.since 2.4 UseDEFAULT_CONSISTENCY_TYPEinstead.Default cache coherence setting- See Also:
- Constant Field Values
-
DEFAULT_CONSISTENCY_TYPE
public static final TerracottaConfiguration.Consistency DEFAULT_CONSISTENCY_TYPE
Default cache consistency setting
-
DEFAULT_SYNCHRONOUS_WRITES
public static final boolean DEFAULT_SYNCHRONOUS_WRITES
Default setting for synchronous-write- See Also:
- Constant Field Values
-
DEFAULT_CONCURRENCY
public static final int DEFAULT_CONCURRENCY
Default value for concurrency of the internal Store.- See Also:
- Constant Field Values
-
DEFAULT_LOCAL_CACHE_ENABLED
public static final boolean DEFAULT_LOCAL_CACHE_ENABLED
Default value for whether local cache is enabled or not- See Also:
- Constant Field Values
-
-
Method Detail
-
clone
public TerracottaConfiguration clone()
Clones this object, following the usual contract.- Overrides:
clonein classjava.lang.Object- Returns:
- a copy, which independent other than configurations than cannot change.
-
setClustered
public void setClustered(boolean clustered)
Indicates whether to cluster this cache with Terracotta.Defaults to true.
- Parameters:
clustered-trueif the cache should be clustered with Terracotta;falseotherwise
-
clustered
public TerracottaConfiguration clustered(boolean clustered)
- Returns:
- this configuration instance
- See Also:
setClustered(boolean)
-
isClustered
public boolean isClustered()
Check whether clustering is enabled
-
setCopyOnRead
@Deprecated public void setCopyOnRead(boolean isCopyOnRead)
Deprecated.Used by BeanHandler to set the copyOnRead flag during parsing
-
setCompressionEnabled
public void setCompressionEnabled(boolean enabled)
Used by BeanHandler to set the compressionEnabled flag during parsing
-
copyOnRead
@Deprecated public TerracottaConfiguration copyOnRead(boolean isCopyOnRead)
Deprecated.- Returns:
- this configuration instance
- See Also:
setCopyOnRead(boolean)
-
compressionEnabled
public TerracottaConfiguration compressionEnabled(boolean enabled)
- Returns:
- this configuration instance
-
isCacheXA
public boolean isCacheXA()
Check whether the [serialized value] cache is an XA enabled cache
-
setCacheXA
public void setCacheXA(boolean cacheXA)
Used by BeanHandler to set the cacheXA flag during parsing
-
cacheXA
public TerracottaConfiguration cacheXA(boolean cacheXA)
- Returns:
- this configuration instance
- See Also:
setCacheXA(boolean)
-
isCopyOnRead
@Deprecated public boolean isCopyOnRead()
Deprecated.Check whether the [serialized value] cache should use copy on read semantics
-
isCompressionEnabled
public boolean isCompressionEnabled()
Check whether compression is enabled
-
setCoherentReads
@Deprecated public void setCoherentReads(boolean coherentReads)
Deprecated.Sets whether this cache should use coherent reads (usually should be true unless optimizing for read-only).Defaults to true.
- Parameters:
coherentReads-trueif coherent reads should be used;falseotherwise
-
coherentReads
@Deprecated public TerracottaConfiguration coherentReads(boolean coherentReads)
Deprecated.- Returns:
- this configuration instance
- See Also:
setCoherentReads(boolean)
-
getCoherentReads
@Deprecated public boolean getCoherentReads()
Deprecated.Check whether coherent reads are enabled
-
setOrphanEviction
public void setOrphanEviction(boolean orphanEviction)
Sets whether this cache should perform orphan eviction (usually should be true).Orphans are elements that are not present on any node in the cluster anymore and hence need additional routines to be detected since they're not locally available anywhere.
Defaults to true.
- Parameters:
orphanEviction-trueif orphan eviction should be used;falseotherwise
-
orphanEviction
public TerracottaConfiguration orphanEviction(boolean orphanEviction)
- Returns:
- this configuration instance
- See Also:
setOrphanEviction(boolean)
-
getOrphanEviction
public boolean getOrphanEviction()
Check whether orphan eviction is enabled
-
setOrphanEvictionPeriod
public void setOrphanEvictionPeriod(int orphanEvictionPeriod)
Set how often this cache should perform orphan eviction (measured in regular eviction periods).Defaults to 4).
- Parameters:
orphanEvictionPeriod- every how many regular evictions an orphan eviction should occur
-
orphanEvictionPeriod
public TerracottaConfiguration orphanEvictionPeriod(int orphanEvictionPeriod)
- Returns:
- this configuration instance
- See Also:
setOrphanEvictionPeriod(int)
-
getOrphanEvictionPeriod
public int getOrphanEvictionPeriod()
Get the number of regular eviction cycles between orphan evictions
-
setLocalKeyCache
public void setLocalKeyCache(boolean localKeyCache)
Sets whether this cache should use an unclustered local key cache (usually should be false unless optimizing for a small read-only cache)Defaults to false.
- Parameters:
localKeyCache-trueif a local key cache should be used;falseotherwise
-
localKeyCache
public TerracottaConfiguration localKeyCache(boolean localKeyCache)
- Returns:
- this configuration instance
- See Also:
setLocalKeyCache(boolean)
-
getLocalKeyCache
public boolean getLocalKeyCache()
Check whether the local key cache is enabled
-
setLocalKeyCacheSize
public void setLocalKeyCacheSize(int localKeyCacheSize)
Sets maximum size of the local key cache (usually the size of the key set of the cache or cache partition).Defaults to 300000.
- Parameters:
localKeyCacheSize- the size of the local key cache in number of keys
-
localKeyCacheSize
public TerracottaConfiguration localKeyCacheSize(int localKeyCacheSize)
- Returns:
- this configuration instance
- See Also:
setLocalKeyCacheSize(int)
-
getLocalKeyCacheSize
public int getLocalKeyCacheSize()
Get the size limit of the local key cache (if enabled)
-
setCoherent
@Deprecated public void setCoherent(boolean coherent)
Deprecated.since 2.4 UsesetConsistency(Consistency)insteadUsed by BeanHandler to set the coherent during parsing
-
coherent
@Deprecated public TerracottaConfiguration coherent(boolean coherent)
Deprecated.since 2.4 Useconsistency(Consistency)instead- Returns:
- this configuration instance
-
isCoherent
@Deprecated public boolean isCoherent()
Deprecated.since 2.4 UsegetConsistency()instead to query theTerracottaConfiguration.Consistencyor Ehcache#isNodeCoherent() to query if the node is coherentIs the cache configured for coherent or incoherent mode.- Returns:
- true if configured in coherent mode.
-
isSynchronousWrites
public boolean isSynchronousWrites()
Is the cache configured for synchronous-write?- Returns:
- true if configured for synchronouse-write, otherwise false. Default is false
-
setSynchronousWrites
public void setSynchronousWrites(boolean synchronousWrites)
Set the value for synchronous-write- Parameters:
synchronousWrites- true for using synchronous-write
-
synchronousWrites
public TerracottaConfiguration synchronousWrites(boolean synchronousWrites)
- Returns:
- this configuration instance
- See Also:
setSynchronousWrites(boolean)
-
concurrency
public TerracottaConfiguration concurrency(int concurrency)
- Returns:
- this configuration instance
- See Also:
setConcurrency(int)
-
setConcurrency
public void setConcurrency(int concurrency)
Sets the value of concurrency. ThrowsIllegalArgumentExceptionif the value is less than 0. This value cannot be changed once cache is initialized.
-
getConcurrency
public int getConcurrency()
Get the value of concurrency. This value cannot be changed once cache is initialized.
-
addNonstop
public void addNonstop(NonstopConfiguration nonstopConfiguration)
Add theNonstopConfiguration- Parameters:
nonstopConfiguration-
-
nonstop
public TerracottaConfiguration nonstop(NonstopConfiguration nonstopConfiguration)
Set theNonstopConfiguration- Parameters:
nonstopConfiguration-- Returns:
- this configuration instance
-
getNonstopConfiguration
public NonstopConfiguration getNonstopConfiguration()
Get theNonstopConfiguration, may be null- Returns:
- the
NonstopConfiguration, may be null
-
isNonstopEnabled
public boolean isNonstopEnabled()
Returns true if nonstop is enabled- Returns:
- true if nonstop is enabled
-
consistency
public TerracottaConfiguration consistency(TerracottaConfiguration.Consistency consistency)
Setter for consistency, returns this instance- Parameters:
consistency-- Returns:
- this instance
-
setConsistency
public void setConsistency(TerracottaConfiguration.Consistency consistency)
Setter for consistency- Parameters:
consistency-
-
setConsistency
public void setConsistency(java.lang.String consistency)
Setter for consistency- Parameters:
consistency-
-
getConsistency
public TerracottaConfiguration.Consistency getConsistency()
Getter for consistency- Returns:
- the consistency
-
isLocalCacheEnabled
public boolean isLocalCacheEnabled()
Returns true if local cache is enabled, otherwise false- Returns:
- true if local cache is enabled, otherwise false
-
setLocalCacheEnabled
public void setLocalCacheEnabled(boolean localCacheEnabled)
Enable or disable the local cache- Parameters:
localCacheEnabled-
-
localCacheEnabled
public TerracottaConfiguration localCacheEnabled(boolean localCacheEnabled)
Enable or disable the local cache- Parameters:
localCacheEnabled-- Returns:
- this instance
-
-