public void TestAffinityKeyMappedWithQueryEntity() { var cacheCfg = new CacheConfiguration(TestUtils.TestName) { QueryEntities = new List <QueryEntity> { new QueryEntity(typeof(QueryEntityKey), typeof(QueryEntityValue)) } }; var cache = Ignition.GetIgnite("grid-0").GetOrCreateCache <QueryEntityKey, QueryEntityValue>(cacheCfg); var cache2 = Ignition.GetIgnite("grid-1").GetOrCreateCache <QueryEntityKey, QueryEntityValue>(cacheCfg); TestAffinityKeyMappedWithQueryEntity0(Ignition.GetIgnite("grid-0"), cacheCfg.Name); TestAffinityKeyMappedWithQueryEntity0(Ignition.GetIgnite("grid-1"), cacheCfg.Name); // Check put/get. var key = new QueryEntityKey { Data = "x", AffinityKey = 123 }; cache[key] = new QueryEntityValue { Name = "y", AffKey = 321 }; var val = cache2[key]; Assert.AreEqual("y", val.Name); Assert.AreEqual(321, val.AffKey); }
/// <summary> /// Checks affinity mapping. /// </summary> private static void TestAffinityKeyMappedWithQueryEntity0(IIgnite ignite, string cacheName) { var aff = ignite.GetAffinity(cacheName); var key1 = new QueryEntityKey { Data = "data1", AffinityKey = 1 }; var key2 = new QueryEntityKey { Data = "data2", AffinityKey = 1 }; var val1 = new QueryEntityValue { Name = "foo", AffKey = 100 }; var val2 = new QueryEntityValue { Name = "bar", AffKey = 100 }; Assert.AreEqual(aff.GetPartition(key1), aff.GetPartition(key2)); Assert.AreEqual(aff.GetPartition(val1), aff.GetPartition(val2)); }