Package org.jgroups.blocks.cs
Class TcpConnectionNonBlocking
- java.lang.Object
-
- org.jgroups.blocks.cs.Connection
-
- org.jgroups.blocks.cs.TcpConnection
-
- org.jgroups.blocks.cs.TcpConnectionNonBlocking
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Runnable
public class TcpConnectionNonBlocking extends TcpConnection implements java.lang.Runnable
TCP connection which (despite the fancy name) blocks only a single thread at most. Uses a bounded queue, to which senders add their messages, and a single consumer sending the messages. When the queue is full, messages will get dropped. Therefore, at most one thread is blocked on TCP write when the send-window is full.
Link: https://issues.redhat.com/browse/JGRP-2759- Since:
- 5.3.3
- Author:
- Bela Ban
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jgroups.blocks.cs.TcpConnection
TcpConnection.Receiver
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.LongAdderdropped_msgsprotected intmax_sizeprotected java.util.concurrent.BlockingQueue<ByteArray>queueprotected FastArray<ByteArray>remove_queueprotected intrq_capacityprotected Runnersender-
Fields inherited from class org.jgroups.blocks.cs.TcpConnection
connected, in, length_buf, out, receiver, sock, use_lock_to_send, writers
-
Fields inherited from class org.jgroups.blocks.cs.Connection
cookie, last_access, peer_addr, send_lock, server
-
-
Constructor Summary
Constructors Constructor Description TcpConnectionNonBlocking(java.net.Socket s, TcpServer server, int max_size)TcpConnectionNonBlocking(Address peer_addr, TcpBaseServer server, int max_size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()longdroppedMessages()intmaxSize()protected java.lang.Stringname()intqueueSize()voidrun()voidsend(byte[] data, int offset, int length)booleansenderRunning()voidstart()java.lang.StringtoString()-
Methods inherited from class org.jgroups.blocks.cs.TcpConnection
connect, connect, createDataInputStream, createDataOutputStream, doSend, flush, getSockAddress, isClosed, isConnected, isConnectionPending, localAddress, locklessSend, readPeerAddress, send, sendLocalAddress, setSocketParameters, status, useLockToSend, useLockToSend
-
Methods inherited from class org.jgroups.blocks.cs.Connection
getTimestamp, isExpired, peerAddress, updateLastAccessed
-
-
-
-
Constructor Detail
-
TcpConnectionNonBlocking
public TcpConnectionNonBlocking(Address peer_addr, TcpBaseServer server, int max_size) throws java.lang.Exception
- Throws:
java.lang.Exception
-
TcpConnectionNonBlocking
public TcpConnectionNonBlocking(java.net.Socket s, TcpServer server, int max_size) throws java.lang.Exception- Throws:
java.lang.Exception
-
-
Method Detail
-
maxSize
public int maxSize()
-
droppedMessages
public long droppedMessages()
-
queueSize
public int queueSize()
-
senderRunning
public boolean senderRunning()
-
start
public void start()
- Overrides:
startin classTcpConnection
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classTcpConnection- Throws:
java.io.IOException
-
send
public void send(byte[] data, int offset, int length) throws java.lang.Exception- Overrides:
sendin classTcpConnection- Throws:
java.lang.Exception
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classTcpConnection
-
name
protected java.lang.String name()
-
-