org.apache.catalina.tribes.transport.nio
Class NioSender
java.lang.Object
   org.apache.catalina.tribes.transport.AbstractSender
org.apache.catalina.tribes.transport.AbstractSender
       org.apache.catalina.tribes.transport.nio.NioSender
org.apache.catalina.tribes.transport.nio.NioSender
- All Implemented Interfaces: 
- DataSender
- public class NioSender 
- extends AbstractSender- implements 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
- Version:
- 1.0
- Author:
- Filip Hanik
 
 
| Method Summary | 
|  void | connect()connect - blocking in this operation
 | 
|  void | disconnect()
 | 
|  byte[] | getMessage()
 | 
|  java.nio.channels.Selector | getSelector()
 | 
|  boolean | isComplete()
 | 
|  boolean | process(java.nio.channels.SelectionKey key,
        boolean waitForAck)State machine to send data
 | 
| protected  boolean | read(java.nio.channels.SelectionKey key)
 | 
|  void | reset()
 | 
|  void | setComplete(boolean complete)
 | 
|  void | setMessage(byte[] data)
 | 
|  void | setMessage(byte[] data,
           int offset,
           int length)
 | 
|  void | setSelector(java.nio.channels.Selector selector)
 | 
| protected  boolean | write(java.nio.channels.SelectionKey key)
 | 
 
| Methods inherited from class org.apache.catalina.tribes.transport.AbstractSender | 
| getAddress, getAttempt, getConnectTime, getDestination, getDirect, getDirectBuffer, getKeepAliveCount, getKeepAliveTime, getMaxRetryAttempts, getOoBInline, getPort, getRequestCount, getRxBufSize, getSoKeepAlive, getSoLingerOn, getSoLingerTime, getSoReuseAddress, getSoTrafficClass, getTcpNoDelay, getThrowOnFailedAck, getTimeout, getTxBufSize, isConnected, keepalive, setAddress, setAttempt, setConnected, setConnectTime, setDestination, setDirect, setDirectBuffer, setKeepAliveCount, setKeepAliveTime, setMaxRetryAttempts, setOoBInline, setPort, setRequestCount, setRxBufSize, setSoKeepAlive, setSoLingerOn, setSoLingerTime, setSoReuseAddress, setSoTrafficClass, setTcpNoDelay, setThrowOnFailedAck, setTimeout, setTxBufSize, transferProperties | 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
 
log
protected static Log log
selector
protected java.nio.channels.Selector selector
socketChannel
protected java.nio.channels.SocketChannel socketChannel
readbuf
protected java.nio.ByteBuffer readbuf
writebuf
protected java.nio.ByteBuffer writebuf
current
protected byte[] current
ackbuf
protected XByteBuffer ackbuf
remaining
protected int remaining
complete
protected boolean complete
connecting
protected boolean connecting
NioSender
public NioSender()
process
public boolean process(java.nio.channels.SelectionKey key,
                       boolean waitForAck)
                throws java.io.IOException
- State machine to send data
 
- 
 
- 
- Parameters:
- key- SelectionKey
- Returns:
- boolean
- Throws:
- java.io.IOException
 
read
protected boolean read(java.nio.channels.SelectionKey key)
                throws java.io.IOException
- 
 
- 
- Throws:
- java.io.IOException
 
write
protected boolean write(java.nio.channels.SelectionKey key)
                 throws java.io.IOException
- 
 
- 
- Throws:
- java.io.IOException
 
connect
public void connect()
             throws java.io.IOException
- connect - blocking in this operation
 
- 
- Specified by:
- connectin interface- DataSender
- Specified by:
- connectin class- AbstractSender
 
- 
- Throws:
- java.io.IOException
 
disconnect
public void disconnect()
- 
- Specified by:
- disconnectin interface- DataSender
- Specified by:
- disconnectin class- AbstractSender
 
- 
 
reset
public void reset()
- 
 
- 
 
setMessage
public void setMessage(byte[] data)
                throws java.io.IOException
- 
 
- 
- Throws:
- java.io.IOException
 
setMessage
public void setMessage(byte[] data,
                       int offset,
                       int length)
                throws java.io.IOException
- 
 
- 
- Throws:
- java.io.IOException
 
getMessage
public byte[] getMessage()
- 
 
- 
 
isComplete
public boolean isComplete()
- 
 
- 
 
getSelector
public java.nio.channels.Selector getSelector()
- 
 
- 
 
setSelector
public void setSelector(java.nio.channels.Selector selector)
- 
 
- 
 
setComplete
public void setComplete(boolean complete)
- 
 
- 
 
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.