Package org.opennms.core.concurrent
Interface ExecutorFactory
-
- All Known Implementing Classes:
ExecutorFactoryCassandraSEPImpl
,ExecutorFactoryJavaImpl
public interface ExecutorFactory
This factory is used to createExecutorService
thread pools for use by daemon processes. This is provided as a service so that thread pools throughout the system are constructed in the same manner and have consistent thread names, logging, and queue implementations.- Author:
- Seth
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.ExecutorService
newExecutor(int threads, int queueSize, java.lang.String daemonName, java.lang.String executorName)
Construct a newExecutorService
with a specified queue size for the backlog of tasks.java.util.concurrent.ExecutorService
newExecutor(int threads, java.lang.String daemonName, java.lang.String executorName)
Construct a newExecutorService
with an unbounded queue size ({@link Integer#MAX_VALUE). For CPU-intensive tasks, it is a good idea to use the value of {@link Runtime#availableProcessors()} (or a reasonable multiple of it based on the tasks) for thethreads
parameter to ensure that the CPU is fully utilized.java.util.concurrent.ExecutorService
newExecutor(java.lang.String daemonName, java.lang.String executorName)
Construct a newExecutorService
with an unbounded queue size and a thread pool size equal to the value ofRuntime.availableProcessors()
so that one thread per core is started.
-
-
-
Method Detail
-
newExecutor
java.util.concurrent.ExecutorService newExecutor(java.lang.String daemonName, java.lang.String executorName)
Construct a newExecutorService
with an unbounded queue size and a thread pool size equal to the value ofRuntime.availableProcessors()
so that one thread per core is started.- Parameters:
daemonName
-executorName
-- Returns:
-
newExecutor
java.util.concurrent.ExecutorService newExecutor(int threads, java.lang.String daemonName, java.lang.String executorName)
Construct a newExecutorService
with an unbounded queue size ({@link Integer#MAX_VALUE). For CPU-intensive tasks, it is a good idea to use the value of {@link Runtime#availableProcessors()} (or a reasonable multiple of it based on the tasks) for thethreads
parameter to ensure that the CPU is fully utilized.- Parameters:
threads
-daemonName
-executorName
-- Returns:
- An ExecutorService pool
-
newExecutor
java.util.concurrent.ExecutorService newExecutor(int threads, int queueSize, java.lang.String daemonName, java.lang.String executorName)
Construct a newExecutorService
with a specified queue size for the backlog of tasks. When the queue is full, the pool may block, discard the incoming task, or throw an exception. This behavior is dependent on the implementation of theExecutorService
. For CPU-intensive tasks, it is a good idea to use the value ofRuntime.availableProcessors()
(or a reasonable multiple of it based on the tasks) for thethreads
parameter to ensure that the CPU is fully utilized.- Parameters:
threads
-daemonName
-executorName
-- Returns:
- An ExecutorService pool
-
-