如何在 Azure ServiceFabric 有状态应用程序的可靠集合中创建数据时传递 PartitionKey

问题描述

我有 3 个分区的 Service Fabric 有状态应用程序,以下是配置

PartitionCount = 3,LowKey = 0 和 HighKey = 2
因此,在 ReliableCollections 中创建数据时,我需要发送什么分区键?下面是几个场景

using (var tx = this.StateManager.CreateTransaction())
                {
                    var result = await myDictionary.TryGetValueAsync(tx,"Counter");

                    ServiceEventSource.Current.ServiceMessage(this.Context,"Current Counter Value: {0}",result.HasValue ? result.Value.ToString() : "Value does not exist.");

                    // will go into 1st partition since given key = 0 = LowKey
                    var t1 = await myDictionary.AddOrUpdateAsync(tx,"0",55,(key,value) => ++value);
                    // will go into 2nd partition since given key = 1
                    var t2 = await myDictionary.AddOrUpdateAsync(tx,"1",65,value) => ++value);
                    // will go into 3rdst partition since given key = 2 = HighKey
                    var t3 = await myDictionary.AddOrUpdateAsync(tx,"2",75,value) => ++value);
                    
                    // but what iff i give key = 5/"nano",in which partition it will create this record
                    var t4 = await myDictionary.AddOrUpdateAsync(tx,"6",99,value) => ++value);
                   
                    await tx.CommitAsync();
                }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...