|
||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Object | +--org.javagroups.blocks.ConnectionTable1_4
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.
| Nested Class Summary | |
|---|---|
static interface |
ConnectionTable1_4.ConnectionListener
Used to be notified about connection establishment and teardown |
static interface |
ConnectionTable1_4.Receiver
Used for message reception |
| Constructor Summary | |
|---|---|
ConnectionTable1_4(ConnectionTable1_4.Receiver r,
java.net.InetAddress bind_addr,
int srv_port)
Create a ConnectionTable |
|
ConnectionTable1_4(ConnectionTable1_4.Receiver r,
java.net.InetAddress bind_addr,
int srv_port,
long reaper_interval,
long conn_expire_time)
ConnectionTable including a connection reaper. |
|
ConnectionTable1_4(int srv_port)
Regular ConnectionTable without expiration of idle connections |
|
ConnectionTable1_4(int srv_port,
long reaper_interval,
long conn_expire_time)
ConnectionTable including a connection reaper. |
|
| Method Summary | |
|---|---|
void |
addConnectionListener(ConnectionTable1_4.ConnectionListener l)
|
Address |
getLocalAddress()
|
void |
receive(Message msg)
Calls the receiver callback. |
void |
remove(Address addr)
Remove addrfrom connection table. |
void |
removeConnectionListener(ConnectionTable1_4.ConnectionListener l)
|
void |
run()
Acceptor thread. |
void |
send(Message msg)
Sends a message to a unicast destination. |
void |
setReceiver(ConnectionTable1_4.Receiver r)
|
void |
start()
|
void |
stop()
Closes all open sockets, the server socket and all threads waiting for incoming messages |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ConnectionTable1_4(int srv_port)
throws java.lang.Exception
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).
public ConnectionTable1_4(int srv_port,
long reaper_interval,
long conn_expire_time)
throws java.lang.Exception
srv_port - The port on which the server will listenreaper_interval - Number of milliseconds to wait for reaper between attepts to reap idle connectionsconn_expire_time - Number of milliseconds a connection can be idle (no traffic sent or received until
it will be reaped
public ConnectionTable1_4(ConnectionTable1_4.Receiver r,
java.net.InetAddress bind_addr,
int srv_port)
throws java.lang.Exception
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).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).
public ConnectionTable1_4(ConnectionTable1_4.Receiver r,
java.net.InetAddress bind_addr,
int srv_port,
long reaper_interval,
long conn_expire_time)
throws java.lang.Exception
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).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).reaper_interval - Number of milliseconds to wait for reaper between attepts to reap idle connectionsconn_expire_time - Number of milliseconds a connection can be idle (no traffic sent or received until
it will be reaped| Method Detail |
public void setReceiver(ConnectionTable1_4.Receiver r)
public void addConnectionListener(ConnectionTable1_4.ConnectionListener l)
public void removeConnectionListener(ConnectionTable1_4.ConnectionListener l)
public Address getLocalAddress()
public void send(Message msg)
public void start()
throws java.lang.Exception
java.lang.Exceptionpublic void stop()
public void remove(Address addr)
addrfrom connection table. This is typically triggered when a member is suspected.
public void run()
run in interface java.lang.Runnablepublic void receive(Message msg)
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||