




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、-作者xxxx-日期xxxx软件体系结构复习内容【精品文档】软件体系结构 第 5 讲: 体系结构风格(一)内容简介:l 概述l 管道/过滤器风格l 仓库风格和黑板风格l 分层系统风格l 客户服务器风格l 软件体系结构风格(模式)定义: 一些特定的元素按照特定方式组成的结构, 它有利于解决上下文环境里的特定问题。描述了一族系统,他们拥有一个类似的结构定义了构件(如客户端、服务器)的字典刻画了构件的主要任务和交互方式l 软件体系结构风格与设计模式等的区别 程序设计样式设计模式体系结构风格重点开发原则、可实现性重用、概念完整性重用、概念完整性抽象层次程序构件体系结构使用直接可用直接可用有约
2、束和指导作用l 体系结构风格作用促进设计重用 带来代码重用 使系统易于理解 有利于系统的互操作性l 体系结构风格分类 固定术语类l 管道和过滤器的风格l 仓库风格和黑板风格l 分层系统风格l 客户服务器风格l 数据抽象和面向对象风格l 基于事件的风格l 模型-视图-控制器风格l 解释器风格(虚拟机风格) 参考模型类l 编译器的顺序参考模型和并行参考模型l 信息系统的参考模型管道/过滤器风格l 构件: 过滤器(对数据进行处理)l 连接件: 管道(传输数据)过滤器过滤器过滤器过滤器过滤器过滤器图5-1 管道和过滤器风格体系结构管道管道管道管道管道管道管道l 应用: Unix 的Shell程序 ca
3、t file |grep xyz |sort |uniq out 编译器 信号处理l 编译器从逻辑上可以分成若干阶段,每个阶段把源程序从一种表示变换成另一种表示l 优点: 允许构造松散结构的系统 过滤器的重用很方便 易于扩展和修改l 缺点: 导致批处理风格的系统设计 交互性不强 同步比较困难 应用范围比较狭隘仓库风格和黑板风格l 构件: 中央数据结构(当前状态) 独立构件(对数据进行处理)l 运作方式: 主动式:构件自己决定操作 被动式:由数据仓库的当前状态来决定调用构件(黑板系统)l 黑板系统三大部分 知识源 黑板数据结构 控制器知识源知识源知识源知识源知识源黑板共享数据知识源知识源知识源知
4、识源存储器计算直接存取图5-2 黑板风格的体系结构l 应用: 语音识别 模式识别 三维分子结构建模l 优点:便于多客户共享大量数据,它们不用关心数据何时有的、谁提供的、怎样提供的; 既便于添加新的作为知识源代理的应用程序,也便于扩展共享的黑板数据结构。l 缺点:不同的知识源代理对于共享数据结构要达成一致,而且,这也造成对黑板数据结构的修改较为困难要考虑到各个代理的调用; 需要一定的同步/加锁机制保证数据结构的完整性和一致性,增大了系统复杂度。分层系统风格l 一个分层风格的系统按照层次结构组织,每一层向它的上层提供服务。内核层用户基本功能可用系统过程调用不同元素组合图5-3 分层系统的体系结构图
5、10-5Windows 2000的网络体系结构图10-7 Windows 2000网络体系结构中的TCP/IPl 应用:OSI-ISO七层模型 操作系统 数据库系统 TCP/IP网络协议l 优点:由于对层次的邻接层数目进行了限制,所以系统易于改进和扩展; 每一层的软件都易于重用,并可为某一层次提供多种可互换的具体实现; 分层系统所支持的设计体现了不断增加的抽象层次,这样,一个复杂问题的求解被分解为一系列递增的步骤。l 缺点:系统的分层可能会带来效率方面的问题; 应当如何界定层次间的划分是一个较为复杂的问题。l 构件:客户构件 服务器构件l 连接件:进程间通信机制l 两种特殊的客户服务器风格 代
6、理l 服务器的服务交给一个代理,由代理来向客户提供服务l 代表性应用:CORBA SOAP WebService UDDI P2Pl 客户服务器对称,既是客户又是服务器l 代表性应用: BT, Emule, Kazza 应用: 大量的信息管理系统 优点:有利于分布式的数据组织; 构件间是位置透明的,客户和服务器都不用考虑对方的运行位置; 便于异质平台间的融合与匹配,客户和服务器可以运行不同操作系统; 具有良好的可扩展性,易于对服务器进行修改、扩展或增加服务器; 缺点:客户必须知道服务器的访问标识,否则很难知道有哪些可用服务。 l 分层系统风格实例l 数据抽象和面向对象风格l 基于事件的风格l
7、模型-视图-控制器风格l 解释器风格(虚拟机风格)l 信息系统的参考模型l 体系结构风格的选择分层系统风格实例l 系统描述:劳动和社会保险管理信息系统 系统的功能是完成劳动和社会保险的主要业务管理,即“五保合一”管理,包括养老保险、医疗保险、劳动就业和失业保险、工伤保险、女工生育保险。整个业务流程十分复杂,牵涉面相当广泛。例如,整个系统要与银行、企业、事业机关、医院、财政部门、税务部门、邮局等多种单位建立连接关系。 核心层 通用打印基类 通用查询基类 权限验证基类 通用数据库连接基类 字符处理基类 码表维护基类 数据转换基类 基层单位管理平台 业务管理系统 扩展应用层数据抽象和面向对象风格l
8、构件: 数据和操作的复合体对象l 连接件: 函数或过程调用l 应用: COM, CORBA等l 优点: 隐藏实现细节 继承性,有利于重用l 缺点: 过程调用依赖于对象标识的确定 不同对象的操作关联性差基于事件的风格(隐式调用)l 构件: 模块l 连接件: 对事件的显式/隐式调用agentagentagentagent广播媒介图5-6 基于事件的体系结构风格声明事件监听事件监听事件声明事件l 应用: 各种基于事件响应的Windows程序l 优点: 事件广播者不必知道哪些部件会被事件影响 有利于软件复用,任何构件均可以注册其相关事件 系统演化、升级比较简单l 缺点: 构件的调用不是主动的 系统正确
9、性难以推理模型-视图-控制器风格 3种构件l 视图:负责显示信息l 模型:负责维护数据,是应用程序的核心l 控制器:负责与用户的交互用户视图控制器模型问题领域的应用程序查看使用操作更新图5-7 模型视图控制器风格的体系结构l 应用: Visual Studio提供的文档视图结构 各种可以更换皮肤的软件l 文档 数据容器l 视图: 查看数据的窗口或是和数据发生交互的窗口。 l 文档/视图的核心是四个关键类: CDocument(或 COleDocument)类支持用于存储或控制程序数据的对象,并为程序员定义的文档类提供基本功能。文档表示数据单元,用户一般用“文件”菜单上的“打开”命令打开它,并用
10、“文件”菜单上的“保存”命令保存它。 CView(或它的许多派生类之一)为程序员定义的视图类提供基本功能。视图被附加到文档并在文档和用户之间充当中介:视图在屏幕上呈现文档的图像并将用户输入解释为对文档的操作。视图还为打印和打印预览呈现图像。 CFrameWnd(或其变体之一)支持在文档的一个或多个视图周围提供框架的对象。 CDocTemplate(或 CSingleDocTemplate 或 CMultiDocTemplate)支持一个对象,该对象协调给定类型的一个或多个现有文档并对创建该类型的正确文档、视图和框架窗口对象进行管理。l 文档视结构带来的好处主要有: 首 先是将数据操作和数据显示
11、、用户界面分离开。这是一种“分而治之”的思想,这种思想使得模块划分更加合理、模块独立性更强,同时也简化了数据操作和数据显 示、用户界面工作。 MFC在文档/视结构上提供了许多标准操作界面,包括新建文件、打开文件、保存文件、打印等,减轻了用户的工作量。 支持打印预览和电子邮件发送功能。l 以下情况不宜采用文档视结构: 不是面向数据的应用或数据量很少的应用程序,不宜采用文档/视结构。如一些工具程序包括磁盘扫描程序、时钟程序,还有一些过程控制程序等。 不使用标准的窗口用户界面的程序,象一些游戏等。l 优点: 简化系统设计, 界面友好l 缺点: 适用范围比较狭隘,局限在用户界面软件开发领域解释器风格(
12、虚拟机风格)l 构件; 被解释程序 执行引擎 执行引擎的当前状态 被解释程序的当前状态l 连接件: 过程调用 存储器访问l 应用: 各种虚拟机,如Java虚拟机 各种脚本语言的解释器,如Perl等l 优点: 应用程序的可移植性和程序设计语言的跨平台能力 对硬件进行仿真l 缺点: 效率比较低信息系统的参考模型图5-16 ISO的OSI参考模型体系结构风格的选择问题描述:l 仓库风格 优点:l 数据共享适合采用高效的表达方式l 计算分布于独立模块,符合呈现问题的自觉思维习惯 缺点:l 不易修改,共享数据表示将影响到所有模块l 数据抽象风格 优点:l 易于修改,数据表示和算法可以在单独模块修改而不会
13、对模块间产生相互影响l 更好地支持重用 缺点:l 不易更改系统功能,除非打破模块界限或增加新的模块l 修改现存模块将导致模块简洁性和完整性受到破坏l 管道过滤器风格 优点:l 维护了一种直觉的处理流程l 更好地支持重用,容易加入新功能 缺点:l 很难支持与用户的交互l 空间使用效率低,每个过滤器必须拷贝全部数据到它的输入口Lecture 7. Domain Specific SA Style-P2P architecture1. Problems with traditional C-S architecture2. Introduction to P2P3. Basic Knowledge
14、of Peer-to-Peer Architecture4. Hybrid P2P architecture5. Pure P2P Architecture6. Pure Peer-to-Peer architecture: Gnutella7. Peer node Architecture, 每个节点的结构8. Data Transfer Mechanism from Node to Node9. Some Issues of Further P2P Evolution . Problems with traditional C-S architectureProblem 1: 很难在海量信
15、息中找到有价值的东西. First, no single search engine can locate and catalog the ever-increasing amount of information on the Web in a timely way Google claims that it searches about 1.3x108 web pages Finding useful information in real time is increasingly difficultProblem 2: 互联网的应用不平衡. Second, although miles
16、of new fiber have been installed, the new bandwidth gets little use if everyone goes to Yahoo and eBay for content Hot spots just get hotter while cold spots remain cold Internet has not been utilized efficiently Resources have not been used efficientlyProblem 3: 服务器的压力. Pressure: As the number of u
17、sers increases, there is a higher demand for computing power, storage space, and bandwidth associated with the server-side Problem 4:可靠性是个问题 Reliability (可靠性) The whole network will depend on the highly loaded server to function properly If a server is down, then the client may suffer heavy losesP2P
18、C/S1. P2P enables any network-aware device to provide services to another network-aware device2. A peer in P2P network acts as both a client and a server. Basic Knowledge of Peer-to-Peer ArchitecturePeer-to-Peer: the Third Generation of the Internet!What is Peer-to-Peer (P2P)? Peer-to-Peer computing
19、 is described as the sharing of computer resources and services by direct exchange between systems. 共享计算机资源 These resources include a) the exchange of information, 信息交换b) processing cycles, 处理能力 (过程,周期)c) cache storage, and 高速缓冲存储器存储d) disk storage for files. 硬盘存储Advantage of P2P-P2P 结构的优点a) It allo
20、ws economical clients (desktop computers, etc) to take advantage of their collective power to benefit the entire enterprise (发挥集体优势)b) Clients in a P2P network are also servers (大家都是客户端,大家都是服务器)c) The load on servers in the traditional sense has reduced (服务器压力减轻了4. hybrid P2P architecture (杂交的P2P结构)
21、 客户互动机制. The interaction between clients by referencing a Directory Server n Client A issues a request to the Directory server 客户A发一个请求给目录服务器n The Directory server then uses the lists it keep to find the peer that contains the content that Client A interests in and tells Client A 目录服务器找到客户A感兴趣的服务器n
22、Client A can then directly interact with that client, in this case Client D which services his request. 客户A 和那个客户直接互动. Detailed description of How one peer interacts with another peer Step 1. When the user connects to the network, the peer first attempts to connect to a directory server (首先连接到目录服务器)
23、 to locate each of the users buddies and 寻找朋友 to register the location of the user that is now coming on-line 登记在线的用户的地址 Note: If a directory service is not available or if information is not available for a particular buddy, the peer first falls back on cached knowledge about the locations of buddi
24、es (如果找不到目录服务器或者朋友信息,到缓存去找) by deriving from previous contact with a directory service, previous contact with those buddies, or information entered by the user. Cache: 高速缓冲存储器n Step 1 (cont) Once peers are located, they can provide information about their capabilities and the services they provide.
25、(找到了朋友,就知道了他们的信息) Step 2. Opening the lines of communication (开通通讯线路) After it determines their locations, the peer then attempts to establish contact with all of the buddies that it has found. The peer can use a user interface for contacts The user interface provides information to the user about w
26、hat other users are on-line. Pure P2P ArchitectureCharacteristics of Pure P2P Architecturea) Peers can act as clients and servers and have the same capability as its neighbors.b) It has no central servers. It has every node as a Peer and has no central router.c) There are two routing structures,
27、16; one is a distributed catalogue (分布式目录) and Ø the other direct messaging. 两台计算机建立联系的过程: 1. Send message to all peers: who has “200 Days on the Moon” 2. Got answer: I have 3. Build direct connection 什么是纯的P2P模型? Gnutella, a Pure P2P Model is a file sharing application and protocol: the end hos
28、ts join Gnutella by connecting to existing end hosts already on the Gnutella. How Gnutella works? 用互相传送消息的方法,实现文件共享 To facilitate file sharing, messages are sent between end hosts. How Gnutella works? 怎样查询广播和回答? 广播要查询的文件 Queries for files are broadcasted on the overlay network, and 回答被发送到初始的发广播的那个pe
29、er Replies are routed back to the host that originally generated the query through the overlay network. 工作步骤-Steps:1. Node A is first connected to the network.2. It Pings to the other Nodes (B and C) to discover new nodes on the network.3. A pong message is sent as a reply to a ping and provides inf
30、ormation on a network node, including IP address, port number, and number of files shared.4. A query message is used to search for files shared by other nodes on the network. It contains a query string and a minimum requested link speed.5. A query reply message contains a list of one or more files w
31、hich match a given query, the size of each file, and the link speed of the responding node.6. A push message is used to upload file to clients behind a firewall who can not download files themselves.Note: For the connection, a node has to know the IP of the other node that is already online.a) once
32、it is connected, it makes an announcement that it is online. b) Each of the other nodes reply to the message of information like the number of files it contains and the other details. b) For the file sharing to happen, the node acts as a HTTP Web Server.c) If the search has to download, it connects
33、to the node in the same way as a browser would connect to a web server. How long will a specific request "live“? 存活时间. TTL: "time to live". It determines how long a specific request will "live" on the network. The number is actually how many "layers" each request w
34、ill pass through, where a layer is when one servant has sent the request to all of the servants connected to it. Gnutella Protocol Gnutella is a distributed protocol, since there are no Gnutella servers in the traditional sense, like web servers or mail servers. Gnutella Protocol (cont) Gnutellas pr
35、otocol is such that the clients become servers and they become clients at the same time. A node is a Client when it is looking for some data and is a Sever if it is servicing a request of another node. The communication between the nodes is done by the TCP/IP protocol.Properties of Gnutellaa) If one
36、 computer goes down the network is unaffected, Hence more reliable.b) Gnutella permits swapping files of any type. c) Gnutella is anonymous-there is no need to provide a name or e-mail address to use Gnutella, since.匿名的. d) Gnutella provides a mechanism of resource sharing: People can share their fa
37、mily photos, masters thesis, computer program, and home movies - anything they want! 资源共享e) Gnutella is Pure P2P and is completely decentralized.f) 开发组织Developing OrganizationGnutella has become much popular recently so there are not a single organization that is very popular, rather there are many
38、who are upcoming. a) LimeWire, b) BearShare, c) Morpheus d) Etc. 7. Peer Node Architecture 每个节点的结构Peer-to-Peer Network Architecture P2P is a type of network in which each workstation has equivalent capabilities and responsibilities. Using the HTTP protocol, peers link together in networks to share i
39、nformation and services.Functionalities of a Peer Each peer provides a basic set of core services: Ø handles communication with the network, Ø manages information about the location, status, and privileges. Ø provides the foundation for extension modules The architecture of a Peer The
40、 architecture of a Peer implements the layered architectural Pattern. The functions are layered one on top of the other. 1. web server 2. Servlet engine3. The request manager 4. The event service 5. Buddy manager6. Access control2. 网络服务器基础层的功能. The system is based on top of a Web server and servlet
41、engine that trigger functionality based on incoming HTTP requests. 1. The network infrastructure may vary by platform and provides the binding to the Web services available on that platform. 2. It provides simple parsing of the HTTP requests, passing the content on to the platform independent reques
42、t manager.Request Manager receives the HTTP request from the server and, depending on the content, invokes services within the peer to handle the request. 模块注册请求并提供服务. Loaded modules may register for requests based on the URL. When the request manager passes a request to a module, it can provide the
43、 response (if any) to be returned, or pass the request along to another module for additional processing. Event Service (事件服务). Receive events that are passed over HTTP. The events carry the bulk (大多数) of communication between peers. Functionalities of Event service (事件服务的功能)Ø receive the event
44、s (接收事件)Ø invoke the services that have registered interest in those events (调用对到来事件感性趣的服务)Ø allow components to send events to other peers本机可以通过事件服务发送事件给其他的peer. 每个事件中包含的内容 Within each event is information about its creation: the address of the creator, a local timestamp, and a globally u
45、nique identifier string. Buddy Manager (朋友管理器) Functionalities Buddy Manager is a means of Ø identifying individual users and (确认用户)Ø controlling the access relationships between peers: who may access resources and about whom the user would like information (控制访问关系)Access Controller (访问控制)
46、 利用到来事件信息决定那些用户是否受欢迎Ø Information in the incoming event or HTTP request serves to identify users as being welcome or notØ It also defined levels of access, thus the user may permit or deny access to services. Module Container (模块箱) Dynamically loaded extension modules that provide new func
47、tionality for specific applications extend the peers core functionality. Ø Allow custom configuration of peers, in most cases even while the peer is running. (定制配制)Ø May be mapped to handle incoming HTTP requests, register for events, send events to other peers, etc. (处理请求)Ø Can commu
48、nicate in a controlled fashion with other modules within the same peer (和其他模块交流)8. Data Transfer Mechanism from Node to Node P2P 用管道-过滤器结构交流The Peer-to-Peer system uses Pipes and Filters to effectively transfer data from one system to another. Functionalities of a filter When a peer requests for a file, a filter component effectively filters the unwanted files which do not match the search criteria and produces a result in the form of a list to the query. (过滤掉不需要的文件) Functionalities of a pipe Then when the user chooses
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 环境工程视频课件
- 《课件制作的核心素质》
- 管道工程行业政策支持与挑战考核试卷
- 胶合板供应链的优化与整合考核试卷
- 2025年一级建造师之一建建设工程经济通关提分题库(考点梳理)
- 2025年LED照明灯具项目合作计划书
- 猫咪美术课件
- 中国水仙盆行业市场前景预测及投资价值评估分析报告
- 岗位责任制考试试题及答案
- 2025年嵌丝橡胶道口板合作协议书
- 2023年航空服务消费者调查报告
- 航空公司客户服务沟通技巧考核试卷
- 服装店员工考勤管理制度
- 2024年国家图书馆招聘应届毕业生105人历年高频500题难、易错点模拟试题附带答案详解
- 铁路信号技师技术总结
- 建筑中级职称《建筑工程管理》历年考试真题题库(含答案)
- 洗瓶机推瓶机构设计计算说明书+运动简图+运动循环图
- 2024年山东省高中学业水平合格考生物试卷试题(含答案详解)
- 医疗器械追溯制度
- 小学六年级下册数学期末考试卷完整版
- 工程伦理案例与分析
评论
0/150
提交评论