Class MdcTopologyValidator
- java.lang.Object
-
- org.apache.ignite.topology.MdcTopologyValidator
-
- All Implemented Interfaces:
Serializable,TopologyValidator
public class MdcTopologyValidator extends Object implements TopologyValidator
Multi-Datacenter Topology Validator.This class is used to validate the cluster topology in a multi-datacenter (MDC) environment by enforcing rules based on the visibility of datacenters. It provides protection against split-brain scenarios during datacenter failures or unavailability due to network issues.
In order to use MdcTopologyValidator one has to specify datacenter ID attribute on each server node. Datacenter ID is an arbitrary string that can be set with
IgniteSystemProperties.IGNITE_DATA_CENTER_IDsystem property on the node startup. All server nodes belonging to the same datacenter should specify the same datacenter ID, and nodes in different datacenters should have different datacenter IDs.The validator supports two modes of operation:
- Majority-based validation: When an odd number of datacenters are defined, the validator enables data modification operations in the cluster segment that contain a majority of datacenters. Any segment containing a minority of datacenters is considered as invalid with only read operations available.
- Main Datacenter validation: When an even number of datacenters are defined, a main datacenter should be specified. The cluster segment remains write-accessible as long as the main datacenter is visible from all nodes of that segment.
Usage Requirements:
- If number of datacenters is even, specify a main datacenter via
setMainDatacenter(String). Set of datacenters could be left null. - If number of datacenters is odd, set of datacenter IDs must be specified via
setDatacenters(Set). Main datacenter setting is ignored and could be left null.
Example:
MdcTopologyValidator mdcValidator = new MdcTopologyValidator(); mdcValidator.setDatacenters(Set.of("DC1", "DC2", "DC3")); CacheConfiguration cacheCfg = new CacheConfiguration("example-cache") .setTopologyValidator(mdcValidator) // other cache properties.Note: This class is marked with the
IgniteExperimentalannotation and may change in future releases.- Since:
- Apache Ignite 2.18
- See Also:
TopologyValidator, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MdcTopologyValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckConfiguration()booleanequals(Object o)inthashCode()voidsetDatacenters(Set<String> datacenters)voidsetMainDatacenter(String mainDatacenter)booleanvalidate(Collection<ClusterNode> nodes)Validates topology.
-
-
-
Method Detail
-
setDatacenters
public void setDatacenters(Set<String> datacenters)
- Parameters:
datacenters- Datacenters.
-
setMainDatacenter
public void setMainDatacenter(String mainDatacenter)
- Parameters:
mainDatacenter- Main datacenter.
-
checkConfiguration
public void checkConfiguration()
-
validate
public boolean validate(Collection<ClusterNode> nodes)
Validates topology.- Specified by:
validatein interfaceTopologyValidator- Parameters:
nodes- Collection of nodes.- Returns:
truein case topology is valid for specific cache, otherwisefalse
-
-