These are chat archives for akkadotnet/akka.net

13th
Feb 2017
Bartosz Sypytkowski
@Horusiath
Feb 13 2017 05:42
@maxcherednik if you think, streams are for one way flows only, you're probably at the beginning of the docs ;) Streams are easier to present this way, but there's pretty big section about building graphs (including cyclic ones).
@webafriq_twitter it's up to you to define how update is done. This is what callback should do in Persist(event, callbackFunction)
in general if you're changing state there, it should match handlers defined in Recovery<> methods.
Bartosz Sypytkowski
@Horusiath
Feb 13 2017 05:48
I don't know what is your intent in the example, because instead of persisting an event you're persisting a command itself, then in persist callback you're trying to store some message in totally separate event store _superAgentMessageStore (for what?) and then save a snapshot of current actor state in snapshot store (again for what?)
Maxim Cherednik
@maxcherednik
Feb 13 2017 06:12
@Horusiath yeah, probably still in the beginning :)
babafemi
@webafriq_twitter
Feb 13 2017 07:38
@Horusiath , basically my intention nis to perform an update to and already persisted object. So, i might hve gotten i wrong. So how is the properer way to go about it. I am trying to perform a crud operation. I already understand create (persist), read. I am confusedon update, and not tried delete.
babafemi
@webafriq_twitter
Feb 13 2017 09:29
This the actor responsible for persistence
public class PersistAgentStore : ReceivePersistentActor
{
    private List<CreateSuperAgentMessage> _superAgentMessageStore = new List<CreateSuperAgentMessage>();
    private int _msgsSinceLastSnapshot = 0;
    public override string PersistenceId { get; } = "SuperAgentStoreActor";
    public PersistAgentStore()
    {
        // recover
        Recover<CreateSuperAgentMessage>(str => _superAgentMessageStore.Add(str)); // from the journal
        Recover<SnapshotOffer>(offer =>
        {
            var superAgents = offer.Snapshot as List<CreateSuperAgentMessage>;
            if (superAgents != null) // null check
                _superAgentMessageStore = superAgents;
        });

        //All SuperAgents Commands
        Command<CreateSuperAgentMessage>(str => Persist(str, s =>
        {
            _superAgentMessageStore.Add(str);
            if (++_msgsSinceLastSnapshot % 100 == 0)
            {
                SaveSnapshot(_superAgentMessageStore);
            }
        }));

        Command<SaveSnapshotSuccess>(success =>
        {
            // soft-delete the journal up until the sequence # at
            // which the snapshot was taken
            DeleteMessages(success.Metadata.SequenceNr);
        });

        Command<EditSuperAgentMessage>(str => Persist(str, s =>
        {
            var superagents = _superAgentMessageStore.Where(x => x.Id == str.Id).Select(x => x).FirstOrDefault();
            superagents = new CreateSuperAgentMessage(str.Id, str.Name, str.OfficeAddress1, str.OfficeAddress2, str.PhoneNumber1, str.PhoneNumber2,
                                                      str.ContactPersonPhoneNumber, str.WebsiteAddress, str.OfficialEmail, str.CACRegistrationDocument,
                                                      str.CbnCertificationDocument, str.Result);
            _superAgentMessageStore.Add(superagents); //add msg to in-memory event store after persisting
            SaveSnapshot(_superAgentMessageStore);
        }));

        Command<GetSuperAgentsBankId>(model =>
       {
           List<CreateSuperAgentMessage> agentsByBankId = _superAgentMessageStore.Where(x => x.Id == model.Id).Select(x => x).ToList();
           Sender.Tell(agentsByBankId, Sender);
       });
    }
}
@Horusiath , thats the code.
so you can see the full picture. Basicall i think i dont understand ow the e and d in crud will work.
Please assist.
Natan Vivo
@nvivo
Feb 13 2017 11:10
Hi all. I'm having some issues with the cluster where sometimes a website is choosen as a leader, and it shutsdown without leaving the cluster properly. Sometimes this node cannot reconnect ever and I have to restart the entire cluster
I was wondering.... do you have some common code in all nodes to deal with cluster events and remove inactive nodes in a smarter way than the auto-down feature?
Or better, what's the recommended way to deal with dead nodes?
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:14
  1. Auto-down - very bad - split brain is highly likely
  2. If you wish to have a smart way it's an external monitoring system of yours
  3. Could you please describe you situation a bit more detailed?
