Package org.jgroups.protocols
Class FD_HOST
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.FD_HOST
-
- All Implemented Interfaces:
Lifecycle
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_ALL3
andFD_SOCK
. This protocol would typically be used when multiple cluster members are running on the same physical box. JIRA: https://issues.redhat.com/browse/JGRP-1855- Version:
- 3.5, 3.4.5
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FD_HOST.CommandExecutor2
protected static class
FD_HOST.ExternalPingCommand
static class
FD_HOST.IsReachablePingCommand
static interface
FD_HOST.PingCommand
Command used to check whether a given host is alive, periodically calledprotected class
FD_HOST.PingTask
Selected members run this task periodically.
-
Field Summary
Fields Modifier and Type Field Description protected long
check_timeout
protected java.lang.String
cmd
protected boolean
has_suspected_mbrs
protected java.util.Map<java.net.InetAddress,java.util.List<Address>>
hosts
Map of hosts and their cluster members, updated on view changes.protected long
interval
protected java.net.InetAddress
local_host
protected java.util.List<Address>
members
protected int
num_liveness_checks
protected int
num_suspect_events
protected FD_HOST.PingCommand
ping_command
The command to detect whether a target is aliveprotected java.util.concurrent.Future<?>
ping_task_future
protected BoundedList<Tuple<java.net.InetAddress,java.lang.Long>>
suspect_history
protected java.util.Set<Address>
suspected_mbrs
protected TimeService
time_service
protected long
timeout
protected TimeScheduler
timer
Timer used to run the ping task onprotected java.util.concurrent.ConcurrentMap<java.net.InetAddress,java.lang.Long>
timestamps
protected boolean
use_time_service
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, 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.Object
down(Event evt)
An event is to be sent down the stack.protected long
getAgeOf(java.net.InetAddress host)
Returns the age (in secs) of the given hostprotected java.net.InetAddress
getHostFor(Address mbr)
protected PhysicalAddress
getPhysicalAddress(Address logical_addr)
java.lang.String
getSuspectedMembers()
protected long
getTimestamp()
protected void
handleView(View view)
void
init()
Called after a protocol has been created and before the protocol is started.boolean
isAlive(java.lang.String host)
protected boolean
isPinger(Address mbr)
boolean
isPingerRunning()
FD_HOST
pingCommand(FD_HOST.PingCommand cmd)
java.lang.String
printHosts()
java.lang.String
printSuspectHistory()
java.lang.String
printTimestamps()
void
resetStats()
FD_HOST
setCommand(java.lang.String command)
protected void
startPingerTask()
void
stop()
Called on aJChannel.disconnect()
; stops work (e.g.protected void
stopPingerTask()
protected void
suspect(java.net.InetAddress host)
Called by ping task; will result in all members of host getting suspectedprotected void
suspect(java.util.List<Address> suspects)
protected boolean
unsuspect(Address mbr)
protected void
updateTimestampFor(java.net.InetAddress host)
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, toString, 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_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:
resetStats
in classProtocol
-
setCommand
public FD_HOST 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.Exception
Description copied from class:Protocol
Called after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent.
-
stop
public void stop()
Description copied from class:Protocol
Called on aJChannel.disconnect()
; stops work (e.g. by closing multicast socket). Will be called from top to bottom.
-
down
public java.lang.Object down(Event evt)
Description copied from class:Protocol
An 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()
-
-