1 Distributed Objects 1 Institute of Computer Software
1 Distributed Objects 分布对象(1) Institute of Computer Software Nanjing University 2022/1/21
摘要 2 背景 Why, What, How 一般框架 CORBA Java RMI Institute of Computer Software Nanjing University 2022/1/21
Acknowledgement 3 本节ppt 有关CORBA部分内容从下列文献摘录 或改编: Bamshad Mobasher http: //maya. cs. depaul. edu/~mobasher/classes/ds 520/ Douglas C. Schmidt http: //www. cs. wustl. edu/~schmidt/corba. html Institute of Computer Software Nanjing University 2022/1/21
摘要 4 背景 Why, What, How 一般框架 CORBA Java RMI Institute of Computer Software Nanjing University 2022/1/21
背景 5 分布式计算(Distributed computing) What: the process of running a single computational task on more than one distinct computer -- from Wikipedia Compare to “Parallel Computing” Why? How? 实践表明,分布式应用系统的开发比集中式应用系统开 发困难的多。 Institute of Computer Software Nanjing University 2022/1/21
分布式计算 6 Why? “世界是分布的”。 有时将涉及的用户、应用、数据集中化不合适、不可行。 资源共享 并行处理 冗余容错 The main goal of a distributed computing system is to connect users and resources in a transparent, open, and scalable way. Ideally this arrangement is drastically more fault tolerant and more powerful than many combinations of stand-alone computer systems. Institute of Computer Software Nanjing University 2022/1/21
The Business Model i Every application is part of your business model 4 must make them work together! Payables/ Receivables Sales Accounting Manufacturing Inventory Shipping/ Receiving Engineering Distributed Systems Frameworks 7
The Problem i Application Integration and Distributed Processing are the same thing 4 Constructing information-sharing distributed systems from diverse sources: hheterogeneous hnetworked hphysically disparate hmulti-vendor Distributed Systems Frameworks 8
常见分布式应用模式 • Client – Server Computing Client Code Server Code Stub Skeleton Infrastructure Client: Thin or Fat? Distributed Systems Frameworks 9
常见分布式应用模式 i Multi-Tier Systems Business Logic User Interface Persistent Store 4 separates persistence from logic and logic from presentation 4 all activity originates in user interface 4 arrows represent client-server relation Distributed Systems Frameworks 10
常见分布式应用模式 i Web Applications Firewall HTTP Servers Business Logic CGI / Servlets User Interface Data Store 4 interaction initiated by user 4 UI based on HTML, Javascript, etc. 4 CGI/Servlet composes HTML, forwards interaction requests to business logic Distributed Systems Frameworks 11
常见分布式应用模式 i Peer-to-Peer Systems s uest q e R Application ons ati tific No Message queue Persistent Store User Interface (mixed initiative) Monitor Enterprise Applications • An architecture where there is no special machine or machines that provide a service or manage the network resources. • Instead all responsibilities are uniformly divided among all machines, known as peers. Peers can serve both as clients and servers. Distributed Systems Frameworks 12
分布式应用的构成 i 3 layers of a distributed application: 4 network level (TCP/IP, network protocols) 4 higher-level services (directory services, security protocols, etc. ) 4 application level i. At the application level: 4 processes 4 threads 4 objects: processes can be made up of one or more objects which can be accessed by one or more threads within the process 4 agents: an “independent” functional element (e. g. , in a banking application we may have a customer agent, a transaction agent, an information brokerage agent) Distributed Systems Frameworks 13
分布式应用的一般技术需求 i. Partitioning and Distributing Data and Functions 4 data-driven distribution 4 functional distribution 4 object-based distribution i. Flexible, Extendible Communication Protocols 4 allocation of tasks to agents has a direct influence on the complexity of the communication protocol (type of data, amount of data, persistence of connections) 4 may also be dictated by legacy systems that need to be incorporated Distributed Systems Frameworks 14
分布式应用的一般技术需求 i. Multi-threading Requirements 4 server object may need to service multiple remote clients at once 4 effective way to optimize resources i. Security Requirements 4 authentication of client identities 4 define resource access levels 4 data encryption Distributed Systems Frameworks 15
分布计算 16 How? 理想主义:Distributed Operating System 现实主义: 操作系统提供网络通信功能 (中间件) 分布应用程序 Institute of Computer Software Nanjing University 2022/1/21
分布计算 17 Socket programming in Java // listen to port 5000 on the local host for socket connection requests Server. Socket s = new Server. Socket(5000); while (true) { // wait for connection request from client Socket client. Conn = s. accept(); Input. Stream in = client. Conn. get. Input. Stream(); Output. Stream out = client. Conn. get. Output. Stream(); // now IO streams are connected to client; do something with them. . . Institute of Computer Software Nanjing University 17 2022/1/21
分布计算 18 // create the socket Inet. Address addr = Inet. Address. get. By. Name(“our. remote. host”); Socket s = new Socket(addr, 5000); Input. Stream in = s. get. Input. Stream(); Output. Stream out = s. get. Output. Stream(); // now we have IO streams to remote process; do something with them. . . Institute of Computer Software Nanjing University 18 2022/1/21
分布计算 19 Message Passing Libraries PVM (Parallel Virtual Machine), MPI (Message Passing Interface) Send/Recv, Multicast Virtual Shared Memory Open. MP Institute of Computer Software Nanjing University 2022/1/21
分布计算 20 远程过程调用(RPC,Remote Procedure Call) 让应用程序开发者可以 象调用本地过程一样调用分布在远程节点上的过程 将结构化方法用于分布环境 实现上 Request – Response 消息传递模式 provides a function-oriented interface to socket-level communications (sits on top of the TCP/IP transport layer) Institute of Computer Software Nanjing University 2022/1/21
摘要 21 背景 Why, What, How 一般框架 CORBA Java RMI Institute of Computer Software Nanjing University 2022/1/21
General Pattern for Remote Invocation Client Code Server Code Stub Skeleton Infrastructure i. Call: 4 marshal arguments 4 convert to network format 4 locate server 4 transmit data Distributed Systems. Frameworks i. Serve: 4 receive data 4 convert & unmarshal 4 invoke method 4 marshal return value 4 transmit data 22
Procedural API for Remote Invocation i DCE (Distributed Computing Environment) 4 OSF standard for RPC 4 provides a common set of services h. Directory Services--Store the names of resources that are available within the distributed environment. The Cell Directory Service (CDS) supports naming within a cell, and the Global Directory Service (GDS) supports naming across all cells within an enterprise. GDS implements the X. 500 directory service standard. h. Distributed File Service (DFS)--An optional DCE service that provides a seamless file system that operates across all computers contained within a cell. h. Distributed Time Service (DTS)--Used for synchronization. h. Security Service--Used for authentication and control access. h. DCE Threads--Similar to Java threads. They are lightweight processes that simplify the design of client/server applications. Distributed Systems. Frameworks 23
分布对象计算(DOC) 24 让应用程序开发者可以象使用本地对象一样使 用远程对象 对象计算模型和分布计算模型的结合 自然 decentralized nature of dist. computing encapsulation required by distributed components information hiding requirements (location transparency, security, etc. ) 优越: Institute of Computer Software Nanjing University 2022/1/21
分布对象技术 25 Location Transparency Caller Machine 1 local call Proxy Machine 2 remote call Implementor Institute of Computer Software Nanjing University 2022/1/21
分布对象技术 26 Proxy Pattern Institute of Computer Software Nanjing University 2022/1/21
分布对象技术 27 Providing the same enhancements to procedural RPC toolkits that OO languages provide to conventional procedural languages 实现对象计算的全面支持 encapsulation, interface inheritance, object-based exception handling 良好的软件组织 promotes separation of interface from implementation (crucial for scalable distributed applications) 甚至Db. C Institute of Computer Software Nanjing University 2022/1/21
Key Advantages of DOC 28 Enabling interworking between applications at a higher level of abstraction developing distributed applications using familiar techniques such as method calls on objects again, location transparency Providing a foundation for building higher-level mechanisms that facilitate collaboration among services in distributed applications common object services (e. g. , global naming, transactional messaging, quality of service facilities, etc. ) Institute of Computer Software Nanjing University 2022/1/21
显式、抽象的对象接口定义 30 allow clients to access objects regardless of implementation details allow object server flexibility in implementing objects platform-independent specification languages existing services may be incorporated via wrappers interface descriptions can be converted into server skeletons which can be compiled and implemented in any language some object interfaces also generate client stub interfaces. Examples: CORBA: Interface Definition Language (IDL) DCOM: Component Object Model language Institute of Computer Software Nanjing University 2022/1/21
对象管理器(Object Manager) 32 The core of a distributed object system Manages object skeletons and object references on the server E. g. , Object Request Broker (ORB) in CORBA or Registry Service in RMI When a client requests a new object, the object manager locates the skeleton for the class of the requested object creates new instance based on skeleton stores new object in the object storage sends a reference to the new object back to the client Institute of Computer Software Nanjing University 2022/1/21
对象管理器 33 Remote method calls by clients are routed by object manager to the proper object on the server Object manager may also destroy objects after clients are done Some other possible features of OM dynamic object activation/deactivation persistent objects Institute of Computer Software Nanjing University 2022/1/21
Registration / Naming Service 34 Acts as an intermediary between the object client and the object manager Once the interface to an object is defined, an implementation of the interface must be registered with the service so that it can be addressed by clients Through the naming service the client can specify the type of the object it needs or the name of a particular object, if it already exists Institute of Computer Software Nanjing University 2022/1/21
对象通信协议 35 General protocol for handling remote object requests Must support a means of transmitting and receiving object and method references, and data in the form of objects or basic data types Ideally should be transparent to clients should interact with local object proxies (stubs) and let the object distribution scheme handle communication behind the scenes Institute of Computer Software Nanjing University 2022/1/21
分布计算的一般框架 36 Registration Service Object Interface Specification IDL Compilers Server Implementation Object Skeleton Object Storage Object Manager Naming Service Client Stub Interface Client Application 2022/1/21
运行时刻远程对象交互 37 Server Object Implementation Object Skeleton 2. Resolve Object 4. Object Interactions Object Manager Naming Service 1. Request Object Client Application 3. Object Handle Object Stubs Institute of Computer Software Nanjing University 2022/1/21
Comparing DOC Frameworks 38 l Distributed Object Computing Frameworks l l l CORBA - Common Object Request Broker Architecture, an industry standard developed by OMG DCOM - Microsoft’s Distributed Component Object Model, a descendant of DCE RPC RMI - Java’s Remote Method Invocation Institute of Computer Software Nanjing University 2022/1/21
摘要 39 背景 Why, What, How 一般框架 CORBA Java RMI Institute of Computer Software Nanjing University 2022/1/21
OMG Reference Model Architecture 40 Institute of Computer Software Nanjing University 2022/1/21
Object Management Architecture 41 Object Services Domain-independent foundational services for use by developers of implementation objects some published services: Naming: allows clients to find objects based on names Trading: allows clients to find objects based on their properties Lifecycle management Event notification Transactions Security … Institute of Computer Software Nanjing University 2022/1/21
Object Management Architecture 42 Common Facilities object services provide functionality for use by objects, CORBA facilities provide standards for services used by applications generic functionality needed by many applications (e. g. , printing, document management, email, etc. ) Institute of Computer Software Nanjing University 2022/1/21
Object Management Architecture 43 Domain Interfaces provide domain-specific objects for vertical application domains Examples: Finance, Healthcare, Manufacturing, Telecom, Electronic Commerce, Transportation Application Interfaces Thus not standardized Institute of Computer Software Nanjing University 2022/1/21
Common Object Request Broker Architecture 44 一个典型的分布对象计算架构 The architecture Objects and Clients 接口 OMG IDL “对象管理器” ORB 底层通信协议 IIOP 其他 对象 Institute of Computer Software Nanjing University 2022/1/21
45 Institute of Computer Software Nanjing University 2022/1/21
Overview of CORBA Objects i. CORBA Object 4<identity, interface, implementation> i. CORBA objects differ from typical programming language objects: 4 CORBA objects can be located anywhere on a network. 4 CORBA objects (like Java objects) can run on any platform. 4 CORBA objects can be written in any of several languages. i. CORBA object developers need know nothing of where their clients will be, what hardware or OS they will run on, or what language they will be written in. 4 CORBA objects approach universal accessibility. Distributed Systems. Frameworks 46
Overview of CORBA Objects i. An object implementation provides the semantics of the object, usually by defining data for the object instance and code for the object's methods. (called a “servant”) i. A client of an object has access to an object reference for the object, and invokes operations on the object. 4 A client knows only the logical structure of the object according to its interface and experiences the behavior of the object through invocations. 4 Client code has no knowledge of the implementation of the object or which ORB is used to access the implementation. Distributed Systems. Frameworks 47
Role of OMG IDL Object Implementation Side Client Side C++ C COBOL IDL COBOL Ada IDL ORB Ada IDL Internet Inter. ORB Protocol (IIOP) IDL IDL IDL Small talk C++ JAVA Distributed Systems. Frameworks Small talk JAVA 48
OMG IDL i. OMG Interface Definition Language (IDL): 4 mappings for many languages/compilers; 4 independent of any particular language/compiler; 4 multiple-inheritance, public interface-structured specification language; 4 not for implementation. 4 primary support for interoperability between static and dynamic requests mechanisms. Distributed Systems. Frameworks 49
OMG IDL i IDL Structure 4 Module ha namespace Module auction { exception Not. Allowed {}; struct Sale { int price; string item; } 4 Interface habstract type hmultiple inheritance 4 Struct interface Auction { void bid (in long price) raises Not. Allowed; } hstructured data } Distributed Systems. Frameworks 50
A Request i. A request consists of: 4 Target object (target object identified by a unique object reference) 4 Operation 4 Parameters (the input, output and in-out parameters defined for the operation; may be specified individually or as a list) 4 Optional request context Client Object Implementation Client Proxy (stub code) Skeleton code Request ORB Distributed Systems. Frameworks 51
CORBA Framework Elements i. Object Request Broker (ORB) 4 This is the object manager in CORBA i. Mechanisms for specifying interfaces 4 Interface Definition Language (IDL) - for static interface definitions 4 Dynamic Invocation Interface (DII) - lets clients access interfaces as first-class objects at run-time from an Interface Repository. i. Internet Inter-Orb Protocol (IIOP) 4 A binary protocol for communication between ORBs. 4 Was added in CORBA 2. 0 Distributed Systems Frameworks 52
Object Request Broker (ORB) i The Object Manager in CORBA i Both on the client side and the server side (allows user programs to act as both clients and servers of remote objects) i On client side the ORB is responsible for 4 accepting requests for a remote object 4 finding implementation of the object 4 accepting client-side reference to the remote object(converted to a language specific form, e. g. , a Java stub object) 4 routing client method calls through the object reference to the object implementation i On server side the ORB 4 lets object servers register new objects 4 receives requests from the client ORB 4 uses object’s skeleton interface to invoke object’s activation method 4 creates reference for new object and sends it back to client Distributed Systems Frameworks 53
Internet Inter-Orb Protocol (IIOP) i CORBA specification is neutral with respect to network protocols 4 the CORBA standard specifies what is known as the General Inter-ORB Protocol (GIOP) 4 GIOP is a high-level standard protocol for communication between ORBs 4 not used directly; instead, it is specialized by a particular protocol that would then be used directly i Internet Inter-ORB Protocol (IIOP) 4 IIOP is the GIOP-based protocol for TCP/IP networks 4 As of the 2. 0 version of the CORBA specification, vendors are required to implement the IIOP protocol i CORBA Networking Model 4 CORBA applications are built on top of GIOP-derived protocols such as IIOP 4 these protocols, in turn, rest on top of TCP/IP, DCE, or other underlying transport protocol the network uses 4 an application architecture can be designed to use a bridge that would interconnect, for instance, DCE-based application components with IIOP-based ones. Distributed Systems Frameworks 54
Passing Objects by Reference i In a distributed application, there are two possible methods for an application component to obtain access to an object in another process: 4 When an object is passed by reference, the object itself remains "in place" while an object reference for that object is passed. Operations on the object through the object reference are actually processed by the object itself. 4 When an object is passed by value, the object's state is copied and passed to its destination (via object serialization), where a new copy of the object is instantiated. Operations on that object's copy are processed by the copy, not by the original object. 4 Note: in CORBA, objects are only passed by reference (however, the new CORBA specifications include facilities for passing objects by value). Distributed Systems. Frameworks 55
Object References i An Object Reference is the information needed to specify an object within an ORB. 4 The representation of an object reference handed to a client is only valid for the lifetime of that client. 4 The language mapping also provides additional ways to access object references in a typed way for the convenience of the programmer. 4 There is a distinguished object reference, the null reference, guaranteed to be different from all object references, that denotes no object. In Java, this is a Java null. i To invoke a CORBA object, you need a reference for the object. There are two ways to get a reference for a CORBA object: 4 from another object, such as a factory or a name service 4 from a string that was specially created from an object reference i Interoperable Object References 4 CORBA uses IOR as a “pointer” to a specific instance of a class in a distributed environment 4 encodes host, port, object identity 4 may be externalized (using object_to_string) Distributed Systems. Frameworks 56
CORBA Components i Client stub 4 Each stub represents (it is a proxy) an object operation (a possible request) which a client invokes in a language-dependent manner (e. g. , by calling a subroutine which represents the operation). 4 The stubs make calls on the rest of the ORB using interfaces that are private to Java IDL. 4 Alternatively, a client may dynamically construct and invoke request objects which can represent any object operation. i Implementation Skeleton 4 Each skeleton provides the interface through which a method receives a request (dynamic and static skeletons) i Object Adapter 4 Purpose is to interface an object's implementation with its ORB 4 Each object adapter provides access to those services of an ORB (such as activation, deactivation, object creation, object reference management) used by a particular type of object implementation. i ORB Interface 4 The interface to the small set of ORB operations common to all objects, e. g. , the operation which returns an object's interface type. Distributed Systems. Frameworks 57
CORBA Components Object Implementation Client Dynamic Invocation Client Stubs ORB Interface Implementation Skeletons Object Adapter ORB Core standard interface Proprietary ORB interface One interface per object adaptor Normal call interface Up call interface One interface per object operation Distributed Systems. Frameworks 58
Client Side Clients perform requests using object references. Clients may issue requests through object interface stubs (static) or dynamic invocation interface. Client Dynamic Invocation Client Stubs Distributed Systems. Frameworks ORB Interface Clients may access general ORB services: • Interface Repository. • Context Management. • List Management. • Request Management. 59
Implementation Side Implementations receive requests through skeletons (without knowledge of invocation approach). Object Implementation ORB Interface Implementation Skeletons Object Adapter The Object Adapter provides for: • management of references; • method invocation; • authentication; • implementation registration; • activation/deactivation. Distributed Systems. Frameworks 60
Static v. Dynamic Invocation i Static Invocation 4 Static interfaces are generated in form of client stubs by the IDL (pre-) compiler. 4 This means that the structure of the object has to be known before hand (at compile time). 4 Allows for better type checking; less runtime overhead; self-documentation. i Dynamic Invocation 4 Dynamic Invocation Interface (DII) allows clients to invoke operations on remote objects without having access to object stubs (another way to do this without dynamic invocation is to download static client stubs via a Java applet). 4 Clients must discover interface-related information at runtime (e. g. , using the interface repository) 4 Servers can offer new services anytime without the need for recompilation on the client side. Distributed Systems. Frameworks 61
Dynamic Requests i The Dynamic Invocation Interface (DII) allows clients to dynamically: 4 4 4 discover objects; discover objects’ interfaces; create requests; invoke requests; receive responses. i Major features of Dynamic Invocation Interface: 4 requests appear as objects themselves; 4 requests are reusable; 4 invocation may be synchronous or asynchronous; 4 requests may be generated dynamically, statically or in combination approach. Distributed Systems. Frameworks 62
CORBA Interface Repository i The Interface Repository is a service that provides persistent objects that represent the IDL information in a form available at runtime. 4 Note: The Java IDL runtime does not include an implementation of an Interface Repository and one is not generally required by clients at runtime. 4 Using the IR, it is possible for a program to encounter an object whose interface was not known at compile time, yet be able to determine what operations are valid on the object and make invocation on it. i Interface Repository provides: 4 Dynamic client access to interface definitions to construct a request. 4 Dynamic type-checking of request signatures. 4 Traversal of inheritance graphs. 4 ORB-to-ORB interoperability. Distributed Systems. Frameworks 63
CORBA Implementation Repository i The Implementation Repository contains information that allows the ORB to locate and activate implementations of objects. i Ordinarily, installation of implementations and control of policies related to the activation and execution of object implementations is done through operations on the Implementation Repository. i In addition to its role in the functioning of the ORB, the Implementation Repository is a common place to store additional information associated with implementations of ORB objects. (e. g. , debugging information, administrative control, resource allocation, security, etc) i The Implementation Repository supports the implementation of object servers. It is not needed by clients in order to access servers. Distributed Systems. Frameworks 64
Summary of CORBA Interfaces Implementation Installation IDL Interface Definitions Interface Repository Accesses Client Stubs Includes Client Implementation Skeletons Implementation Repository Includes Describes Object Implementation 4 All objects are defined in IDL by specifying their interfaces. 4 Object definitions (interfaces) are manifested as objects in the Interface Repository, as client stubs, and as implementation skeletons. 4 Descriptions of object implementations are maintained as objects in the Implementation Repository. Distributed Systems. Frameworks 65
Summary: CORBA Remote Method Invocation i Clients use “object interfaces” through language mapping 4 Java clients should work on any ORB that supports the Java language bindings. 4 Clients can call any object instance remotely, so long as the object instance implements the interface. i Clients can call remote objects statically or dynamically 4 The server cannot tell whether the client is using static or dynamic invocation. i Objects are identified using a unique id: Interoperable Object Reference (IOR) 4 CORBA normally passes objects by reference 4 IOR was Introduced in CORBA 2. 0 4 Object references can be converted to strings and back to “live” objects via ORB interface functions. Distributed Systems. Frameworks 66
摘要 67 背景 Why, What, How 一般框架 CORBA Java RMI Institute of Computer Software Nanjing University 2022/1/21
RMI: Java distributed object model 68 Remote Method Invocation Java语言之内,充分利用这一点! Stub可下载! 可以传“对象”! Garbage Collection! 传“引用” java. rmi. Remote (Remote. Exception) Institute of Computer Software Nanjing University 2022/1/21
69 Institute of Computer Software Nanjing University 2022/1/21
- Slides: 70