org.jgroups.blocks
public class ConnectionTable extends Object implements Runnable
Incoming messages from any of the sockets can be received by setting the message listener.
| Nested Class Summary | |
|---|---|
| interface | ConnectionTable.ConnectionListener Used to be notified about connection establishment and teardown. |
| interface | ConnectionTable.Receiver Used for message reception. |
| Field Summary | |
|---|---|
| protected Log | log |
| Constructor Summary | |
|---|---|
| ConnectionTable(int srv_port)
Regular ConnectionTable without expiration of idle connections | |
| ConnectionTable(InetAddress bind_addr, int srv_port) | |
| ConnectionTable(int srv_port, long reaper_interval, long conn_expire_time)
ConnectionTable including a connection reaper. | |
| ConnectionTable(ConnectionTable.Receiver r, InetAddress bind_addr, InetAddress external_addr, int srv_port, int max_port)
Create a ConnectionTable | |
| ConnectionTable(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 | |
|---|---|
| void | addConnectionListener(ConnectionTable.ConnectionListener l) |
| protected ServerSocket | createServerSocket(int start_port, int end_port) Finds first available port starting at start_port and returns server socket.
|
| Address | getLocalAddress() |
| int | getNumConnections() |
| int | getReceiveBufferSize() |
| int | getSendBufferSize() |
| int | getSocketConnectionTimeout() |
| boolean | getUseSendQueues() |
| protected void | init() |
| void | receive(Address sender, byte[] data, int offset, int length)
Calls the receiver callback. |
| void | remove(Address addr)
Remove addrfrom connection table. |
| void | removeConnectionListener(ConnectionTable.ConnectionListener l) |
| void | run()
Acceptor thread. |
| void | send(Address dest, byte[] data, int offset, int length) |
| void | setReceiveBufferSize(int recv_buf_size) |
| void | setReceiver(ConnectionTable.Receiver r) |
| void | setSendBufferSize(int send_buf_size) |
| void | setSocketConnectionTimeout(int sock_conn_timeout) |
| void | setUseSendQueues(boolean flag) |
| void | start() |
| void | stop() Closes all open sockets, the server socket and all threads waiting for incoming messages |
| String | toString() |
Parameters: srv_port The port on which the server will listen. If this port is reserved, the next free port will be taken (incrementing srv_port).
Parameters: srv_port The port on which the server will listen reaper_interval Number of milliseconds to wait for reaper between attepts to reap idle connections conn_expire_time Number of milliseconds a connection can be idle (no traffic sent or received until it will be reaped
Parameters: r A reference to a receiver of all messages received by this class. Method receive()
will be called. 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, the
server socket will bind to the first available interface (e.g. /dev/hme0 on
Solaris or /dev/eth0 on Linux systems). external_addr The address which will be broadcast to the group (the externally visible address
which this host should be contacted on). If external_addr is null, it will default to
the same address that the server socket is bound to. srv_port The port to which the server socket will bind to. If this port is reserved, the next
free port will be taken (incrementing srv_port). max_port The largest port number that the server socket will be bound to. If max_port < srv_port
then there is no limit.
Parameters: r The Receiver 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, the server socket will bind to the first available interface (e.g. /dev/hme0 on Solaris or /dev/eth0 on Linux systems). external_addr The address which will be broadcast to the group (the externally visible address which this host should be contacted on). If external_addr is null, it will default to the same address that the server socket is bound to. srv_port The port to which the server socket will bind to. If this port is reserved, the next free port will be taken (incrementing srv_port). max_port The largest port number that the server socket will be bound to. If max_port < srv_port then there is no limit. reaper_interval Number of milliseconds to wait for reaper between attepts to reap idle connections conn_expire_time Number of milliseconds a connection can be idle (no traffic sent or received until it will be reaped
addrfrom connection table. This is typically triggered when a member is suspected.