org.jgroups.protocols

Class FD_SOCK

Implemented Interfaces:
Runnable

public class FD_SOCK
extends Protocol
implements Runnable

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.

Author:
Bela Ban May 29 2001

Nested Class Summary

static class
FD_SOCK.FdHeader

Field Summary

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

Method Summary

void
down(Event evt)
String
getLocalAddress()
String
getMembers()
String
getName()
int
getNumSuspectEventsGenerated()
String
getPingDest()
String
getPingableMembers()
void
init()
String
printSuspectHistory()
void
resetStats()
void
run()
Runs as long as there are 2 members and more.
boolean
setProperties(Properties props)
void
stop()
void
up(Event evt)

Methods inherited from class org.jgroups.stack.Protocol

destroy, down, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, start, startDownHandler, startUpHandler, statsEnabled, stop, stopInternal, up, upThreadEnabled

Method Details

down

public void down(Event evt)
Overrides:
down in interface Protocol

getLocalAddress

public String getLocalAddress()

getMembers

public String getMembers()

getName

public String getName()
Overrides:
getName in interface Protocol

getNumSuspectEventsGenerated

public int getNumSuspectEventsGenerated()

getPingDest

public String getPingDest()

getPingableMembers

public String getPingableMembers()

init

public void init()
            throws Exception
Overrides:
init in interface Protocol

printSuspectHistory

public String printSuspectHistory()

resetStats

public void resetStats()
Overrides:
resetStats in interface Protocol

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).

setProperties

public boolean setProperties(Properties props)
Overrides:
setProperties in interface Protocol

stop

public void stop()
Overrides:
stop in interface Protocol

up

public void up(Event evt)
Overrides:
up in interface Protocol

Copyright B) 1998-2005 Bela Ban. All Rights Reserved.