10. Distributed object-based systems

Slides:



Advertisements
Similar presentations
1 Java 语言程序设计 计算机系 鲍金玲. 2 引子 甲骨文 甲骨文是全球最大的信息管理软件及服务供应商,成立于 1977 年,公司总部 设在美国加利福尼亚州的红木城( Redwood Shores ),全球员工达 名, 包括 名开发人员、 7500 多名技术支持人员和.
Advertisements

1 中 间 件 技 术中 间 件 技 术. 2 第 1 章 中间件产生背景及分布式计算环境 主要内容 开放系统 互操作性 中间件.
JAVA 编 程 技 术 主编 贾振华 2010年1月.
第16章 代理模式 Website:
Memory Pool ACM Yanqing Peng.
第一章 C语言概述 计算机公共教学部.
面向对象的程序设计(一).
第8章 系統架構.
操作系统结构.
第二章 JAVA语言基础.
潘爱民 北京大学计算机科学技术研究所 组件技术——最后一讲 潘爱民 北京大学计算机科学技术研究所
新世代計算機概論 第14章 程式語言.
作業系統 第二十章 分散式系統實例.
形式语言与网络 计算环境构建 1.
Operating System Concepts 作業系統原理 Chapter 3 行程觀念 (Process Concept)
第五章 编写服务端程序.
例外處理(Exception Handling)
第五章 信息与系统集成技术 概述 数据流集成技术 信息流集成技术 信息管理集成技术 流程重组与业务流程集成 企业门户集成 企业集成架构
分布式对象标准介绍 企业要构建多层分布式系统,必须遵循分布式标准,基于什么样的标准将直接影响到企业应用系统的开放性和可扩展性。目前业界分布式对象技术主要有三种架构标准: Microsoft的COM/DCOM/COM+ OMG组织的 CORBA。 Sun Microsystems的Enterprise.
从UNIX到Windows的 电信软件移植实践
Chap 3 資料庫模型與處理架構.
Operating System Concepts 作業系統原理 CHAPTER 2 系統結構 (System Structures)
單元3:軟體設計 3-2 順序圖(Sequence Diagrams)
Draft Amendment to STANDARD FOR Information Technology -Telecommunications and Information Exchange Between Systems - LAN/: R: Fast BSS.
本單元介紹何謂變數,及說明變數的宣告方式。
Chapter 3 行程觀念 (Process Concept)
创建型设计模式.
ICT RTOS Research Group 胡伟平,王剑
授课老师:龚涛 信息科学与技术学院 2018年3月 教材: 《Visual C++程序员成长攻略》 《C++ Builder程序员成长攻略》
在一定程度上 人类的思维产生于 简单个体之间的相互作用 ——Marvin Minsky.
Java语言程序设计 第五部分 Java异常处理.
第六章 编写客户端程序.
SAP 架構及基本操作 SAP前端軟體安裝與登入 Logical View of the SAP System SAP登入 IDES
常见问题解答 II. App上重置并清空数据库之后,手机app找不到圣诞灯怎么办? I. 打开APP,发现并连接不了圣诞灯怎么办?
預官考試輔導 計算機概論提要 91年12月4日.
臺北市立大學 資訊科學系(含碩士班) 賴阿福 CS TEAM
第8章 Service解析.
第九單元 Classes and data abstraction I
第4章 商务逻辑层及其技术.
重點 資料結構之選定會影響演算法 選擇對的資料結構讓您上天堂 程式.
校園網路架構介紹與資源利用 主講人:趙志宏 圖書資訊館網路通訊組.
Java程序设计 第2章 基本数据类型及操作.
C/C++/Java 哪些值不是头等程序对象
服務於中國研究的網絡基礎設施 A Cyberinfrastructure for Historical China Studies
Chapter 5 Recursion.
Web Server 王宏瑾.
第1章 概述 本章要点: C语言程序结构和特点 C语言程序的基本符号与关键字 C语言程序的编辑及运行 学习方法建议:
Westmont College 网络应用软件 第一讲 (客户-服务器 概念, 协议端口的使用, 套接字API)
資料結構 Data Structures Fall 2006, 95學年第一學期 Instructor : 陳宗正.
SAP R/3架構及前端軟體安裝 Logical View of the R/3 System SAP Frontend 6.2安裝
企业级分布式应用平台 —— Orbix 2000 CTO 张 恂 博讯科技(上海)有限公司 2001年3月.
JAVA 编 程 技 术 主编 贾振华 2010年1月.
Speaker: Liu Yu-Jiun Date: 2009/4/29
中国科学技术大学计算机系 陈香兰 2013Fall 第七讲 存储器管理 中国科学技术大学计算机系 陈香兰 2013Fall.
虚 拟 仪 器 virtual instrument
第二章 基于CORBA的分布式平台 苗启广 计算机学院.
Inheritance -II.
第二章 Java语法基础.
Chapter 10 Mobile IP TCP/IP Protocol Suite
SAP 架構及基本操作 SAP前端軟體安裝與登入 Logical View of the SAP System SAP登入 IDES
IEEM 5352 Enterprise Integration
Create and Use the Authorization Objects in ABAP
第二章 Java基本语法 讲师:复凡.
第一讲 面向对象方法学与信息系统建模.
11 Overview Cloud Computing 2012 NTHU. CS Che-Rung Lee
Operating System Software School of SCU
助教:廖啟盛 JAVA Socket(UDP) 助教:廖啟盛
第2章 Java语言基础.
SAP 架構及前端軟體安裝 Logical View of the SAP System SAP Frontend 7.1安裝 SAP登入
作業系統 Operating System 第六單元 分散式系統
Presentation transcript:

