EricssonResearch / calvin-base

Calvin is an application environment that lets things talk to things, among other things.
Apache License 2.0
282 stars 91 forks source link

On peer setup, call peer setup for peer nodes as well #31

Closed PStahl closed 7 years ago

PStahl commented 8 years ago

This commit avoids having to do multiple peer setup, for example like it's done in test_calvin2.py utils.peer_setup(rt1, ["calvinip://%s:5001" % (ip_addr,), "calvinip://%s:5002" % (ip_addr, )]) utils.peer_setup(rt2, ["calvinip://%s:5000" % (ip_addr,), "calvinip://%s:5002" % (ip_addr, )]) utils.peer_setup(rt3, ["calvinip://%s:5000" % (ip_addr,), "calvinip://%s:5001" % (ip_addr, )]) This results in the following behaviour: calvin-base(develop)$ csruntime --host localhost --port 5001 --controlport 5002 --keep-alive calvin-base(develop)$ csruntime --host localhost --port 5003 --controlport 5004 --keep-alive calvin-base(develop)$ csruntime --host localhost --port 5005 --controlport 5006 --keep-alive calvin-base(develop)$ cscontrol http://localhost:5002 nodes add calvinip://localhost:5003 calvinip://localhost:5005 {u'calvinip://localhost:5005': [u'80c3bc0f-0164-4cd4-a6cb-da4e2cdccaa9', 200], u'calvinip://localhost:5003': [u'c6b187c9-5858-47ad-91a8-52ff0cd97bca', 200]} calvin-base(develop)$ cscontrol http://localhost:5002 nodes list [u'80c3bc0f-0164-4cd4-a6cb-da4e2cdccaa9', u'c6b187c9-5858-47ad-91a8-52ff0cd97bca'] calvin-base(develop)$ cscontrol http://localhost:5004 nodes list [u'cd9bc012-13cd-4746-b65a-6e01d8388501'] calvin-base(develop)$ cscontrol http://localhost:5006 nodes list [u'cd9bc012-13cd-4746-b65a-6e01d8388501']

Instead, we use proto to call peer_setup for each of the nodes we add. The result if the following: (same setup with 3 runtimes) calvin-base(peer-setup)$ cscontrol http://localhost:5002 nodes add calvinip://localhost:5003 calvinip://localhost:5005 {u'calvinip://localhost:5005': [u'8d1df665-12c1-425b-af9e-7f739833ca6e', 200], u'calvinip://localhost:5003': [u'08be4b54-9813-40d6-8e4b-0ba347e4fe8e', 200]} calvin-base(peer-setup)$ cscontrol http://localhost:5002 nodes list [u'08be4b54-9813-40d6-8e4b-0ba347e4fe8e', u'8d1df665-12c1-425b-af9e-7f739833ca6e'] calvin-base(peer-setup)$ cscontrol http://localhost:5004 nodes list [u'a9dac5c7-88d3-4389-ab02-bf518c59068e', u'8d1df665-12c1-425b-af9e-7f739833ca6e'] calvin-base(peer-setup)$ cscontrol http://localhost:5006 nodes list [u'a9dac5c7-88d3-4389-ab02-bf518c59068e', u'08be4b54-9813-40d6-8e4b-0ba347e4fe8e']

Now node 5004 knows about both 5002 and 5006, not only 5002 as it would have before this change. Same for 5006.

olaan commented 7 years ago

This is normally done using the calvin registry. The peer_setup trick is mostly used during tests.