sergey-chugunov-1985 commented on code in PR #12442:
URL: https://github.com/apache/ignite/pull/12442#discussion_r2465854263


##########
modules/core/src/main/java/org/apache/ignite/topology/MdcTopologyValidator.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.topology;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Stream;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.TopologyValidator;
+import org.apache.ignite.lang.IgniteExperimental;
+
+/**
+ * Multi-Datacenter topology validator.
+ * Performs data protection in case of DC failure.
+ * Covered DCs MUST be specified via {@link 
MdcTopologyValidator#setDatacenters}
+ * and main DC MAY be specified via {@link 
MdcTopologyValidator#setMainDatacenter} in case of even DC count.
+ * When main datacenter is specified Topology Validator keeps cluster write 
accessed while main DC is visible,
+ * otherwise DC majority check is used.
+ * For example, when you have 2N+1 DCs (3, 5 ,...) topology validator will 
keep cluster write accessed while 2N/2+1 (2, 3, ...)
+ * DCs are visible. In case you have 2N DCs (2, 4, ...) it's impossible to use 
majority pattern, so topology validator
+ * will keep cluster write accessed while the main DC is visible.
+ * */

Review Comment:
   ```suggestion
   /**
    * Multi-Datacenter Topology Validator.
    *
    * <p>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.</p>
    *
    * <p>The validator supports two modes of operation:</p>
    * <ul>
    *     <li><strong>Majority-based validation:</strong> 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.</li>
    *     <li><strong>Main Datacenter validation:</strong> 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.</li>
    * </ul>
    *
    * <p><strong>Usage Requirements:</strong></p>
    * <ul>
    *     <li>If number of datacenters is even, specify a main datacenter via 
{@link #setMainDatacenter(String)}. Set of datacenters could be left null.</li> 
  
    *     <li>If number of datacenters is odd, set of datacenter IDs must be 
specified via {@link #setDatacenters(Set)}. Main datacenter setting is ignored 
and could be left null.</li>
    *     
    * </ul>
    *
    * <p><strong>Example:</strong></p>
    * <pre>
    * MdcTopologyValidator mdcValidator = new MdcTopologyValidator();
    * mdcValidator.setDatacenters(Set.of("DC1", "DC2", "DC3"));
    * 
    * CacheConfiguration cacheCfg = new CacheConfiguration("example-cache")
    *     .setTopologyValidator(mdcValidator)
    *      // other cache properties.
    * </pre>
    *
    * <p><strong>Note:</strong> This class is marked with the {@link 
IgniteExperimental} annotation and may change in future releases.</p>
    *
    * @see TopologyValidator
    * @since Apache Ignite 2.18
    */
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to