org.jgroups.blocks
Class Link
- Runnable
public class Link
extends java.lang.Object
implements Runnable
Implements a physical link between 2 parties (point-to-point connection). For incoming traffic,
a server socket is created (bound to a given local address and port). The receiver thread does the
following: it accepts a new connection from the server socket and (on the same thread) reads messages
until the connection breaks. Then it goes back to accept(). This is done in 2 nested while-loops.
The outgoing connection is established when started. If this fails, the link is marked as not established.
This means that there is not outgoing socket.
A heartbeat will be exchanged between the 2 peers periodically as long as the connection is established
(outgoing socket is okay). When the connection breaks, the heartbeat will stop and a connection establisher
thread will be started. It periodically tries to re-establish connection to the peer. When this happens
it will stop and the heartbeat thread will resume.
For details see Link.txt
- Bela Ban, June 2000
Link(String local_addr, int local_port, String remote_addr, int remote_port)
|
Link(String local_addr, int local_port, String remote_addr, int remote_port, long timeout, long hb_interval, Link.Receiver r)
|
Link(String local_addr, int local_port, String remote_addr, int remote_port, Link.Receiver r)
|
Link
public Link(String local_addr,
int local_port,
String remote_addr,
int remote_port)
Link
public Link(String local_addr,
int local_port,
String remote_addr,
int remote_port,
long timeout,
long hb_interval,
Link.Receiver r)
Link
public Link(String local_addr,
int local_port,
String remote_addr,
int remote_port,
Link.Receiver r)
equals
public boolean equals(Object other)
established
public boolean established()
getLocalAddress
public InetAddress getLocalAddress()
getLocalPort
public int getLocalPort()
getRemoteAddress
public InetAddress getRemoteAddress()
getRemotePort
public int getRemotePort()
hashCode
public int hashCode()
main
public static void main(String[] args)
run
public void run()
Receiver thread main loop. Accept a connection and then read on it until the connection
breaks. Only then is the next connection handled. The reason is that there is only supposed
to be 1 connection to this server socket at the same time.
send
public boolean send(byte[] buf)
Tries to send buffer across out socket. Tries to establish connection if not yet connected.
setTrace
public void setTrace(boolean t)
start
public void start()
throws Exception
toString
public String toString()
Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.