These are chat archives for akkadotnet/akka.net

9th
Nov 2017
Notour
@notour
Nov 09 2017 08:32
HI, Is their a way for lighthouse nodes to be skipped in the leader election process for a singleton actor ? (https://stackoverflow.com/questions/47197194/akka-net-made-singleton-actor-skip-lighthouse-node-in-cluster)
Bart de Boer
@boekabart
Nov 09 2017 08:34
Roles
Notour
@notour
Nov 09 2017 08:38
thanks
Bart de Boer
@boekabart
Nov 09 2017 08:44
Sorry for the short answer, no time now, let me know if the hint (and bit more text on SO) is enough to get you going
Sean Templeton
@seantempleton
Nov 09 2017 19:47
There is no "transitive" or "contagious" poison pill is there? I want to stop a root actor that has a child, that child has children, etc. but I want all children to have emptied their queues. A poison pill seemed the way to go at first. It caused the root actor to process it's messages first, but it doesn't give it's children a chance to do the same
Aaron Stannard
@Aaronontheweb
Nov 09 2017 21:07
@seantempleton way I'd go about doing that
is to use a user-defined message to signal to the parent at the top of some hierarchy that it's time to shut stuff down
I'd iterate over all of the children and use the GracefulStop extension method
which PoisonPills the child and returns a Task that completes once the child actor has terminated
and I'd aggregate all of the Tasks from each GracefulStop call into a Task.WhenAll call
and once that aggregate task completes, I'd shut myself down (the parent)
you can also use stuff like behavior-switching to do things like reject new messages that start arriving after the shutdown process
RoBiK75
@RoBiK75
Nov 09 2017 21:14
you could also use ReceiveTimeout to process the last burst of messages caused by the shutdown signal and then when everything goes silent - signaled by the receive timeout - finally shut down
let's call that EvenMoreGracefullStop :D
Aaron Stannard
@Aaronontheweb
Nov 09 2017 21:15
SuperSmoothStop
icon is a tuxedo holding a martini glass
RoBiK75
@RoBiK75
Nov 09 2017 21:15
yeah ;)
Jessie Wadman
@JessieWadman
Nov 09 2017 21:16
Is this when I should hold up one of those paper signs they have at the Olympics, that reads "10"? :)
Sean Templeton
@seantempleton
Nov 09 2017 21:18
@Aaronontheweb would that for all intents and purposes put a PoisonPill in each actors mailbox at the same time? So if I have A with a child B, and B has a child C, I would receive my message in A, iterate all children and grandchildren, telling them to GracefulStop? If so, then if B was still processing and needed to send C something, C would discard that message since it would process the PoisonPill first. If I have that all correctly...
In my scenario I'm guaranteed no more messages coming into the root actor A, so whatever I need to do to ensure that everyone is guaranteed finished processing should be doable
If I used a user-defined message at each level to graceful stop the immediate child seems like that should work
Aaron Stannard
@Aaronontheweb
Nov 09 2017 22:08
ah crap
I assumed those links had a recording or something
Sean Templeton
@seantempleton
Nov 09 2017 22:24
How can I iterate through the children of an actor, inside the parent? this and Self don't appear to give me access to the list
Sean Templeton
@seantempleton
Nov 09 2017 22:58
Looks like I can accomplish what I want with this if I put it in each actor (code modified for brevity, no error handling, etc.)
            Receive<GracefulPill>(_ =>
            {
                foreach (var child in ((ActorRefWithCell)Self).Children)
                    child.GracefulStop(TimeSpan.FromSeconds(60), new GracefulPill()).Wait();

                Self.Tell(PoisonPill.Instance);
            });