Class NioSender
- java.lang.Object
- 
- org.apache.catalina.tribes.transport.AbstractSender
- 
- org.apache.catalina.tribes.transport.nio.NioSender
 
 
- 
- All Implemented Interfaces:
- DataSender
 
 public class NioSender extends AbstractSender 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 SummaryFields Modifier and Type Field Description protected XByteBufferackbufprotected booleancompleteprotected booleanconnectingprotected byte[]currentprotected java.nio.channels.DatagramChanneldataChannelprotected java.nio.ByteBufferreadbufprotected intremainingprotected java.nio.channels.Selectorselectorprotected static StringManagersmprotected java.nio.channels.SocketChannelsocketChannelprotected java.nio.ByteBufferwritebuf
 - 
Constructor SummaryConstructors Constructor Description NioSender()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()connect - blocking in this operationvoiddisconnect()disconnect TODO Implement this org.apache.catalina.tribes.transport.IDataSender methodbyte[]getMessage()java.nio.channels.SelectorgetSelector()booleanisComplete()booleanprocess(java.nio.channels.SelectionKey key, boolean waitForAck)State machine to send data.protected booleanread()voidreset()voidsetComplete(boolean complete)voidsetMessage(byte[] data)sendMessagevoidsetMessage(byte[] data, int offset, int length)voidsetSelector(java.nio.channels.Selector selector)protected booleanwrite()- 
Methods inherited from class org.apache.catalina.tribes.transport.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 Detail- 
smprotected static final StringManager sm 
 - 
selectorprotected java.nio.channels.Selector selector 
 - 
socketChannelprotected java.nio.channels.SocketChannel socketChannel 
 - 
dataChannelprotected java.nio.channels.DatagramChannel dataChannel 
 - 
readbufprotected java.nio.ByteBuffer readbuf 
 - 
writebufprotected java.nio.ByteBuffer writebuf 
 - 
currentprotected volatile byte[] current 
 - 
ackbufprotected final XByteBuffer ackbuf 
 - 
remainingprotected int remaining 
 - 
completeprotected boolean complete 
 - 
connectingprotected boolean connecting 
 
- 
 - 
Method Detail- 
processpublic boolean process(java.nio.channels.SelectionKey key, boolean waitForAck) throws java.io.IOExceptionState machine to send data.- Parameters:
- key- The key to use
- waitForAck- Wait for an ack
- Returns:
- trueif the processing was successful
- Throws:
- java.io.IOException- An IO error occurred
 
 - 
readprotected boolean read() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
writeprotected boolean write() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
connectpublic void connect() throws java.io.IOExceptionconnect - blocking in this operation- Specified by:
- connectin interface- DataSender
- Specified by:
- connectin class- AbstractSender
- Throws:
- java.io.IOException- TODO Implement this org.apache.catalina.tribes.transport.IDataSender method
 
 - 
disconnectpublic void disconnect() disconnect TODO Implement this org.apache.catalina.tribes.transport.IDataSender method- Specified by:
- disconnectin interface- DataSender
- Specified by:
- disconnectin class- AbstractSender
 
 - 
resetpublic void reset() 
 - 
setMessagepublic void setMessage(byte[] data) throws java.io.IOExceptionsendMessage- Parameters:
- data- ChannelMessage
- Throws:
- java.io.IOException- TODO Implement this org.apache.catalina.tribes.transport.IDataSender method
 
 - 
setMessagepublic void setMessage(byte[] data, int offset, int length) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
getMessagepublic byte[] getMessage() 
 - 
isCompletepublic boolean isComplete() 
 - 
getSelectorpublic java.nio.channels.Selector getSelector() 
 - 
setSelectorpublic void setSelector(java.nio.channels.Selector selector) 
 - 
setCompletepublic void setComplete(boolean complete) 
 
- 
 
-