com.tangosol.io
Class AsyncBinaryStore

An AsyncBinaryStore is a BinaryStore wrapper that performs the "O" (output) portion of its I/O asynchronously on a daemon thread. The output portion consists of store and erase processing.

Since the "O" portion is passed along to the wrapped BinaryStore on a separate thread, only read operations are blocking, thus the BinaryStore operations on a whole appear much faster. As such, it is somewhat analogous to a write-behind cache.

If an operation fails on the daemon thread, all further operations will occur synchronously, so that exceptions will propagate successfully up. It is assumed that once one exception occurs, the underlying BinaryStore is in a state that will cause more exceptions to occur. Even when an exception occurs on the daemon thread, that write-behind data will not be "lost" because it will still be available in the internal data structures that keeps track of pending writes.

close

getBinaryStore

Obtain the BinaryStore that this AsyncBinaryStore wraps. The wrapped BinaryStore is also referred to as the "underlying" BinaryStore. All I/O operations are delegated to the underlying BinaryStore; some write operations are performed asynchronously on the QueueDaemon thread.

setBinaryStore

Specify the underlying BinaryStore. When the AsyncBinaryStore is closed, it should clear out its reference to the underlying BinaryStore to indicate that it no longer is open.

Parameters:

store - the underlying BinaryStore

getQueuedLimit

public int getQueuedLimit()

Determine the size, in bytes, of the data that can be queued to be written asynchronously by the QueueDaemon thread. Once the limit is exceeded, operations will be forced to be synchronous to avoid running out of memory or getting too far behind on the I/O operations.

Returns:

the number of bytes allowed to be queued to be written

getQueuedSize

public int getQueuedSize()

Determine the current number of bytes that are pending being written.

Returns:

the number of bytes currently queued to be written

updateQueuedSize

protected void updateQueuedSize(int cb)

Update the number of bytes that are pending to be written.

Parameters:

cb - the number of bytes that the queue length changed by

isAsync

public boolean isAsync()

Determine if the AsyncBinaryStore is operating in an asynchronous manner.

Returns:

true if the AsyncBinaryStore is still operating in an async mode

forceSync

public void forceSync()

Indicate the future write operations must be synchronous.

getPendingMap

Obtain the map that contains all of the pending store and erase data. The key of the map is a Binary key to pass to the underlying store. The corresponding value will be DELETED to indicate an erase operation, otherwise it will be a Binary value.