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 and FD_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
  • Field Details

    • cmd

      protected 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 Set<Address> suspected_mbrs
    • has_suspected_mbrs

      protected volatile boolean has_suspected_mbrs
    • suspect_history

      protected final BoundedList<Tuple<InetAddress,Long>> suspect_history
    • local_host

      protected InetAddress local_host
    • members

      protected final List<Address> members
    • ping_command

      protected FD_HOST.PingCommand ping_command
      The command to detect whether a target is alive
    • hosts

      protected final Map<InetAddress,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 ConcurrentMap<InetAddress,Long> timestamps
    • timer

      protected TimeScheduler timer
      Timer used to run the ping task on
    • time_service

      protected TimeService time_service
    • ping_task_future

      protected Future<?> ping_task_future
  • Constructor Details

    • FD_HOST

      public FD_HOST()
  • Method Details

    • pingCommand

      public FD_HOST pingCommand(FD_HOST.PingCommand cmd)
    • resetStats

      public void resetStats()
      Overrides:
      resetStats in class Protocol
    • setCommand

      public FD_HOST setCommand(String command)
    • printSuspectHistory

      public String printSuspectHistory()
    • printTimestamps

      public String printTimestamps()
    • isPingerRunning

      public boolean isPingerRunning()
    • printHosts

      public String printHosts()
    • isAlive

      public boolean isAlive(String host) throws Exception
      Throws:
      Exception
    • getSuspectedMembers

      public String getSuspectedMembers()
    • init

      public void init() throws 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.
      Specified by:
      init in interface Lifecycle
      Overrides:
      init in class Protocol
      Throws:
      Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
    • stop

      public void stop()
      Description copied from class: Protocol
      Called on a JChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.
      Specified by:
      stop in interface Lifecycle
      Overrides:
      stop in class Protocol
    • down

      public 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 using down_prot.down().
      Overrides:
      down in class Protocol
    • handleView

      protected void handleView(View view)
    • getPhysicalAddress

      protected PhysicalAddress getPhysicalAddress(Address logical_addr)
    • getHostFor

      protected InetAddress getHostFor(Address mbr)
    • isPinger

      protected boolean isPinger(Address mbr)
    • startPingerTask

      protected void startPingerTask()
    • stopPingerTask

      protected void stopPingerTask()
    • suspect

      protected void suspect(InetAddress host)
      Called by ping task; will result in all members of host getting suspected
    • suspect

      protected void suspect(List<Address> suspects)
    • unsuspect

      protected boolean unsuspect(Address mbr)
    • _printTimestamps

      protected String _printTimestamps()
    • updateTimestampFor

      protected void updateTimestampFor(InetAddress host)
    • getAgeOf

      protected long getAgeOf(InetAddress host)
      Returns the age (in secs) of the given host
    • getTimestamp

      protected long getTimestamp()