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 FD_SOCK protocol will work for groups where members are on different hosts, but its main usage is when all group members are on the same host.

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, up_handler, up_prot, up_queue, up_thread, up_thread_prio

Method Summary

void
down(Event evt)
String
getName()
void
init()
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, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, passDown, passUp, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setUpProtocol, start, startDownHandler, startUpHandler, stop, stopInternal, up

Method Details

down

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

getName

public String getName()
Overrides:
getName in interface Protocol

init

public void init()
            throws Exception
Overrides:
init 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) 2001,2002 www.jgroups.com . All Rights Reserved.