Different Actors same maschine

46 views
Skip to first unread message

Stef Zeh

unread,
Feb 16, 2020, 1:52:57 PM2/16/20
to actor-framework
Hi for testing purposes I want to create two actors on the same machine and connect it to another one (we use stateful_actor). However, when I run on the server

auto sap = current_sender();
auto hdl = actor_cast<actor>(sap);

both actors have exactly the same id. What can I do and how do the both actors must differ such that they will use different ids?

Thanks
Steffen

Dominik Charousset

unread,
Feb 16, 2020, 2:30:00 PM2/16/20
to actor-f...@googlegroups.com
The ID of an actor is simply an ascending integer for differentiating actors *within the same system*. Once you exchange actors between multiple systems, you get a globally unique ID by combining the actor ID and the node ID.

Usually, neither actor ID not node ID are meant for user code. Actor handles take that role. Whenever CAF needs to represent an actor without any knowledge of its type, we’ll use actor_addr (which is a weak pointer, so it also won’t keep your actors alive).

Hope that helps,

Dominik

steffen.zeuch

unread,
Feb 16, 2020, 3:51:17 PM2/16/20
to actor-f...@googlegroups.com
hello thanks a lot for the answer. so with what call/function can I distingush two workers on the same node on the server side? is there a handle.getID? so which should be used for user code? 

thanks
steffen

-------- Ursprüngliche Nachricht --------
Von: Dominik Charousset <dom...@charousset.de>
Datum: 16.02.20 20:30 (GMT+01:00)
Betreff: Re: [caf] Different Actors same maschine

--
You received this message because you are subscribed to the Google Groups "actor-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actor-framewo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/actor-framework/DCF86714-792E-47BE-9D5C-C4AB328F44CB%40charousset.de.

Dominik Charousset

unread,
Feb 18, 2020, 2:37:36 AM2/18/20
to actor-f...@googlegroups.com
> so with what call/function can I distingush two workers on the same node on the server side? is there a handle.getID? so which should be used for user code?

It’s simple: just compare the handles. :)

```
auto sap = current_sender();
if (sap == my_actor) {
// …
} else {
// …
}
```

The variable my_actor can be any of: caf::actor, caf::typed_actor<…>, caf::actor_addr, or caf::strong_actor_ptr.

Dominik


> -------- Ursprüngliche Nachricht --------
> Von: Dominik Charousset <dom...@charousset.de>
> Datum: 16.02.20 20:30 (GMT+01:00)
> An: actor-f...@googlegroups.com
> Betreff: Re: [caf] Different Actors same maschine
>
> > Hi for testing purposes I want to create two actors on the same machine and connect it to another one (we use stateful_actor). However, when I run on the server
> >
> > auto sap = current_sender();
> > auto hdl = actor_cast<actor>(sap);
> >
> > both actors have exactly the same id. What can I do and how do the both actors must differ such that they will use different ids?
>
> The ID of an actor is simply an ascending integer for differentiating actors *within the same system*. Once you exchange actors between multiple systems, you get a globally unique ID by combining the actor ID and the node ID.
>
> Usually, neither actor ID not node ID are meant for user code. Actor handles take that role. Whenever CAF needs to represent an actor without any knowledge of its type, we’ll use actor_addr (which is a weak pointer, so it also won’t keep your actors alive).
>
> Hope that helps,
>
> Dominik
>
> --
> You received this message because you are subscribed to the Google Groups "actor-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to actor-framewo...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/actor-framework/DCF86714-792E-47BE-9D5C-C4AB328F44CB%40charousset.de.
>
> --
> You received this message because you are subscribed to the Google Groups "actor-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to actor-framewo...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/actor-framework/5e49ab43.1c69fb81.11052.0f14%40mx.google.com.

Stef Zeh

unread,
Apr 6, 2020, 2:31:22 PM4/6/20
to actor-framework
Hi Dominik,

so this is actually not totally true. When I spawn two actors on the same system, they only differ by their id such that the sap would look for example like this:
5@B6A14C8A08351ED258D0ED1AEDD9143C44A98C01#29179
12@B6A14C8A08351ED258D0ED1AEDD9143C44A98C01#29179

However, two consecutive calls from the same worker will end up in different ids (the part before @) which should not be the case right?

Thanks
Steffen
> To unsubscribe from this group and stop receiving emails from it, send an email to actor-f...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/actor-framework/DCF86714-792E-47BE-9D5C-C4AB328F44CB%40charousset.de.
>
> --
> You received this message because you are subscribed to the Google Groups "actor-framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to actor-f...@googlegroups.com.

Dominik Charousset

unread,
Apr 7, 2020, 3:15:01 PM4/7/20
to actor-f...@googlegroups.com
> so this is actually not totally true. When I spawn two actors on the same system, they only differ by their id such that the sap would look for example like this:
> 5@B6A14C8A08351ED258D0ED1AEDD9143C44A98C01#29179
> 12@B6A14C8A08351ED258D0ED1AEDD9143C44A98C01#29179
>
> However, two consecutive calls from the same worker will end up in different ids (the part before @) which should not be the case right?

I’m not quite sure what you mean by consecutive calls. The current_sender can change with any incoming message. Can you provide a minimal example with a short description what your expected vs. observed behavior is?
> To unsubscribe from this group and stop receiving emails from it, send an email to actor-framewo...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/actor-framework/2c854892-5ad3-444f-a46b-042a5383cb67%40googlegroups.com.

Stef Zeh

unread,
Apr 9, 2020, 7:05:10 AM4/9/20
to actor-framework
Hello our current design has one server and many clients. The clients connect to the server on startup and the server put a hash value of their handle in a bookkeeping structure. Whenever a client then sends a messages the server looks up to which client this handle belongs by calling current_sender(). However, we experience many times that between two messages send from the same client the to_string of the handle changes, in particular the id before the @ of the string.

My question was not can we can some kind of consistent id/tag for each client such that we can identify it uniquely.

Thanks
Steffen
Reply all
Reply to author
Forward
0 new messages