public static class WorkManagerImpl.WorkThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor
that keeps available the list of scheduled,
running and completed tasks and provides other methods.
The methods checking the sizes are sure not to lose tasks in transit between the various queues.
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Constructor and Description |
---|
WorkManagerImpl.WorkThreadPoolExecutor(String queueId,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> queue,
ThreadFactory threadFactory) |
Modifier and Type | Method and Description |
---|---|
void |
afterCommit(Work work)
Called from
WorkManagerImpl.WorkSchedulingSynchronization after commit to
actually schedule the work. |
boolean |
awaitTerminationOrSave(long timeout,
TimeUnit unit)
Blocks until all work instances have completed after a shutdown and
suspend request.
|
boolean |
cancelScheduled(Work work)
Removes any work instances equal to this one from the scheduled queue
and cancels them.
|
void |
cancelScheduledAfterCommit(Work work)
Called from
WorkManagerImpl.WorkSchedulingSynchronization after commit to
actually remove the work from the queue and cancel it. |
void |
clearCompleted()
Clears the completed tasks.
|
void |
clearCompleted(long completionTime)
Clears the completed tasks older than the given date.
|
void |
execute(Runnable r)
This method does not wait for transaction to be committed to schedule
the task for execution.
|
void |
execute(Work work,
boolean afterCommit)
Executes the given task sometime in the future.
|
Work |
find(Work work,
Work.State state,
boolean useEquals,
int[] pos)
Finds a work instance in the scheduled or running queue.
|
List<Work> |
getCompleted()
Gets the completed tasks.
|
List<Work> |
getNonCompleted()
Gets the non-completed tasks.
|
int |
getNonCompletedWorkSize()
Gets the number of non-completed tasks.
|
List<Work> |
getRunning()
Gets the running tasks.
|
List<Work> |
getScheduled()
Gets the scheduled tasks.
|
void |
shutdownAndSuspend()
Initiates a shutdown of this executor and asks for work instances to
suspend themselves.
|
void |
suspend()
Requests all running and scheduled work instances to suspend.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, toString
public WorkManagerImpl.WorkThreadPoolExecutor(String queueId, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> queue, ThreadFactory threadFactory)
public boolean cancelScheduled(Work work)
work
- the work to canceltrue
if there was work to cancelpublic void cancelScheduledAfterCommit(Work work)
WorkManagerImpl.WorkSchedulingSynchronization
after commit to
actually remove the work from the queue and cancel it.public Work find(Work work, Work.State state, boolean useEquals, int[] pos)
work
- the work to findstate
- the state defining the queue to look in,
SCHEDULED
, RUNNING
, COMPLETED
, or
null
for non-completeduseEquals
- if true
then use Work#equals
to find
the work instance, otherwise use object identitypos
- a 1-element array to return the position in the internal
queuepublic void execute(Runnable r)
execute
in interface Executor
execute
in class ThreadPoolExecutor
r
- the task to executepublic void execute(Work work, boolean afterCommit)
work
- the work to executeafterCommit
- if true
and the work is scheduled, it will
only be run after the current transaction (if any) has
committedexecute(Runnable)
public void afterCommit(Work work)
WorkManagerImpl.WorkSchedulingSynchronization
after commit to
actually schedule the work.public void shutdownAndSuspend()
public boolean awaitTerminationOrSave(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the time to waitunit
- the timeout unitInterruptedException
public void suspend()
public int getNonCompletedWorkSize()
public void clearCompleted()
public void clearCompleted(long completionTime)
Copyright © 2013 Nuxeo SA. All Rights Reserved.