azure-service-fabric - 如何枚举所有分区和聚合结果

标签 azure-service-fabric

我有一个多分区的有状态服务。如何使用 service remoting 枚举其所有分区和聚合结果用于客户端和服务之间的通信?

最佳答案

您可以使用 FabricClient 枚举分区:

var serviceName = new Uri("fabric:/MyApp/MyService");
using (var client = new FabricClient())
{
    var partitions = await client.QueryManager.GetPartitionListAsync(serviceName);

    foreach (var partition in partitions)
    {
        Debug.Assert(partition.PartitionInformation.Kind == ServicePartitionKind.Int64Range);
        var partitionInformation = (Int64RangePartitionInformation)partition.PartitionInformation;
        var proxy = ServiceProxy.Create<IMyService>(serviceName, new ServicePartitionKey(partitionInformation.LowKey));
        // TODO: call service
    }
}

请注意,您可能应该缓存 GetPartitionListAsync 的结果。因为如果不重新创建服务就无法更改服务分区(您可以保留 LowKey 值的列表)。

另外,FabricClient也应该尽可能多地共享(参见 documentation)。

关于azure-service-fabric - 如何枚举所有分区和聚合结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37774965/

相关文章:

metrics - Service Fabric 资源平衡器使用陈旧的报告负载

c# - Service Fabric 本地集群设置问题

visual-studio - Service Fabric 服务引用具有黄色三角形

c# - Service Fabric 应用程序拒绝访问路径

azure-devops - 如何从 VSTS 发布管道部署 Service Fabric 应用程序?

azure-service-fabric - Azure Service Fabric 可靠集合和内存

Azure Service Fabric 与 Azure 容器服务

.net - 在 Azure devops 上为服务结构应用构建管道

linux - 将 .Net Core 应用程序部署到 Linux Service Fabric 集群

azure-service-fabric - 强制删除 Service Fabric 应用程序