10. Distributed object-based systems P493

广州 北京 employee dept personnel hire() obj server Corp server 南京

Features Commercial systems P152, P496 Offer services and resources in the form of objects object server ~ concurrent server (FTP, Web) hide distributed aspect behind an object’s interface Commercial systems CORBA: an industry-defined standard for distributed system DCOM: a middleware layer on top of Windows OS Java: distributed object

Common Object Request Broker Architecture P494 10.1 CORBA Common Object Request Broker Architecture

10.1 Introduction 1. Two kinds of applications for distributed system Resource sharing build up distributed application system, C/S, XML Parallel distributed computing use several computers to solve a large problem 2. Two kinds of tools

Distributed programming language --- is used to write distributed parallel program Linda PVM (Parallel Virtual Machine) MPI (Message Passing Interface) Communication middleware --- build up distributed application system CORBA, DCOM Object-oriented Web services

Goals of CORBA different platform different OS different language different protocol prog obj OS1,Lang1 OS2,Lang2 OS3,Lang3 Internet?

目标 在异构, 开放环境中,各机间实现互操作。 独立于厂商的软件工业规范 CORBA提供公共服务和开发工具,以支持分布式应用程序开发 OMG(Object Management Group)制定CORBA规范

3. Why CORBA? 一个单位有不同的应用系统: 人事处:教师的人事资料,Windows 教务处:学生成绩和档案,上课教师, Unix 校医院:教师和学生的健康状况 如何共享数据,如何系统集成? CORBA能解决应用系统集成,包括传统应用程序,也能为动态变化的企业环境提供适应性

4. What is CORBA? 一种面向对象的分布式应用程序体系规范,是分布式计算和面向对象技术的结合。 一应用程序能共享和访问其他应用程序的对象。这样可连接图形应用程序, 数据库应用程序, GI S 应用程序等。所有分布式对象都有统一的接口,遵守统一通信方法。CORBA可称为通信中间件. 用OO方法构造可重用的, 可共享的软件组件.

