Module org.snmp4j
Package org.snmp4j.transport
Class AbstractTcpServerThread<S extends AbstractSocketEntry>
- java.lang.Object
-
- org.snmp4j.transport.AbstractTcpServerThread<S>
-
- All Implemented Interfaces:
java.lang.Runnable,WorkerTask
- Direct Known Subclasses:
DefaultTcpTransportMapping.ServerThread,TLSTM.ServerThread
public abstract class AbstractTcpServerThread<S extends AbstractSocketEntry> extends java.lang.Object implements WorkerTask
-
-
Field Summary
Fields Modifier and Type Field Description private static LogAdapterloggerprotected java.util.LinkedList<S>pendingprotected java.nio.channels.Selectorselectorprotected booleanstopprotected TcpTransportMapping<?>tcpTransportMapping
-
Constructor Summary
Constructors Constructor Description AbstractTcpServerThread(TcpTransportMapping<?> tcpTransportMapping)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()protected voidcloseChannel(java.nio.channels.SelectableChannel channel)protected voidconnectChannel(java.nio.channels.SelectionKey sk, TcpAddress incomingAddress)protected voidconnectSocketToSendMessage(Address address, byte[] message, java.net.Socket s, S entry, java.util.Map<Address,S> sockets)voidinterrupt()Interrupts this task.voidjoin()Waits until this task has been finished.private voidqueueNewMessage(S entry)abstract SremoveSocketEntry(TcpAddress incomingAddress)abstract voidrun()voidterminate()TheWorkerPoolmight call this method to hint the activeWorkTaskinstance to complete execution as soon as possible.protected TcpAddresswriteData(java.nio.channels.SelectionKey sk, TcpAddress incomingAddress)private voidwriteMessage(S entry, java.nio.channels.SocketChannel sc)
-
-
-
Field Detail
-
logger
private static final LogAdapter logger
-
tcpTransportMapping
protected TcpTransportMapping<?> tcpTransportMapping
-
stop
protected volatile boolean stop
-
selector
protected java.nio.channels.Selector selector
-
pending
protected final java.util.LinkedList<S extends AbstractSocketEntry> pending
-
-
Constructor Detail
-
AbstractTcpServerThread
public AbstractTcpServerThread(TcpTransportMapping<?> tcpTransportMapping) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
connectSocketToSendMessage
protected void connectSocketToSendMessage(Address address, byte[] message, java.net.Socket s, S entry, java.util.Map<Address,S> sockets)
-
queueNewMessage
private void queueNewMessage(S entry)
-
run
public abstract void run()
- Specified by:
runin interfacejava.lang.Runnable
-
removeSocketEntry
public abstract S removeSocketEntry(TcpAddress incomingAddress)
-
connectChannel
protected void connectChannel(java.nio.channels.SelectionKey sk, TcpAddress incomingAddress)
-
writeData
protected TcpAddress writeData(java.nio.channels.SelectionKey sk, TcpAddress incomingAddress)
-
closeChannel
protected void closeChannel(java.nio.channels.SelectableChannel channel)
-
writeMessage
private void writeMessage(S entry, java.nio.channels.SocketChannel sc) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close()
-
terminate
public void terminate()
Description copied from interface:WorkerTaskTheWorkerPoolmight call this method to hint the activeWorkTaskinstance to complete execution as soon as possible.- Specified by:
terminatein interfaceWorkerTask
-
join
public void join()
Description copied from interface:WorkerTaskWaits until this task has been finished.- Specified by:
joinin interfaceWorkerTask
-
interrupt
public void interrupt()
Description copied from interface:WorkerTaskInterrupts this task.- Specified by:
interruptin interfaceWorkerTask- See Also:
Thread.interrupt()
-
-