Class 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
    • Field Detail

      • queue

        protected java.util.concurrent.BlockingQueue<ByteArray> queue
      • max_size

        protected int max_size
      • 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()
      • droppedMessages

        public long droppedMessages()
      • queueSize

        public int queueSize()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class TcpConnection
        Throws:
        java.io.IOException
      • send

        public void send​(byte[] data,
                         int offset,
                         int length)
                  throws java.lang.Exception
        Overrides:
        send in class TcpConnection
        Throws:
        java.lang.Exception
      • name

        protected java.lang.String name()
      • senderRunning

        protected boolean senderRunning()