ehcache

net.sf.ehcache.config
Class TerracottaConfiguration

java.lang.Object
  extended by net.sf.ehcache.config.TerracottaConfiguration
All Implemented Interfaces:
Cloneable

public class TerracottaConfiguration
extends Object
implements Cloneable

Class 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
static class TerracottaConfiguration.Consistency
          Enum for various consistency settings
 
Field Summary
static boolean DEFAULT_CACHE_COHERENT
          Deprecated. since 2.4 Use DEFAULT_CONSISTENCY_TYPE instead.
static boolean DEFAULT_CACHE_XA
          Default xa enabled
static boolean DEFAULT_CLUSTERED
          Default clustered mode
static boolean DEFAULT_COHERENT_READS
          Default coherent read behavior
static boolean DEFAULT_COMPRESSION_ENABLED
          Default compression setting
static int DEFAULT_CONCURRENCY
          Default value for concurrency of the internal Store.
static TerracottaConfiguration.Consistency DEFAULT_CONSISTENCY_TYPE
          Default cache consistency setting
static boolean DEFAULT_COPY_ON_READ
          Default copy on read setting
static boolean DEFAULT_LOCAL_CACHE_ENABLED
          Default value for whether local cache is enabled or not
static boolean DEFAULT_LOCAL_KEY_CACHE
          Default local key cache status
static int DEFAULT_LOCAL_KEY_CACHE_SIZE
          Default local key cache size
static NonstopConfiguration DEFAULT_NON_STOP_CONFIGURATION
          Default value for NonstopConfiguration
static boolean DEFAULT_ORPHAN_EVICTION
          Default orphan eviction status
static int DEFAULT_ORPHAN_EVICTION_PERIOD
          Default orphan eviction period
static boolean DEFAULT_SYNCHRONOUS_WRITES
          Default setting for synchronous-write
 
