These are chat archives for akkadotnet/akka.net

3rd
Sep 2016
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 07:40
About Akka .NET clustering: is my understanding correct that the way it works (via gossip) is a form of broadcast-based P2P?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 09:07
@dandago2_twitter not necessarily broadcast-based
but yes, it's p2p
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 09:08
if a node has something to gossip about, doesn't it send the gossip to all nodes it knows about? how does it actually work?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 09:09
@jon49 hot-code loading and swapping is possible (maybe I'll be able to provide some example in the future) - hot code unloading however is not, due to limitations of .NET platform itself
@dandago2_twitter @Aaronontheweb knows the complete algorithm, I know that it's either broadcast to all known nodes or using ring structure (like cassandra ie)
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 09:11
cool, would be great to have Aaron's insight on this; is it documented anywhere?
and any reason why it was implemented like this as opposed to e.g. using a distributed hash table?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 09:13
gossip protocol and dht are two different concepts
@dandago2_twitter if you're interested, there are two good sources on how akka cluster works:
  1. Petabridge video
  2. Akka docs
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 09:19
I've already been through the video and although it's a good overview, it doesn't go into a lot of detail
I didn't make the assumption that clustering works the same for Akka .NET and Akka.io
does it?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 09:21
mostly it does, Akka.NET doesn't have a notion of weakly-up nodes (yet)
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 09:22
so how does gossip compare to DHT in general? I'm under the impression that DHT scales better but don't really have enough experience to be really sure about any of this
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 09:26
DHT is about distributing resources in the cluster, Gossip is about communicating state of the cluster itself to all of it's nodes and keeping it consistent
Horusiath @Horusiath sorry it's Saturday, time leave the cave
Maciek Misztal
@mmisztal1980
Sep 03 2016 14:58
@Aaronontheweb 's talks from NDC Sydney have appeared on vimeo
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 16:33
Is there a standard API for implementing custom loggers? Or just handle a specific set of messages as per https://github.com/akkadotnet/akka.net/blob/92177da15a7ef54e23b5224c05997592cbceb8e4/src/core/Akka/Event/TraceLogger.cs ?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 16:40
@dandago2_twitter you only need actor which is able to handle With<InitializeLogger>(m => Sender.Tell(new LoggerInitialized())) + set of log messages you're interested in.
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 16:44
Set of log messages? I thought logger usage typically looked like logger.Info(), logger.Error(), etc... how does that work when you do a custom logger?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 16:47
logger.Info etc. are methods that just hide publishing predefined system messages to event bus
some time age I've written a blog post, how to build logger working with SignalR to push logs to the browser
maybe you'll find it useful
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 16:50
thanks, I will read it - it would really help if these messages were documented somewhere
first place I looked was here: http://getakka.net/docs/Logging#configuring-custom-loggers but it doesn't explain how to write a custom logger
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 16:53
@dandago2_twitter a more detailed documentation can be found on the JVM docs: http://doc.akka.io/docs/akka/current/scala/logging.html#Loggers
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:07
thanks
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:14
let's say I write a custom logger that writes to a file. I can take care of opening the file in the InitializeLogger handler. But who takes care of cleanup (e.g. when the actorsystem shuts down)?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 17:16
each actor has set of virtual methods associated with it's lifetime. Two of them are PreStart - which runs before actor will receive any message, and PostStop - which runs after actor has been stopped for whatever reason.
You can use them to aquire/dispose resources
this will ofc work with graceful actorsystem shutdown - if you'll get hard reset, then there's no guarantee that PostStop will be called
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:26
makes perfect sense, thanks!
although I was supposing you have to acquire resources in the InitializeLogger handler
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 17:28
sure you can, InitializeLogger is mostly for event bus to be sure, that logger is ready to receive messages.
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:29
ok
I just tried the lifecycle hooks... AroundPreStart gets called, but AroundPostStop doesn't
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 17:29
I would say, that Around* hooks are only for advanced use cases
use just PreStart and PostStop
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:31
Oh, I used the Around* because I didn't get anything else when looking for overridable methods
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 17:31
Around* hooks are mostly for abstract classes, that needs to make some special operations without blocking inheriting classes an ability to redefine PreStart and PostStop methods
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:31
it's cause I started typing public, that's why :)
PostStop() doesn't get called anyway
anyhow thanks a lot, I understand writing custom loggers now, and have enough material to write a blog post... you guys might want to look at the PostStop issue though, it may be a resource leak
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 17:36
how are you stopping an actor>
usually loggers will go down only when actor system itself is terminating
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:37
yes, I am terminating the actorsystem
or at least I think I am - I am wrapping actorsystem in a using block with a Console.ReadLine() to keep it open, then I press enter to kill it
        using (var actorSystem = ActorSystem.Create("MyActorSystem"))
        {
            var logger = Logging.GetLogger(actorSystem, actorSystem, null);
            logger.Info("ActorSystem created!");

            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();
        }
