Package io.hekate.cluster.split
Class AddressReachabilityDetector
- java.lang.Object
-
- io.hekate.cluster.split.AddressReachabilityDetector
-
- All Implemented Interfaces:
SplitBrainDetector
,ConfigReportSupport
public class AddressReachabilityDetector extends Object implements SplitBrainDetector, ConfigReportSupport
Socket address connectivity-based detector.This implementation of
SplitBrainDetector
tries to establish a socket connection to check if some pre-configured address is reachable. Assumption is that if local node can connect to that address 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 ofAddressReachabilityDetector(String, int)
.
-
Constructor Summary
Constructors Constructor Description AddressReachabilityDetector(String address)
Constructs new instance with the default timeout value (=3000).AddressReachabilityDetector(String address, int timeout)
Constructs new instance.AddressReachabilityDetector(InetSocketAddress address, int timeout)
Constructs new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InetSocketAddress
address()
Address 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 ofAddressReachabilityDetector(String, int)
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AddressReachabilityDetector
public AddressReachabilityDetector(String address)
Constructs new instance with the default timeout value (=3000).- Parameters:
address
- Address in a form of<host>:<port>
(f.e.192.168.39.41:10012
).
-
AddressReachabilityDetector
public AddressReachabilityDetector(String address, int timeout)
Constructs new instance.- Parameters:
address
- Address in a form of<host>:<port>
(f.e.192.168.39.41:10012
).timeout
- Connect timeout in milliseconds (seeSocket.connect(SocketAddress, int)
).
-
AddressReachabilityDetector
public AddressReachabilityDetector(InetSocketAddress address, int timeout)
Constructs new instance.- Parameters:
address
- Address.timeout
- Connect timeout in milliseconds (seeSocket.connect(SocketAddress, int)
).
-
-
Method Detail
-
report
public void report(ConfigReporter report)
Description copied from interface:ConfigReportSupport
Report configuration.- Specified by:
report
in interfaceConfigReportSupport
- Parameters:
report
- Reporter.
-
address
public InetSocketAddress address()
Address to check.- Returns:
- Address 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.
-
-