public class QueueService extends WorkflowExecutorService<ExecutorService> implements Runnable, QueueAccess
This code to be revisited to see if all that was needed is the single scheduled queue, implicitly making actions immediate by giving them an execution time of "now". It would force having a sequence number to all actions, one which the queue would have to set from its (monotonic, thread-safe) counter on every submission, with a modified comparison operator. This would guarantee that earlier submissions were picked before later ones.
| Modifier and Type | Field and Description |
|---|---|
BlockingDeque<AsyncAction> |
actionQueue
Immediate actions.
|
static String |
NAME |
DelayQueue<AsyncAction> |
scheduledActions
Actions to be scheduled in the future
|
| Constructor and Description |
|---|
QueueService()
Create a queue instance with a single thread executor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
flushActionQueue(Class<? extends AsyncAction> clazz)
Flush an action queue of all types of a specific action
|
boolean |
hasQueuedActionWithAttribute(int attr)
Look in the immediate queue for any actions of a specific attribute
|
boolean |
isCompleted()
Check to see if the queue executor has completed
|
RenewingAction<? extends AsyncAction> |
lookupRenewingAction(String name)
Look up a renewing action
|
void |
put(AsyncAction action)
Put an action on the immediate queue -to be executed when the queue
reaches it.
|
boolean |
remove(AsyncAction action)
Remove an action from the queues.
|
boolean |
removeRenewingAction(String name)
Remove a renewing action
|
void |
renewing(String name,
RenewingAction<? extends AsyncAction> renewingAction)
Add a named renewing action
|
void |
run()
Run until the queue has been told to stop
|
void |
schedule(AsyncAction action)
Put a delayed action: this will only be added to the main queue
after its action time has been reached
|
protected void |
serviceStop()
Stop the service by scheduling an
ActionStopQueue action
..if the processor thread is working this will propagate through
and stop the queue handling after all other actions complete. |
execute, getExecutor, setExecutor, stopExecutor, submitclose, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceInit, serviceStart, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStoppublic static final String NAME
public final BlockingDeque<AsyncAction> actionQueue
public final DelayQueue<AsyncAction> scheduledActions
public QueueService()
public void put(AsyncAction action)
QueueAccessput in interface QueueAccessaction - action to queuepublic void schedule(AsyncAction action)
QueueAccessschedule in interface QueueAccessaction - action to queuepublic boolean remove(AsyncAction action)
QueueAccessremove in interface QueueAccessaction - action to removepublic void renewing(String name, RenewingAction<? extends AsyncAction> renewingAction)
QueueAccessrenewing in interface QueueAccessname - namerenewingAction - wrapped actionpublic RenewingAction<? extends AsyncAction> lookupRenewingAction(String name)
QueueAccesslookupRenewingAction in interface QueueAccessname - name of the actionpublic boolean removeRenewingAction(String name)
QueueAccessremoveRenewingAction in interface QueueAccessname - action name name of the actionprotected void serviceStop()
throws Exception
ActionStopQueue action
..if the processor thread is working this will propagate through
and stop the queue handling after all other actions complete.serviceStop in class WorkflowExecutorService<ExecutorService>Exceptionprotected void flushActionQueue(Class<? extends AsyncAction> clazz)
clazz - public boolean hasQueuedActionWithAttribute(int attr)
QueueAccesshasQueuedActionWithAttribute in interface QueueAccesspublic void run()
public boolean isCompleted()
Copyright © 2014–2015 The Apache Software Foundation. All rights reserved.