Class CacheWriterConfiguration

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class CacheWriterConfiguration
    extends java.lang.Object
    implements java.lang.Cloneable
    Class to hold the CacheWriterManager configuration
    Version:
    $Id$
    Author:
    Geert Bevin
    • Field Detail

      • DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION

        public static final boolean DEFAULT_NOTIFY_LISTENERS_ON_EXCEPTION
        Default notifyListenersOnException behavior
        See Also:
        Constant Field Values
      • DEFAULT_MIN_WRITE_DELAY

        public static final int DEFAULT_MIN_WRITE_DELAY
        Default minimum write delay
        See Also:
        Constant Field Values
      • DEFAULT_MAX_WRITE_DELAY

        public static final int DEFAULT_MAX_WRITE_DELAY
        Default maximum write delay
        See Also:
        Constant Field Values
      • DEFAULT_RATE_LIMIT_PER_SECOND

        public static final int DEFAULT_RATE_LIMIT_PER_SECOND
        Default rate limit per second
        See Also:
        Constant Field Values
      • DEFAULT_WRITE_COALESCING

        public static final boolean DEFAULT_WRITE_COALESCING
        Default write coalescing behavior
        See Also:
        Constant Field Values
      • DEFAULT_WRITE_BATCHING

        public static final boolean DEFAULT_WRITE_BATCHING
        Default writeBatching behavior
        See Also:
        Constant Field Values
      • DEFAULT_WRITE_BATCH_SIZE

        public static final int DEFAULT_WRITE_BATCH_SIZE
        Default write batch size
        See Also:
        Constant Field Values
      • DEFAULT_RETRY_ATTEMPTS

        public static final int DEFAULT_RETRY_ATTEMPTS
        Default retry attempts
        See Also:
        Constant Field Values
      • DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS

        public static final int DEFAULT_RETRY_ATTEMPT_DELAY_SECONDS
        Default retry attempt delay
        See Also:
        Constant Field Values
      • DEFAULT_WRITE_BEHIND_CONCURRENCY

        public static final int DEFAULT_WRITE_BEHIND_CONCURRENCY
        Default concurrency level for write behind
        See Also:
        Constant Field Values
      • DEFAULT_WRITE_BEHIND_MAX_QUEUE_SIZE

        public static final int DEFAULT_WRITE_BEHIND_MAX_QUEUE_SIZE
        Default max queue size for write behind
        See Also:
        Constant Field Values
    • Constructor Detail

      • CacheWriterConfiguration

        public CacheWriterConfiguration()
    • Method Detail

      • clone

        public CacheWriterConfiguration 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.
      • setWriteMode

        public void setWriteMode​(java.lang.String writeMode)
        Converts the writeMode string argument to uppercase and looks up enum constant in WriteMode.
      • setNotifyListenersOnException

        public void setNotifyListenersOnException​(boolean notifyListenersOnException)
        Sets whether to notify listeners when an exception occurs on a writer operation.

        This is only applicable to write through mode.

        Defaults to false.

        Parameters:
        notifyListenersOnException - true if listeners should be notified when an exception occurs on a writer operation; false otherwise
      • getNotifyListenersOnException

        public boolean getNotifyListenersOnException()
        Check whether listeners should be notified when an exception occurs on a writer operation
      • setMinWriteDelay

        public void setMinWriteDelay​(int minWriteDelay)
        Set the minimum number of seconds to wait before writing behind. If set to a value greater than 0, it permits operations to build up in the queue. This is different from the maximum write delay in that by waiting a minimum amount of time, work is always being built up. If the minimum write delay is set to zero and the CacheWriter performs its work very quickly, the overhead of processing the write behind queue items becomes very noticeable in a cluster since all the operations might be done for individual items instead of for a collection of them.

        This is only applicable to write behind mode.

        Defaults to 1).

        Parameters:
        minWriteDelay - the minimum number of seconds to wait before writing behind
      • getMinWriteDelay

        public int getMinWriteDelay()
        Get the minimum number of seconds to wait before writing behind
      • setMaxWriteDelay

        public void setMaxWriteDelay​(int maxWriteDelay)
        Set the maximum number of seconds to wait before writing behind. If set to a value greater than 0, it permits operations to build up in the queue to enable effective coalescing and batching optimisations.

        This is only applicable to write behind mode.

        Defaults to 1).

        Parameters:
        maxWriteDelay - the maximum number of seconds to wait before writing behind
      • getMaxWriteDelay

        public int getMaxWriteDelay()
        Get the maximum number of seconds to wait before writing behind
      • setRateLimitPerSecond

        public void setRateLimitPerSecond​(int rateLimitPerSecond)
        Sets the maximum number of write operations to allow per second when writeBatching is enabled.

        This is only applicable to write behind mode.

        Defaults to 0.

        Parameters:
        rateLimitPerSecond - the number of write operations to allow; use a number <=0 to disable rate limiting.
      • getRateLimitPerSecond

        public int getRateLimitPerSecond()
        Get the maximum number of write operations to allow per second.
      • setWriteCoalescing

        public void setWriteCoalescing​(boolean writeCoalescing)
        Sets whether to use write coalescing. If set to true and multiple operations on the same key are present in the write-behind queue, only the latest write is done, as the others are redundant. This can dramatically reduce load on the underlying resource.

        This is only applicable to write behind mode.

        Defaults to false.

        Parameters:
        writeCoalescing - true to enable write coalescing; or false to disable it
      • getWriteBatching

        public boolean getWriteBatching()
        Check whether write operations should be batched
      • setWriteBatchSize

        public void setWriteBatchSize​(int writeBatchSize)
        Sets the number of operations to include in each batch when writeBatching is enabled. If there are less entries in the write-behind queue than the batch size, the queue length size is used.

        This is only applicable to write behind mode.

        Defaults to 1.

        Parameters:
        writeBatchSize - the number of operations to include in each batch; numbers smaller than 1 will cause the default batch size to be used
      • getWriteBatchSize

        public int getWriteBatchSize()
        Retrieves the size of the batch operation.
      • setRetryAttempts

        public void setRetryAttempts​(int retryAttempts)
        Sets the number of times the operation is retried in the CacheWriter, this happens after the original operation.

        This is only applicable to write behind mode.

        Defaults to 0.

        Parameters:
        retryAttempts - the number of retries for a particular element
      • getRetryAttempts

        public int getRetryAttempts()
        Retrieves the number of times the write of element is retried.
      • setRetryAttemptDelaySeconds

        public void setRetryAttemptDelaySeconds​(int retryAttemptDelaySeconds)
        Sets the number of seconds to wait before retrying an failed operation.

        This is only applicable to write behind mode.

        Defaults to 1.

        Parameters:
        retryAttemptDelaySeconds - the number of seconds to wait before retrying an operation
      • getRetryAttemptDelaySeconds

        public int getRetryAttemptDelaySeconds()
        Retrieves the number of seconds to wait before retrying an failed operation.
      • setWriteBehindConcurrency

        public void setWriteBehindConcurrency​(int concurrency)
        Configures the amount of thread/bucket pairs WriteBehind should use
        Parameters:
        concurrency - Amount of thread/bucket pairs, has to be at least 1
      • getWriteBehindConcurrency

        public int getWriteBehindConcurrency()
        Accessor
        Returns:
        the amount of bucket/thread pairs configured for this cache's write behind
      • setWriteBehindMaxQueueSize

        public void setWriteBehindMaxQueueSize​(int writeBehindMaxQueueSize)
        Configures the maximum amount of operations to be on the waiting queue, before it blocks
        Parameters:
        writeBehindMaxQueueSize - maximum amount of operations allowed on the waiting queue
      • getWriteBehindMaxQueueSize

        public int getWriteBehindMaxQueueSize()
        Accessor
        Returns:
        the maximum amount of operations allowed on the write behind queue
      • writeBehindMaxQueueSize

        public CacheWriterConfiguration writeBehindMaxQueueSize​(int writeBehindMaxQueueSize)
        Parameters:
        writeBehindMaxQueueSize - maximum amount of operations allowed on the waiting queue
        Returns:
        this configuration instance
        See Also:
        setWriteBehindMaxQueueSize(int)
      • hashCode

        public int hashCode()
        Overrided hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrided equals()
        Overrides:
        equals in class java.lang.Object
      • validate

        public void validate​(java.util.Collection<ConfigError> errors)
        Check for errors/inconsistencies in this configuration. Add any erros found as ConfigError in the errors collection.
        Parameters:
        errors - collection to add errors to.