|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.constructs.asynchronous.AsynchronousCommandExecutor
public final class AsynchronousCommandExecutor
Handles the asynchronous execution of commands. This class contains subtle threading interactions and should not be modified without comprehensive multi-threaded tests.
AsynchronousCommandExecutor is a singleton. Multiple clients may use it. It will execute commands in the order they were added per client. To preserve order, if a command cannot be executed, all commands will wait behind it. This code requires JDK1.5 at present.
Field Summary | |
---|---|
static int |
DEFAULT_DISPATCHER_THREAD_INTERVAL_SECONDS
The dispatcher thread interval. |
static java.lang.String |
MESSAGE_CACHE
The name of the message cache in the ehcache.xml configuration file. |
static int |
MINIMUM_SAFE_DISPATCHER_THREAD_INTERVAL
Minimum setting for the dispatcher thread interval. |
static java.lang.String |
QUEUE_KEY
The messageCache contains Command element values, and a queue that maintains their order. |
static java.lang.String |
SUCCESSFUL_EXECUTION
The command completed successfully |
Method Summary | |
---|---|
int |
countCachedPublishCommands()
|
void |
dispose()
ehcache also has a shutdown hook, so it will save all to disk. |
(package private) java.lang.String |
generateUniqueIdentifier()
Generates an ID that is guaranteed to be unique for all VM invocations on a machine with a given IP address. |
int |
getExecuteAttemptsForCommand(java.lang.String uid)
Gets the number of attempts for the command so far |
static AsynchronousCommandExecutor |
getInstance()
Factory method to get an instance of MessageDispatcher. |
Ehcache |
getMessageCache()
Gets the message cache |
(package private) edu.emory.mathcs.backport.java.util.Queue |
getQueue()
Must be synchronized as potentially two threads could create new queues at the same time, with the result that one element would be lost. |
java.lang.String |
queueForExecution(Command command)
Stores parameters in the MESSAGE_CACHE for later execution. |
void |
setDispatcherThreadIntervalSeconds(long dispatcherThreadIntervalSeconds)
Sets the interval between runs of the dispatch thread, when no new dispatch invocations have occurred. |
void |
setUnsafeDispatcherThreadIntervalSeconds(long dispatcherThreadIntervalSeconds)
Sets the interval between runs of the dispatch thread, when no new dispatch invocations have occurred. |
(package private) java.lang.String |
storeCommandToCache(net.sf.ehcache.constructs.asynchronous.AsynchronousCommandExecutor.InstrumentedCommand instrumentedCommand)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MESSAGE_CACHE
public static final java.lang.String SUCCESSFUL_EXECUTION
public static final int DEFAULT_DISPATCHER_THREAD_INTERVAL_SECONDS
public static final int MINIMUM_SAFE_DISPATCHER_THREAD_INTERVAL
DEFAULT_DISPATCHER_THREAD_INTERVAL_SECONDS
,
Constant Field Valuespublic static final java.lang.String QUEUE_KEY
Command
element values, and a queue that maintains their order.
This is the key of the queue element.
Method Detail |
---|
public static AsynchronousCommandExecutor getInstance() throws AsynchronousCommandException
AsynchronousCommandException
edu.emory.mathcs.backport.java.util.Queue getQueue() throws AsynchronousCommandException
AsynchronousCommandException
public Ehcache getMessageCache() throws AsynchronousCommandException
MESSAGE_CACHE
cache
AsynchronousCommandException
- if the MESSAGE_CACHE
is nullpublic java.lang.String queueForExecution(Command command) throws AsynchronousCommandException
MESSAGE_CACHE
for later execution. A unique id is assigned to the
PublisherCommand and that id is enqueued. Values stored will persist across VM restarts, provided the
VM shutdown hooks have a chance to run.
This method is synchronized because the underlying Queue implementation is not threadsafe.
command
- the Command
which will be called on to publish the message
AsynchronousCommandException
public int getExecuteAttemptsForCommand(java.lang.String uid) throws CommandNotFoundInCacheException, AsynchronousCommandException
uid
- - the unique id for the command returned from queueForExecution(Command)
CommandNotFoundInCacheException
- if the command was not found in the cache.
AsynchronousCommandException
- if their is a problem accessing the cache.public int countCachedPublishCommands()
public void dispose()
java.lang.String storeCommandToCache(net.sf.ehcache.constructs.asynchronous.AsynchronousCommandExecutor.InstrumentedCommand instrumentedCommand) throws AsynchronousCommandException
instrumentedCommand
-
AsynchronousCommandException
java.lang.String generateUniqueIdentifier()
public void setDispatcherThreadIntervalSeconds(long dispatcherThreadIntervalSeconds) throws java.lang.IllegalArgumentException
dispatcherThreadIntervalSeconds
- the time in seconds
java.lang.IllegalArgumentException
- if the argument is less than 30for more information.
public void setUnsafeDispatcherThreadIntervalSeconds(long dispatcherThreadIntervalSeconds)
dispatcherThreadIntervalSeconds
- the time in secondsfor more information.
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |