简体   繁体   English

如何从特定筒仓(奥尔良 2.0)中获取无状态谷物

[英]How can I get the Stateless Grain from Specific Silo (Orleans 2.0)

Have 3 silos on server and have Stateless grain在服务器上有 3 个筒仓,并有无状态谷物

[StatelessWorker(1)] // max 1 activation per silo
public class MyLonelyWorkerGrain : ILonelyWorkerGrain
{
 ...
}

So create 1(Max) grain per silo.因此,每个筒仓创建 1(最大)粒。 Is there any way force to get the Grain from specific silo?有什么办法可以从特定的筒仓中获取粮食吗?

GrainFactory.GetGrain<ILonelyWorkerGrain>(0); //?????

From the Orleans documentation :奥尔良文档

When the [StatelessWorker] attribute is applied to a grain class, it indicates to the Orleans runtime that grains of that class should be treated as Stateless Worker grains.当 [StatelessWorker] 属性应用于 Grain class 时,它向 Orleans 运行时指示该 class 的 Grain 应被视为无状态 Worker Grain。 Stateless Worker grains have the following properties that make their execution very different from that of normal grain classes. Stateless Worker grain 具有以下属性,使其执行与普通grain 类的执行非常不同。

  1. The Orleans runtime can and will create multiple activations of a Stateless Worker grain on different silos of the cluster. Orleans 运行时可以并且将在集群的不同孤岛上创建多个无状态工作者颗粒的激活。
  2. Requests made to Stateless Worker grains are always executed locally, that is on the same silo where the request originated , either made by a grain running on the silo or received by the silo's client gateway.向 Stateless Worker grains 发出的请求总是在本地执行,即在请求发起的同一筒仓上,要么由筒仓上运行的grain发出,要么由筒仓的客户端网关接收。 Hence, calls to Stateless Worker grains from other grains or from client gateways never incur a remote message .因此,从其他 grain 或客户端网关调用 Stateless Worker grain 永远不会产生远程消息
  3. The Orleans Runtime automatically creates additional activations of a Stateless Worker grain if the already existing ones are busy. Orleans Runtime 会自动创建额外的 Stateless Worker grain 如果已经存在的激活很忙。 The maximum number of activations of a Stateless Worker grain the runtime creates per silo is limited by default by the number of CPU cores on the machine, unless specified explicitly by the optional maxLocalWorkers argument.默认情况下,运行时为每个筒仓创建的无状态 Worker 颗粒的最大激活次数受机器上 CPU 内核数的限制,除非由可选的 maxLocalWorkers 参数明确指定。
  4. Because of 2 and 3, Stateless Worker grain activations are not individually addressable.由于 2 和 3,Stateless Worker 粒度激活不能单独寻址。 Two subsequent requests to a Stateless Worker grain may be processed by different activations of it.对 Stateless Worker 粒度的两个后续请求可能由它的不同激活处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM