Search code examples
orleans

MSR Orleans, How does PlacementStrategy work?


In Orleans, how do the PlacementStrategy’s work? I see that there are several implementations of the PlacementStrategy including RandomPlacement, PreferLocalPlacement, ActivationCountBasedPlacement and StatelessWorkerPlacement.

I have a few question from how to use these to how are they implemented? How do I specify that a call should be Prefer-Local vs RandomPlacement?

I am looking through the code and I do not see the code which chooses one execution path versus another based on these placement strategies. Where does that happen?


Solution

  • There are more details by Richard here: http://richorama.github.io/blog/2015/01/02/grain-placement-in-orleans/ We should, and will, move this into our docs here on github.io.

    How to use: add an attribute [PreferLocal] on the grain class.

    The code: https://github.com/dotnet/orleans/blob/master/src/OrleansRuntime/Core/Dispatcher.cs#L555

    SelectOrAddActivation(..., strategy) forwards to the specific placement director, based on the specified placement policy.