Package org.jgroups.blocks
Class ConnectionTableNIO
java.lang.Object
org.jgroups.blocks.BasicConnectionTable
org.jgroups.blocks.ConnectionTableNIO
- All Implemented Interfaces:
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).
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
Nested classes/interfaces inherited from class org.jgroups.blocks.BasicConnectionTable
BasicConnectionTable.ConnectionListener, BasicConnectionTable.Receiver
-
Field Summary
Fields inherited from class org.jgroups.blocks.BasicConnectionTable
log, pm
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionTableNIO
(int srv_port) ConnectionTableNIO
(int srv_port, long reaper_interval, long conn_expire_time) ConnectionTableNIO
(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port) ConnectionTableNIO
(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, boolean doStart) ConnectionTableNIO
(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, long reaper_interval, long conn_expire_time) ConnectionTableNIO
(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, long reaper_interval, long conn_expire_time, boolean doStart) ConnectionTableNIO
(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, PortsManager pm, boolean doStart) ConnectionTableNIO
(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, PortsManager pm, long reaper_interval, long conn_expire_time, boolean doStart) -
Method Summary
Modifier and TypeMethodDescriptionprotected ServerSocket
createServerSocket
(int start_port, int end_port) Finds first available port starting at start_port and returns server socket.long
int
int
int
int
int
int
protected void
init()
void
run()
Acceptor thread.protected void
runRequest
(Address addr, ByteBuffer buf) void
setProcessorKeepAliveTime
(long m_processor_keepAliveTime) void
setProcessorMaxThreads
(int m_processor_maxThreads) void
setProcessorMinThreads
(int m_processor_minThreads) void
setProcessorQueueSize
(int m_processor_queueSize) void
setProcessorThreads
(int m_processor_threads) void
setReaderThreads
(int m_reader_threads) void
setWriterThreads
(int m_writer_threads) final void
start()
void
stop()
Closes all open sockets, the server socket and all threads waiting for incoming messagesMethods inherited from class org.jgroups.blocks.BasicConnectionTable
addConnectionListener, getLinger, getLocalAddress, getNumberOfConnectionCreations, getNumConnections, getPeerAddressReadTimeout, getReceiveBufferSize, getSendBufferSize, getSendQueueSize, getSocketConnectionTimeout, getTcpNodelay, getThreadFactory, getUseSendQueues, receive, removeConnection, removeConnectionListener, retainAll, send, setLinger, setPeerAddressReadTimeout, setReceiveBufferSize, setReceiver, setSendBufferSize, setSendQueueSize, setSocketConnectionTimeout, setTcpNodelay, setThreadFactory, setUseSendQueues, toString
-
Constructor Details
-
ConnectionTableNIO
- Parameters:
srv_port
-- Throws:
Exception
-
ConnectionTableNIO
public ConnectionTableNIO(int srv_port, long reaper_interval, long conn_expire_time) throws Exception - Parameters:
srv_port
-reaper_interval
-conn_expire_time
-- Throws:
Exception
-
ConnectionTableNIO
public ConnectionTableNIO(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port) throws Exception - Parameters:
r
-bind_addr
-external_addr
-srv_port
-max_port
-- Throws:
Exception
-
ConnectionTableNIO
public ConnectionTableNIO(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, boolean doStart) throws Exception - Throws:
Exception
-
ConnectionTableNIO
public ConnectionTableNIO(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, PortsManager pm, boolean doStart) throws Exception - Throws:
Exception
-
ConnectionTableNIO
public ConnectionTableNIO(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, long reaper_interval, long conn_expire_time) throws Exception - Parameters:
r
-bind_addr
-external_addr
-srv_port
-max_port
-reaper_interval
-conn_expire_time
-- Throws:
Exception
-
ConnectionTableNIO
public ConnectionTableNIO(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, long reaper_interval, long conn_expire_time, boolean doStart) throws Exception - Throws:
Exception
-
ConnectionTableNIO
public ConnectionTableNIO(BasicConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, PortsManager pm, long reaper_interval, long conn_expire_time, boolean doStart) throws Exception - Throws:
Exception
-
-
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
- Overrides:
start
in classBasicConnectionTable
- Throws:
Exception
-
init
- Throws:
Exception
-
stop
public void stop()Closes all open sockets, the server socket and all threads waiting for incoming messages- Overrides:
stop
in classBasicConnectionTable
-
run
public void run()Acceptor thread. Continuously accept new connections and assign readhandler/writehandler to them. -
createServerSocket
Finds first available port starting at start_port and returns server socket. Sets srv_port- Throws:
Exception
-
runRequest
- Throws:
InterruptedException
-