Sending multi-node broadcast messages

48 views
Skip to first unread message

aravind c

unread,
Oct 6, 2015, 7:40:54 PM10/6/15
to beehive-dev
Soheil,
From the beehive Readme:

Life of a Message

When a message is emitted on a hive, we first pass that message to the Map function of the registered message handlers for that type of message. The Map function returns the mapped cells of that message. Then, we relay the message to the bee that has any of the keys in the mapped cell. That bee in response calls the Rcv function of that message handler. This bee may be on the same hive or can be on another hive.


I am running two hives on two separate nodes with internally generated id's ID1 and ID2. My map function computes MappedCells as
beehive.MappedCells{{dict_name, ID1}, {dict_name, ID2}}

I was expecting to Rcv function on nodes 1 and 2 to see the emitted message but I see that the message is only seen by the Rcv function on whichever node emits the message of the relevant type first. Is this the expected behavior?
Is there any way to re-emit the message to be received by the bees on the other hive?

Thanks,
Aravind

Soheil Hassas Yeganeh

unread,
Oct 16, 2015, 8:19:19 PM10/16/15
to beehive-dev
Sorry for the late reply! I'm traveling and am out of reach.
 
I am running two hives on two separate nodes with internally generated id's ID1 and ID2. My map function computes MappedCells as
beehive.MappedCells{{dict_name, ID1}, {dict_name, ID2}}

That's not what the Map function is about. The code you've written, sends the message to THE bee that owns both dict/ID1 and dict/ID2. 
 
I was expecting to Rcv function on nodes 1 and 2 to see the emitted message but I see that the message is only seen by the Rcv function on whichever node emits the message of the relevant type first. Is this the expected behavior?
Is there any way to re-emit the message to be received by the bees on the other hive?

In my experience, this could always be fixed with a quick redesign, but if you absolutely need a broadcast, you'll need to implement an extra handler that does the broadcast for you. For example: 

Bcast step:
Msg -> mapped to local hive ID -> Bcast Rcv -> Emit(BcastMsg{Hive: 1, Msg: Msg}), Emit(BcastMsg{Hive: 2, Msg: Msg})

Processing step:
BcastMsg{Hive: HID, msg: Msg} -> mapped to HID -> ...

Now you need to write a placement method that places bees processing BcastMsg mapped to HID on Hive HID https://godoc.org/github.com/kandoo/beehive#Placement

Again, I'd like to emphasize that there is almost always a better design to avoid this in Beehive. 

Best,
Soheil

 

Thanks,
Aravind

Reply all
Reply to author
Forward
0 new messages