This project is dedicated to visualizing a communications graph for the elastic database system Dispersy in localhost experiments. It does this by performing some exceptionally ugly hooks on Dispersy, so you don't have to.
The bare essentials for migration are the following steps:
- Instead of starting Dispersy, start VisualDispersy.
- Instead of inheriting from Community, inherit from VisualCommunity.
- Provide your community class with a main function which accepts (peerid, totalpeers, mymessagecount, totalmessagecount, visualserverport) to start it.
- Call
vz_init_server_connection(visualserverport)
on your VisualDispersy instance to make it report to the VisualServer. - Place your newly migrated experiment in the experiments folder.
VisualDispersy requires two things to run:
- Dispersy in the same folder
- The Python package
graph-tool
(a.k.a.graph_tool
)
To get Dispersy you can either clone it or download it from its repository.
To get graph-tool
you can run bash tools/quick_graph_tool.sh
if you are running either the trusty, vivid or wily Ubuntu or the stretch or sid Debian OS releases.
Otherwise you will have to download (and build?) it from the graph-tool website.
To run Visual Dispersy open a terminal and run python dispersyviz_gui.py
.
This will show a window with all experiments in your experiments folder.
You can then set the amount of peers you wish to spawn and their message starting amount.
PRO TIP: you can use python in the message count line with the variable peerid (in range of 1~peercount per spawned process). You can, for example, set the message count to:
10 if peerid==1 else 0
Note that, to get more out of your Visual Dispersy experience, you can set custom targets for display in your graph and have it shut down your experiments for you.
To keep track of targets you can call the following in your community for some target targetname
, its current value currentvalue
and the target value targetvalue
:
# Inside community code:
self.vz_report_target(targetname, currentvalue, targetvalue)
To show Visual Dispersy your peer has finished its business with the community and it wishes to exit once all others are done, you can perform the following blocking call:
# Inside community code:
self.vz_wait_for_experiment_end()
self.dispersy.stop()
Note that if you don't perform this blocking call in a reactor thread but in the bare message handler, you will block Dispersy from handling any other messages.
This project comes with an example Community for your convenience.
It is an updated version of the original tutorial-part1.org
dispersy tutorial by Boudewijn Schoon.