Package org.nuxeo.ecm.core.work.api
Interface WorkManager
-
- All Known Implementing Classes:
StreamWorkManager
,WorkManagerImpl
public interface WorkManager
AWorkManager
executesWork
instances asynchronously.A
Work
can be scheduled by callingschedule(org.nuxeo.ecm.core.work.api.Work)
.Work is executed in a thread pool and a work queue that depends on the work's category.
- Since:
- 5.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
WorkManager.Scheduling
The scheduling policy to use when adding a work instance usingschedule(Work, Scheduling)
.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description boolean
awaitCompletion(long timeout, TimeUnit unit)
Waits for completion of all work.boolean
awaitCompletion(String queueId, long timeout, TimeUnit unit)
Waits for completion of work in a given queue.void
enableProcessing(boolean value)
Set processing for all queuesvoid
enableProcessing(String queueId, boolean value)
Set processing for a given queue id.Work
find(String workId, Work.State state)
Deprecated.since 10.2 not scalableString
getCategoryQueueId(String category)
Gets the queue id used for a given work category.WorkQueueMetrics
getMetrics(String queueId)
Gets the metrics for thequeueId
int
getQueueSize(String queueId, Work.State state)
Deprecated.since 5.8,WorkQueueDescriptor
getWorkQueueDescriptor(String queueId)
Gets the work queue descriptor for a given queue id.List<String>
getWorkQueueIds()
Lists the ids of the existing work queues.Work.State
getWorkState(String workId)
Deprecated.void
init()
Starts up thisWorkManager
and attempts to resume work previously suspended and saved atshutdown(long, java.util.concurrent.TimeUnit)
time.boolean
isProcessingEnabled()
Is processing enabled for at least one queueboolean
isProcessingEnabled(String queueId)
Is processing enabled for a given queue id.boolean
isQueuingEnabled(String queueId)
Is queuing enabled for a given queue id.boolean
isStarted()
List<Work>
listWork(String queueId, Work.State state)
Deprecated.since 10.2 not scalableList<String>
listWorkIds(String queueId, Work.State state)
Deprecated.since 10.2 not scalablevoid
schedule(Work work)
Schedules work for execution at a later time.void
schedule(Work work, boolean afterCommit)
Schedules work for execution at a later time, after the current transaction (if any) has committed.void
schedule(Work work, WorkManager.Scheduling scheduling)
Schedules work for execution at a later time, with a specific scheduling policy.void
schedule(Work work, WorkManager.Scheduling scheduling, boolean afterCommit)
Schedules work for execution at a later time, with a specific scheduling policy.boolean
shutdown(long timeout, TimeUnit unit)
Shuts down thisWorkManager
and attempts to suspend and save the running and scheduled work instances.boolean
shutdownQueue(String queueId, long timeout, TimeUnit unit)
Shuts down a work queue and attempts to suspend and save the running and scheduled work instances.boolean
supportsProcessingDisabling()
-
-
-
Method Detail
-
schedule
void schedule(Work work)
Schedules work for execution at a later time.This method is identical to
schedule(Work, boolean)
withafterCommit = false
.- Parameters:
work
- the work to execute
-
schedule
void schedule(Work work, boolean afterCommit)
Schedules work for execution at a later time, after the current transaction (if any) has committed.- Parameters:
work
- the work to executeafterCommit
- iftrue
and the work is scheduled, it will only be run after the current transaction (if any) has committed
-
schedule
void schedule(Work work, WorkManager.Scheduling scheduling)
Schedules work for execution at a later time, with a specific scheduling policy.This method is identical to
schedule(Work, Scheduling, boolean)
withafterCommit = false
.- Parameters:
work
- the work to executescheduling
- the scheduling policy- See Also:
schedule(Work)
-
schedule
void schedule(Work work, WorkManager.Scheduling scheduling, boolean afterCommit)
Schedules work for execution at a later time, with a specific scheduling policy.- Parameters:
work
- the work to executescheduling
- the scheduling policyafterCommit
- iftrue
and the work is scheduled, it will only be run after the current transaction (if any) has committed- See Also:
schedule(Work)
-
getWorkQueueIds
List<String> getWorkQueueIds()
Lists the ids of the existing work queues.- Returns:
- the list of queue ids
-
getCategoryQueueId
String getCategoryQueueId(String category)
Gets the queue id used for a given work category.- Parameters:
category
- the category- Returns:
- the queue id
-
getWorkQueueDescriptor
WorkQueueDescriptor getWorkQueueDescriptor(String queueId)
Gets the work queue descriptor for a given queue id.- Parameters:
queueId
- the queue id- Returns:
- the work queue descriptor, or
null
-
isProcessingEnabled
boolean isProcessingEnabled()
Is processing enabled for at least one queue- Since:
- 8.3
-
supportsProcessingDisabling
boolean supportsProcessingDisabling()
- Returns:
- true if the implementation supports processing disabling
- Since:
- 10.3
-
enableProcessing
void enableProcessing(boolean value)
Set processing for all queues- Since:
- 8.3
-
isProcessingEnabled
boolean isProcessingEnabled(String queueId)
Is processing enabled for a given queue id.- Since:
- 8.3
-
enableProcessing
void enableProcessing(String queueId, boolean value)
Set processing for a given queue id.- Since:
- 8.3
-
isQueuingEnabled
boolean isQueuingEnabled(String queueId)
Is queuing enabled for a given queue id.- Since:
- 8.3
-
init
void init()
Starts up thisWorkManager
and attempts to resume work previously suspended and saved atshutdown(long, java.util.concurrent.TimeUnit)
time.
-
shutdownQueue
boolean shutdownQueue(String queueId, long timeout, TimeUnit unit) throws InterruptedException
Shuts down a work queue and attempts to suspend and save the running and scheduled work instances.- Parameters:
queueId
- the queue idtimeout
- the time to waitunit
- the timeout unit- Returns:
true
if shutdown is done,false
if there are still some threads executing after the timeout- Throws:
InterruptedException
-
shutdown
boolean shutdown(long timeout, TimeUnit unit) throws InterruptedException
Shuts down thisWorkManager
and attempts to suspend and save the running and scheduled work instances.- Parameters:
timeout
- the time to waitunit
- the timeout unit- Returns:
true
if shutdown is done,false
if there are still some threads executing after the timeout- Throws:
InterruptedException
-
getQueueSize
@Deprecated int getQueueSize(String queueId, Work.State state)
Deprecated.since 5.8,Gets the number of work instances in a given queue in a defined state.
-
getMetrics
WorkQueueMetrics getMetrics(String queueId)
Gets the metrics for thequeueId
- Since:
- 8.3
-
awaitCompletion
boolean awaitCompletion(String queueId, long timeout, TimeUnit unit) throws InterruptedException
Waits for completion of work in a given queue.- Parameters:
queueId
- the queue idtimeout
- the time to waitunit
- the timeout unit- Returns:
true
if all work completed in the queue, orfalse
if there is still some non-completed work after the timeout- Throws:
InterruptedException
-
awaitCompletion
boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException
Waits for completion of all work.- Parameters:
timeout
- the time to waitunit
- the timeout unit- Returns:
true
if all work completed, orfalse
if there is still some non-completed work after the timeout- Throws:
InterruptedException
-
isStarted
boolean isStarted()
- Returns:
true
if active- Since:
- 6.0
- See Also:
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
,init()
,shutdown(long, TimeUnit)
-
getWorkState
@Deprecated Work.State getWorkState(String workId)
Deprecated.- Parameters:
workId
- the id of the work to find- Returns:
- the work state, or
null
if not found - Since:
- 5.8
-
find
@Deprecated Work find(String workId, Work.State state)
Deprecated.since 10.2 not scalableFinds a work instance.
-
listWork
@Deprecated List<Work> listWork(String queueId, Work.State state)
Deprecated.since 10.2 not scalableLists the work instances in a given queue in a defined state.
-
listWorkIds
@Deprecated List<String> listWorkIds(String queueId, Work.State state)
Deprecated.since 10.2 not scalableLists the work ids in a given queue in a defined state.
-
-