Class NioSender
java.lang.Object
org.apache.catalina.tribes.transport.AbstractSender
org.apache.catalina.tribes.transport.nio.NioSender
- All Implemented Interfaces:
- DataSender
This class is NOT thread safe and should never be used with more than one thread at a time. This is a state machine,
handled by the process method. States are:
- NOT_CONNECTED -> connect() -> CONNECTED
- CONNECTED -> setMessage() -> READY TO WRITE
- READY_TO_WRITE -> write() -> READY TO WRITE | READY TO READ
- READY_TO_READ -> read() -> READY_TO_READ | TRANSFER_COMPLETE
- TRANSFER_COMPLETE -> CONNECTED
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final XByteBufferprotected booleanprotected booleanprotected byte[]protected DatagramChannelprotected ByteBufferprotected intprotected Selectorprotected static final StringManagerprotected SocketChannelprotected ByteBuffer
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidconnect()Connect.voidDisconnect.byte[]booleanbooleanprocess(SelectionKey key, boolean waitForAck) State machine to send data.protected booleanread()voidreset()voidsetComplete(boolean complete) voidsetMessage(byte[] data) Send message.voidsetMessage(byte[] data, int offset, int length) voidsetSelector(Selector selector) protected booleanwrite()Methods inherited from class AbstractSendergetAddress, getAttempt, getConnectTime, getDestination, getDirectBuffer, getKeepAliveCount, getKeepAliveTime, getMaxRetryAttempts, getOoBInline, getPort, getRequestCount, getRxBufSize, getSoKeepAlive, getSoLingerOn, getSoLingerTime, getSoReuseAddress, getSoTrafficClass, getTcpNoDelay, getThrowOnFailedAck, getTimeout, getTxBufSize, getUdpPort, getUdpRxBufSize, getUdpTxBufSize, isConnected, isUdpBased, keepalive, setAddress, setAttempt, setConnected, setConnectTime, setDestination, setDirectBuffer, setKeepAliveCount, setKeepAliveTime, setMaxRetryAttempts, setOoBInline, setPort, setRequestCount, setRxBufSize, setSoKeepAlive, setSoLingerOn, setSoLingerTime, setSoReuseAddress, setSoTrafficClass, setTcpNoDelay, setThrowOnFailedAck, setTimeout, setTxBufSize, setUdpBased, setUdpPort, setUdpRxBufSize, setUdpTxBufSize, transferProperties
- 
Field Details- 
sm
- 
selector
- 
socketChannel
- 
dataChannel
- 
readbuf
- 
writebuf
- 
currentprotected volatile byte[] current
- 
ackbuf
- 
remainingprotected int remaining
- 
completeprotected boolean complete
- 
connectingprotected boolean connecting
 
- 
- 
Constructor Details- 
NioSenderpublic NioSender()
 
- 
- 
Method Details- 
processState machine to send data.- Parameters:
- key- The key to use
- waitForAck- Wait for an ack
- Returns:
- trueif the processing was successful
- Throws:
- IOException- An IO error occurred
 
- 
read- Throws:
- IOException
 
- 
write- Throws:
- IOException
 
- 
connect
- 
disconnect
- 
resetpublic void reset()
- 
setMessageSend message.- Parameters:
- data- ChannelMessage
- Throws:
- IOException- if an error occurs
 
- 
setMessage- Throws:
- IOException
 
- 
getMessagepublic byte[] getMessage()
- 
isCompletepublic boolean isComplete()
- 
getSelector
- 
setSelector
- 
setCompletepublic void setComplete(boolean complete) 
 
-