Distributed object --- component` self-contained entity provide standard interface is independent of programming language interoperability reuse It is easy to assemble distributed application system

10.2 建立CORBA应用程序的大致步骤 假设已建立要解决问题的对象模型. 把 实体 对象 实体的活动 对象的操作 data data 实体 对象 实体的活动 对象的操作 data op1( ) {…. } op2( ) data op3( ) {….. } 要做工作 的描述 …... object i object1

实例:公司雇员人事数据的分布式应用程序 实体 属性 操作 Department DeptID manager Employee personal-data promote( ) department dismiss( ) transfer( ) Manager approve-transfer( ) Personnel hire( ) PersonnelManager arbitrate( )

1. 建立CORBA应用程序的大致步骤 ~RPC 用IDL语言写各对象接口定义。建立 .IDL文件或接口仓库 Fileserver.IDL IR Corp.IDL

Employee Personnel Manger hire( ) promote( ) dismiss( ) transfer( ) personal-data department approve-transfer( ) hire( ) promote( ) dismiss( ) transfer( ) Department DeptID manager Corp.IDL GO

编译 .IDL生成 IDL_stub和IDL_skeletons 例如 Corp_cstub.c Corp_sskel.c 用某种语言写客户方程序 例如 Client_main.c 用某种语言写server各对象接口的实现代码 例如 Personnel_Impl { hire(…) {实现代码……………} } 连接,部署上述应用程序的两部分

初始化Server, 创建客户所需要的对象实例等 (可用CORBA产品提供的wizard生成) 例如 Server_main.cpp Client Server Corp_cstub.c Corp_sskel.c Client_main.c Server_main.c 初始化Server, 创建客户所需要的对象实例等 (可用CORBA产品提供的wizard生成) 例如 Server_main.cpp pers_cs 运行上述应用程序 obj

基于CORBA的分布式应用开发过程 应 用 开 发 者 return 客户应用 C++, Java编译器 客户程序 IDL Stub Skeleton C++, Java编译器 服务程序 对象实现 return

2. CORBA concepts 对象:由标识,接口,实现组成 对象实例 接口:描述对象上哪些操作可用 请求:是C与S之间传送的消息 激发:发送消息的过程

…… …… Personnel object hire(emp_data,dept,...) { … implementation ……} pers_cs object instance object reference …… hire(emp_data,dept,...) interface Personnel interface

Why object reference? Department Personnel …… hire(emp,dept,.. ) { …… DeptID manager Personnel …… hire(emp,dept,.. ) { …… } pers_cs = resolve(“personnel_cs”) hire(emp,dept,.. ) { …… } pers_cs pers_cshire( , , ); Data Client in 南京 Server in 北京

对象引用应含内容? network address of the machine server id or endpoint object id pointer = object reference

The organization of an IOR with specific information for IIOP. interoperable

3. 请求的基本形式: C : hire(对象引用, *ev, 参数) C++ : 对象引用 hire(参数, *ev) OO: 对象.方法名(参数) hire(emp,dept,.. ) { …… } pers_cs

10.3 General organization of CORBA 两种角度: 开发应用系统角度 怎么设计、建立、实现CORBA应用程序 CORBA系统实现角度 怎么样的体系结构、怎么实现CORBA系统 1. General organization of a CORBA system

Client IR Object implementation DII IDL stub Client ORB ORB intf. OA DSI IDL skel ORB intf. Server ORB IR Interface-specific stubs and skeletons Same for all ORBs There may be multiple OA P496 return

The general organization of a CORBA system. P496 The general organization of a CORBA system.

DII --- Dynamic Invocation Interface DSI --- Dynamic Skeleton Interface IR ----- Interface Repository OA --- Object Adapter ORB --- Object Request Broker adapter (e-dap’ter`) adaptor noun A printed circuit board that enables a personal computer to use a peripheral device, such as a CD-ROM drive, modem, or joystick, for which it does not already have the necessary connections, ports, or circuit boards. Commonly, a single adapter card can have more than one adapter on it.

Stubs:静态调用的客户方桩。由IDL编译程序 产生,将被link到Client程序 Skeletons:静态调用的服务方框架,提供客户 请求到某对象上各操作(方法)的连接 ORB:用客户请求中的信息来发现特定的实现. 把客户请求传送到server的对象实现,并 返回结果。ORB是通信中间件,处理对象引用 OA:ORB---OA---对象实现。ORB传来的请求 通过OA选择特定的实现(bind),中间经由 Skeleton来调用有关方法。它的职责:

对象注册:把具体程序语言实体注册为 CORBA 对象 激活server:若必要,OA启动server进程, 以便 在其中能激活对象 激活对象:OA激活对象,若这些对象在请求到 达时还未活动 请求分路:OA必须与ORB合作以保证能在多个 连接上接收请求, 分路给不同服务器 调用对象:OA分派请求给注册的对象

