Class MdcAffinityBackupFilter
- java.lang.Object
-
- org.apache.ignite.cache.affinity.rendezvous.MdcAffinityBackupFilter
-
- All Implemented Interfaces:
Serializable,IgniteBiPredicate<ClusterNode,List<ClusterNode>>
public class MdcAffinityBackupFilter extends Object implements IgniteBiPredicate<ClusterNode,List<ClusterNode>>
Multi-data center affinity backup filter that ensures each partition's data is distributed across multiple data centers, providing high availability and fault tolerance. This implementation guarantees at least one copy of the data in each data center and attempts to maintain the configured backup factor without discarding copies.The filter works by grouping nodes based on their data center identification attribute (@see
ClusterNode.dataCenterId()) and ensuring that for every partition, at least one node from each data center is included in the primary-backup set.The filter will discard backup copies only if the number of available nodes in a given data center is less than the number of copies assigned to that data center. For example, if a partition has 4 copies (1 primary and 3 backups) and the cluster has 2 data centers, than 2 copies are assigned to each data center. The only scenario when just a single copy is assigned to a node in a data center is when the number of nodes in that data center is one.
This class is constructed with a number of data centers the cluster spans and a number of backups of the cache this filter is applied to. Implementation expects that all copies can be spread evenly across all data centers. In other words, (backups + 1) is divisible by number of data centers without remainder. Uneven distributions of copies are not supported.
Warning: Ensure that all nodes have a consistent and valid data center identifier attribute. Missing or inconsistent values may lead to unexpected placement of data.
Spring Example
Create a partitioned cache template where each data center has at least one copy of the data, and the backup count is maintained.<property name="cacheConfiguration"> <list> <bean id="cache-template-bean" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration"> <property name="name" value="JobcaseDefaultCacheConfig*"/> <property name="cacheMode" value="PARTITIONED" /> <property name="backups" value="3" /> <property name="affinity"> <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction"> <property name="affinityBackupFilter"> <bean class="org.apache.ignite.cache.affinity.rendezvous.MdcAffinityBackupFilter"> <constructor-arg value="2"/> <constructor-arg value="3"/> </bean> </property> </bean> </property> </bean> </list> </property>With more backups, additional replicas can be distributed across different data centers to further improve redundancy.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MdcAffinityBackupFilter(int dcsNum, int backups)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(ClusterNode candidate, List<ClusterNode> previouslySelected)Predicate body.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.lang.IgniteBiPredicate
and
-
-
-
-
Method Detail
-
apply
public boolean apply(ClusterNode candidate, List<ClusterNode> previouslySelected)
Predicate body.- Specified by:
applyin interfaceIgniteBiPredicate<ClusterNode,List<ClusterNode>>- Parameters:
candidate- First parameter.previouslySelected- Second parameter.- Returns:
- Return value.
-
-