Package org.nuxeo.ecm.core.work
Interface WorkQueuing
-
- All Known Implementing Classes:
MemoryWorkQueuing,RedisWorkQueuing
public interface WorkQueuingInterface describing how theWorkManagerimplements 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
ThreadPoolExecutorand 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 interfaceWorkQueuing.Listener
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longcount(String queueId, Work.State state)Gets the number of work instances in the given state in a given queue.Workfind(String workId, Work.State state)Finds a work instance in the scheduled or running or completed sets.NuxeoBlockingQueuegetQueue(String queueId)Gets the blocking queue of work used by theThreadPoolExecutor.Work.StategetWorkState(String workId)Gets the state in which a work instance is.NuxeoBlockingQueueinit(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 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.WorkQueueMetricsmetrics(String queueId)Returns current metrics of queue identified by thequeueIdvoidremoveScheduled(String queueId, String workId)Finds a scheduled work instance and removes it from the scheduled queue.voidsetActive(String queueId, boolean value)Enable/disable thisqueueIdprocessingbooleansupportsProcessingDisabling()voidworkCanceled(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.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.
-
-
-
Method Detail
-
init
NuxeoBlockingQueue init(WorkQueueDescriptor config)
Starts up thisWorkQueuingand attempts to resume work previously suspended and saved at shutdown time.
-
setActive
void setActive(String queueId, boolean value)
Enable/disable thisqueueIdprocessing- 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 theThreadPoolExecutorand 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.SCHEDULEDorWork.State.RUNNING.- Parameters:
workId- the id of the work to find- Returns:
- the work state, or
nullif 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
-
-