DII:动态客户请求调用。应用程序在运行时访 问IR,以发现对象的接口定义,建立对对 象的请求 DSI:动态地把客户请求分派到所希望的对象 IR:包含用IDL写的接口,为动态调用提供信息, 如请求操作的参数,及其类型等

employee ORB promote() {…} dismiss() {… } Corp server pers_cs hire() {… } ORB Corp server corp_pers_cs _hire corp_pers_cs_hire OA sale_salesman_bonus salesman bonus() {… } Sale server advertise cost() {… }

employee ORB promote() {…} dismiss() {… } Corp server pers_cs hire() {… } corp_pers_cs_hire corp_pers_cs _hire ORB OA salesman bonus() {… } Sale server advertise cost() {… } skeleton

2. CORBA加入代理器 C/S: CORBA: C S C S C 代理器 S ORB C S

CORBA的C,S无需直接了解对方。代理知道双方的位置和能力 (from object reference) S同时也能作为C

10.4 OMG IDL ILD是一种中性语言,是说明语言,不是编程语言。用来定义对象的接口,这些接口说明该对象所支持的操作和类型 P496 ILD是一种中性语言,是说明语言,不是编程语言。用来定义对象的接口,这些接口说明该对象所支持的操作和类型 IDL可以映射到多种语言 IDL compiler for C .idl IDL_stub.c IDL_skeleton.c .h return

类型 类似于许多程序设计语言中的类型 IDL C++ long (32), short (16) long, short float (32), double (64) float, double char … char octet (8) unsigned char any string, struct, array, … char*, … object reference pointer or object interface class

Example of CORBA CDR message (Common data representation) Person struct with value: {‘Smith’, ‘London’, 1934} index in sequence of bytes 4 bytes 0-3 5 4-7 “Smit” 8-11 “h___” 12-15 6 16-19 “Lond” 20-23 “on__” 24-27 1934 string string unsigned long don’t include type information

IDL例子 Module CORP typedef long BadgeNum; typedef long DeptNum; enum DismissalCode {Dismiss_Fired, Dismiss_Quit} enum DenyApprovalReason {Reason, Codes}; struct PersonalData { } struct EmpData { } struct DeptInfo { } name phone site id personal_info job_class wage id name return

GO interface Employee; //forward declaration for interface interface Department { attribute DeptInfo DeptID readonly attribute Employee manager_obj; }; interface Employee { attribute EmpData personal_data; readonly attribute Department department_obj; void promote(in char new_job_class); void dismiss(in DismissalCode reason, in string description); void transfer(in Department new_dept_obj) }; return return

interface Manager : Employee { void approve-transfer(in Employee employee-obj, in Department current-department, in Department new-department ) raise(DENY_APPROVAL) context(“division”); }; interface Personnel : Employee { Employee hire(in EmpData employee_data, in Department department_obj, out BadgeNum new_employee_id); return

方向属性 in 参数 参数 out 参数 *参数 inout 参数 *参数 interface PersonnelManager : Personnel, Manager { void arbitrate( ); }; }; 方向属性 in 参数 参数 out 参数 *参数 inout 参数 *参数 Inherit: promote( ), transfer( ), dismiss( ); approve-transfer( ); hire( )

10.5 调用类型和通信方式 客户程序通常包括: 界面显示,接收输入 调用已定义对象上的操作 需选择 处理结果,显示结果等 P502 客户程序通常包括: 界面显示,接收输入 调用已定义对象上的操作 需选择 处理结果,显示结果等 两类调用和三种通信方式 桩类型调用 动态调用 同步 synchronous 单向 one-way 异步 deferred synchronous

10.5.1 桩类型调用 1. 调用形式 同步通信的调用形式 与RPC的不同 C++ : 对象引用 操作名(参数, *ev, 上下文对象引用) OO: 对象.方法名(参数) 与RPC的不同 Server must create a instance first. Client must get the object reference of the object pers_cs hire(tom_data, dept_cs, tom_id, &ev)

2. 桩类型调用步骤 3. 如何获取对象引用 编写获取调用所需的对象引用, 参数填写等 调用 处理结果, 包括异常情况处理代码 释放存区 go Server Personnel { … hire(参数) } 如何获得 pers_cs; …... pers_cs hire(tom_data, CS,… ); … … 客户方程序 pers_cs

