org.terracotta.modules.async.configs
Class DefaultAsyncConfig

java.lang.Object
  extended by org.terracotta.modules.async.configs.DefaultAsyncConfig
All Implemented Interfaces:
AsyncConfig

public class DefaultAsyncConfig
extends Object
implements AsyncConfig


Field Summary
static int BATCH_SIZE
           
static boolean BATCHING_ENABLED
           
static long MAX_ALLOWED_FALLBEHIND
           
static int RATE_LIMIT
           
static long RETRY_ATTEMPT_DELAY
           
static int RETRY_ATTEMPTS
           
static boolean STEALING_ENABLED
           
static boolean SYNCHRONOUS_WRITE
           
static long WORK_DELAY
           
 
Constructor Summary
protected DefaultAsyncConfig()
           
 
Method Summary
 int getBatchSize()
          The number of items to include in each batch when batching is enabled.
static AsyncConfig getInstance()
           
 long getMaxAllowedFallBehind()
          The maximum amount of time that a queue is allowed to fall behind on the work that it's processing.
 int getRateLimit()
          Sets the maximum number of operations to allow per second when AsyncConfig.isBatchingEnabled() is enabled.
 long getRetryAttemptDelay()
          Retrieves the number of milliseconds to wait before retrying a failed operation.
 int getRetryAttempts()
          Retrieves the number of times the processing of an item os retried.
 long getWorkDelay()
          Returns the amount of time to at least wait between individual work cycles.
 boolean isBatchingEnabled()
          Indicates whether to batch items.
 boolean isStealingEnabled()
          Indicates whether items can be stolen amongst queues or if each queue always has to process its own items
 boolean isSynchronousWrite()
          Perform all writes to the Terracotta backend in a synchronous fashion, hence increasing reliability but decreasing performance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORK_DELAY

public static final long WORK_DELAY
See Also:
Constant Field Values

MAX_ALLOWED_FALLBEHIND

public static final long MAX_ALLOWED_FALLBEHIND
See Also:
Constant Field Values

STEALING_ENABLED

public static final boolean STEALING_ENABLED
See Also:
Constant Field Values

BATCH_SIZE

public static final int BATCH_SIZE
See Also:
Constant Field Values

BATCHING_ENABLED

public static final boolean BATCHING_ENABLED
See Also:
Constant Field Values

SYNCHRONOUS_WRITE

public static final boolean SYNCHRONOUS_WRITE
See Also:
Constant Field Values

RETRY_ATTEMPTS

public static final int RETRY_ATTEMPTS
See Also:
Constant Field Values

RETRY_ATTEMPT_DELAY

public static final long RETRY_ATTEMPT_DELAY
See Also:
Constant Field Values

RATE_LIMIT

public static final int RATE_LIMIT
See Also:
Constant Field Values
Constructor Detail

DefaultAsyncConfig

protected DefaultAsyncConfig()
Method Detail

getInstance

public static AsyncConfig getInstance()

getWorkDelay

public long getWorkDelay()
Description copied from interface: AsyncConfig
Returns the amount of time to at least wait between individual work cycles.

This allows work to accumulate in the write behind queue and be processed more efficiently.

Specified by:
getWorkDelay in interface AsyncConfig
Returns:
the work delay that should be used, in milliseconds

getMaxAllowedFallBehind

public long getMaxAllowedFallBehind()
Description copied from interface: AsyncConfig
The maximum amount of time that a queue is allowed to fall behind on the work that it's processing.

This parameter is used to determine if the outstanding work of a queue can be stolen by another queue in the cluster.

Specified by:
getMaxAllowedFallBehind in interface AsyncConfig
Returns:
the maximum of time that the queue is allowed to fall behind, in milliseconds

isStealingEnabled

public boolean isStealingEnabled()
Description copied from interface: AsyncConfig
Indicates whether items can be stolen amongst queues or if each queue always has to process its own items

Specified by:
isStealingEnabled in interface AsyncConfig
Returns:
true when stealing is enabled; or false otherwise

getBatchSize

public int getBatchSize()
Description copied from interface: AsyncConfig
The number of items to include in each batch when batching is enabled. If there are less entries in the queue than the batch size, the queue length size is used.

Specified by:
getBatchSize in interface AsyncConfig
Returns:
the amount of items to batch

isBatchingEnabled

public boolean isBatchingEnabled()
Description copied from interface: AsyncConfig
Indicates whether to batch items. If set to true, ItemProcessor.process(java.util.Collection) will be called rather than ItemProcessor.process(Object) being called for individual item. Resources such as databases can perform more efficiently if updates are batched, thus reducing load.

Specified by:
isBatchingEnabled in interface AsyncConfig
Returns:
true if items should be batched; false otherwise

isSynchronousWrite

public boolean isSynchronousWrite()
Description copied from interface: AsyncConfig
Perform all writes to the Terracotta backend in a synchronous fashion, hence increasing reliability but decreasing performance.

Specified by:
isSynchronousWrite in interface AsyncConfig
Returns:
true to enable synchronous writes; or false to perform the write asynchronously

getRetryAttempts

public int getRetryAttempts()
Description copied from interface: AsyncConfig
Retrieves the number of times the processing of an item os retried.

Specified by:
getRetryAttempts in interface AsyncConfig
Returns:
the number of tries before this pass is considered failed

getRetryAttemptDelay

public long getRetryAttemptDelay()
Description copied from interface: AsyncConfig
Retrieves the number of milliseconds to wait before retrying a failed operation.

Specified by:
getRetryAttemptDelay in interface AsyncConfig
Returns:
the delay in between retries, in milliseconds

getRateLimit

public int getRateLimit()
Description copied from interface: AsyncConfig
Sets the maximum number of operations to allow per second when AsyncConfig.isBatchingEnabled() is enabled.

Specified by:
getRateLimit in interface AsyncConfig
Returns:
the rate limit


Copyright © 2010 Terracotta, Inc.. All Rights Reserved.