Natan Vivo
@nvivo
Feb 13 2017 11:16
It's not that I want a smarter way. It's just that I noticed that if I don't handle these cases the default thing for akka is to do nothing.
For example in dead nodes.
So, a node is dead and there is no auto down. What should I do? should I have code to handle it manually? Is there another feature that handles it?
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:17
why do have dead nodes in the first place?
Natan Vivo
@nvivo
Feb 13 2017 11:18
Unexpected reboot for example
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:18
reboot will bring it up
Natan Vivo
@nvivo
Feb 13 2017 11:18
The issue is that sometimes it doesn't
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:18
this is another topic :)
it should
Natan Vivo
@nvivo
Feb 13 2017 11:18
Ok, so first
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:18
if it's not - more details would be cool about your cluster setup
version
how many nodes
how many seed nodes
and so on
Natan Vivo
@nvivo
Feb 13 2017 11:19
I'm using the latest version. 1.1.3
And actually, for now most nodes are in the same machine
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:19
version - ok
same machine - doesn't matter if everything configured fine
do you use static ports for the nodes ?
Natan Vivo
@nvivo
Feb 13 2017 11:21
Yes
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:21
ok, seed nodes
Natan Vivo
@nvivo
Feb 13 2017 11:21
the thing is that sometimes for some reason I didn't get yet, a node will try to join but never rejoin
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:21
how many ?
Natan Vivo
@nvivo
Feb 13 2017 11:22
let me see
it happened 2 or 3 times already, I had to restart the entire cluster
a node kept trying to rejoin for 2 entire days
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:22
sure - might be... just let's have a look at your config
Natan Vivo
@nvivo
Feb 13 2017 11:23
wait a minute
akka {
  loglevel=DEBUG

    actor.provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"

    remote {
        helios.tcp {
            port = 10101
            hostname = localhost
        }
    }

  cluster {
    seed-nodes = [ "akka.tcp://App@localhost:10000" ],
    roles = [├Čntegration]
  }
}
I'm not yet 100% sure of the situation. But from what I remember this weekend, a website was choosen as a leader and shutdown without leaving the cluster properly. The website is restarted and try to rejoin, but didn't
Natan Vivo
@nvivo
Feb 13 2017 11:30
But I'll need to investigate more. I'll see if I set debug on for all the nodes and try to track exactly what is happening and which messages are logged
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:35
yeah, def it's not enough to help....
all we can do is guessing here
Natan Vivo
@nvivo
Feb 13 2017 11:36
ok, so let me ask this... if I want to have dynamic ports for websites, how do I remove them if they shutdown unexpectedly?
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:36
it's nearly an empty cluster...
but you can play around with the setup

ok, so let me ask this... if I want to have dynamic ports for websites, how do I remove them if they shutdown unexpectedly?

you can't do anything here... it should be static

Natan Vivo
@nvivo
Feb 13 2017 11:38
keeping track of ports is a pain in the ass
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:38
you shouldn't just pick one
Natan Vivo
@nvivo
Feb 13 2017 11:38
shouldn't the leader be able to remove dead nodes?

you shouldn't just pick one

what do you mean by that?

Maxim Cherednik
@maxcherednik
Feb 13 2017 11:41
let's say you have 20 web machine, each node should be using port 4053 for example
and you don't need to track or do something about it
just be sure that it's open in firewall
that's it
Natan Vivo
@nvivo
Feb 13 2017 11:42
yeah. the issue is that for now, i need some of the nodes to run on the same machine
that's why I need to track them
maybe a container should help... but not there yet
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:42
use 4053, 4054,4055 and so on
this is the requirement
Natan Vivo
@nvivo
Feb 13 2017 11:43
that's what I'm doing. but I need to keep track of them =)
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:43
nothing comes for free :)
Natan Vivo
@nvivo
Feb 13 2017 11:43
ok, so one thing doesn't make sense. If dynamic ports don't work, why are they there?
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:43
don't create super big cluster :) create 3-5 nodes cluster and play around
they do work, but node recovery doesn't work out of the box- you need to have a smart monitoring system for this
Natan Vivo
@nvivo
Feb 13 2017 11:45
yeah, so that was my question. how do I remove a node? Does the cluster extension allow me to remove any node?
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:45
you have to manually down it
Natan Vivo
@nvivo
Feb 13 2017 11:46
Ok, so I can do Cluster.Leave from any node with any node address?
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:46
yep
Natan Vivo
@nvivo
Feb 13 2017 11:46
ok
sounds enough
thanks
Maxim Cherednik
@maxcherednik
Feb 13 2017 11:46
first of all have a graceful stop for the node itself
have a look at the example I sent
Natan Vivo
@nvivo
Feb 13 2017 11:47
ok
I'll take a look
Bartosz Sypytkowski
@Horusiath
Feb 13 2017 17:04
@webafriq_twitter Akka.Persistence uses concepts from eventsourcing. I don't know if you're familiar with that concept. It's not meant for standard CRUD and to be honest, you don't need any library for crud/snapshotting. It could be just few lines of hand-written code.
btw. guys, If you want to contribute and you're looking for low-hanging fruit akkadotnet/akka.net#2515 would be the one
Francis Paulin
@paulinfrancis
Feb 13 2017 19:28
Hypothetically, if one has an actor cluster running on regular .NET, would an actor running on Mono be able to join the cluster?
Bartosz Sypytkowski
@Horusiath
Feb 13 2017 20:14
@paulinfrancis yes
Francis Paulin
@paulinfrancis
Feb 13 2017 20:17
awesome, thanks :)