public final class NioNetworking extends Object implements Networking
Networking 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:
NioInboundPipeline: triggered by the NioThread when data is available
in the socket. The NioInboundPipeline takes care of reading data from the socket
and calling the appropriate
InboundHandlerNioOutboundPipeline: 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 NioOutboundPipeline takes care of calling the
appropriate OutboundHandler
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).| Modifier and Type | Class and Description |
|---|---|
static class |
NioNetworking.Context |
| Constructor and Description |
|---|
NioNetworking(NioNetworking.Context ctx) |
| Modifier and Type | Method and Description |
|---|---|
NioThread[] |
getInputThreads() |
IOBalancer |
getIOBalancer() |
NioThread[] |
getOutputThreads() |
Channel |
register(SocketChannel socketChannel,
boolean clientMode)
Registers the SocketChannel to the EventLoop group and returns the
created Channel.
|
void |
shutdown()
Shuts down this Networking.
|
void |
start()
Starts this Networking.
|
public NioNetworking(NioNetworking.Context ctx)
public NioThread[] getInputThreads()
public NioThread[] getOutputThreads()
public IOBalancer getIOBalancer()
public void start()
Networkingstart in interface Networkingpublic void shutdown()
Networkingshutdown in interface Networkingpublic Channel register(SocketChannel socketChannel, boolean clientMode) throws IOException
NetworkingChannel.start()
needs to be called.register in interface NetworkingsocketChannel - the socketChannel to registerclientMode - if the channel is made in clientMode or server modeIOExceptionCopyright © 2018 Hazelcast, Inc.. All Rights Reserved.