class DefaultTcpTransportMapping.ServerThread extends java.lang.Object implements WorkerTask
Modifier and Type | Field and Description |
---|---|
private byte[] |
buf |
private java.lang.Throwable |
lastError |
private java.util.LinkedList<DefaultTcpTransportMapping.SocketEntry> |
pending |
private java.nio.channels.Selector |
selector |
private java.nio.channels.ServerSocketChannel |
ssc |
private boolean |
stop |
Constructor and Description |
---|
ServerThread() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
private void |
closeChannel(java.nio.channels.SelectableChannel channel) |
private void |
connectChannel(java.nio.channels.SelectionKey sk,
TcpAddress incomingAddress) |
private void |
dispatchMessage(TcpAddress incomingAddress,
java.nio.ByteBuffer byteBuffer,
long bytesRead,
java.lang.Object sessionID) |
java.lang.Throwable |
getLastError() |
void |
interrupt()
Interrupts this task.
|
void |
join()
Waits until this task has been finished.
|
private void |
processPending() |
private void |
readMessage(java.nio.channels.SelectionKey sk,
java.nio.channels.SocketChannel readChannel,
TcpAddress incomingAddress) |
void |
run() |
void |
sendMessage(Address address,
byte[] message,
TransportStateReference tmStateReference) |
void |
terminate()
The
WorkerPool might call this method to hint the active
WorkTask instance to complete execution as soon as possible. |
private TcpAddress |
writeData(java.nio.channels.SelectionKey sk,
TcpAddress incomingAddress) |
private void |
writeMessage(DefaultTcpTransportMapping.SocketEntry entry,
java.nio.channels.SocketChannel sc) |
private byte[] buf
private volatile boolean stop
private java.lang.Throwable lastError
private java.nio.channels.ServerSocketChannel ssc
private java.nio.channels.Selector selector
private java.util.LinkedList<DefaultTcpTransportMapping.SocketEntry> pending
public ServerThread() throws java.io.IOException
java.io.IOException
private void processPending()
public java.lang.Throwable getLastError()
public void sendMessage(Address address, byte[] message, TransportStateReference tmStateReference) throws java.io.IOException
java.io.IOException
public void run()
run
in interface java.lang.Runnable
private void connectChannel(java.nio.channels.SelectionKey sk, TcpAddress incomingAddress)
private TcpAddress writeData(java.nio.channels.SelectionKey sk, TcpAddress incomingAddress)
private void closeChannel(java.nio.channels.SelectableChannel channel)
private void readMessage(java.nio.channels.SelectionKey sk, java.nio.channels.SocketChannel readChannel, TcpAddress incomingAddress) throws java.io.IOException
java.io.IOException
private void dispatchMessage(TcpAddress incomingAddress, java.nio.ByteBuffer byteBuffer, long bytesRead, java.lang.Object sessionID)
private void writeMessage(DefaultTcpTransportMapping.SocketEntry entry, java.nio.channels.SocketChannel sc) throws java.io.IOException
java.io.IOException
public void close()
public void terminate()
WorkerTask
WorkerPool
might call this method to hint the active
WorkTask
instance to complete execution as soon as possible.terminate
in interface WorkerTask
public void join()
WorkerTask
join
in interface WorkerTask
public void interrupt()
WorkerTask
interrupt
in interface WorkerTask
Thread.interrupt()