|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.io.AsyncBinaryStore
public 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.
Nested Class Summary | |
---|---|
protected class |
AsyncBinaryStore.QueueDaemon
A daemon that processes queued writes. |
Field Summary | |
---|---|
protected static int |
DEFAULT_LIMIT
Default size limit for write-queued data. |
protected static Binary |
DELETED
A special token that is used to signify a queued erase operation. |
protected static Object |
LOCK_ALL
Special key to indicate that all keys should be locked. |
protected static long |
WAIT_FOREVER
Special wait time to indicate that a lock should be blocked on until it becomes available. |
Constructor Summary | |
---|---|
AsyncBinaryStore(BinaryStore store)
Construct an AsyncBinaryStore. |
|
AsyncBinaryStore(BinaryStore store,
int cbMax)
Construct an AsyncBinaryStore. |
Method Summary | |
---|---|
void |
close()
Close the store. |
protected AsyncBinaryStore.QueueDaemon |
ensureQueueDaemon()
Obtain the QueueDaemon, if one already exists; otherwise, create and start one. |
void |
erase(Binary binKey)
Remove the specified key from the underlying store if present. |
void |
eraseAll()
Remove all data from the underlying store. |
protected void |
finalize()
Perform cleanup during garbage collection. |
void |
forceSync()
Indicate the future write operations must be synchronous. |
BinaryStore |
getBinaryStore()
Obtain the BinaryStore that this AsyncBinaryStore wraps. |
protected ConcurrentMap |
getPendingMap()
Obtain the map that contains all of the pending store and erase data. |
protected AsyncBinaryStore.QueueDaemon |
getQueueDaemon()
|
int |
getQueuedLimit()
Determine the size, in bytes, of the data that can be queued to be written asynchronously by the QueueDaemon thread. |
int |
getQueuedSize()
Determine the current number of bytes that are pending being written. |
protected AsyncBinaryStore.QueueDaemon |
instantiateQueueDaemon()
Factory method: Instantiate a QueueDaemon. |
boolean |
isAsync()
Determine if the AsyncBinaryStore is operating in an asynchronous manner. |
Iterator |
keys()
Iterate all keys in the underlying store. |
Binary |
load(Binary binKey)
Return the value associated with the specified key, or null if the key does not have an associated value in the underlying store. |
protected void |
setBinaryStore(BinaryStore store)
Specify the underlying BinaryStore. |
protected void |
setQueueDaemon(AsyncBinaryStore.QueueDaemon daemon)
|
void |
store(Binary binKey,
Binary binValue)
Store the specified value under the specific key in the underlying store. |
String |
toString()
Return a human readable description of the AsyncBinaryStore. |
protected void |
updateQueuedSize(int cb)
Update the number of bytes that are pending to be written. |
Field Detail |
---|
protected static final Binary DELETED
protected static final int DEFAULT_LIMIT
protected static final Object LOCK_ALL
protected static final long WAIT_FOREVER
Constructor Detail |
---|
public AsyncBinaryStore(BinaryStore store)
store
- the BinaryStore to wrappublic AsyncBinaryStore(BinaryStore store, int cbMax)
store
- the BinaryStore to wrapcbMax
- the maximum number of bytes to queue before blockingMethod Detail |
---|
public Binary load(Binary binKey)
load
in interface BinaryStore
binKey
- key whose associated value is to be returned
public void store(Binary binKey, Binary binValue)
store
in interface BinaryStore
binKey
- key to store the value underbinValue
- value to be stored
UnsupportedOperationException
- if this implementation or the
underlying store is read-onlypublic void erase(Binary binKey)
erase
in interface BinaryStore
binKey
- key whose mapping is to be removed from the map
UnsupportedOperationException
- if this implementation or the
underlying store is read-onlypublic void eraseAll()
eraseAll
in interface BinaryStore
UnsupportedOperationException
- if this implementation or the
underlying store is read-onlypublic Iterator keys()
keys
in interface BinaryStore
UnsupportedOperationException
- if the underlying store is not
iterablepublic void close()
public BinaryStore getBinaryStore()
protected void setBinaryStore(BinaryStore store)
store
- the underlying BinaryStorepublic int getQueuedLimit()
public int getQueuedSize()
protected void updateQueuedSize(int cb)
cb
- the number of bytes that the queue length changed bypublic boolean isAsync()
public void forceSync()
protected ConcurrentMap getPendingMap()
DELETED
to indicate an erase
operation, otherwise it will be a Binary value.
public String toString()
protected void finalize()
protected AsyncBinaryStore.QueueDaemon getQueueDaemon()
protected void setQueueDaemon(AsyncBinaryStore.QueueDaemon daemon)
daemon
- the daemon that manages the write-behind queueprotected AsyncBinaryStore.QueueDaemon ensureQueueDaemon()
protected AsyncBinaryStore.QueueDaemon instantiateQueueDaemon()
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |