Class 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
    Author:
    Bela Ban
    • 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
      • ping_task_future

        protected java.util.concurrent.Future<?> ping_task_future
    • Constructor Detail

      • FD_HOST

        public FD_HOST()
    • Method Detail

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

        protected void handleView​(View view)
      • 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()