Package org.ldaptive.transport.netty
Class StatefulNettyTransport
- java.lang.Object
-
- org.ldaptive.transport.netty.StatefulNettyTransport
-
- All Implemented Interfaces:
Transport
class StatefulNettyTransport extends Object implements Transport
Creates netty connections with configured event loops. This implementation reuses the same event loops for each connection created. Event loop groups are not shutdown when the connection closed, they can be shared between multiple connections.shutdownOnClose
controls whether event loop groups are shutdown when the transport is closed.
-
-
Field Summary
Fields Modifier and Type Field Description private Class<? extends io.netty.channel.Channel>
channelType
Channel type.private io.netty.channel.EventLoopGroup
ioWorkerGroup
Event loop group for I/O, must support the channel type.protected Logger
logger
Logger for this class.private io.netty.channel.EventLoopGroup
messageWorkerGroup
Event loop group for message handling.private boolean
shutdownOnClose
Whether to shut down the event loop groups onclose()
.
-
Constructor Summary
Constructors Constructor Description StatefulNettyTransport()
Creates a new stateful netty transport.StatefulNettyTransport(int ioThreads)
Creates a new stateful netty transport.StatefulNettyTransport(int ioThreads, int messageThreads)
Creates a new stateful netty transport.StatefulNettyTransport(Class<? extends io.netty.channel.Channel> type, io.netty.channel.EventLoopGroup ioGroup, io.netty.channel.EventLoopGroup messageGroup, boolean shutdown)
Creates a new netty connection factory transport.StatefulNettyTransport(String name, int ioThreads, int messageThreads, boolean shutdown)
Creates a new stateful netty transport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Free any resources associated with this transport.Connection
create(ConnectionConfig cc)
Create a connection object.(package private) boolean
getShutdownOnClose()
Returns whether thread pools will be shutdown on close.void
shutdown()
Force shutdown of this transport.String
toString()
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
channelType
private final Class<? extends io.netty.channel.Channel> channelType
Channel type.
-
ioWorkerGroup
private final io.netty.channel.EventLoopGroup ioWorkerGroup
Event loop group for I/O, must support the channel type.
-
messageWorkerGroup
private final io.netty.channel.EventLoopGroup messageWorkerGroup
Event loop group for message handling.
-
shutdownOnClose
private final boolean shutdownOnClose
Whether to shut down the event loop groups onclose()
.
-
-
Constructor Detail
-
StatefulNettyTransport
StatefulNettyTransport()
Creates a new stateful netty transport.
-
StatefulNettyTransport
StatefulNettyTransport(int ioThreads)
Creates a new stateful netty transport.- Parameters:
ioThreads
- number of threads used for I/O in the event loop group
-
StatefulNettyTransport
StatefulNettyTransport(int ioThreads, int messageThreads)
Creates a new stateful netty transport.- Parameters:
ioThreads
- number of threads used for I/O in the event loop groupmessageThreads
- number of threads for LDAP message handling in the event loop group
-
StatefulNettyTransport
StatefulNettyTransport(String name, int ioThreads, int messageThreads, boolean shutdown)
Creates a new stateful netty transport.- Parameters:
name
- to assign the thread poolioThreads
- number of threads used for I/O in the event loop groupmessageThreads
- number of threads for LDAP message handling in the event loop groupshutdown
- whether to shut down the event loop groups on close
-
StatefulNettyTransport
StatefulNettyTransport(Class<? extends io.netty.channel.Channel> type, io.netty.channel.EventLoopGroup ioGroup, io.netty.channel.EventLoopGroup messageGroup, boolean shutdown)
Creates a new netty connection factory transport.- Parameters:
type
- of channelioGroup
- event loop group to handle I/OmessageGroup
- event loop group to handle inbound messages, can be nullshutdown
- whether to shut down the event loop groups on close
-
-
Method Detail
-
create
public Connection create(ConnectionConfig cc)
Description copied from interface:Transport
Create a connection object. Implementations should not open a TCP socket in this method.
-
close
public void close()
Description copied from interface:Transport
Free any resources associated with this transport. This method is invoked by the connection factory using this transport.
-
shutdown
public void shutdown()
Description copied from interface:Transport
Force shutdown of this transport. This method is only needed in cases where the connection factory is configured not to close the transport. SeeThreadPoolConfig.setShutdownStrategy(ThreadPoolConfig.ShutdownStrategy)
.
-
getShutdownOnClose
boolean getShutdownOnClose()
Returns whether thread pools will be shutdown on close.- Returns:
- whether thread pools will be shutdown on close
-
-