Package org.nuxeo.ecm.core.work
Interface WorkQueuing
-
- All Known Implementing Classes:
MemoryWorkQueuing
,RedisWorkQueuing
public interface WorkQueuing
Interface describing how theWorkManager
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
Nested Classes Modifier and Type Interface Description static interface
WorkQueuing.Listener
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
count(String queueId, Work.State state)
Gets the number of work instances in the given state in a given queue.Work
find(String workId, Work.State state)
Finds a work instance in the scheduled or running or completed sets.NuxeoBlockingQueue
getQueue(String queueId)
Gets the blocking queue of work used by theThreadPoolExecutor
.Work.State
getWorkState(String workId)
Gets the state in which a work instance is.NuxeoBlockingQueue
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 purposeList<Work>
listWork(String queueId, Work.State state)
Lists the work instances in a given queue in a defined state.List<String>
listWorkIds(String queueId, Work.State state)
Lists the work ids in a given queue in a defined state.WorkQueueMetrics
metrics(String queueId)
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
setActive(String queueId, boolean value)
Enable/disable thisqueueId
processingboolean
supportsProcessingDisabling()
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 Detail
-
init
NuxeoBlockingQueue init(WorkQueueDescriptor config)
Starts up thisWorkQueuing
and attempts to resume work previously suspended and saved at shutdown time.
-
setActive
void setActive(String queueId, boolean value)
Enable/disable thisqueueId
processing- Since:
- 8.3
-
supportsProcessingDisabling
boolean supportsProcessingDisabling()
- Returns:
- true if the implementation supports processing disabling
- Since:
- 10.3
-
getQueue
NuxeoBlockingQueue getQueue(String queueId)
Gets the blocking queue of work used by theThreadPoolExecutor
.- Since:
- 8.1
-
workSchedule
void workSchedule(String queueId, Work work)
Submit a work to theThreadPoolExecutor
and put it in the scheduled set.- Parameters:
queueId
- the queue idwork
- the work instance- Since:
- 8.1
-
workCanceled
void workCanceled(String queueId, Work work)
Removes a work instance from scheduled set.- Since:
- 8.3
-
workRunning
void workRunning(String queueId, Work work)
Put the work instance into the running set.- Parameters:
queueId
- the queue idwork
- the work instance- Since:
- 5.8
-
workCompleted
void workCompleted(String queueId, Work work)
Moves a work instance from the running set to the completed set.- Parameters:
queueId
- the queue idwork
- the work instance- Since:
- 5.8
-
workReschedule
void workReschedule(String queueId, Work work)
Moves back a work instance from running set to the scheduled set.- Since:
- 8.3
-
find
Work find(String workId, Work.State state)
Finds a work instance in the scheduled or running or completed sets.
-
removeScheduled
void removeScheduled(String queueId, String workId)
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
boolean isWorkInState(String workId, Work.State state)
Checks if a work instance with the given id is in the given state.
-
getWorkState
Work.State getWorkState(String workId)
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
List<Work> listWork(String queueId, Work.State state)
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
List<String> listWorkIds(String queueId, Work.State state)
Lists the work ids in a given queue in a defined state.
-
count
long count(String queueId, Work.State state)
Gets the number of work instances in the given state in a given queue.
-
metrics
WorkQueueMetrics metrics(String queueId)
Returns current metrics of queue identified by thequeueId
- Since:
- 8.3
-
listen
void listen(WorkQueuing.Listener listener)
Set the callback for debugging purpose- Since:
- 8.3
-
-