Class DefaultTcpTransportMapping.ServerThread
java.lang.Object
org.snmp4j.transport.AbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>
org.snmp4j.transport.DefaultTcpTransportMapping.ServerThread
- All Implemented Interfaces:
Runnable, WorkerTask
- Enclosing class:
DefaultTcpTransportMapping
protected class DefaultTcpTransportMapping.ServerThread
extends AbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>
- Version:
- 3.0
- Author:
- Frank Fock
-
Field Summary
FieldsFields inherited from class AbstractTransportServerThread
exitLatch, pending, selector, serverAddress, shutdown, ssc, stop, transportMapping -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TcpAddressprotected DefaultTcpTransportMapping.SocketEntrycreateSocketEntry(TcpAddress address, SocketChannel socketChannel, boolean useClientMode, TransportStateReference tmStateReference) voidjoin()Waits until this task has been finished.booleanjoin(long timeout) Waits until this task has been finished or the specified timeout has elapsed.protected SocketChannelopenSocketChannel(ProtocolFamily family) protected voidprotected booleanreadMessage(SelectionKey sk, SocketChannel readChannel, TcpAddress incomingAddress, DefaultTcpTransportMapping.SocketEntry socketEntry) protected voidreadSnmpMessagePayload(SocketChannel readChannel, TcpAddress incomingAddress, DefaultTcpTransportMapping.SocketEntry entry, ByteBuffer byteBuffer) removeSocketEntry(TcpAddress incomingAddress) voidrun()voidshutdown()Gracefully shuts down this task.Methods inherited from class AbstractTransportServerThread
close, closeChannel, connectChannel, connectSocketToSendMessage, doServer, fireIncrementCounterSessionClose, getSelector, interrupt, sendMessage, terminate, writeData, writeMessage
-
Field Details
-
buf
protected byte[] buf
-
-
Constructor Details
-
ServerThread
- Throws:
IOException
-
-
Method Details
-
getLastError
-
createSocketEntry
protected DefaultTcpTransportMapping.SocketEntry createSocketEntry(TcpAddress address, SocketChannel socketChannel, boolean useClientMode, TransportStateReference tmStateReference) - Specified by:
createSocketEntryin classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>
-
openSocketChannel
- Specified by:
openSocketChannelin classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>- Throws:
IOException
-
run
public void run()- Specified by:
runin interfaceRunnable- Specified by:
runin classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>
-
readMessage
protected boolean readMessage(SelectionKey sk, SocketChannel readChannel, TcpAddress incomingAddress, DefaultTcpTransportMapping.SocketEntry socketEntry) throws IOException - Specified by:
readMessagein classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>- Throws:
IOException
-
processQueues
protected void processQueues()- Specified by:
processQueuesin classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>
-
removeSocketEntry
- Specified by:
removeSocketEntryin classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>
-
createIncomingAddress
- Specified by:
createIncomingAddressin classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>- Throws:
IOException
-
readSnmpMessagePayload
protected void readSnmpMessagePayload(SocketChannel readChannel, TcpAddress incomingAddress, DefaultTcpTransportMapping.SocketEntry entry, ByteBuffer byteBuffer) throws IOException - Throws:
IOException
-
join
Description copied from interface:WorkerTaskWaits until this task has been finished or the specified timeout has elapsed.- Parameters:
timeout- the maximum time to wait in milliseconds.- Returns:
trueif the task has been finished,falseotherwise.- Throws:
InterruptedException- if the join has been interrupted by another thread.
-
shutdown
public void shutdown()Description copied from interface:WorkerTaskGracefully shuts down this task. All pending operations should be finished, but no new operations should be accepted. -
join
Description copied from interface:WorkerTaskWaits until this task has been finished.- Specified by:
joinin interfaceWorkerTask- Overrides:
joinin classAbstractTransportServerThread<TcpAddress, DefaultTcpTransportMapping.SocketEntry>- Throws:
InterruptedException- if the join has been interrupted by another thread.
-