Package org.nuxeo.ecm.core.work
Class WorkManagerImpl.WorkThreadPoolExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- org.nuxeo.ecm.core.work.WorkManagerImpl.WorkThreadPoolExecutor
-
- All Implemented Interfaces:
Executor
,ExecutorService
- Enclosing class:
- WorkManagerImpl
protected class WorkManagerImpl.WorkThreadPoolExecutor extends ThreadPoolExecutor
AThreadPoolExecutor
that keeps available the list of running tasks.Completed tasks are passed to another queue.
The scheduled queue and completed list are passed as arguments and can have different implementations (in-memory, persisted, etc).
- Since:
- 5.6
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Field Summary
Fields Modifier and Type Field Description protected io.dropwizard.metrics5.Counter
completedCount
protected String
queueId
protected ConcurrentLinkedQueue<Work>
running
List of running Work instances, in order to be able to interrupt them if requested.protected io.dropwizard.metrics5.Counter
runningCount
protected io.dropwizard.metrics5.Counter
scheduledCount
protected io.dropwizard.metrics5.Timer
workTimer
-
Constructor Summary
Constructors Modifier Constructor Description protected
WorkThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, NuxeoBlockingQueue queue, ThreadFactory threadFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
afterExecute(Runnable r, Throwable t)
protected void
beforeExecute(Thread t, Runnable r)
void
execute(Runnable r)
void
execute(Work work)
Deprecated.since 10.2 because unusedint
getScheduledOrRunningSize()
void
removeScheduled(String workId)
void
shutdownAndSuspend()
Initiates a shutdown of this executor and asks for work instances to suspend themselves.protected void
submit(Work work)
go through the queue instead of using super.execute which may skip the queue and hand off to a thread directly-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, 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, terminated, toString
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
-
-
-
Field Detail
-
queueId
protected final String queueId
-
running
protected final ConcurrentLinkedQueue<Work> running
List of running Work instances, in order to be able to interrupt them if requested.
-
scheduledCount
protected final io.dropwizard.metrics5.Counter scheduledCount
-
runningCount
protected final io.dropwizard.metrics5.Counter runningCount
-
completedCount
protected final io.dropwizard.metrics5.Counter completedCount
-
workTimer
protected final io.dropwizard.metrics5.Timer workTimer
-
-
Constructor Detail
-
WorkThreadPoolExecutor
protected WorkThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, NuxeoBlockingQueue queue, ThreadFactory threadFactory)
-
-
Method Detail
-
getScheduledOrRunningSize
public int getScheduledOrRunningSize()
-
execute
public void execute(Runnable r)
- Specified by:
execute
in interfaceExecutor
- Overrides:
execute
in classThreadPoolExecutor
-
execute
@Deprecated public void execute(Work work)
Deprecated.since 10.2 because unusedExecutes the given task sometime in the future.- Parameters:
work
- the work to execute- See Also:
execute(Runnable)
-
submit
protected void submit(Work work) throws RuntimeException
go through the queue instead of using super.execute which may skip the queue and hand off to a thread directly- Throws:
RuntimeException
-
beforeExecute
protected void beforeExecute(Thread t, Runnable r)
- Overrides:
beforeExecute
in classThreadPoolExecutor
-
afterExecute
protected void afterExecute(Runnable r, Throwable t)
- Overrides:
afterExecute
in classThreadPoolExecutor
-
shutdownAndSuspend
public void shutdownAndSuspend() throws InterruptedException
Initiates a shutdown of this executor and asks for work instances to suspend themselves.- Throws:
InterruptedException
-
removeScheduled
public void removeScheduled(String workId)
-
-