Class SingleThreadExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- org.apache.bookkeeper.common.util.SingleThreadExecutor
-
- All Implemented Interfaces:
java.lang.Runnable,java.util.concurrent.Executor,java.util.concurrent.ExecutorService
public class SingleThreadExecutor extends java.util.concurrent.AbstractExecutorService implements java.util.concurrent.ExecutorService, java.lang.RunnableImplements a single thread executor that drains the queue in batches to minimize contention between threads.Tasks are executed in a safe manner: if there are exceptions they are logged and the executor will proceed with the next tasks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classSingleThreadExecutor.State
-
Constructor Summary
Constructors Constructor Description SingleThreadExecutor(java.util.concurrent.ThreadFactory tf)SingleThreadExecutor(java.util.concurrent.ThreadFactory tf, int maxQueueCapacity, boolean rejectExecution)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitTermination(long timeout, java.util.concurrent.TimeUnit unit)voidexecute(java.lang.Runnable r)(package private) voidexecuteRunnableOrList(java.lang.Runnable runnable, java.util.List<java.lang.Runnable> runnableList)longgetCompletedTasksCount()longgetFailedTasksCount()(package private) intgetPendingTaskCount()longgetQueuedTasksCount()longgetRejectedTasksCount()longgetSubmittedTasksCount()booleanisShutdown()booleanisTerminated()voidregisterMetrics(StatsLogger statsLogger)voidrun()voidshutdown()java.util.List<java.lang.Runnable>shutdownNow()-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
-
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfacejava.util.concurrent.ExecutorService
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
- Specified by:
shutdownNowin interfacejava.util.concurrent.ExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
awaitTerminationin interfacejava.util.concurrent.ExecutorService- Throws:
java.lang.InterruptedException
-
getQueuedTasksCount
public long getQueuedTasksCount()
-
getSubmittedTasksCount
public long getSubmittedTasksCount()
-
getCompletedTasksCount
public long getCompletedTasksCount()
-
getRejectedTasksCount
public long getRejectedTasksCount()
-
getFailedTasksCount
public long getFailedTasksCount()
-
execute
public void execute(java.lang.Runnable r)
- Specified by:
executein interfacejava.util.concurrent.Executor
-
executeRunnableOrList
void executeRunnableOrList(java.lang.Runnable runnable, java.util.List<java.lang.Runnable> runnableList)
-
registerMetrics
public void registerMetrics(StatsLogger statsLogger)
-
getPendingTaskCount
int getPendingTaskCount()
-
-