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 Summary
Modifier and TypeFieldDescriptionprotected final XByteBuffer
protected boolean
protected boolean
protected byte[]
protected DatagramChannel
protected ByteBuffer
protected int
protected Selector
protected static final StringManager
protected SocketChannel
protected ByteBuffer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
connect - blocking in this operationvoid
disconnect TODO Implement this org.apache.catalina.tribes.transport.IDataSender methodbyte[]
boolean
boolean
process
(SelectionKey key, boolean waitForAck) State machine to send data.protected boolean
read()
void
reset()
void
setComplete
(boolean complete) void
setMessage
(byte[] data) sendMessagevoid
setMessage
(byte[] data, int offset, int length) void
setSelector
(Selector selector) protected boolean
write()
Methods inherited from class org.apache.catalina.tribes.transport.AbstractSender
getAddress, 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
-
current
protected volatile byte[] current -
ackbuf
-
remaining
protected int remaining -
complete
protected boolean complete -
connecting
protected boolean connecting
-
-
Constructor Details
-
NioSender
public NioSender()
-
-
Method Details
-
process
State machine to send data.- Parameters:
key
- The key to usewaitForAck
- Wait for an ack- Returns:
true
if the processing was successful- Throws:
IOException
- An IO error occurred
-
read
- Throws:
IOException
-
write
- Throws:
IOException
-
connect
connect - blocking in this operation- Specified by:
connect
in interfaceDataSender
- Specified by:
connect
in classAbstractSender
- Throws:
IOException
- TODO Implement this org.apache.catalina.tribes.transport.IDataSender method
-
disconnect
public void disconnect()disconnect TODO Implement this org.apache.catalina.tribes.transport.IDataSender method- Specified by:
disconnect
in interfaceDataSender
- Specified by:
disconnect
in classAbstractSender
-
reset
public void reset() -
setMessage
sendMessage- Parameters:
data
- ChannelMessage- Throws:
IOException
- TODO Implement this org.apache.catalina.tribes.transport.IDataSender method
-
setMessage
- Throws:
IOException
-
getMessage
public byte[] getMessage() -
isComplete
public boolean isComplete() -
getSelector
-
setSelector
-
setComplete
public void setComplete(boolean complete)
-