Class ConnectionTableNIO

java.lang.Object
org.jgroups.blocks.BasicConnectionTable
org.jgroups.blocks.ConnectionTableNIO
All Implemented Interfaces:
Runnable

public class ConnectionTableNIO extends BasicConnectionTable implements Runnable
Manages incoming and outgoing TCP connections. For each outgoing message to destination P, if there is not yet a connection for P, one will be created. Subsequent outgoing messages will use this connection. For incoming messages, one server socket is created at startup. For each new incoming client connecting, a new thread from a thread pool is allocated and listens for incoming messages until the socket is closed by the peer.
Sockets/threads with no activity will be killed after some time.

Incoming messages from any of the sockets can be received by setting the message listener. We currently require use_incoming_packet_handler=true (release 2.4 will support use_incoming_packet_handler=false due to threadless stack support).

Author:
Bela Ban, Scott Marlow, Alex Fu
  • Constructor Details

  • Method Details

    • getReaderThreads

      public int getReaderThreads()
    • setReaderThreads

      public void setReaderThreads(int m_reader_threads)
    • getWriterThreads

      public int getWriterThreads()
    • setWriterThreads

      public void setWriterThreads(int m_writer_threads)
    • getProcessorThreads

      public int getProcessorThreads()
    • setProcessorThreads

      public void setProcessorThreads(int m_processor_threads)
    • getProcessorMinThreads

      public int getProcessorMinThreads()
    • setProcessorMinThreads

      public void setProcessorMinThreads(int m_processor_minThreads)
    • getProcessorMaxThreads

      public int getProcessorMaxThreads()
    • setProcessorMaxThreads

      public void setProcessorMaxThreads(int m_processor_maxThreads)
    • getProcessorQueueSize

      public int getProcessorQueueSize()
    • setProcessorQueueSize

      public void setProcessorQueueSize(int m_processor_queueSize)
    • getProcessorKeepAliveTime

      public long getProcessorKeepAliveTime()
    • setProcessorKeepAliveTime

      public void setProcessorKeepAliveTime(long m_processor_keepAliveTime)
    • start

      public final void start() throws Exception
      Overrides:
      start in class BasicConnectionTable
      Throws:
      Exception
    • init

      protected void init() throws Exception
      Throws:
      Exception
    • stop

      public void stop()
      Closes all open sockets, the server socket and all threads waiting for incoming messages
      Overrides:
      stop in class BasicConnectionTable
    • run

      public void run()
      Acceptor thread. Continuously accept new connections and assign readhandler/writehandler to them.
      Specified by:
      run in interface Runnable
    • createServerSocket

      protected ServerSocket createServerSocket(int start_port, int end_port) throws Exception
      Finds first available port starting at start_port and returns server socket. Sets srv_port
      Throws:
      Exception
    • runRequest

      protected void runRequest(Address addr, ByteBuffer buf) throws InterruptedException
      Throws:
      InterruptedException