Class TCP_NIO2

  • All Implemented Interfaces:
    Receiver, AdditionalJmxObjects, DiagnosticsHandler.ProbeHandler

    public class TCP_NIO2
    extends BasicTCP
    Protocol using TCP/IP to send and receive messages. Contrary to TCP, TCP_NIO uses non-blocking I/O (NIO), which eliminates the thread per connection model. Instead, TCP_NIO uses a single selector to poll for incoming messages and dispatches handling of those to a (configurable) thread pool.

    Most of the functionality is in NioServer. TCP_NIO sends messages using BaseServer.send(Address,byte[],int,int) and registers with the server to receive messages.

    Since:
    3.6.5
    Author:
    Bela Ban
    • Field Detail

      • max_send_buffers

        protected int max_send_buffers
      • copy_on_partial_write

        protected boolean copy_on_partial_write
      • reader_idle_time

        protected long reader_idle_time
    • Constructor Detail

      • TCP_NIO2

        public TCP_NIO2()
    • Method Detail

      • getOpenConnections

        public int getOpenConnections()
      • printBuffers

        public java.lang.String printBuffers()
      • clearConnections

        public void clearConnections()
      • isSelectorOpen

        public boolean isSelectorOpen()
      • isAcceptorRunning

        public boolean isAcceptorRunning()
      • numSelects

        public int numSelects()
      • numPartialWrites

        public int numPartialWrites()
      • readerIdleTime

        public void readerIdleTime​(long t)
      • send

        public void send​(Address dest,
                         byte[] data,
                         int offset,
                         int length)
                  throws java.lang.Exception
        Specified by:
        send in class BasicTCP
        Throws:
        java.lang.Exception
      • retainAll

        public void retainAll​(java.util.Collection<Address> members)
        Specified by:
        retainAll in class BasicTCP
      • start

        public void start()
                   throws java.lang.Exception
        Description copied from class: TP
        Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
        Overrides:
        start in class TP
        Throws:
        java.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so JChannel.connect(String) will throw an exception
      • stop

        public void stop()
        Description copied from class: Protocol
        This method is called on a JChannel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed
        Overrides:
        stop in class TP
      • handleConnect

        protected void handleConnect()
                              throws java.lang.Exception
        Overrides:
        handleConnect in class TP
        Throws:
        java.lang.Exception
      • handleDisconnect

        protected void handleDisconnect()
        Overrides:
        handleDisconnect in class TP