public class ClientMessageRouter extends MessageRouter
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<NetworkDestination,java.nio.channels.SocketChannel> |
destinationToSocket |
protected static java.util.logging.Logger |
logger |
protected java.util.Queue<java.nio.channels.SocketChannel> |
pendingRegistrations |
protected java.util.Map<java.nio.channels.SocketChannel,NetworkDestination> |
socketToDestination |
protected java.util.Map<java.nio.channels.SocketChannel,mendel.network.TransmissionTracker> |
socketToTracker |
changeInterest, DEFAULT_READ_BUFFER_SIZE, DEFAULT_WRITE_QUEUE_SIZE, online, PREFIX_SZ, READ_BUFFER_PROPERTY, readBufferSize, selector, WRITE_QUEUE_PROPERTY, writeQueueSize
Constructor and Description |
---|
ClientMessageRouter() |
ClientMessageRouter(int readBufferSize,
int maxWriteQueueSize) |
Modifier and Type | Method and Description |
---|---|
java.util.List<Transmission> |
broadcastMessage(java.lang.Iterable<NetworkDestination> destinations,
MendelMessage message)
Sends a message to multiple network destinations.
|
protected void |
disconnect(java.nio.channels.SelectionKey key)
Handle termination of connections.
|
void |
forceShutdown()
Forcibly shuts down the message processor and disconnects from any
connected server(s).
|
void |
run()
As long as the MessageRouter is online, monitor connection operations
through the Selector instance.
|
Transmission |
sendMessage(NetworkDestination destination,
MendelMessage message)
Sends a message to the specified network destination.
|
Transmission |
sendMessage(NodeInfo destination,
MendelMessage message)
Sends a message to the specified node.
|
void |
shutdown()
Shuts down the message processor and disconnects from the server(s).
|
accept, addListener, connect, dispatchConnect, dispatchDisconnect, dispatchMessage, getClientString, getDestination, isOnline, processIncomingMessage, processSelectionKeys, read, readPrefix, sendMessage, updateInterestOps, wrapWithPrefix
protected static final java.util.logging.Logger logger
protected java.util.Map<NetworkDestination,java.nio.channels.SocketChannel> destinationToSocket
protected java.util.Map<java.nio.channels.SocketChannel,NetworkDestination> socketToDestination
protected java.util.Map<java.nio.channels.SocketChannel,mendel.network.TransmissionTracker> socketToTracker
protected java.util.Queue<java.nio.channels.SocketChannel> pendingRegistrations
public ClientMessageRouter() throws java.io.IOException
java.io.IOException
public ClientMessageRouter(int readBufferSize, int maxWriteQueueSize) throws java.io.IOException
java.io.IOException
public void run()
MessageRouter
run
in interface java.lang.Runnable
run
in class MessageRouter
public java.util.List<Transmission> broadcastMessage(java.lang.Iterable<NetworkDestination> destinations, MendelMessage message) throws java.io.IOException
java.io.IOException
public Transmission sendMessage(NetworkDestination destination, MendelMessage message) throws java.io.IOException
java.io.IOException
public Transmission sendMessage(NodeInfo destination, MendelMessage message) throws java.io.IOException
java.io.IOException
protected void disconnect(java.nio.channels.SelectionKey key)
MessageRouter
disconnect
in class MessageRouter
key
- The SelectionKey of the SocketChannel that has disconnected.public void forceShutdown()
public void shutdown()