分区解析在Service Fabric中没有意义

时间:2018-07-29 11:40:28

标签: azure-service-fabric partitioning service-fabric-stateful

我有状态服务,该服务使用具有5个分区的统一int64分区

<UniformInt64Partition PartitionCount="5" LowKey="-9223372036854775808" HighKey="9223372036854775807" />

这将导致以下分区

[
  {
    "lowKey": -5534023222112865000,
    "highKey": -1844674407370955300,
    "id": "92b4c32e-cb3c-432f-aea0-4579fc72850c",
    "kind": 2
  },
  {
    "lowKey": 5534023222112865000,
    "highKey": 9223372036854776000,
    "id": "dd9b084d-88fa-4773-94d9-f634d22a2c03",
    "kind": 2
  },
  {
    "lowKey": -9223372036854776000,
    "highKey": -5534023222112865000,
    "id": "d7322e52-cf1e-47c2-b713-e983f443b533",
    "kind": 2
  },
  {
    "lowKey": -1844674407370955300,
    "highKey": 1844674407370955300,
    "id": "dfe2f994-bdc7-4b32-b54f-78a0245e4c4c",
    "kind": 2
  },
  {
    "lowKey": 1844674407370955300,
    "highKey": 5534023222112865000,
    "id": "6ad81ffb-5f3c-48ba-91d9-e65b23c528a4",
    "kind": 2
  }
]

所以,如果我有使用分区键55340232221128650067的请求

为什么92b4c32e-cb3c-432f-aea0-4579fc72850c分区可以解决此问题?

我正在使用下面的逻辑来查找分区

public static long MapUlongToLong(ulong ulongValue)
{
    return unchecked((long)ulongValue + long.MinValue);
}

protected override async Task<ResolvedServicePartition> FindPartition(ulong key = 0)
{
    var longValue = MapUlongToLong(key);
    var partitionKey = new ServicePartitionKey(longValue);
    var resolver = ServicePartitionResolver.GetDefault();
    var result = await resolver.ResolveAsync(FullServiceName, partitionKey, CancellationToken.None).ConfigureAwait(false);
    return result;
}

我必须将ulong映射到很长的时间,因为当我尝试在代码中使用大值时,将其归类为ulong值

这是引起问题的原因吗?

有其他选择吗?

保罗

0 个答案:

没有答案