Package org.apache.cassandra.concurrent
Class ThreadPoolExecutorBuilder<E extends ExecutorPlus>
java.lang.Object
org.apache.cassandra.concurrent.NamedThreadFactory.MetaFactory
org.apache.cassandra.concurrent.ThreadPoolExecutorBuilder<E>
- All Implemented Interfaces:
ExecutorBuilder<E>
public class ThreadPoolExecutorBuilder<E extends ExecutorPlus>
extends NamedThreadFactory.MetaFactory
implements ExecutorBuilder<E>
Configure a Core threads may timeout, and use a default Threads share the same By default queues are unbounded in length
The default The default
ThreadPoolExecutorPlus, applying Cassandra's best practices by default
keepAlive time in keepAliveUnits
ThreadGroup, which may be configurably a child of a specified ThreadGroup
descended from the same parent of the NamedThreadFactory.MetaFactory
RejectedExecutionHandler is implementation dependent, but may be overridden
Thread.UncaughtExceptionHandler is inherited from NamedThreadFactory.MetaFactory, which in turn receives it
from the ExecutorBuilderFactory-
Field Summary
Fields inherited from class org.apache.cassandra.concurrent.NamedThreadFactory.MetaFactory
contextClassLoader, threadGroup, uncaughtExceptionHandler -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThreadPoolExecutorBuilder(Function<ThreadPoolExecutorBuilder<E>, E> constructor, ClassLoader contextClassLoader, ThreadGroup overrideThreadGroup, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, String name, int threads) -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the configured executorUse the system default thread group for the threads we create.Core threads for the executor built by this factory will never timeout (default for single threaded builders).withKeepAlive(long keepAlive, TimeUnit keepAliveUnits) Threads for the executor built by this factory will timeout (terminate) after the specified period.withQueueLimit(int queueLimit) The executor built by this factory will limit the number of queued tasks; default is unlimited.withRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) Set theRejectedExecutionHandlerfor the executor built by this factory.withThreadGroup(ThreadGroup threadGroup) Threads for the executor built by this factory will all be (transitively) members ofthreadGroup, but may directly reside in a child thread group.withThreadPriority(int threadPriority) Specify the priority of threads that service the executor built by this factory (default toThread.NORM_PRIORITY)withUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Set theThread.UncaughtExceptionHandlerfor threads that service executors built by this factory.
-
Constructor Details
-
ThreadPoolExecutorBuilder
protected ThreadPoolExecutorBuilder(Function<ThreadPoolExecutorBuilder<E>, E> constructor, ClassLoader contextClassLoader, ThreadGroup overrideThreadGroup, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, String name, int threads)
-
-
Method Details
-
withKeepAlive
Description copied from interface:ExecutorBuilderThreads for the executor built by this factory will timeout (terminate) after the specified period.- Specified by:
withKeepAlivein interfaceExecutorBuilder<E extends ExecutorPlus>
-
withKeepAlive
Description copied from interface:ExecutorBuilderCore threads for the executor built by this factory will never timeout (default for single threaded builders). Note that there is ordinarily no difference between core and non-core threads; only when the queue limit is zero do we create non-core threads.- Specified by:
withKeepAlivein interfaceExecutorBuilder<E extends ExecutorPlus>
-
withThreadPriority
Description copied from interface:ExecutorBuilderSpecify the priority of threads that service the executor built by this factory (default toThread.NORM_PRIORITY)- Specified by:
withThreadPriorityin interfaceExecutorBuilder<E extends ExecutorPlus>
-
withThreadGroup
Description copied from interface:ExecutorBuilderThreads for the executor built by this factory will all be (transitively) members ofthreadGroup, but may directly reside in a child thread group.- Specified by:
withThreadGroupin interfaceExecutorBuilder<E extends ExecutorPlus>
-
withDefaultThreadGroup
Description copied from interface:ExecutorBuilderUse the system default thread group for the threads we create. This is used only for testing, so that we do not hold onto a transitive global reference to all threads.- Specified by:
withDefaultThreadGroupin interfaceExecutorBuilder<E extends ExecutorPlus>
-
withQueueLimit
Description copied from interface:ExecutorBuilderThe executor built by this factory will limit the number of queued tasks; default is unlimited. Once the queue limit is reached and all threads are executing tasks will be rejected (seeExecutorBuilder.withRejectedExecutionHandler(RejectedExecutionHandler))- Specified by:
withQueueLimitin interfaceExecutorBuilder<E extends ExecutorPlus>
-
withRejectedExecutionHandler
public ThreadPoolExecutorBuilder<E> withRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) Description copied from interface:ExecutorBuilderSet theRejectedExecutionHandlerfor the executor built by this factory. By default this is executor-specific, either:ThreadPoolExecutorBase.blockingExecutionHandlerScheduledThreadPoolExecutorPlus.rejectedExecutionHandler- and maybe wrapped by
ThreadPoolExecutorJMXAdapter.rejectedExecutionHandler(org.apache.cassandra.metrics.ThreadPoolMetrics, java.util.concurrent.RejectedExecutionHandler)- Specified by:
withRejectedExecutionHandlerin interfaceExecutorBuilder<E extends ExecutorPlus>
-
withUncaughtExceptionHandler
public ThreadPoolExecutorBuilder<E> withUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Description copied from interface:ExecutorBuilderSet theThread.UncaughtExceptionHandlerfor threads that service executors built by this factory. By defaultJVMStabilityInspector.uncaughtException(Thread, Throwable)- Specified by:
withUncaughtExceptionHandlerin interfaceExecutorBuilder<E extends ExecutorPlus>
-
build
Description copied from interface:ExecutorBuilderBuild the configured executor- Specified by:
buildin interfaceExecutorBuilder<E extends ExecutorPlus>
-