Package org.nuxeo.ecm.core.work
Interface WorkQueuing
- All Known Implementing Classes:
MemoryWorkQueuing
public interface WorkQueuing
Interface describing how the
WorkManager
implements queuing.
There are 4 structures maintained per-queue:
- the work queue managed by the
ThreadPoolExecutor
, - the set of scheduled work, this enables to list a work as being scheduled while it has been removed from the
queue by the
ThreadPoolExecutor
and not yet executed (not yet running). - the set of running work,
- the set of completed work.
- Since:
- 5.8
-
Nested Class 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.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.
-
Method Details
-
init
Starts up thisWorkQueuing
and attempts to resume work previously suspended and saved at shutdown time. -
setActive
Enable/disable thisqueueId
processing- Since:
- 8.3
-
supportsProcessingDisabling
boolean supportsProcessingDisabling()- Returns:
- true if the implementation supports processing disabling
- Since:
- 10.3
-
getQueue
Gets the blocking queue of work used by theThreadPoolExecutor
.- Since:
- 8.1
-
workSchedule
Submit a work to theThreadPoolExecutor
and put it in the scheduled set.- Parameters:
queueId
- the queue idwork
- the work instance- Since:
- 8.1
-
workCanceled
Removes a work instance from scheduled set.- Since:
- 8.3
-
workRunning
Put the work instance into the running set.- Parameters:
queueId
- the queue idwork
- the work instance- Since:
- 5.8
-
workCompleted
Moves a work instance from the running set to the completed set.- Parameters:
queueId
- the queue idwork
- the work instance- Since:
- 5.8
-
workReschedule
Moves back a work instance from running set to the scheduled set.- Since:
- 8.3
-
find
Finds a work instance in the scheduled or running or completed sets. -
removeScheduled
Finds a scheduled work instance and removes it from the scheduled queue.- Parameters:
queueId
- the queue idworkId
- the id of the work to find- Since:
- 5.8
-
isWorkInState
Checks if a work instance with the given id is in the given state. -
getWorkState
Gets the state in which a work instance is.This can be
Work.State.SCHEDULED
orWork.State.RUNNING
.- Parameters:
workId
- the id of the work to find- Returns:
- the work state, or
null
if not found - Since:
- 5.8
-
listWork
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.
-
listWorkIds
Lists the work ids in a given queue in a defined state. -
count
Gets the number of work instances in the given state in a given queue. -
metrics
Returns current metrics of queue identified by thequeueId
- Since:
- 8.3
-
listen
Set the callback for debugging purpose- Since:
- 8.3
-