Open JorgeCandeias opened 5 years ago
Do you mean to take something like https://github.com/dotnet/orleans/blob/master/test/Grains/TestGrains/TestPlacementStrategyFixedSiloDirector.cs#L9 and turn it into a sample?
Yes, to make it very obvious, with associated instructions and maybe other use cases, e.g. by environment variable or injected configuration, etc. Obvious helps on-board new developers and ease the learning curve. I'll do it myself as time allows if no one has a go at it in the meantime.
I was just recently trying to experiment on how to implement a custom placement strategy. One area where added samples / documentation would be of great help is in how to re-use parts of existing strategies (if it is possible). In our case we'd have liked to try a strategy where you could via external configuration mark silos as "cooling" silos, meaning new activations would not be placed onto them (in order to avoid this situation for example when shutting down a busy silo https://github.com/dotnet/orleans/issues/5687).
It looks like it's not particuarly straightforward to extend the internal-marked default placement strategies. In this case it would be a pretty trivial change to add one more filtering rule to the relevantSilo selection, but can't really see any easy way to do that other than copy-pasting the entire class implementation and changing one line. Even that approach seems not possible though, because some of the injected dependencies to the ActivationCountPlacementDirector are internal as well.
On that point, there may be merit in opening up the default strategies, while keeping their own internals safe, maybe via some base classes or a composition model. The latter could allow combination of default strategies like hash-based + silo-role-based, for forced distribution on a blue-green deployment, something we could make use of at my place. Then again, this can be over-engineering something simple.
@JorgeCandeias
In our case we'd have liked to try a strategy where you could via external configuration mark silos as "cooling" silos, meaning new activations would not be placed onto them
We wanted to implement similar placement director. We even thought about dynamic setting per grain type a weight or percentage to random select it:
It would be very kind of you to share your implementation. Many thanks!
This often comes around, will be nice to have something to show for it.