Package org.ldaptive.transport
Class ThreadPoolConfig
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.AbstractConfig
-
- org.ldaptive.transport.ThreadPoolConfig
-
- All Implemented Interfaces:
Freezable
public final class ThreadPoolConfig extends AbstractConfig
Contains configuration properties for creating thread pools used by transports.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ThreadPoolConfig.Builder
static class
ThreadPoolConfig.ShutdownStrategy
Enum to describe how thread pools should be shutdown.
-
Field Summary
Fields Modifier and Type Field Description private int
ioThreads
Number of I/O threads. 0 uses the default number of threads.private int
messageThreads
Number of message threads. 0 uses the default number of threadsprivate ThreadPoolConfig.ShutdownStrategy
shutdownStrategy
Thread pool shutdown strategy.private String
threadPoolName
Name of the thread pool.-
Fields inherited from class org.ldaptive.AbstractConfig
logger
-
-
Constructor Summary
Constructors Constructor Description ThreadPoolConfig()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ThreadPoolConfig.Builder
builder()
Creates a builder for this class.static ThreadPoolConfig
defaultIoThreads(String name, ThreadPoolConfig.ShutdownStrategy strategy)
Creates a new transport config that uses the default number of I/O threads and no message worker threads.int
getIoThreads()
Returns the number of I/O threads.int
getMessageThreads()
Returns the number of message threads.ThreadPoolConfig.ShutdownStrategy
getShutdownStrategy()
Returns the thread pool shutdown strategy.String
getThreadPoolName()
Returns the thread pool name.void
setIoThreads(int count)
Sets the number of I/O threads.void
setMessageThreads(int count)
Sets the number of message threads.void
setShutdownStrategy(ThreadPoolConfig.ShutdownStrategy strategy)
Sets thread pool shutdown strategy.void
setThreadPoolName(String name)
Sets the thread pool name.static ThreadPoolConfig
singleIoThread(String name, ThreadPoolConfig.ShutdownStrategy strategy)
Creates a new transport config that uses a single I/O thread.String
toString()
-
Methods inherited from class org.ldaptive.AbstractConfig
checkArrayContainsNull, checkStringInput
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
threadPoolName
private String threadPoolName
Name of the thread pool.
-
ioThreads
private int ioThreads
Number of I/O threads. 0 uses the default number of threads.
-
messageThreads
private int messageThreads
Number of message threads. 0 uses the default number of threads. -1 means do not configure a separate message thread pool
-
shutdownStrategy
private ThreadPoolConfig.ShutdownStrategy shutdownStrategy
Thread pool shutdown strategy.
-
-
Method Detail
-
getThreadPoolName
public String getThreadPoolName()
Returns the thread pool name.- Returns:
- thread pool name
-
setThreadPoolName
public void setThreadPoolName(String name)
Sets the thread pool name.- Parameters:
name
- thread pool name
-
getIoThreads
public int getIoThreads()
Returns the number of I/O threads.- Returns:
- number of I/O threads
-
setIoThreads
public void setIoThreads(int count)
Sets the number of I/O threads.- Parameters:
count
- number of I/O threads
-
getMessageThreads
public int getMessageThreads()
Returns the number of message threads.- Returns:
- number of message threads
-
setMessageThreads
public void setMessageThreads(int count)
Sets the number of message threads.- Parameters:
count
- number of message threads
-
getShutdownStrategy
public ThreadPoolConfig.ShutdownStrategy getShutdownStrategy()
Returns the thread pool shutdown strategy.- Returns:
- thread pool shutdown strategy
-
setShutdownStrategy
public void setShutdownStrategy(ThreadPoolConfig.ShutdownStrategy strategy)
Sets thread pool shutdown strategy.- Parameters:
strategy
- thread pool shutdown strategy
-
singleIoThread
public static ThreadPoolConfig singleIoThread(String name, ThreadPoolConfig.ShutdownStrategy strategy)
Creates a new transport config that uses a single I/O thread.- Parameters:
name
- of the thread poolstrategy
- transport shutdown strategy- Returns:
- transport config
-
defaultIoThreads
public static ThreadPoolConfig defaultIoThreads(String name, ThreadPoolConfig.ShutdownStrategy strategy)
Creates a new transport config that uses the default number of I/O threads and no message worker threads.- Parameters:
name
- of the thread poolstrategy
- transport shutdown strategy- Returns:
- transport config
-
builder
public static ThreadPoolConfig.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-