Class TerracottaConfiguration

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class TerracottaConfiguration
    extends java.lang.Object
    implements java.lang.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
    • 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_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 java.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 - true if the cache should be clustered with Terracotta; false otherwise
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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.
      • isNonstopEnabled

        public boolean isNonstopEnabled()
        Returns true if nonstop is enabled
        Returns:
        true if nonstop is enabled
      • setConsistency

        public void setConsistency​(java.lang.String consistency)
        Setter for consistency
        Parameters:
        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