Package io.hekate.cluster.split
Class JdbcConnectivityDetector
- java.lang.Object
-
- io.hekate.cluster.split.JdbcConnectivityDetector
-
- All Implemented Interfaces:
SplitBrainDetector
,ConfigReportSupport
public class JdbcConnectivityDetector extends Object implements SplitBrainDetector, ConfigReportSupport
JDBC connectivity-based detector.This implementation of
SplitBrainDetector
utilizesConnection.isValid(int)
method to check if some pre-configured JDBC database is reachable.Note that it is possible to combine multiple detectors with the help of
SplitBrainDetectorGroup
.
-
-
Constructor Summary
Constructors Constructor Description JdbcConnectivityDetector(DataSource ds, int timeout)
Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataSource
datasource()
Datasource 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 seconds.String
toString()
-
-
-
Constructor Detail
-
JdbcConnectivityDetector
public JdbcConnectivityDetector(DataSource ds, int timeout)
Constructs a new instance.- Parameters:
ds
- Data source.timeout
- Timeout in seconds (seeConnection.isValid(int)
).
-
-
Method Detail
-
report
public void report(ConfigReporter report)
Description copied from interface:ConfigReportSupport
Report configuration.- Specified by:
report
in interfaceConfigReportSupport
- Parameters:
report
- Reporter.
-
datasource
public DataSource datasource()
Datasource to check.- Returns:
- Datasource to check.
-
timeout
public int timeout()
Check timeout in seconds.- Returns:
- Timeout in seconds.
-
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.
-
-