tom_obj = pers_cs hire(tom_data, dept_cs, tom_id, &ev, ) 通过调用某操作产生一对象引用。如, tom_obj = pers_cs hire(tom_data, dept_cs, tom_id, &ev, ) tom_obj promote(参数, &ev, ) CORBA应提供一种机制,使客户方能获得所需对象引用, 如第一个调用所需的对象引用。 类似于:域名 ——> IP地址 新对象引用 已有对象引用

10.5.2 对象获得 1. 抽象模型 对象目录:存储对象引用和一些可选择的描述 性数据。例如, 对象目录 查找 公布 客户机 服务器 使用 10.5.2 对象获得 1. 抽象模型 对象目录:存储对象引用和一些可选择的描述 性数据。例如, 对象目录 查找 公布 客户机 服务器 使用 对象引用 对象名

2. CORBA提供的服务 CORBA命名服务 <名字, 对象引用> CORBA交易对象服务 P500 CORBA命名服务 <名字, 对象引用> CORBA交易对象服务 <一系列属性, 对象引用 > 配置文件 对象引用 ---> 字符串 ---> 放入配置文件

4. CORBA naming service P517 Naming service client server ORB object name object name & reference object reference client server ORB

使用命名服务 服务器调用对象目录中“命名上下文对象”中的bind(name, object)方法来公布对象 P517 服务器调用对象目录中“命名上下文对象”中的bind(name, object)方法来公布对象 客户机通过调用对象目录中“命名上下文对象”中的resolve(name)方法来查找对象 Interface NamingContext { void bind(in Name n, in Object obj); Object resolve(in Name n); } 通用对象

10.6 POA 1. Two key issues in CORBA How do clients get object references? Naming service, configuration file, trading service How map implementations in various languages into CORBA object? Server - creates a object instance in a particular language, such as C++ (dynamic object, pointer) - registers the instance as a CORBA object via POA (object id)

2. Jobs for client and server use an existing language (C, C++, Java,…) to implement objects and their methods (servant), create necessary instances. use POA’ operation to register the instance as a CORBA object, and return an CORBA identifier use naming service’ bind(name, object) to publish object name (and its object reference) Servant: is implementation of object, dependent of language

pers_cs = new Personnel; oid = poa ->activate_object (pers_cs); // Create a new C++ object oid = poa ->activate_object (pers_cs); // Register C++ object as CORBA object NamingContext.bind(“personnel_cs”, oid) // Public object name and object reference Naming service Object reference Object name (IP address, port no.) oid personnel_cs

Servant Map pers_Math pers_CS var x, y = servant = C++ object C function1( ) { … } function2( ) { … } C pers_Math C++ object pers_CS = servant = POA oid Naming service object name object reference

Client use naming service’ resolve(name) to get the required object reference do RMI Example: per_cs = NamingContext.resolve (“personnel_cs”) per_cs hire( . . .)

3. Functions of OA P153 adapt (register,包装) a program (server-side code) as a CORBA object generate object reference call a method of an object implement a specific activation policy for a group of objects: thread-per-object

GIOP (General Inter-ORB Protocol) IIOP (Internet Inter-ORB Protocol) server client Corp server sale server per-cs per-cs hire(..) li ORB OA OA ORB GIOP (General Inter-ORB Protocol) IIOP (Internet Inter-ORB Protocol)

10.2 Distributed object in Java Java RMI Distributed Systems Concepts and Design P208

1. Distributed object caller callee invoke method on * define remote interface, remote object each method must throw handle remote remote exception exceptions * implement remote interface Features: a single language system need not use IDL no mapping IDL to implementation language

2. Example: shared whiteboard C S C * maintain the current state of a drawing * keep a record of all shapes it has received inform(latest shape) get version number retrieve(latest shapes) ? CSCW = Computer Supported Cooperative Work

