Package org.jgroups.protocols
Class FD_HOST
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.FD_HOST
-
public class FD_HOST extends Protocol
Failure detection protocol which detects the crash or hanging of entire hosts and suspects all cluster members on those hosts. By default InetAddress.isReachable() is used, but any script/command can be used for liveness checks by defining the 'cmd' property. FD_HOST does not detect the crash or hanging of single members on the local host, but only checks liveness of all other hosts in a cluster. Therefore it is meant to be used together with other failure detection protocols, e.g.FD_ALLandFD_SOCK. This protocol would typically be used when multiple cluster members are running on the same physical box. JIRA: https://issues.jboss.org/browse/JGRP-1855- Version:
- 3.5, 3.4.5
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFD_HOST.CommandExecutor2protected static classFD_HOST.ExternalPingCommandstatic classFD_HOST.IsReachablePingCommandstatic interfaceFD_HOST.PingCommandCommand used to check whether a given host is alive, periodically calledprotected classFD_HOST.PingTaskSelected members run this task periodically.
-
Field Summary
Fields Modifier and Type Field Description protected longcheck_timeoutprotected java.lang.Stringcmdprotected booleanhas_suspected_mbrsprotected java.util.Map<java.net.InetAddress,java.util.List<Address>>hostsMap of hosts and their cluster members, updated on view changes.protected longintervalprotected Addresslocal_addrprotected java.net.InetAddresslocal_hostprotected java.util.List<Address>membersprotected intnum_liveness_checksprotected intnum_suspect_eventsprotected FD_HOST.PingCommandping_commandThe command to detect whether a target is aliveprotected java.util.concurrent.Future<?>ping_task_futureprotected BoundedList<Tuple<java.net.InetAddress,java.lang.Long>>suspect_historyprotected java.util.Set<Address>suspected_mbrsprotected TimeServicetime_serviceprotected longtimeoutprotected TimeSchedulertimerTimer used to run the ping task onprotected java.util.concurrent.ConcurrentMap<java.net.InetAddress,java.lang.Long>timestampsprotected booleanuse_time_service-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description FD_HOST()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String_printTimestamps()java.lang.Objectdown(Event evt)An event is to be sent down the stack.protected longgetAgeOf(java.net.InetAddress host)Returns the age (in secs) of the given hostprotected java.net.InetAddressgetHostFor(Address mbr)protected PhysicalAddressgetPhysicalAddress(Address logical_addr)java.lang.StringgetSuspectedMembers()protected longgetTimestamp()protected voidhandleView(View view)voidinit()Called after instance has been created (null constructor) and before protocol is started.booleanisAlive(java.lang.String host)protected booleanisPinger(Address mbr)booleanisPingerRunning()FD_HOSTpingCommand(FD_HOST.PingCommand cmd)java.lang.StringprintHosts()java.lang.StringprintSuspectHistory()java.lang.StringprintTimestamps()voidresetStats()voidsetCommand(java.lang.String command)protected voidstartPingerTask()voidstop()This method is called on aJChannel.disconnect().protected voidstopPingerTask()protected voidsuspect(java.net.InetAddress host)Called by ping task; will result in all members of host getting suspectedprotected voidsuspect(java.util.List<Address> suspects)protected booleanunsuspect(Address mbr)protected voidupdateTimestampFor(java.net.InetAddress host)-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, destroy, down, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, up, up, up
-
-
-
-
Field Detail
-
cmd
protected java.lang.String cmd
-
timeout
protected long timeout
-
interval
protected long interval
-
check_timeout
protected long check_timeout
-
use_time_service
protected boolean use_time_service
-
num_liveness_checks
protected int num_liveness_checks
-
num_suspect_events
protected int num_suspect_events
-
suspected_mbrs
protected final java.util.Set<Address> suspected_mbrs
-
has_suspected_mbrs
protected volatile boolean has_suspected_mbrs
-
suspect_history
protected final BoundedList<Tuple<java.net.InetAddress,java.lang.Long>> suspect_history
-
local_addr
protected Address local_addr
-
local_host
protected java.net.InetAddress local_host
-
members
protected final java.util.List<Address> members
-
ping_command
protected FD_HOST.PingCommand ping_command
The command to detect whether a target is alive
-
hosts
protected final java.util.Map<java.net.InetAddress,java.util.List<Address>> hosts
Map of hosts and their cluster members, updated on view changes. Used to suspect all members of a suspected host
-
timestamps
protected final java.util.concurrent.ConcurrentMap<java.net.InetAddress,java.lang.Long> timestamps
-
timer
protected TimeScheduler timer
Timer used to run the ping task on
-
time_service
protected TimeService time_service
-
ping_task_future
protected java.util.concurrent.Future<?> ping_task_future
-
-
Method Detail
-
pingCommand
public FD_HOST pingCommand(FD_HOST.PingCommand cmd)
-
resetStats
public void resetStats()
- Overrides:
resetStatsin classProtocol
-
setCommand
public void setCommand(java.lang.String command)
-
printSuspectHistory
public java.lang.String printSuspectHistory()
-
printTimestamps
public java.lang.String printTimestamps()
-
isPingerRunning
public boolean isPingerRunning()
-
printHosts
public java.lang.String printHosts()
-
isAlive
public boolean isAlive(java.lang.String host) throws java.lang.Exception- Throws:
java.lang.Exception
-
getSuspectedMembers
public java.lang.String getSuspectedMembers()
-
init
public void init() throws java.lang.ExceptionDescription copied from class:ProtocolCalled 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:ProtocolThis method is called on aJChannel.disconnect(). 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
-
down
public java.lang.Object down(Event evt)
Description copied from class:ProtocolAn event is to be sent down the stack. A protocol 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 protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down().
-
handleView
protected void handleView(View view)
-
getPhysicalAddress
protected PhysicalAddress getPhysicalAddress(Address logical_addr)
-
getHostFor
protected java.net.InetAddress getHostFor(Address mbr)
-
isPinger
protected boolean isPinger(Address mbr)
-
startPingerTask
protected void startPingerTask()
-
stopPingerTask
protected void stopPingerTask()
-
suspect
protected void suspect(java.net.InetAddress host)
Called by ping task; will result in all members of host getting suspected
-
suspect
protected void suspect(java.util.List<Address> suspects)
-
unsuspect
protected boolean unsuspect(Address mbr)
-
_printTimestamps
protected java.lang.String _printTimestamps()
-
updateTimestampFor
protected void updateTimestampFor(java.net.InetAddress host)
-
getAgeOf
protected long getAgeOf(java.net.InetAddress host)
Returns the age (in secs) of the given host
-
getTimestamp
protected long getTimestamp()
-
-