Firefly官方教程之Distributed使用文档

6 篇文章 0 订阅
6 篇文章 0 订阅
distributed使用文档  
1、distributed说明  
该模块主要封装了各个服务进程间进行通信的方法。node子节点域root根节点进程中的接口调用返回的都是延迟对象。关于延迟对象的使用,详见twisted中Deferred对象。  
2、结构解析  



PBRoot,root节点对象  
ChildsManager,子节点管理基类  
Child对象对应的是连接到本服务进程的某个服务进程对象。称为子节点对象  
RemoteObject远程调用对象,子节点服务进程中实现。可以通过这对象去调用root节点的进程中的接口方法。  
3、使用示例  
1)test_distributed_root.py  



2)test_distributed_node.py  



3)上面分别为root(根节点)和node(子节点)的例子,运行test_distributed_root.py文件,你会看到下图,说明服务器已经启动,并开始监听1000这个端口。  



5秒内运行test_distributed_node.py文件,你会在root这边看到下图,  



并在node这边看到下图,  



4)解释下,test_distributed_root.py运行时,root回去监听1000这个端口,处理消息的协议为BilateralFactory(root),并在5秒后调用“调用子节点接口”这个方法,后面三个参数,‘test_node’是子节点的id,即要调用哪个子节点的接口,‘printOK’是子节点中要被调用的方法名,‘asdfawefasdf’是要调用的那个方法需要的参数。即root会在5秒后调用node中的printOK这个方法,参数是‘asdfawefasdf’,所以test_distributed_node.py要在5秒内启动。test_distributed_node.py运行时,会去连接root监听的这个端口,所以你会在root这边看到“node [test_node] takeProxy ready”,说明test_node这个子节点已经连到root节点了,可以进行交互了。node会在启动后的1秒后去调root中的printData1这个方法,后面是需要的参数,执行结果如上。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Computers and computer networks are one of the most incredible inventions of the 20th century, having an ever-expanding role in our daily lives by enabling complex human activities in areas such as entertainment, education, and commerce. One of the most challenging problems in computer science for the 21st century is to improve the design of distributed systems where computing devices have to work together as a team to achieve common goals. In this book, I have tried to gently introduce the general reader to some of the most fundamental issues and classical results of computer science underlying the design of algorithms for distributed systems, so that the reader can get a feel of the nature of this exciting and fascinating field called distributed computing. The book will appeal to the educated layperson and requires no computer-related background. I strongly suspect that also most computer-knowledgeable readers will be able to learn something new. Gadi Taubenfeld is a professor and past dean of the School of Computer Science at the Interdisciplinary Center in Herzliya, Israel. He is an established authority in the area of concurrent and distributed computing and has published widely in leading journals and conferences. He authored the book Synchronization Algorithms and Concurrent Programming, published by Pearson Education. His primary research interests are in concurrent and distributed computing. Gadi was the head of the computer science division at Israel's Open University; member of technical staff at AT&T Bell Laboratories; consultant to AT&T Labs–Research; and a research scientist and lecturer at Yale University. Gadi served as the program committee chair of PODC 2013 and DISC 2008 and holds a Ph.D. in Computer Science from the Technion–Israel Institute of Technology.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值