public interface IOThreadingModel
Connection.
The default implementation of this is the NonBlockingIOThreadingModel
that relies on selectors. But also different implementations can be added like spinning, thread per connection etc.
Apart from providing a hook to add new functionality, it also simplifies the Connection and
ConnectionManager since concerns are separated:
separated:
SocketReader: responsible for reading data from the socket(channel)SocketWriter: responsible for writing data to the socket(channel)TcpIpConnection is pretty dumb; it doesn't know anything about threading models; it just owns
a SocketReader and SocketWriter. This keeps the TcpIpConnection very clean and flexible.
The idea is that different SocketReader and SocketWriter implementations can be made. We already have specific
one for non blocking (selector based) IO and for spinning io. These SocketReader/SocketWriter instances only
focus on getting data to and from the socket; they do not concern themselves about interpreting the data. This
is a concern of the ReadHandler and the WriteHandler instance each SocketReader/SocketWriter
has. So a SocketReader/SocketWriter-class is independent of the type of communication that runs on top of it.| Modifier and Type | Method and Description |
|---|---|
boolean |
isBlocking()
Tells whether or not every I/O operation on SocketChannel should block until it completes.
|
SocketReader |
newSocketReader(SocketConnection connection)
Creates a new SocketReader for the given connection.
|
SocketWriter |
newSocketWriter(SocketConnection connection)
Creates a new SocketWriter for the given connection.
|
void |
onConnectionAdded(SocketConnection connection)
Is called when a connection is added.
|
void |
onConnectionRemoved(SocketConnection connection)
Is called when a connection is removed.
|
void |
shutdown()
Shuts down the IOThreadingModel.
|
void |
start()
Starts the IOThreadingModel.
|
boolean isBlocking()
java.nio.channels.SelectableChannel#configureBlocking(boolean)}SocketWriter newSocketWriter(SocketConnection connection)
connection - the TcpIpConnection to create the SocketWriter for.SocketReader newSocketReader(SocketConnection connection)
connection - the TcpIpConnection to create the SocketReader for.void onConnectionAdded(SocketConnection connection)
connection - the connection added.void onConnectionRemoved(SocketConnection connection)
connection - the connection removed.void start()
void shutdown()
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.