| java.lang.Object org.jgroups.blocks.Link
All known Subclasses: org.jgroups.blocks.LogicalLink,
Link | public class Link implements Runnable(Code) | | 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
author: Bela Ban, June 2000 |
Inner Class :public interface Receiver | |
Inner Class :class Heartbeat implements Runnable | |
Constructor Summary | |
public | Link(String local_addr, int local_port, String remote_addr, int remote_port) | public | Link(String local_addr, int local_port, String remote_addr, int remote_port, Receiver r) | public | Link(String local_addr, int local_port, String remote_addr, int remote_port, long timeout, long hb_interval, Receiver r) |
HB_PACKET | final static int HB_PACKET(Code) | | |
established | boolean established(Code) | | |
hb_interval | long hb_interval(Code) | | |
local_portremote_port | int local_portremote_port(Code) | | |
receiver | Receiver receiver(Code) | | |
receiver_thread_join_timeout | final long receiver_thread_join_timeout(Code) | | |
Link | public Link(String local_addr, int local_port, String remote_addr, int remote_port)(Code) | | |
Link | public Link(String local_addr, int local_port, String remote_addr, int remote_port, Receiver r)(Code) | | |
Link | public Link(String local_addr, int local_port, String remote_addr, int remote_port, long timeout, long hb_interval, Receiver r)(Code) | | |
closeConnections | synchronized void closeConnections()(Code) | | Close outgoing and incoming sockets.
|
closeIncomingConnection | synchronized void closeIncomingConnection()(Code) | | When the heartbeat thread detects that the peer 'hangs' (not detected by incoming.read()),
then it closes the outgoing *and* incoming socket. The latter needs to be done,
so that we can return to accept() and await a new client connection request.
|
closeOutgoingConnection | void closeOutgoingConnection()(Code) | | Closes the outgoing connection
|
createOutgoingConnection | boolean createOutgoingConnection()(Code) | | Tries to create an outgoing connection. If successful, the heartbeat is started. Does not
stop the connection establisher ! The reason is that this method is going to be called by the
connection establisher as well, therefore it would kill itself !
|
createOutgoingConnection | boolean createOutgoingConnection(long timeout)(Code) | | Tries to create an outgoing connection. If successful, the heartbeat is started. Does not
stop the connection establisher ! The reason is that this method is going to be called by the
connection establisher as well, therefore it would kill itself !
|
established | public boolean established()(Code) | | |
getLocalPort | public int getLocalPort()(Code) | | |
getRemotePort | public int getRemotePort()(Code) | | |
hashCode | public int hashCode()(Code) | | |
retry | boolean retry(byte[] buf)(Code) | | |
run | public void run()(Code) | | 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)(Code) | | Tries to send buffer across out socket. Tries to establish connection if not yet connected.
|
setReceiver | public void setReceiver(Receiver r)(Code) | | |
setTrace | public void setTrace(boolean t)(Code) | | |
startReceiverThread | void startReceiverThread()(Code) | | |
stopReceiverThread | void stopReceiverThread()(Code) | | |
|
|