I am making the assumption that disposing the actorsystem is the same as terminating it
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 17:41
are you sure, you've configured your actor system to use your logger?
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:43
of course, it is hitting the breakpoints inside it
just not the one in PostStop()
let me see if awaiting termination makes a difference
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 17:44
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 17:47
the Console.ReadLine() made the difference - I think my console app was exiting before the actorsystem actually did the cleanup
I suppose this is because the disposal occurs asynchronously (or something), so the program proceeds before the cleanup is actually done
wyldebill
@wyldebill
Sep 03 2016 17:53
question about clustering behavior. i'm using the web crawler sample and if start a new actor process like crawlerservice it joins the cluster and evenutally starts getting messges to process. but if i then kill it, that seems to mess up the other actors and all of them start sending red error messages. will the gossip clean this up evenutally and realize the actor is gone and remove it from the cluster?
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 18:00
@wyldebill I think, your messing two concepts, actor and cluster node.
and your problem is probably related to fact, that you've got some node, that has become unreachable
you may try to set some timeout in akka.cluster.auto-down-unreachable-after HOCON key - this way nodes will automatically mark the unreachable node after specified timeout
wyldebill
@wyldebill
Sep 03 2016 18:11
@Horusiath yes, i am effectively stopping one node. am i correct that this situation shouldn't effect the other nodes though? and what is the differece between an actor and a cluster node? node != actor in a cluster?
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 18:25
if I want to define custom configuration (e.g. log filename for a custom logging actor that writes to file), how do I read it from an actor?
Chris G. Stevens
@cgstevens
Sep 03 2016 18:29
@Horusiath Here is my Log4Net example that I have been using.... https://github.com/cgstevens/MyClusterServices/blob/master/MyServices/Logger/Log4NetLogger.cs
If anyone want to find it useful I guess. :)
The one thing I needed to do was set the EventId for the EventLog.
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 19:21
@dandago2_twitter you can set it in actor system configuration - i.e. Context.System.Settings.Config.GetConfig("akka.persistence.journal") will give you the HOCON seqment of configuration living under provided path. So you can read it when actor initializes.
@wyldebill no ActorSystem is effectively an equivalent of cluster node. It can contains millions of actors.
Vagif Abilov
@object
Sep 03 2016 21:30
I am investigating reasons for some dead messages, and apparently they are caused by an attempt to send a message to a router after the routee is stopped and restarting (which I guess cause restart of the router with the whole pool). This raises a question of how to properly deal with this situation avoiding dead messages. Senders always send messages to the router (that uses consistent hash) assuming it's available. Apparently it might not.
In case of ActorSelection it's clear that the sender need to expect that there is no actor is available and it may first send Identify. When using routers it's a bit different - a router is expected to be present, isn't it? If not then what is a handshaking mechanism in such case?
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 22:29
The fallback mechanism for Akka .NET config looks pretty scary to work with. Isn't there an easy way to do something like config.Get<T>(key, defaultValueIfNotFound)?
Sergey Prytkov
@Rattenkrieg
Sep 03 2016 22:30
@object you should implement proper supervision strategy on router, e.g. one-for-one strategy.
Bartosz Sypytkowski
@Horusiath
Sep 03 2016 23:21
@dandago2_twitter each config getter (ie. config.GetInt(configPath)) can take optional default value in case, when config has no configPath defined
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 23:23
ah, I missed that
but still, I see this as odd
        filePath = Context.System.Settings.Config
            .GetConfig("akka.logfilepath").GetString("akka.logfilepath", "log.txt");
like why do I have to specify the path in both GetConfig() and GetString()?
Daniel D'Agostino
@dandago2_twitter
Sep 03 2016 23:59
blob
There seems to be a race... when PostStop() occurs, there is an influx of log messages at the same time