Class SingleThreadExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
org.apache.bookkeeper.common.util.SingleThreadExecutor
- All Implemented Interfaces:
Runnable,Executor,ExecutorService
public class SingleThreadExecutor
extends AbstractExecutorService
implements ExecutorService, Runnable
Implements 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 -
Constructor Summary
ConstructorsConstructorDescriptionSingleThreadExecutor(ThreadFactory tf, int maxQueueCapacity, boolean rejectExecution) -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) void(package private) voidexecuteRunnableOrList(Runnable runnable, List<Runnable> runnableList) longlong(package private) intlonglonglongbooleanbooleanvoidregisterMetrics(StatsLogger statsLogger) voidrun()voidshutdown()Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Constructor Details
-
SingleThreadExecutor
-
SingleThreadExecutor
-
-
Method Details
-
run
public void run() -
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
getQueuedTasksCount
public long getQueuedTasksCount() -
getSubmittedTasksCount
public long getSubmittedTasksCount() -
getCompletedTasksCount
public long getCompletedTasksCount() -
getRejectedTasksCount
public long getRejectedTasksCount() -
getFailedTasksCount
public long getFailedTasksCount() -
execute
-
executeRunnableOrList
-
registerMetrics
-
getPendingTaskCount
int getPendingTaskCount()
-