Constructor Summary
TerracottaConfiguration()
           
 
Method Summary
 void addNonstop(NonstopConfiguration nonstopConfiguration)
          Add the NonstopConfiguration
 TerracottaConfiguration cacheXA(boolean cacheXA)
           
 TerracottaConfiguration clone()
          Clones this object, following the usual contract.
 TerracottaConfiguration clustered(boolean clustered)
           
 TerracottaConfiguration coherent(boolean coherent)
          Deprecated. since 2.4 Use consistency(Consistency) instead
 TerracottaConfiguration coherentReads(boolean coherentReads)
          Deprecated. 
 TerracottaConfiguration compressionEnabled(boolean enabled)
           
 TerracottaConfiguration concurrency(int concurrency)
           
 TerracottaConfiguration consistency(TerracottaConfiguration.Consistency consistency)
          Setter for consistency, returns this instance
 TerracottaConfiguration copyOnRead(boolean isCopyOnRead)
          Deprecated. 
 boolean getCoherentReads()
          Deprecated. 
 int getConcurrency()
          Get the value of concurrency.
 TerracottaConfiguration.Consistency getConsistency()
          Getter for consistency
 boolean getLocalKeyCache()
          Check whether the local key cache is enabled
 int getLocalKeyCacheSize()
          Get the size limit of the local key cache (if enabled)
 NonstopConfiguration getNonstopConfiguration()
          Get the NonstopConfiguration, may be null
 boolean getOrphanEviction()
          Check whether orphan eviction is enabled
 int getOrphanEvictionPeriod()
          Get the number of regular eviction cycles between orphan evictions
 boolean isCacheXA()
          Check whether the [serialized value] cache is an XA enabled cache
 boolean isClustered()
          Check whether clustering is enabled
 boolean isCoherent()
          Deprecated. since 2.4 Use getConsistency() instead to query the TerracottaConfiguration.Consistency or Ehcache#isNodeCoherent() to query if the node is coherent
 boolean isCompressionEnabled()
          Check whether compression is enabled
 boolean isCopyOnRead()
          Deprecated. 
 boolean isLocalCacheEnabled()
          Returns true if local cache is enabled, otherwise false
 boolean isNonstopEnabled()
          Returns true if nonstop is enabled
 boolean isSynchronousWrites()
          Is the cache configured for synchronous-write?
 TerracottaConfiguration localCacheEnabled(boolean localCacheEnabled)
          Enable or disable the local cache
 TerracottaConfiguration localKeyCache(boolean localKeyCache)
           
 TerracottaConfiguration localKeyCacheSize(int localKeyCacheSize)
           
 TerracottaConfiguration nonstop(NonstopConfiguration nonstopConfiguration)
          Set the NonstopConfiguration
 TerracottaConfiguration orphanEviction(boolean orphanEviction)
           
 TerracottaConfiguration orphanEvictionPeriod(int orphanEvictionPeriod)
           
 void setCacheXA(boolean cacheXA)
          Used by BeanHandler to set the cacheXA flag during parsing
 void setClustered(boolean clustered)
          Indicates whether to cluster this cache with Terracotta.
 void setCoherent(boolean coherent)
          Deprecated. since 2.4 Use setConsistency(Consistency) instead
 void setCoherentReads(boolean coherentReads)
          Deprecated. 
 void setCompressionEnabled(boolean enabled)
          Used by BeanHandler to set the compressionEnaled flag during parsing
 void setConcurrency(int concurrency)
          Sets the value of concurrency.
 void setConsistency(String consistency)
          Setter for consistency
 void setConsistency(TerracottaConfiguration.Consistency consistency)
          Setter for consistency
 void setCopyOnRead(boolean isCopyOnRead)
          Deprecated. 
 void setLocalCacheEnabled(boolean localCacheEnabled)
          Enable or disable the local cache
 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.

 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).
 void setOrphanEviction(boolean orphanEviction)
          Sets whether this cache should perform orphan eviction (usually should be true).
 void setOrphanEvictionPeriod(int orphanEvictionPeriod)
          Set how often this cache should perform orphan eviction (measured in regular eviction periods).
 void setSynchronousWrites(boolean synchronousWrites)
          Set the value for synchronous-write
 TerracottaConfiguration synchronousWrites(boolean synchronousWrites)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 for NonstopConfiguration


DEFAULT_CACHE_COHERENT

@Deprecated
public static final boolean DEFAULT_CACHE_COHERENT
Deprecated. since 2.4 Use DEFAULT_CONSISTENCY_TYPE instead.
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
Constructor Detail

TerracottaConfiguration

public TerracottaConfiguration()
Method Detail

clone

public TerracottaConfiguration clone()
Clones this object, following the usual contract.

Overrides:
clone in class 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 - true if the cache should be clustered with Terracotta; false otherwise

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 compressionEnaled 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 - true if coherent reads should be used; false otherwise

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 - true if orphan eviction should be used; false otherwise

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 - true if a local key cache should be used; false otherwise

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 Use setConsistency(Consistency) instead

Used by BeanHandler to set the coherent during parsing


coherent

@Deprecated
public TerracottaConfiguration coherent(boolean coherent)
Deprecated. since 2.4 Use consistency(Consistency) instead

Returns:
this configuration instance

isCoherent

@Deprecated
public boolean isCoherent()
Deprecated. since 2.4 Use getConsistency() instead to query the TerracottaConfiguration.Consistency or Ehcache#isNodeCoherent() to query if the node is coherent

Is 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. Throws IllegalArgumentException if 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 the NonstopConfiguration

Parameters:
nonstopConfiguration -

nonstop

public TerracottaConfiguration nonstop(NonstopConfiguration nonstopConfiguration)
Set the NonstopConfiguration

Parameters:
nonstopConfiguration -
Returns:
this configuration instance

getNonstopConfiguration

public NonstopConfiguration getNonstopConfiguration()
Get the NonstopConfiguration, 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(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

ehcache

Copyright 2001-2015, Terracotta, Inc.