| java.lang.Object org.jgroups.blocks.BasicConnectionTable org.jgroups.blocks.ConnectionTable
All known Subclasses: org.jgroups.tests.ConnectionTableDemo, org.jgroups.protocols.TCP,
ConnectionTable | public class ConnectionTable extends BasicConnectionTable implements Runnable(Code) | | 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.
author: Bela Ban |
Constructor Summary | |
public | ConnectionTable(int srv_port) Regular ConnectionTable without expiration of idle connections
Parameters: srv_port - The port on which the server will listen. | public | ConnectionTable(InetAddress bind_addr, int srv_port) | public | ConnectionTable(int srv_port, long reaper_interval, long conn_expire_time) ConnectionTable including a connection reaper. | public | ConnectionTable(Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port) Create a ConnectionTable
Parameters: r - A reference to a receiver of all messages received by this class. | public | ConnectionTable(Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, long reaper_interval, long conn_expire_time) ConnectionTable including a connection reaper. |
Method Summary | |
protected ServerSocket | createServerSocket(int start_port, int end_port) Finds first available port starting at start_port and returns server socket.
Will not bind to port >end_port. | Connection | getConnection(Address dest) | protected void | init() | public void | run() Acceptor thread. | final public void | start() | public void | stop() |
ConnectionTable | public ConnectionTable(int srv_port) throws Exception(Code) | | Regular ConnectionTable without expiration of idle connections
Parameters: srv_port - The port on which the server will listen. If this port is reserved, the nextfree port will be taken (incrementing srv_port). |
ConnectionTable | public ConnectionTable(int srv_port, long reaper_interval, long conn_expire_time) throws Exception(Code) | | ConnectionTable including a connection reaper. Connections that have been idle for more than conn_expire_time
milliseconds will be closed and removed from the connection table. On next access they will be re-created.
Parameters: srv_port - The port on which the server will listen Parameters: reaper_interval - Number of milliseconds to wait for reaper between attepts to reap idle connections Parameters: conn_expire_time - Number of milliseconds a connection can be idle (no traffic sent or received untilit will be reaped |
ConnectionTable | public ConnectionTable(Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port) throws Exception(Code) | | Create a ConnectionTable
Parameters: r - A reference to a receiver of all messages received by this class. Method receive() will be called. Parameters: bind_addr - The host name or IP address of the interface to which the server socket will bind.This is interesting only in multi-homed systems. If bind_addr is null, theserver socket will bind to the first available interface (e.g. /dev/hme0 onSolaris or /dev/eth0 on Linux systems). Parameters: external_addr - The address which will be broadcast to the group (the externally visible addresswhich this host should be contacted on). If external_addr is null, it will default tothe same address that the server socket is bound to. Parameters: srv_port - The port to which the server socket will bind to. If this port is reserved, the nextfree port will be taken (incrementing srv_port). Parameters: max_port - The largest port number that the server socket will be bound to. If max_port < srv_portthen there is no limit. |
ConnectionTable | public ConnectionTable(Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port, long reaper_interval, long conn_expire_time) throws Exception(Code) | | ConnectionTable including a connection reaper. Connections that have been idle for more than conn_expire_time
milliseconds will be closed and removed from the connection table. On next access they will be re-created.
Parameters: r - The Receiver Parameters: bind_addr - The host name or IP address of the interface to which the server socket will bind.This is interesting only in multi-homed systems. If bind_addr is null, theserver socket will bind to the first available interface (e.g. /dev/hme0 onSolaris or /dev/eth0 on Linux systems). Parameters: external_addr - The address which will be broadcast to the group (the externally visible addresswhich this host should be contacted on). If external_addr is null, it will default tothe same address that the server socket is bound to. Parameters: srv_port - The port to which the server socket will bind to. If this port is reserved, the nextfree port will be taken (incrementing srv_port). Parameters: max_port - The largest port number that the server socket will be bound to. If max_port < srv_portthen there is no limit. Parameters: reaper_interval - Number of milliseconds to wait for reaper between attepts to reap idle connections Parameters: conn_expire_time - Number of milliseconds a connection can be idle (no traffic sent or received untilit will be reaped |
createServerSocket | protected ServerSocket createServerSocket(int start_port, int end_port) throws Exception(Code) | | Finds first available port starting at start_port and returns server socket.
Will not bind to port >end_port. Sets srv_port
|
getConnection | Connection getConnection(Address dest) throws Exception(Code) | | Try to obtain correct Connection (or create one if not yet existent)
|
run | public void run()(Code) | | Acceptor thread. Continuously accept new connections. Create a new thread for each new
connection and put it in conns. When the thread should stop, it is
interrupted by the thread creator.
|
stop | public void stop()(Code) | | Closes all open sockets, the server socket and all threads waiting for incoming messages
|
|
|