Class 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_ID system 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 IgniteExperimental annotation and may change in future releases.

    Since:
    Apache Ignite 2.18
    See Also:
    TopologyValidator, Serialized Form
    • Constructor Detail

      • MdcTopologyValidator

        public MdcTopologyValidator()
    • 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:
        validate in interface TopologyValidator
        Parameters:
        nodes - Collection of nodes.
        Returns:
        true in case topology is valid for specific cache, otherwise false
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object