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
public class TcpConnectionNonBlocking extends TcpConnection
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 Modifier and Type Class Description protected class
TcpConnectionNonBlocking.Sender
-
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.LongAdder
dropped_msgs
protected int
max_size
protected java.util.concurrent.BlockingQueue<ByteArray>
queue
protected TcpConnectionNonBlocking.Sender
sender
-
Fields inherited from class org.jgroups.blocks.cs.TcpConnection
connected, in, length_buf, out, receiver, send_lock, sock, writers
-
Fields inherited from class org.jgroups.blocks.cs.Connection
cookie, last_access, peer_addr, server
-
-
Constructor Summary
Constructors Constructor Description TcpConnectionNonBlocking(java.net.Socket s, TcpServer server)
TcpConnectionNonBlocking(Address peer_addr, TcpBaseServer server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
long
droppedMessages()
int
maxSize()
TcpConnectionNonBlocking
maxSize(int s)
protected java.lang.String
name()
int
queueSize()
void
send(byte[] data, int offset, int length)
protected boolean
senderRunning()
void
start()
java.lang.String
toString()
-
Methods inherited from class org.jgroups.blocks.cs.TcpConnection
connect, connect, createDataInputStream, createDataOutputStream, doSend, doSend, flush, getSockAddress, isClosed, isConnected, isConnectionPending, localAddress, readPeerAddress, send, sendLocalAddress, setSocketParameters, status
-
Methods inherited from class org.jgroups.blocks.cs.Connection
getTimestamp, isExpired, peerAddress, updateLastAccessed
-
-
-
-
Field Detail
-
queue
protected java.util.concurrent.BlockingQueue<ByteArray> queue
-
max_size
protected int max_size
-
sender
protected volatile TcpConnectionNonBlocking.Sender sender
-
dropped_msgs
protected final java.util.concurrent.atomic.LongAdder dropped_msgs
-
-
Constructor Detail
-
TcpConnectionNonBlocking
public TcpConnectionNonBlocking(Address peer_addr, TcpBaseServer server) throws java.lang.Exception
- Throws:
java.lang.Exception
-
TcpConnectionNonBlocking
public TcpConnectionNonBlocking(java.net.Socket s, TcpServer server) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
maxSize
public int maxSize()
-
maxSize
public TcpConnectionNonBlocking maxSize(int s)
-
droppedMessages
public long droppedMessages()
-
queueSize
public int queueSize()
-
start
public void start()
- Overrides:
start
in classTcpConnection
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classTcpConnection
- Throws:
java.io.IOException
-
send
public void send(byte[] data, int offset, int length) throws java.lang.Exception
- Overrides:
send
in classTcpConnection
- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toString
in classTcpConnection
-
name
protected java.lang.String name()
-
senderRunning
protected boolean senderRunning()
-
-