如何枚举所有分区并汇总结果

编程入门 行业动态 更新时间:2024-10-28 01:21:28
本文介绍了如何枚举所有分区并汇总结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有多个分区的有状态服务.如何使用服务远程处理,用于客户端和服务之间的通信?

I have a multiple partitioned stateful service. How can I enumerate all its partitions and aggregate results, using service remoting for communication between client and service?

推荐答案

您可以使用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值的列表).

Note that you should probably cache the results of GetPartitionListAsync since service partitions cannot be changed without recreating the service (you can just keep a list of the LowKey values).

此外,还应尽可能共享FabricClient(请参阅文档).

In addition, FabricClient should also be shared as much as possible (see the documentation).

更多推荐

如何枚举所有分区并汇总结果

本文发布于:2023-10-24 15:06:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524263.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分区

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!