public class SendBuffer
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.atomic.AtomicReference<java.nio.ByteBuffer> |
blockerBuffer |
protected static java.nio.ByteBuffer |
BUFFER_IS_CLOSED |
protected java.nio.channels.SocketChannel |
channel |
protected boolean |
debug
Debug mode
|
java.lang.String |
host |
protected java.nio.channels.SelectionKey |
key |
protected static org.slf4j.Logger |
logger |
java.lang.String |
nodeID |
int |
port |
protected java.util.concurrent.ConcurrentLinkedQueue<java.nio.ByteBuffer> |
queue |
| Modifier | Constructor and Description |
|---|---|
protected |
SendBuffer(java.lang.String nodeID,
java.lang.String host,
int port,
boolean debug) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
append(byte[] packet)
Adds a packet to the buffer's queue.
|
protected void |
close() |
protected void |
closeResources() |
protected void |
connected(java.nio.channels.SelectionKey key,
java.nio.channels.SocketChannel channel) |
java.util.LinkedList<byte[]> |
getUnsentPackets() |
protected boolean |
tryToClose()
Tries to close this buffer.
|
protected void |
write()
Writes N bytes to the target channel.
|
protected static final org.slf4j.Logger logger
protected final java.util.concurrent.ConcurrentLinkedQueue<java.nio.ByteBuffer> queue
protected static final java.nio.ByteBuffer BUFFER_IS_CLOSED
protected java.util.concurrent.atomic.AtomicReference<java.nio.ByteBuffer> blockerBuffer
public final java.lang.String nodeID
public final java.lang.String host
public final int port
protected final boolean debug
protected java.nio.channels.SocketChannel channel
protected java.nio.channels.SelectionKey key
protected SendBuffer(java.lang.String nodeID,
java.lang.String host,
int port,
boolean debug)
protected void connected(java.nio.channels.SelectionKey key,
java.nio.channels.SocketChannel channel)
protected boolean append(byte[] packet)
packet - packet to writeprotected boolean tryToClose()
protected void close()
protected void closeResources()
protected void write()
throws java.lang.Exception
java.lang.Exception - any I/O exceptionpublic java.util.LinkedList<byte[]> getUnsentPackets()