Define Remote interfaces Shape and ShapeList import java.rmi.*; import java.util.Vector; public interface Shape extends Remote { int getVersion( ) throws RemoteException; GraphicalObject getAllState( ) throws RemoteException; } public interface ShapeList extends Remote { Shape newShape(GraphicalObject g) throws RemoteException; Vector allShape( ) throws RemoteException; int getVersion( ) throws RemoteException;

3. Parameter and result passing Parameter is a remote object (i.e. interface) pass remote object reference Parameter is non-remote object object is copied and passed by value If the recipient doesn't’t possess the class of an object, its code is downloaded automatically (object is created)

4. RMI registry naming service client server client server object name & reference object reference client server client server naming service

bind(“URL name”, remote obj.) 4. RMI registry remote object bind(“URL name”, remote obj.) lookup(URL name) remote obj. ref. RMIregistry client name remote object server bind(“//domain name:port/objName”, remote object) This service is not system-wide binding service. Clients must direct their lookup to particular hosts

Naming class of Java RMIregistry P211 void rebind(String name, Remote obj) this method is used by a server to register the identifier of a remote object by name. void bind(String name, Remote obj) this is alternative way to rebind, but if the name is already bound to a remote object an exception is thrown void unbind(String name, Remote obj) Remote lookup(String name) String [ ] list( ) return an array of strings containing the names bound in the registry.

5. Server program server= main( ) + implement each of its remote interface main( ) create an instance of ShapeListServant object as remote one bind it to a name “Shape List” in RMIregistry ShapeListServant – implementation of ShapeList interface. implement newSpape which is used by clients to create a remote object (Shape); add it to its vector …… ShapeServant – implementation of Shape interface …

class ShapeListServer with main method public class ShapeListServer { public static void main(String args[ ]) { System.setSecurityManager(new RMISecurityManager()); try { ShapeList aShapeList = new ShapeListServant( ); Naming.rebind(“Shape List”, aShapeList); System.out.println(“server is ready”); } catch(Exception e) { System.out.println(“server main” + e.getMessage()); } Default security manager

class ShapeListServant implements interface ShapeList public class ShapeListServant extends UnicastRemoteObject implements ShapeList { private Vector theList; private int version; public ShapeListServant( ) throws RemoteException {……} public Shape newShape(GraphicalObject g) throws RemoteException { version++; Shape s= new ShapeServant(g, version); theList.addElement(s); return s; } public Vector allShapes( ) throws RemoteException {……} public int getVersion ( ) throws RemoteException {……} }

class ShapeServant implements interface Shape public class ShapeServant extends UnicastRemoteObject implements Shape { private int version; public ShapeServant(…) throws RemoteException {……} public getAllState( ) throws RemoteException {……} public int getVersion ( ) throws RemoteException {……} }

6. Client program import … public class ShapeListClient { public static void main(String args[ ]) { System.setSecurityManager(new RMISecurityManager()); ShapeList aShapeList = null; try { aShapeList = (ShapeList) Naming.lookup(“//bruno/Shape List”); Vector sList = aShapeList.allShapes( ); …} catch(RemoteException e) { System.out.println(e.getMessage());} catch(Exception e) { System.out.println(“Client:”+e.getMessage());} }

Summary 1. Goals interoperable in heterogeneous environment 2. How build up a distributed application 3. General organization of CORBA 4. Functions of OA 5. Object reference and naming service 6. Distributed object in Java and Java RMI 7. Difference between CORBA and Java

Project 3 Use Java or CORBA or DCOM to build up a distributed application, such as whiteboard, database application, … Requirement: the application must access database

IDL Implement RPC: CORBA: Java: (no IDL) } func1(in int i, string s) func1(in int i, string s) {implement … } CORBA: interface name1 class name1Impl extends …name1POA { method1(in int i, …); { method1(in int i, …) method2(in param, …); {implement … } ……} method2( ……) …… Java: (no IDL) } interface name2 extends Remote class name2Servant extends … name2 { method1(int i, …) throw …; { method1(int i, …) throw … method2(param, …) throw …; {implement … } ……} method2(……) …… }

Stub and message RPC: CORBA: Java: C_stub S_stub func1(16,’abc,…) IDL_stub Skeleton objRef.method1(…) Java: Serialization Deserialization int 16 string “abc” func1 16 3 a b c _ obj. ref. method1 P23 3 a b c obj. ref. method1 16 2, int i, sting s