Package org.nuxeo.ecm.core.work
Class MemoryWorkQueuing
java.lang.Object
org.nuxeo.ecm.core.work.MemoryWorkQueuing
- All Implemented Interfaces:
WorkQueuing
Implementation of a
WorkQueuing using in-memory queuing.- Since:
- 5.8
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.work.WorkQueuing
WorkQueuing.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String,MemoryBlockingQueue> protected WorkQueuing.Listener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcount(String queueId, Work.State state) Gets the number of work instances in the given state in a given queue.find(String workId, Work.State state) Finds a work instance in the scheduled or running or completed sets.Gets the blocking queue of work used by theThreadPoolExecutor.getWorkState(String workId) Gets the state in which a work instance is.init(WorkQueueDescriptor config) Starts up thisWorkQueuingand attempts to resume work previously suspended and saved at shutdown time.booleanisWorkInState(String workId, Work.State state) Checks if a work instance with the given id is in the given state.voidlisten(WorkQueuing.Listener listener) Set the callback for debugging purposelistWork(String queueId, Work.State state) Lists the work instances in a given queue in a defined state.listWorkIds(String queueId, Work.State state) Lists the work ids in a given queue in a defined state.Returns current metrics of queue identified by thequeueIdvoidremoveScheduled(String queueId, String workId) Finds a scheduled work instance and removes it from the scheduled queue.voidEnable/disable thisqueueIdprocessingbooleanvoidworkCanceled(String queueId, Work work) Removes a work instance from scheduled set.voidworkCompleted(String queueId, Work work) Moves a work instance from the running set to the completed set.protected static booleanworkHasState(Work work, Work.State state) Returnstrueif the given state is notnulland matches the state of the given work or if the state isnulland the work's state is eitherWork.State.SCHEDULEDorWork.State.RUNNING,falseotherwise.voidworkReschedule(String queueId, Work work) Moves back a work instance from running set to the scheduled set.voidworkRunning(String queueId, Work work) Put the work instance into the running set.voidworkSchedule(String queueId, Work work) Submit a work to theThreadPoolExecutorand put it in the scheduled set.
-
Field Details
-
allQueued
-
listener
-
-
Constructor Details
-
MemoryWorkQueuing
-
-
Method Details
-
init
Description copied from interface:WorkQueuingStarts up thisWorkQueuingand attempts to resume work previously suspended and saved at shutdown time.- Specified by:
initin interfaceWorkQueuing
-
getQueue
Description copied from interface:WorkQueuingGets the blocking queue of work used by theThreadPoolExecutor.- Specified by:
getQueuein interfaceWorkQueuing
-
workSchedule
Description copied from interface:WorkQueuingSubmit a work to theThreadPoolExecutorand put it in the scheduled set.- Specified by:
workSchedulein interfaceWorkQueuing- Parameters:
queueId- the queue idwork- the work instance
-
workCanceled
Description copied from interface:WorkQueuingRemoves a work instance from scheduled set.- Specified by:
workCanceledin interfaceWorkQueuing
-
workRunning
Description copied from interface:WorkQueuingPut the work instance into the running set.- Specified by:
workRunningin interfaceWorkQueuing- Parameters:
queueId- the queue idwork- the work instance
-
workCompleted
Description copied from interface:WorkQueuingMoves a work instance from the running set to the completed set.- Specified by:
workCompletedin interfaceWorkQueuing- Parameters:
queueId- the queue idwork- the work instance
-
workReschedule
Description copied from interface:WorkQueuingMoves back a work instance from running set to the scheduled set.- Specified by:
workReschedulein interfaceWorkQueuing
-
find
Description copied from interface:WorkQueuingFinds a work instance in the scheduled or running or completed sets.- Specified by:
findin interfaceWorkQueuing- Parameters:
workId- the id of the work to findstate- the state defining the state to look into,SCHEDULED,RUNNING, ornullfor SCHEDULED or RUNNING- Returns:
- the found work instance, or
nullif not found
-
isWorkInState
Description copied from interface:WorkQueuingChecks if a work instance with the given id is in the given state.- Specified by:
isWorkInStatein interfaceWorkQueuing- Parameters:
workId- the work idstate- the state,SCHEDULED,RUNNING, ornullfor non-completed- Returns:
trueif a work instance with the given id is in the given state
-
getWorkState
Description copied from interface:WorkQueuingGets the state in which a work instance is.This can be
Work.State.SCHEDULEDorWork.State.RUNNING.- Specified by:
getWorkStatein interfaceWorkQueuing- Parameters:
workId- the id of the work to find- Returns:
- the work state, or
nullif not found
-
listWork
Description copied from interface:WorkQueuingLists the work instances in a given queue in a defined state.Note that an instance requested as RUNNING could be found SUSPENDING or SUSPENDED, and an instance requested as COMPLETED could be found FAILED.
- Specified by:
listWorkin interfaceWorkQueuing- Parameters:
queueId- the queue idstate- the state defining the state to look into,SCHEDULED,RUNNING, ornullfor non-completed- Returns:
- the list of work instances in the given state
-
listWorkIds
Description copied from interface:WorkQueuingLists the work ids in a given queue in a defined state.- Specified by:
listWorkIdsin interfaceWorkQueuing- Parameters:
queueId- the queue idstate- the state defining the state to look into,SCHEDULED,RUNNING, ornullfor non-completed- Returns:
- the list of work ids in the given state
-
count
Description copied from interface:WorkQueuingGets the number of work instances in the given state in a given queue.- Specified by:
countin interfaceWorkQueuing- Parameters:
queueId- the queue idstate- the state,SCHEDULEDorRUNNING- Returns:
- the number of scheduled work instances in the queue
-
removeScheduled
Description copied from interface:WorkQueuingFinds a scheduled work instance and removes it from the scheduled queue.- Specified by:
removeScheduledin interfaceWorkQueuing- Parameters:
queueId- the queue idworkId- the id of the work to find
-
setActive
Description copied from interface:WorkQueuingEnable/disable thisqueueIdprocessing- Specified by:
setActivein interfaceWorkQueuing
-
listen
Description copied from interface:WorkQueuingSet the callback for debugging purpose- Specified by:
listenin interfaceWorkQueuing
-
metrics
Description copied from interface:WorkQueuingReturns current metrics of queue identified by thequeueId- Specified by:
metricsin interfaceWorkQueuing
-
workHasState
Returnstrueif the given state is notnulland matches the state of the given work or if the state isnulland the work's state is eitherWork.State.SCHEDULEDorWork.State.RUNNING,falseotherwise.- Since:
- 9.3
-
supportsProcessingDisabling
public boolean supportsProcessingDisabling()- Specified by:
supportsProcessingDisablingin interfaceWorkQueuing- Returns:
- true if the implementation supports processing disabling
-