bb060338b359a03aaf600cbfdbc5026a.ppt
- Количество слайдов: 138
第 2章 分布式通信 中国科技大学软件学院 丁箐
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 2. 7 分布式对象 2. 8 组通信 2
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 2. 7 分布式对象 2. 8 组通信 3
2. 1 通信基础 l l l 开放式系统:使用标准化规则与其它开放系统 通信的系统 协议:进程间通信所必须遵循的规则,消息的 格式、内容和意义 协议的种类 – l 分层协议 – – 4 面向连接、非面向连接 ISO OSI参考模型 Internet
OSI参考模型分层协议 进程A 5 进程B
The Internet 协议 Application TCP UDP IP Network 6 Messages (UDP) Streams (TCP) Transport Datagrams
典型消息结构 7
网络技术的发展(1) l 分组交换协议 – l TCP/IP协议 – – l R. Kahn(MIT, ARPA), V, Cerf(UCB, Stanford), 《IEEE通信》974 CDMA协议与Ethernet – – 8 Dr. L. Kleinrock(MIT), 1962 Dr. B. Metcalfe(HU, MIT,PARC), 1973 3 COM, 以太网适配器
网络技术的发展(2) l ARPANET与Internet – – – l Stanford校园网与LAN – – 9 IPTO, Dr. J. Licklider(1960), Dr. B. Taylor(1966) Dr. L. Roberts(MIT),BBN公司 ARPANET(1969, UCB, SRI) L. Bosack, S. Lerner(Stanford), 1980 -1983 Cisco(1984), Cisco路由器
ATM网络技术 l l 分组交换、线路交换和信元交换 信元(cell): – l 信元交换: – 10 小的、定长的单元 同时支持点到点(point-point)和多播(multicast) 功能
ATM参考模型 l 物理层: – – – l 上面各层 ATM层: – l SONET OC-1(51. 8 M), OC-3 c(155 M) 信元传输和路由 适配层: – VBR,CBR 适配层 ATM层 物理层 11
信元头格式 12
ATM交换网络及交换机内部构造 13
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 2. 7 分布式对象 14 2. 8 组通信
2. 2 客户/服务器模型 v 服务器:为用户提供服务的一组协同进程 v 客户:代理用户 15
客户/服务器(1 -1) Client invocation result Client 16 invocation Server result Server
客户-服务器交互 (I) • Remote procedure call 17
客户-服务器交互(II) • 多层结构 18
客户-服务器交互(III) • 异步 remote procedure call 19
客户/服务器(1 -N) 20
Example: Web proxy server 21
客户-服务器交互(IV) 22
Peer-to-Peer 合作 23
Mobile Code Example: Applet 24
瘦客户 Compute server Network computer or PC Thin Client 25 network Application Process
消息格式 struct message { long source; /* 发送者标识*/ long dest; /* 接受者标识 */ long opcode; /* 操作码:读、写、创建、删除 */ long result; /* 返回结果代码 :成功、失败*/ long offset; /* 读写位置 */ long count; /* 读写计数 */ char filename[MAX_PATH}; /* 文件名*/ char data[BUF_SIZE]; /* 数据区*/ } 26
服务器程序 void main(void){ struct message m 1, m 2; /* 输入、输出的消息 */ int r; /* 返回的执行结果 */ while (1) { receive(FILE_SERVER, &m 1); /* 等待客户请求 */ case(m 1. opcode) { /* 执行请求的操作 */ case READ: r = do_read(&m 1, &m 2); break; : default: r = E_BAD_OPCODE; } m 2. result = r; send(m 1. source, &m 2); /* 返回结果 */ } } 27
客户程序 int read(char *file, int position , int nbytes, char *buf){ struct message m 1; /* 消息缓冲区 */ m 1. opcode = READ; /* 设置参数 */ m 1. offset = position; /* 读位置 */ m 1. count = nbytes; /* 读长度 */ strcpy(&m 1. filename, src) /* 文件名 */ 28 send(FILE_SERVER, &m 1); /* 发送请求 */ receive(CLIENT, &m 1); /* 等待服务器应答 */ if(m 1. result == OK) strcpy(buf, &m 1. data); /* 置缓冲区 */ return(m 1. result); /* 返回结果 */ } }
寻址方式(Addressing) 1、机器号+本地标识号 例:UNIX – – 机器IP地址 端口号(port) /* Socket address, internet style. */ struct sockaddr_in { short sin_family; /*AF_INET*/ u_short sin_port; struct in_addr sin_addr; char sin_zero[8]; }; 29
2、广播定位进程 –全局唯一标识号 30
3、ASCII码进程名 –名字服务器 31
阻塞与非阻塞原语 (1)阻塞发送原语 – 同步原语 时间 (2)非阻塞发送原语 – 异步原语 –在消息被发送之前, 发送者不能修改消息 缓冲区 32 时间
有缓冲与无缓冲型接收 l 无缓冲区 发送比接收先发生 ? – 直接丢弃消息 – 暂存“意外”消息 l 有缓冲区 – – – 33 邮箱(mailbox): 缓存所有的输入消息 “溢出”问题
可靠的和非可靠的发送和接收 非可靠的收发 l – – 可能丢失消息 由用户负责确认 独立的确认消息 l – 内核-内核确认 应答用作请求的确认消息 l – – 客户内核确认 折衷方法 l 34 服务器端设置计时器,超时后,发确认消息
35
实现技术小结 项目 选择 2 寻址 机器+进 程 共享进 程地址 ASCII名字通过 服务 器 查找 阻塞 阻塞原语 具有拷贝 到核的非 阻塞 具有中断的非阻塞 原语 无缓 冲,丢 弃不期望的 消息 无缓 冲,临时 保持 不期望的消息 邮箱 可靠性 36 选择 1 选择 3 非可靠 请 求-应 答确认
客户/服务器协议中的包类型 代码 来源 至 说明 REQ 请求 客户 服务 器 客户 要求服务 REP 应答 服务 器 客户 服务 器对 客户 的应 答 ACK 确认 服务 器、客 户 其他 前面的包已到达 AYA 你在这 里吗 ? 客户 服务 器 查 看服务 器是否崩溃 IAA 我在这 里 服务 器 客户 服务 器没有崩溃 TA 再试 一次? 服务 器 客户 服务 器没有空间 AU 37 包类型 地址未知 服务 器 客户 没有进 程在使用此地 址
包交换举例 38
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 2. 7 分布式对象 39 2. 8 组通信
2. 3 套接字socket • socket通信的基本原理 • socket通信的 作过程 40
l 一个socket在逻辑上有三 个特征(三要素): –网域 –类型 –规程 41
l 网域:表明一个socket用于哪一种网络 或说哪一族网络规程。各种网络对节点 地址的命名方法不同,又称“地址族” 或“规程族”。 – AF_INET表示Internet网插口,故各节点使用IP 地 址 。 AF_IPX为 Novell的 IPX网 插 口 , AF_X 25为 X. 25网插口,等等。其中的特殊,不走网络而在 同一台计算机上用于进程通信,BSD称为AF_UNIX, 在POSIX标准里定义了一种AF_LOCAL域名。 42
l 类型:表明网络中通信所遵循的模式 – – 43 “面向连接”:又叫“虚电路”模式,通信双方先要在互 相之间建立起一种虚拟连接(线路),再通过虚拟线路进行 通信。在通信过程中,所有报文传递保持原来次序,所以, 报文之间是有关联的,每个报文都不是孤立的。在这种模 式中,所有报文的传递都是可靠的,由网络中物理线路引 入差错控制来保证。 “无连接”:事先不必建立虚线路,直接可发送和接收报 文。但报文是孤立的,正确性没有保证,甚至可能丢失。 由于网络延迟或路径不同,接收端收到报文的次序可能与 发送端发送报文的次序不一样。这种模式传递的报文是不 可靠的,无保证的。也没有“流量控制”手段,进程从系 统调用返回时仅表明该socket会把报文发送去,并不表明 报文已到达了接收方的socket。
l 规程:表明具体网络规程。一般来说, 网域与类型结合作一起就大体上决定 了规程。如网域为AF_INET,而类型 为“无连接”,则规程大致为UDP了。 但有时,还会有其他选择。 44
Berkeley Sockets API Primitive Socket Attach a local address to a socket Listen Announce willingness to accept connections Accept Block caller until a connection request arrives Connect Actively attempt to establish a connection Send some data over the connection Receive some data over the connection Close 45 Create a new communication endpoint Bind l Meaning Release the connection Socket primitives for TCP/IP.
基本的socket调用 socket sockaddr_in() bind socket localhost sockaddr_in() connect listen sockaddr_in() accept 46 peer recv send SERVER CLIENT peer
服务器方 客户方 socket()建立数据报式套 接字,返回套接字号 bind()把套接字s与本地 地址相连接 recvfrom()/sendto()在s 上读写数据,直至结束 closesocket()关闭套接 字,服务结束 47 socket()建立数据报式套 接字,返回套接字号 closesocket()关闭套接 字,结束对话 无连接协议的套接字调用时序
服务器方 socket()建立流式套 接字,返回套接字号s bind()把套接字s与本 地地址相连 客户方 listen()通知TCP/IP, 服务器准备好接收连接 建立连接 accept()接收连接, 并得到第二个套接字 ns recev()/send()在ns 服务请求 上读写数据,直到结 服务响应 束 closesocket() 关闭套接字ns closesocket() 关闭最初套接字 s 48 socket()建立流式套 接字,返回套接字号 s connect()把套接字s 与远程主机相连 send()/recev()在ns 上读写数据,直到结 束 Closesocket()关闭套 接字s,结束TCP/IP对 话 面向连接的套接字调用时序
Berkeley Sockets调用 l 49 Connection-oriented communication pattern using sockets.
数据流 (1) l 50 Setting up a stream between two processes across a network.
数据流(2) l 51 Setting up a stream directly between two devices.
数据流(3) l 52 An example of multicasting a stream to several receivers.
定义 Qo. S (1) Characteristics of the Input Service Required lmaximum l. Loss data unit size (bytes) l. Token bucket rate (bytes/sec) l. Toke bucket size (bytes) l. Maximum transmission rate (bytes/sec) l 53 A flow specification. sensitivity (bytes) l. Loss interval ( sec) l. Burst loss sensitivity (data units) l. Minimum delay noticed ( sec) l. Maximum delay variation ( sec) l. Quality of guarantee
定义 Qo. S (2) l 54 The principle of a token bucket algorithm.
配置流 l 55 The basic organization of RSVP for resource reservation in a distributed system.
同步机制 (1) l 56 The principle of explicit synchronization on the level data units.
同步机制 (2) l The principle of synchronization as supported by high-level interfaces. 2 -41 57
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 2. 7 分布式对象 58 2. 8 组通信
2. 4 远程过程调用 l 允许程序去调用位于其它机器上的过程 – l 举例: – – l int read(int fd, char * buf, int nbytes); count = read(fd, buf, nbytes); 参数传递 – – 59 调用者和被调者都不用考虑消息通信 call-by-value call-by-reference
传统的过程调用 a) b) 60 本地过程调用中的参数传递:调用读前的堆栈 调用过程激活时的堆栈
软件层 RPC and RMI request-reply protocol marshalling and external data representation middleware Applications and Services UDP and TCP RPC is more than a (transport) protocol: a structuring mechanism for distributed systems 61
RPC中的调用与消息 客户机 服务器 客户应用 客户存根 服务存根 5 本地调用 1 打包 参数 10 返回结果 OS内核 62 拆包 参数 本地调用 拆包 参数 4 客户 客户 服务应用 2 打包 参数 7 9 3 8 网络消息 传送 6 返回结果 OS内核 服务过 程
RPC执行的主要步骤 1. 客户过程以普通方式调用相应的客户存根。 2. 客户存根建立消息并激活内核陷阱。 3. 内核将消息发送到远程内核。 4. 远程内核将消息送到服务器存根。 5. 服务器存根取出消息中的参数后调用服务器的过程。 6. 服务器完成 作后将结果返回至服务器存根。 7. 服务器存根将它打包并激活内核陷阱。 8. 远程内核将消息发送至客户内核。 9. 客户内核将消息交给客户存根。 10. 客户存根从消息中取出结果返回给客户。 63
客户和服务Stubs l 64 Principle of RPC between a client & server program.
异步RPC (I) 65
异步RPC (II) 66
编写Client和Server的步骤 67
RPC编程举例 /* 生成RPC程序 */ rpcgen FILE_RPC. x ==〉编译结果 /* 参数定义 */ FILE_RPC_xdr. c /* 服务器端程序 */ FILE_RPC_svc. c /* server存根 */ FILE_RPC_server. c /* 服务器模版程序 */ /* 客户端程序 */ FILE_RPC_clnt. c /* client存根 */ FILE_RPC_client. c /* 客户模版程序 */ 68
RPC申明-- File_RPC. x #define RPC_ARGSIZE 256 #define RPC_RETSIZE 256 /* the interface version number */ #define u. SERVERVERS 1 /* program number range established by ONC */ #define u. SERVERPROG 0 x 20000051 struct Call. Arg_t { char body[RPC_ARGSIZE]; }; /* RPC's arg data form */ 69 struct Return_t { char body[RPC_RETSIZE]; }; /* RPC's arg data form */ /* program definition*/ program SERVERPROG { version SERVERVERS { Return_t FILE_CREATE(Call. Arg_t) = 1; Return_t FILE_READ(Call. Arg_t) = 2; Return_t FILE_WRITE(Call. Arg_t) = 3; Return_t FILE_DEL(Call. Arg_t) = 2; } = u. SERVERVERS; } = u. SERVERPROG;
RPC服务端程序 -- File. RPC_svc. c . . . void main 2() { SVCXPRT *transp; transp = svcudp_create(RPC_ANYSOCK); svc_register(transp, SERVERPROG, SERVERVERS, serverprog_1, IPPROTO_UDP); /* 注册 */ transp = svctcp_create(RPC_ANYSOCK, 0, 0); svc_register(transp, SERVERPROG, SERVERVERS, serverprog_1, IPPROTO_TCP)) ; /* 注册 */ svc_run(); // 启动RPC exit(1); } static void serverprog_1(struct svc_req * rqstp, SVCXPRT * transp) { 70 union { Call. Arg_t file_create_1_arg; Call. Arg_t file_read_1_arg; : } argument; switch (rqstp->rq_proc) { : case FILE_READ: xdr_argument = xdr_Call. Arg_t; xdr_result = xdr_Return_t; local = (char *(*)(char *, struct svc_req *)) file_read_1_svc; break; : default: svcerr_noproc(transp); return; } }
RPC客户端程序 -- File. RPC_clnt. c . . . /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 25, 0 }; Return_t * file_read_1(Call. Arg_t *argp, CLIENT *clnt) { static Return_t res; bzero((char *)&res, sizeof(res)); if (clnt_call(clnt, FILE_READ, xdr_Call. Arg_t, argp, xdr_Return_t, &res, TIMEOUT) != RPC_SUCCESS) return (NULL); } return (&res); } . . . 71
基本RPC操作 (a)调用read之前的栈; b)调用过程处于激 活状态时的栈; (c)返回调用者之后的 栈 l 值参调用和变参调用 l 72 call-by-copy/restore
参数定义和产生Stub 73 procedure Corresponding message
参数传递 • • 74 参数编组(marshalling): 将 参数装入消息 例:add(i, j)远程计算
参数传递问题 • 编码表示:ASCII, EDBIC • 数字表示:小末端、大末端 规范形式:整形、字符型、布尔型、浮点型等 v 指针参数: Ø Ø 75 copy/restore dereference
参数传递问题 (a)486中的原始消息; (b)在SPARC上接受到的消息; (c)经过翻译之后的消息;(框中的小数字表明 了每一个字节的地址) 76
建立表示基本数据类型的标准 77
参数传递问题 l 如何传递 指针 ? – l 已知长度的数组和结构 – – l 只有在特定地址空间才有意义! Copy/restore 语义 IN/OUT/INOUT 标签 到任意数据结构的指针 ? – – 没有一般的解决办法 通常: l 78 把指针传递给它的 “源”
客户如何定位服务器呢? l l 79 将服务器的网络地址固化到客户机中 动态捆绑
动态捆绑 客户 查找 绑定器 80 绑定、调用 注册、取消 服务器
绑定(SUN RPC) Port Mapper (rpcbind) listens at UDP port 111 Server registers program ID & version l l – rpcinfo -p -> display all registered RPC servers When client issues clnt_create, the port mapper is contacted: l – program-to-port number mapping l l 81 arguments: (program ID, version, protocol) response: server’s port number
绑定(DCE) 82
绑定接口 调用 输 入 注册 名字、版本、唯一id 查找 名字、版本 句柄(handle): 如IP地址 唯一标识(ID):程序号 认证:身份标识 83 出 名字、版本、句柄、唯一id 注销 输 句柄、唯一id
RPC故障处理 1. 客户不能定位服务器 a) b) 2. 丢失请求信息 a) 3. 超时重发 丢失应答信息 a) b) 84 返回错误号errno 产生例外:SIG_NOSERVER 等幂性请求 序号
RPC故障处理 4. 服务器崩溃解决 a) b) c) d) 至少一次语义 (重发请求 ) 至多一次语义 (立即放弃并报告失败) 不做任何保证 恰好一次? (a)正常状态;(b)执行后崩溃;(c)执行前崩溃 85
RPC故障处理 5. 客户崩溃 – – 孤儿问题:资源浪费、资源封锁 解决方案: l l 86 根除(日志文件 ) 再生(epochs, 所有远程计算被终止 ) 温和再生(试图去找到该远程计算的调用者 ) 过期(标准时间段T )
RPC实现技术 l RPC可以使用哪些协议? – TCP 提供可靠传输 l – – – UDP 不提供可靠传输,但RPC执行RETRANSMIT timeou 因此在total timeout后,无论使用TCP或UDP都重复请求 TCP需要建立连接 l – – 87 ACKs, timeouts, retransmissions 对于一些短的RPCs,有额外开销 专门协议 信包和报文的长度
RPC实现技术 确认 l l 88 停等(stop-and-waitt)协议(b) 爆发 (blast)协议© 差错控制 流量控制:数据溢出(overrun)
RPC实现技术 3. 关键路径 客户机 调用存根过程 准备消息缓冲区 将参数编排进缓冲区 填写消息头 陷入内核 将上下文切换到内核 将消息复制到内核 确定目的地址 将地址写入消息头 设置网络接口 启动计时器 89 服务器 执行服务 调用服务器 在堆栈上设置参数 解析参数 将上下文切换到存根 将消息复制到存根 检查存根是否在等待 确定使用哪个服务器存根 检查消息包的有效性 处理中断
RPC实现技术 拷贝 4. 客户存根 网络 内核 – – – 90 DMA 分散-聚集(scatter-gather) 虚拟内存映射 服务器存根 内核
RPC实现技术 计时器管理 5. 计时器列表 – 扫描算法(sweep algorithms) (a)排序表中的时间片耗 尽; (b)进程表中的时间片耗 尽 – 91
RPC实现技术 6. 存在的问题 – – 全局变量的共享 弱数据类型的传 递,数组? 指针传递 管道:读驱动、 写驱动 (a)管道 (b)读驱动方法 (c)写驱动方法 92
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 2. 7 分布式对象 93 2. 8 组通信
2. 5 Web Services “Web services” is an effort to build a distributed computing platform for the Web. 94
Web Services 框架 l 可以用术语描述为: – – What describes what goes on the wire: Description languages. – 95 What goes “on the wire”: Formats and protocols. What allows us to find these descriptions: Discovery of services.
Web-Services 体系结构 服务提供方 服务代理方 WSDL docs XSD docs Servlets, CGI, Perl 1 创建业务/服务 UDDI Registry 2 检索 WSDL文档 发现业务/服务 5 6 3 调用服务 4 8 使用 e 7 services的应 用 SOAP消息 服务请求方 96
XML Messaging: SOAP l SOAP 1. 1 defined: – An XML envelope for XML messaging, l – An HTTP binding for SOAP messaging. l – – l SOAP is “transport independent”. A convention for doing RPC. An XML serialization format for structured data SOAP Attachments adds – 97 Headers + body How to carry and reference data attachments using in a MIME envelope and a SOAP envelope.
The SOAP Envelope <SOAP-ENV: Envelope xmlns="http: //schemas. xmlsoap. org/soap/envelope/"> < SOAP-ENV: Header>. . . </ SOAP-ENV: Header> < SOAP-ENV: Body>. . . </ SOAP-ENV: Envelope> 98
What goes on the wire l l Internet-scale integration needs a lingua-franca – XML messaging protocol over HTTP: SOAP Intra-enterprise integration needs to allow alternates: – CORBA, RMI – Messaging – In-memory method calls Context Transactions Routing Reliability Security SOAP 99 W 3 C Attachments
Descriptions: Meta-data Agreements l Enables dynamic, delayed binding of components. Public Flows l Language extensibility provides support for different levels of application integration. Flows and Composition Service XML Schema WSDL Service Qo. S Interface 10 0 WSFL Integration requires interoperable machineunderstandable descriptions l
Web Services Description Language l Provides functional description of network services: – – l A short history: – – – 10 1 IDL description Protocol and deployment details Platform independent description. Extensible language. WSDL v 1. 0, 9/2000 WSDL v 1. 1 submitted to W 3 C 3/2001. A de facto industry standard.
WSDL Structure Service l port. Type – l Multiple bindings per port. Type: – – l How to access it SOAP, JMS, direct call Ports – 10 2 Abstract definition of a service (set of operations) Where to access it Port Binding (e. g. http: //host/svc) (e. g. SOAP) port. Type operation(s) in. Mesage out. Message Abstract interface
Using WSDL 1. As extended IDL: WSDL allows tools to generate compatible client and server stubs. § 2. 3. Allows industries to define standardized service interfaces. Allows advertisement of service descriptions, enables dynamic discovery and binding of compatible services. § 4. 10 3 Tool support for top-down, bottom-up and “meet in the middle” development. Used in conjunction with UDDI registry Provides a normalized description of heterogeneous applications.
Client invocation l l Single stub can invoke services over different bindings – Depends only on abstract interface. Are independent of binding (but pluggable). – Add new bindings without recompiling/redeploying stub Allows optimisations based on the bindings of service. l Will support extended services models if described In WSDL l 10 4 RMIIIOP Client Proxy object SOAP/ HTTP JMS/ MQ
WSFL Overview l WSFL describes Web Service compositions. [ WS] 1. Usage patterns of Web Services: describes workflow or business processes. 2. Interaction patterns: describes overall partner interactions. 10 5 [ WS] A C B
WSFL Flow Models Control links define execution flow as a directed acyclic graph Activities represent units of processing. [ WS] Flow of data is modeled through data links. 10 6 Activities are associated with specific typed service providers Activities can be mapped to the flow interface
Using Flow Models l “Public flows” provide a representation of the service behavior as required by its users. – – l “Private flows” are the flows executed in practice. – l 10 7 Typically, an abstraction of the actual flow begin executed Defines a “behavioral contract” for the service. Internal implementation need not be flow-based. Flows are reusable: specify components types, but not what specific services should be used! WSFL serves as a “portable flow implementation language” Same language is used in WSFL to represent both types of processes.
Global Models n n n 10 8 Global models describe how the composed Web Services interact. n Rosetta. Net automated. n Like an ADL. Interactions are modeled as links between endpoints of two service interfaces (WSDL operations). An essentially distributed description of the interaction. A C B
Discovery: Finding Meta-data l Static binding requires service “libraries”. l Dynamic binding requires runtime discovery of metadata Directory Inspection 10 9 UDDI ADS, DISCO
UDDI Overview l UDDI defines the operation of a service registry: – Data structures for registering l l l – – SOAP Access API Rules for the operation of a global registry l 11 0 Businesses Technical specifications: t. Model is a keyed reference to a technical specification. Service and service endpoints: referencing the supported t. Models “private” UDDI nodes are likely to appear, though.
Web Service UDDI Relationships Web Service business. Entity business. Service binding. Template Instance. Details category. Bag keyed. Reference 11 1 identifier. Bag keyed. Reference Rosetta-Net BASDA Simple. Buy Schemas, Interchange specification t. Models SIC CODE NAICS DUNS Numbers Thomas Registry ID
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 11 2 2. 7 分布式对象 2. 8 组通信
2. 6 消息队列 l 11 3 四种松散组合的通信使用队列
消息队列原语 Primitive Put Append a message to a specified queue Get Block until the specified queue is nonempty, and remove the first message Poll Check a specified queue for messages, and remove the first. Never block. Notify 11 4 Meaning Install a handler to be called when a message is put into the specified queue.
消息队列的一般结构 (I) l 11 5 队列层地址和网络层地址间的关系
消息队列的一般结构(II) 2 -29 11 6
消息代理 l l 11 7 The general organization of a message broker in a message-queuing system.
IBM MQSeries 11 8
Channels l Some attributes associated with message channel agents. Attribute Transport type Determines the transport protocol to be used FIFO delivery Indicates that messages are to be delivered in the order they are sent Message length Maximum length of a single message Setup retry count Specifies maximum number of retries to start up the remote MCA Delivery retries 11 9 Description Maximum times MCA will try to put received message into queue
消息传输 (I) l 12 0 使用路由表和别名表
消息传输 (II) l IBM MQSeries MQI原语 Primitive MQopen Open a (possibly remote) queue MQclose Close a queue MQput Put a message into an opened queue MQget 12 1 Description Get a message from a (local) queue
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 12 2 2. 7 分布式对象 2. 8 组通信
2. 7 分布式对象 12 3
Binding a Client to an Object Distr_object* obj_ref; obj_ref = …; obj_ref-> do_something(); //Declare a systemwide object reference // Initialize the reference to a distributed object // Implicitly bind and invoke a method (a) Distr_object obj. Pref; Local_object* obj_ptr; obj_ref = …; obj_ptr = bind(obj_ref); obj_ptr -> do_something(); //Declare a systemwide object reference //Declare a pointer to local objects //Initialize the reference to a distributed object //Explicitly bind and obtain a pointer to the local proxy //Invoke a method on the local proxy (b) a) 12 4 b) 使用global references不明确绑定 使用global and local references明确绑定
参数传递 l 12 5 The situation when passing an object by reference or by value. Local vs remote object references
DCE分布式对象模型 a) b) 12 6 Distributed dynamic objects in DCE. Distributed named objects
主要内容 2. 1 通信基础 2. 2 客户/服务器模型 2. 3 套接字socket 2. 4 远程过程调用 2. 5 Web Service 2. 6 消息队列 12 7 2. 7 分布式对象 2. 8 组通信
2. 8 组通信:通信涉及到多个进程 l l 组:由系统或用户确定的若干个进程的集合 – 组的成员籍(membership) 通信方式: – – 12 8 点到点通信(point-to-point): 单播(unicast) 一到多通信(one-to-many) : 多播(multicast)、广播( broadcast)
设计的问题 l 12 9 封闭组与开放组
设计的问题 l 对等组与分层组 参与者 13 0
设计的问题 l 组的成员籍( membership) – – l 组的寻址 – – – 13 1 组服务器 分布式管理 组地址 目的地址列表 谓词寻址(predicate addressing)
设计的问题 l 发送和接收原语 – – – l 原子性 – 13 2 group_send group_receive 单程(one-way)模型 原子性广播:一个消息被所有成员接收到,或者, 一个也没有接收到。
设计的问题 l 消息的顺序 – – 13 3 全局时间顺序(global time ordering) 一致性时间顺序 (consistent time ordering)
组通信的设计 l 重叠组 不同组之间的 协调 – l 可伸缩性 – – 13 4 互联网络 网关
ISIS中的组通信 l l ISIS: 康奈尔大学开发的 具集(1987) 同步类型: – 13 5 同步、弱同步、虚拟同步
ISIS中的组通信 l 事件类型: – – l 因果相关的 并发的 ISIS广播原语 – ABCAST:弱同步 l – – 13 6 两段提交协议 CBCAST:虚拟同步 GBCAST:管理组成员的ABCAST通信
CBCAST协议 l 13 7 n个进程设置n维向量
CBCAST应用举例 13 8
bb060338b359a03aaf600cbfdbc5026a.ppt