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
Modifier and TypeFieldDescriptionprotected final Map<String,
MemoryBlockingQueue> protected WorkQueuing.Listener
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
count
(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 thisWorkQueuing
and attempts to resume work previously suspended and saved at shutdown time.boolean
isWorkInState
(String workId, Work.State state) Checks if a work instance with the given id is in the given state.void
listen
(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 thequeueId
void
removeScheduled
(String queueId, String workId) Finds a scheduled work instance and removes it from the scheduled queue.void
Enable/disable thisqueueId
processingboolean
void
workCanceled
(String queueId, Work work) Removes a work instance from scheduled set.void
workCompleted
(String queueId, Work work) Moves a work instance from the running set to the completed set.protected static boolean
workHasState
(Work work, Work.State state) Returnstrue
if the given state is notnull
and matches the state of the given work or if the state isnull
and the work's state is eitherWork.State.SCHEDULED
orWork.State.RUNNING
,false
otherwise.void
workReschedule
(String queueId, Work work) Moves back a work instance from running set to the scheduled set.void
workRunning
(String queueId, Work work) Put the work instance into the running set.void
workSchedule
(String queueId, Work work) Submit a work to theThreadPoolExecutor
and put it in the scheduled set.
-
Field Details
-
allQueued
-
listener
-
-
Constructor Details
-
MemoryWorkQueuing
-
-
Method Details
-
init
Description copied from interface:WorkQueuing
Starts up thisWorkQueuing
and attempts to resume work previously suspended and saved at shutdown time.- Specified by:
init
in interfaceWorkQueuing
-
getQueue
Description copied from interface:WorkQueuing
Gets the blocking queue of work used by theThreadPoolExecutor
.- Specified by:
getQueue
in interfaceWorkQueuing
-
workSchedule
Description copied from interface:WorkQueuing
Submit a work to theThreadPoolExecutor
and put it in the scheduled set.- Specified by:
workSchedule
in interfaceWorkQueuing
- Parameters:
queueId
- the queue idwork
- the work instance
-
workCanceled
Description copied from interface:WorkQueuing
Removes a work instance from scheduled set.- Specified by:
workCanceled
in interfaceWorkQueuing
-
workRunning
Description copied from interface:WorkQueuing
Put the work instance into the running set.- Specified by:
workRunning
in interfaceWorkQueuing
- Parameters:
queueId
- the queue idwork
- the work instance
-
workCompleted
Description copied from interface:WorkQueuing
Moves a work instance from the running set to the completed set.- Specified by:
workCompleted
in interfaceWorkQueuing
- Parameters:
queueId
- the queue idwork
- the work instance
-
workReschedule
Description copied from interface:WorkQueuing
Moves back a work instance from running set to the scheduled set.- Specified by:
workReschedule
in interfaceWorkQueuing
-
find
Description copied from interface:WorkQueuing
Finds a work instance in the scheduled or running or completed sets.- Specified by:
find
in interfaceWorkQueuing
- Parameters:
workId
- the id of the work to findstate
- the state defining the state to look into,SCHEDULED
,RUNNING
, ornull
for SCHEDULED or RUNNING- Returns:
- the found work instance, or
null
if not found
-
isWorkInState
Description copied from interface:WorkQueuing
Checks if a work instance with the given id is in the given state.- Specified by:
isWorkInState
in interfaceWorkQueuing
- Parameters:
workId
- the work idstate
- the state,SCHEDULED
,RUNNING
, ornull
for non-completed- Returns:
true
if a work instance with the given id is in the given state
-
getWorkState
Description copied from interface:WorkQueuing
Gets the state in which a work instance is.This can be
Work.State.SCHEDULED
orWork.State.RUNNING
.- Specified by:
getWorkState
in interfaceWorkQueuing
- Parameters:
workId
- the id of the work to find- Returns:
- the work state, or
null
if not found
-
listWork
Description copied from interface:WorkQueuing
Lists 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:
listWork
in interfaceWorkQueuing
- Parameters:
queueId
- the queue idstate
- the state defining the state to look into,SCHEDULED
,RUNNING
, ornull
for non-completed- Returns:
- the list of work instances in the given state
-
listWorkIds
Description copied from interface:WorkQueuing
Lists the work ids in a given queue in a defined state.- Specified by:
listWorkIds
in interfaceWorkQueuing
- Parameters:
queueId
- the queue idstate
- the state defining the state to look into,SCHEDULED
,RUNNING
, ornull
for non-completed- Returns:
- the list of work ids in the given state
-
count
Description copied from interface:WorkQueuing
Gets the number of work instances in the given state in a given queue.- Specified by:
count
in interfaceWorkQueuing
- Parameters:
queueId
- the queue idstate
- the state,SCHEDULED
orRUNNING
- Returns:
- the number of scheduled work instances in the queue
-
removeScheduled
Description copied from interface:WorkQueuing
Finds a scheduled work instance and removes it from the scheduled queue.- Specified by:
removeScheduled
in interfaceWorkQueuing
- Parameters:
queueId
- the queue idworkId
- the id of the work to find
-
setActive
Description copied from interface:WorkQueuing
Enable/disable thisqueueId
processing- Specified by:
setActive
in interfaceWorkQueuing
-
listen
Description copied from interface:WorkQueuing
Set the callback for debugging purpose- Specified by:
listen
in interfaceWorkQueuing
-
metrics
Description copied from interface:WorkQueuing
Returns current metrics of queue identified by thequeueId
- Specified by:
metrics
in interfaceWorkQueuing
-
workHasState
Returnstrue
if the given state is notnull
and matches the state of the given work or if the state isnull
and the work's state is eitherWork.State.SCHEDULED
orWork.State.RUNNING
,false
otherwise.- Since:
- 9.3
-
supportsProcessingDisabling
public boolean supportsProcessingDisabling()- Specified by:
supportsProcessingDisabling
in interfaceWorkQueuing
- Returns:
- true if the implementation supports processing disabling
-