Class SendBuffer
java.lang.Object
services.moleculer.transporter.tcp.SendBuffer
Attachment of TcpWriter's SelectionKeys.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicReference<ByteBuffer> protected static final ByteBufferprotected SocketChannelprotected final booleanDebug modefinal Stringprotected SelectionKeyprotected static final org.slf4j.Loggerfinal Stringfinal intprotected final ConcurrentLinkedQueue<ByteBuffer> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSendBuffer(String nodeID, String host, int port, boolean debug) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanappend(byte[] packet) Adds a packet to the buffer's queue.protected voidclose()protected voidprotected voidconnected(SelectionKey key, SocketChannel channel) LinkedList<byte[]> protected booleanTries to close this buffer.protected voidwrite()Writes N bytes to the target channel.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
queue
-
BUFFER_IS_CLOSED
-
blockerBuffer
-
nodeID
-
host
-
port
public final int port -
debug
protected final boolean debugDebug mode -
channel
-
key
-
-
Constructor Details
-
SendBuffer
-
-
Method Details
-
connected
-
append
protected boolean append(byte[] packet) Adds a packet to the buffer's queue.- Parameters:
packet- packet to write- Returns:
- true, if success (false = buffer is closed)
-
tryToClose
protected boolean tryToClose()Tries to close this buffer.- Returns:
- true, is closed (false = buffer is not empty)
-
close
protected void close() -
closeResources
protected void closeResources() -
write
-
getUnsentPackets
-