|
|||||||||
| Home >> All >> org >> jgroups >> [ protocols overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.jgroups.protocols
Class FD_SOCK

java.lang.Objectorg.jgroups.stack.Protocol
org.jgroups.protocols.FD_SOCK
- All Implemented Interfaces:
- java.lang.Runnable
- public class FD_SOCK
- extends org.jgroups.stack.Protocol
- implements java.lang.Runnable
- extends org.jgroups.stack.Protocol
Failure detection protocol based on sockets. Failure detection is ring-based. Each member creates a server socket and announces its address together with the server socket's address in a multicast. A pinger thread will be started when the membership goes above 1 and will be stopped when it drops below 2. The pinger thread connects to its neighbor on the right and waits until the socket is closed. When the socket is closed by the monitored peer in an abnormal fashion (IOException), the neighbor will be suspected.
The main feature of this protocol is that no ping messages need to be exchanged between any 2 peers, and failure detection relies entirely on TCP sockets. The advantage is that no activity will take place between 2 peers as long as they are alive (i.e. have their server sockets open). The disadvantage is that hung servers or crashed routers will not cause sockets to be closed, therefore they won't be detected. The FD_SOCK protocol will work for groups where members are on different hosts
The costs involved are 2 additional threads: one that monitors the client side of the socket connection (to monitor a peer) and another one that manages the server socket. However, those threads will be idle as long as both peers are running.
| Nested Class Summary | |
private class |
FD_SOCK.BroadcastTask
Task that periodically broadcasts a list of suspected members to the group. |
private static class |
FD_SOCK.ClientConnectionHandler
Handles a client connection; multiple client can connect at the same time |
static class |
FD_SOCK.FdHeader
|
private class |
FD_SOCK.ServerSocketHandler
Handles the server-side of a client-server socket connection. |
| Fields inherited from class org.jgroups.stack.Protocol |
down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, trace, up_handler, up_prot, up_queue, up_thread, up_thread_prio, warn |
| Constructor Summary | |
FD_SOCK()
|
|
| Method Summary | |
(package private) void |
broadcastSuspectMessage(org.jgroups.Address suspected_mbr)
Sends a SUSPECT message to all group members. |
(package private) void |
broadcastWhoHasSockMessage(org.jgroups.Address mbr)
|
(package private) org.jgroups.Address |
determineCoordinator()
|
(package private) org.jgroups.Address |
determinePingDest()
|
void |
down(org.jgroups.Event evt)
An event is to be sent down the stack. |
(package private) org.jgroups.stack.IpAddress |
fetchPingAddress(org.jgroups.Address mbr)
Attempts to obtain the ping_addr first from the cache, then by unicasting q request to mbr,
then by multicasting a request to all members. |
(package private) void |
getCacheFromCoordinator()
Determines coordinator C. |
java.lang.String |
getLocalAddress()
|
java.lang.String |
getMembers()
|
java.lang.String |
getName()
|
int |
getNumSuspectEventsGenerated()
|
java.lang.String |
getPingableMembers()
|
java.lang.String |
getPingDest()
|
(package private) void |
handleSocketClose(java.lang.Exception ex)
|
void |
init()
Called after instance has been created (null constructor) and before protocol is started. |
(package private) void |
interruptPingerThread()
Interrupts the pinger thread. |
java.lang.String |
printSuspectHistory()
|
void |
resetStats()
|
void |
run()
Runs as long as there are 2 members and more. |
(package private) void |
sendIHaveSockMessage(org.jgroups.Address dst,
org.jgroups.Address mbr,
org.jgroups.stack.IpAddress addr)
Sends or broadcasts a I_HAVE_SOCK response. |
boolean |
setProperties(java.util.Properties props)
Configures the protocol initially. |
(package private) boolean |
setupPingSocket(org.jgroups.stack.IpAddress dest)
Creates a socket to dest, and assigns it to ping_sock. |
(package private) void |
startPingerThread()
|
(package private) void |
startServerSocket()
|
void |
stop()
This method is called on a Channel.disconnect()> Channel.disconnect() 55 . |
(package private) void |
stopPingerThread()
|
(package private) void |
stopServerSocket()
|
(package private) void |
teardownPingSocket()
|
void |
up(org.jgroups.Event evt)
An event was received from the layer below. |
| Methods inherited from class org.jgroups.stack.Protocol |
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, start, startDownHandler, startUpHandler, statsEnabled, stopInternal, upThreadEnabled |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
get_cache_timeout
long get_cache_timeout
get_cache_retry_timeout
final long get_cache_retry_timeout
- See Also:
- Constant Field Values
suspect_msg_interval
long suspect_msg_interval
num_tries
int num_tries
members
final java.util.Vector members
srv_sock_sent
boolean srv_sock_sent
pingable_mbrs
final java.util.Vector pingable_mbrs
get_cache_promise
final org.jgroups.util.Promise get_cache_promise
got_cache_from_coord
boolean got_cache_from_coord
local_addr
org.jgroups.Address local_addr
srv_sock
java.net.ServerSocket srv_sock
srv_sock_bind_addr
java.net.InetAddress srv_sock_bind_addr
srv_sock_handler
FD_SOCK.ServerSocketHandler srv_sock_handler
srv_sock_addr
org.jgroups.stack.IpAddress srv_sock_addr
ping_dest
org.jgroups.Address ping_dest
ping_sock
java.net.Socket ping_sock
ping_input
java.io.InputStream ping_input
pinger_thread
java.lang.Thread pinger_thread
cache
final java.util.Hashtable cache
start_port
int start_port
- Start port for server socket (uses first available port starting at start_port). A value of 0 (default)
picks a random port
ping_addr_promise
final org.jgroups.util.Promise ping_addr_promise
sock_mutex
final java.lang.Object sock_mutex
timer
org.jgroups.util.TimeScheduler timer
bcast_task
final FD_SOCK.BroadcastTask bcast_task
regular_sock_close
boolean regular_sock_close
num_suspect_events
int num_suspect_events
NORMAL_TEMINATION
private static final int NORMAL_TEMINATION
- See Also:
- Constant Field Values
ABNORMAL_TEMINATION
private static final int ABNORMAL_TEMINATION
- See Also:
- Constant Field Values
name
private static final java.lang.String name
- See Also:
- Constant Field Values
suspect_history
org.jgroups.util.BoundedList suspect_history
| Constructor Detail |
FD_SOCK
public FD_SOCK()
| Method Detail |
getName
public java.lang.String getName()
getLocalAddress
public java.lang.String getLocalAddress()
getMembers
public java.lang.String getMembers()
getPingableMembers
public java.lang.String getPingableMembers()
getPingDest
public java.lang.String getPingDest()
getNumSuspectEventsGenerated
public int getNumSuspectEventsGenerated()
printSuspectHistory
public java.lang.String printSuspectHistory()
setProperties
public boolean setProperties(java.util.Properties props)
- Description copied from class:
org.jgroups.stack.Protocol - Configures the protocol initially. A configuration string consists of name=value
items, separated by a ';' (semicolon), e.g.:
"loopback=false;unicast_inport=4444"
init
public void init()
throws java.lang.Exception
- Description copied from class:
org.jgroups.stack.Protocol - Called after instance has been created (null constructor) and before protocol is started.
Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
stop
public void stop()
- Description copied from class:
org.jgroups.stack.Protocol - This method is called on a Channel.disconnect()>
Channel.disconnect()55 . Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed
resetStats
public void resetStats()
up
public void up(org.jgroups.Event evt)
- Description copied from class:
org.jgroups.stack.Protocol - An event was received from the layer below. Usually the current layer will want to examine
the event type and - depending on its type - perform some computation
(e.g. removing headers from a MSG event type, or updating the internal membership list
when receiving a VIEW_CHANGE event).
Finally the event is either a) discarded, or b) an event is sent down
the stack using
passDown()or c) the event (or another event) is sent up the stack usingpassUp().
down
public void down(org.jgroups.Event evt)
- Description copied from class:
org.jgroups.stack.Protocol - An event is to be sent down the stack. The layer may want to examine its type and perform
some action on it, depending on the event's type. If the event is a message MSG, then
the layer may need to add a header to it (or do nothing at all) before sending it down
the stack using
passDown(). In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack usingpassUp().
run
public void run()
- Runs as long as there are 2 members and more. Determines the member to be monitored and fetches its
server socket address (if n/a, sends a message to obtain it). The creates a client socket and listens on
it until the connection breaks. If it breaks, emits a SUSPECT message. It the connection is closed regularly,
nothing happens. In both cases, a new member to be monitored will be chosen and monitoring continues (unless
there are fewer than 2 members).
- Specified by:
runin interfacejava.lang.Runnable
handleSocketClose
void handleSocketClose(java.lang.Exception ex)
startPingerThread
void startPingerThread()
stopPingerThread
void stopPingerThread()
interruptPingerThread
void interruptPingerThread()
- Interrupts the pinger thread. The Thread.interrupt() method doesn't seem to work under Linux with JDK 1.3.1
(JDK 1.2.2 had no problems here), therefore we close the socket (setSoLinger has to be set !) if we are
running under Linux. This should be tested under Windows. (Solaris 8 and JDK 1.3.1 definitely works).
Oct 29 2001 (bela): completely removed Thread.interrupt(), but used socket close on all OSs. This makes this code portable and we don't have to check for OSs.
startServerSocket
void startServerSocket()
stopServerSocket
void stopServerSocket()
setupPingSocket
boolean setupPingSocket(org.jgroups.stack.IpAddress dest)
- Creates a socket to
dest, and assigns it to ping_sock. Also assigns ping_input
teardownPingSocket
void teardownPingSocket()
getCacheFromCoordinator
void getCacheFromCoordinator()
- Determines coordinator C. If C is null and we are the first member, return. Else loop: send GET_CACHE message
to coordinator and wait for GET_CACHE_RSP response. Loop until valid response has been received.
broadcastSuspectMessage
void broadcastSuspectMessage(org.jgroups.Address suspected_mbr)
- Sends a SUSPECT message to all group members. Only the coordinator (or the next member in line if the coord
itself is suspected) will react to this message by installing a new view. To overcome the unreliability
of the SUSPECT message (it may be lost because we are not above any retransmission layer), the following scheme
is used: after sending the SUSPECT message, it is also added to the broadcast task, which will periodically
re-send the SUSPECT until a view is received in which the suspected process is not a member anymore. The reason is
that - at one point - either the coordinator or another participant taking over for a crashed coordinator, will
react to the SUSPECT message and issue a new view, at which point the broadcast task stops.
broadcastWhoHasSockMessage
void broadcastWhoHasSockMessage(org.jgroups.Address mbr)
sendIHaveSockMessage
void sendIHaveSockMessage(org.jgroups.Address dst, org.jgroups.Address mbr, org.jgroups.stack.IpAddress addr)
- Sends or broadcasts a I_HAVE_SOCK response. If 'dst' is null, the reponse will be broadcast, otherwise
it will be unicast back to the requester
fetchPingAddress
org.jgroups.stack.IpAddress fetchPingAddress(org.jgroups.Address mbr)
- Attempts to obtain the ping_addr first from the cache, then by unicasting q request to
mbr, then by multicasting a request to all members.
determinePingDest
org.jgroups.Address determinePingDest()
determineCoordinator
org.jgroups.Address determineCoordinator()
|
|||||||||
| Home >> All >> org >> jgroups >> [ protocols overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC