Search in sources :

Example 26 with AffinityFunction

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);
}
Also used : AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction)

Example 27 with AffinityFunction

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());
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) AffinityFunctionContext(org.apache.ignite.cache.affinity.AffinityFunctionContext) LinkedList(java.util.LinkedList) GridAffinityFunctionContextImpl(org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) Map(java.util.Map)

Aggregations

AffinityFunction (org.apache.ignite.cache.affinity.AffinityFunction)27 ArrayList (java.util.ArrayList)10 List (java.util.List)10 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)9 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)9 AffinityFunctionContext (org.apache.ignite.cache.affinity.AffinityFunctionContext)8 GridAffinityFunctionContextImpl (org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl)8 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Ignite (org.apache.ignite.Ignite)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 Random (java.util.Random)3 IgniteKernal (org.apache.ignite.internal.IgniteKernal)3 HashSet (java.util.HashSet)2 UUID (java.util.UUID)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)2 PlatformAffinityFunction (org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction)2