public class NioEventLoopGroup extends Object implements EventLoopGroup
EventLoopGroup implementation that makes use of Selector to have a
limited set of io threads, handle an arbitrary number of connections.
Each NioChannel has 2 parts:
NioChannelReader: triggered by the NioThread when data is available in the socket. The NioChannelReader
takes care of reading data from the socket and calling the appropriate
ChannelInboundHandlerNioChannelWriter: triggered by the NioThread when either space is available in the socket for writing,
or when there is something that needs to be written e.g. a Packet. The NioChannelWriter takes care of calling the
appropriate ChannelOutboundHandler to convert the
OutboundFrame to bytes in in the ByteBuffer and writing it to the socket.
NioThread blocks on the Selector, but it can be put in a 'selectNow' mode that makes it
spinning on the selector. This is an experimental feature and will cause the io threads to run hot. For this reason, when
this feature is enabled, the number of io threads should be reduced (preferably 1).| Constructor and Description |
|---|
NioEventLoopGroup(LoggingService loggingService,
MetricsRegistry metricsRegistry,
String hzName,
ChannelErrorHandler errorHandler,
int inputThreadCount,
int outputThreadCount,
int balanceIntervalSeconds,
ChannelInitializer channelInitializer) |
| Modifier and Type | Method and Description |
|---|---|
NioThread[] |
getInputThreads() |
IOBalancer |
getIOBalancer() |
NioThread[] |
getOutputThreads() |
void |
register(Channel channel)
Registers a channel at this
EventLoopGroup. |
void |
setSelectorMode(SelectorMode mode) |
void |
shutdown()
Shuts down this EventLoopGroup.
|
void |
start()
Starts this EventLoopGroup.
|
public NioEventLoopGroup(LoggingService loggingService, MetricsRegistry metricsRegistry, String hzName, ChannelErrorHandler errorHandler, int inputThreadCount, int outputThreadCount, int balanceIntervalSeconds, ChannelInitializer channelInitializer)
public void setSelectorMode(SelectorMode mode)
public NioThread[] getInputThreads()
public NioThread[] getOutputThreads()
public IOBalancer getIOBalancer()
public void start()
EventLoopGroupstart in interface EventLoopGrouppublic void shutdown()
EventLoopGroupshutdown in interface EventLoopGrouppublic void register(Channel channel)
EventLoopGroupEventLoopGroup.
Every Channel should be registered at at most 1 EventLoopGroup and it is very unlikely that during the lifespan of the
Channel, it will change its EventLoopGroup.register in interface EventLoopGroupchannel - the channel to register.Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.