Package io.hekate.cluster.split
Class HostReachabilityDetector
- java.lang.Object
-
- io.hekate.cluster.split.HostReachabilityDetector
-
- All Implemented Interfaces:
SplitBrainDetector
,ConfigReportSupport
public class HostReachabilityDetector extends Object implements SplitBrainDetector, ConfigReportSupport
Host reachability-based detector.This implementation of
SplitBrainDetector
utilizesInetAddress.isReachable(int)
method to check if some pre-configured host address is reachable. Assumption is that if local node can reach that host then it is not cut off the network and can communicate with other nodes.Note that it is possible to combine multiple detectors with the help of
SplitBrainDetectorGroup
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_TIMEOUT
Default value (=3000) in milliseconds for thetimeout
parameter ofHostReachabilityDetector(String, int)
.
-
Constructor Summary
Constructors Constructor Description HostReachabilityDetector(String host)
Constructs new instance with the default timeout value (=3000).HostReachabilityDetector(String host, int timeout)
Constructs new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
host()
Host to check.boolean
isValid(ClusterNode localNode)
Performs a split-brain check and returnstrue
if local node can reach other members of the cluster.void
report(ConfigReporter report)
Report configuration.int
timeout()
Check timeout in milliseconds.String
toString()
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUT
Default value (=3000) in milliseconds for thetimeout
parameter ofHostReachabilityDetector(String, int)
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HostReachabilityDetector
public HostReachabilityDetector(String host)
Constructs new instance with the default timeout value (=3000).- Parameters:
host
- Host to be checked for reachability.
-
HostReachabilityDetector
public HostReachabilityDetector(String host, int timeout)
Constructs new instance.- Parameters:
host
- Host to be checked for reachability.timeout
- Timeout in milliseconds for host reachability checking (seeInetAddress.isReachable(int)
).
-
-
Method Detail
-
report
public void report(ConfigReporter report)
Description copied from interface:ConfigReportSupport
Report configuration.- Specified by:
report
in interfaceConfigReportSupport
- Parameters:
report
- Reporter.
-
host
public String host()
Host to check.- Returns:
- Host to check.
-
timeout
public int timeout()
Check timeout in milliseconds.- Returns:
- Timeout in milliseconds.
-
isValid
public boolean isValid(ClusterNode localNode)
Description copied from interface:SplitBrainDetector
Performs a split-brain check and returnstrue
if local node can reach other members of the cluster.If this method returns
false
thenHekateFatalErrorPolicy
will be applied withClusterSplitBrainException
as a cause.- Specified by:
isValid
in interfaceSplitBrainDetector
- Parameters:
localNode
- Local node (where the check is performed).- Returns:
true
if local node can reach other members of the cluster.
-
-