class TLSTM.ServerThread extends java.lang.Object implements WorkerTask
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.BlockingQueue<TLSTM.SocketEntry> |
inQueue |
private java.lang.Throwable |
lastError |
private java.util.concurrent.BlockingQueue<TLSTM.SocketEntry> |
outQueue |
private java.util.LinkedList<TLSTM.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 java.nio.ByteBuffer |
createBufferCopy(java.nio.ByteBuffer buffer) |
private void |
dispatchMessage(TcpAddress incomingAddress,
java.nio.ByteBuffer byteBuffer,
long bytesRead,
java.lang.Object sessionID,
TransportStateReference tmStateReference) |
java.lang.Throwable |
getLastError() |
void |
interrupt()
Interrupts this task.
|
void |
join()
Waits until this task has been finished.
|
private void |
processPending() |
private void |
processQueues() |
private void |
readMessage(java.nio.channels.SelectionKey sk,
java.nio.channels.SocketChannel readChannel,
TcpAddress incomingAddress,
TLSTM.SocketEntry session) |
void |
run() |
boolean |
runDelegatedTasks(javax.net.ssl.SSLEngineResult result,
TLSTM.SocketEntry entry)
If the result indicates that we have outstanding tasks to do,
go ahead and run them in this thread.
|
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(TLSTM.SocketEntry entry,
java.nio.channels.SocketChannel sc) |
private void |
writeNetBuffer(TLSTM.SocketEntry entry,
java.nio.channels.SocketChannel sc) |
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<TLSTM.SocketEntry> pending
private java.util.concurrent.BlockingQueue<TLSTM.SocketEntry> outQueue
private java.util.concurrent.BlockingQueue<TLSTM.SocketEntry> inQueue
public ServerThread() throws java.io.IOException, java.security.NoSuchAlgorithmException
java.io.IOException
java.security.NoSuchAlgorithmException
private void processQueues()
private void processPending()
public boolean runDelegatedTasks(javax.net.ssl.SSLEngineResult result, TLSTM.SocketEntry entry) throws java.io.IOException
result
- the SSLEngine wrap/unwrap result.entry
- the session to use.true
if processing of delegated tasks has been
finished, false
otherwise.java.io.IOException
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, TLSTM.SocketEntry session) throws java.io.IOException
java.io.IOException
private java.nio.ByteBuffer createBufferCopy(java.nio.ByteBuffer buffer)
private void dispatchMessage(TcpAddress incomingAddress, java.nio.ByteBuffer byteBuffer, long bytesRead, java.lang.Object sessionID, TransportStateReference tmStateReference)
private void writeMessage(TLSTM.SocketEntry entry, java.nio.channels.SocketChannel sc) throws java.io.IOException
java.io.IOException
private void writeNetBuffer(TLSTM.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()