Firefly Official Tutorials: Distributed Instructions - 9miao/Firefly GitHub Wiki
Distributed mainly encapsulates communication methods among service processes. The call to interface of child nodes and root nodes processes all returns deferred objects. You can read the “Deferred object” part in Twisted about the using of deferred objects.
PBRoot: node object
ChildsManager: child node management base class
Child: object corresponds with a service process object which attaches to this server process. We call it child node object.
RemoteObject: remote call object which realizes itself in child node service process. We can call the interface method in root node processes via this object.
1) test_distributed_root.py
2) Test_distributed_node.py
3) the aforementioned images are respectively the examples of root and node, now you can run test_distributed_root.py, and you will see the below image, it shows that sever has been started and is monitoring the 1000 port.
Run test_distributed_node.py in five seconds and you will see the below image in root
And see the below image in node:
4) Further explanation: when test_distributed_root.py is running, root monitors 1000 port, BilateralFactory(root) is the protocol to handle messages, and it will call the method “call child node interface” in five seconds. The three parameters: ‘test_node’ is child node id which means the child node interface that will be called; ‘printOK’ is child node method name that will be called; ‘asdfawefasdf’ is the required parameter of the method that will be called. That is to say, root will call printOK with ‘asdfwwefasdf’ parameter of node after five seconds, so test_distributed_node.py need to be started in five seconds.
A running test_distributed_node.py will connect the port that root monitors, so you can see “node [test_node] takeProxy ready” in root, it means child node test_node has been successfully connected to root node and is ready for interacting. Node will call the pringtData1 method in root after one second it starts. The required parameter and execution result is shown above.