我希望在Windows 10上使用C#和Apache Ignite 2.4来实现多个复制节点,每个节点都有一个自定义CacheStoreFactory。我希望每当缓存条目更改时都将调用每个节点的CacheStoreFactory。下面的代码示例将输出为我期望的CacheMode.Partitioned行为。对于CacheMode.Replicated,我希望每个cache.Put操作都有两条输出线(因为正在运行两个节点)。我怎样才能做到这一点?输出Node count: 2Started..Write 0-0 by 63642613Write 1-1 by 12036987Write 2-2 by 63642613Write 3-3 by 12036987Write 4-4 by 63642613Write 5-5 by 63642613Write 6-6 by 12036987Write 7-7 by 63642613Write 8-8 by 12036987Write 9-9 by 12036987Finished count1:10 count2:10样例代码class Program{ static void Main(string[] args) { var config = new IgniteConfiguration() { IgniteInstanceName = "A", CacheConfiguration = new List<CacheConfiguration> { new CacheConfiguration("mycache",new QueryEntity(typeof(int), typeof(int))) { CacheMode = CacheMode.Replicated, WriteThrough = true, CacheStoreFactory = new StoreFactory(), }, }, }; var ignite1 = Ignition.Start(config); config.IgniteInstanceName = "B"; var ignite2 = Ignition.Start(config); Console.WriteLine("Node count: " + ignite1.GetCluster().GetNodes().Count); ignite1.GetCluster().SetActive(true); var mycache1 = ignite1.GetCache<int, int>("mycache"); var mycache2 = ignite2.GetCache<int, int>("mycache"); Console.WriteLine("Started.."); for (int i = 0; i < 10; i++) { mycache1.Put(i, i); } Console.WriteLine($"Finished count1:{mycache1.Count()} count2:{mycache2.Count()}"); Console.ReadLine(); ignite1.Dispose(); ignite2.Dispose(); }
1 回答
- 1 回答
- 0 关注
- 144 浏览
添加回答
举报
0/150
提交
取消