use of org.apache.ignite.cache.affinity.AffinityFunction in project ignite by apache.
the class RendezvousAffinityFunctionSimpleBenchmark method _testAffinityCompatibility.
/**
*
*/
public void _testAffinityCompatibility() {
mode = TopologyModificationMode.ADD;
AffinityFunction aff0 = new RendezvousAffinityFunction(true, 1024);
// Use the full copy of the old implementaion of the RendezvousAffinityFunction to check the compatibility.
AffinityFunction aff1 = new RendezvousAffinityFunctionOld(true, 1024);
GridTestUtils.setFieldValue(aff1, "ignite", ignite);
affinityCompatibility(aff0, aff1);
}
use of org.apache.ignite.cache.affinity.AffinityFunction in project ignite by apache.
the class GridCacheAffinityApiSelfTest method testMapPartitionsToNodeCollection.
/**
* JUnit.
*
* @throws Exception If failed.
*/
public void testMapPartitionsToNodeCollection() throws Exception {
Collection<Integer> parts = new LinkedList<>();
for (int p = 0; p < affinity().partitions(); p++) parts.add(p);
Map<Integer, ClusterNode> map = grid(0).affinity(DEFAULT_CACHE_NAME).mapPartitionsToNodes(parts);
AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(new ArrayList<>(grid(0).cluster().nodes()), null, null, new AffinityTopologyVersion(1), 1);
AffinityFunction aff = affinity();
List<List<ClusterNode>> assignment = aff.assignPartitions(ctx);
for (Map.Entry<Integer, ClusterNode> e : map.entrySet()) assert F.eqNodes(F.first(nodes(assignment, aff, e.getKey())), e.getValue());
}
Aggregations