分布对象 (1) distributed objects 2015-9-14 institute of computer software nanjing university 1
Post on 28-Dec-2015
254 Views
Preview:
TRANSCRIPT
分布对象 (1)
Distributed Objects
23/4/19Institute of Computer Software
Nanjing University
1
摘要 背景
Why, What, How 一般框架 CORBA Java RMI
23/4/19Institute of Computer Software
Nanjing University
2
Acknowledgement
本节 ppt 有关 CORBA 部分内容从下列文献摘录或改编: Bamshad Mobasher
http://maya.cs.depaul.edu/~mobasher/classes/ds520/
Douglas C. Schmidt http://www.cs.wustl.edu/~schmidt/corba.html
23/4/19Institute of Computer Software
Nanjing University
3
摘要 背景
Why, What, How 一般框架 CORBA Java RMI
23/4/19Institute of Computer Software
Nanjing University
4
背景 分布式计算( 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?
实践表明,分布式应用系统的开发比集中式应用系统开发困难的多。
23/4/19Institute of Computer Software
Nanjing University
5
分布式计算 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.
23/4/19Institute of Computer Software
Nanjing University
6
Distributed Systems Frameworks 77
The Business Model Every application is part of your business model
must make them work together!
Shipping/ Receiving
Inventory
Engineering
Manufacturing
Accounting
Payables/ Receivables
Sales
Distributed Systems Frameworks 88
The Problem Application Integration and Distributed Processing are the same
thing Constructing information-sharing distributed systems from
diverse sources: heterogeneous networked physically disparate multi-vendor
Distributed Systems Frameworks 9
常见分布式应用模式
Client CodeClient Code
Stub
Server CodeServer Code
Skeleton
InfrastructureInfrastructure
Client: Thin or Fat?
• Client – Server Computing
Distributed Systems Frameworks 10
常见分布式应用模式 Multi-Tier Systems
separates persistence from logic and logic from presentation all activity originates in user interface arrows represent client-server relation
Business LogicBusiness Logic
User Interface Persistent Store
Distributed Systems Frameworks 1111
常见分布式应用模式 Web Applications
interaction initiated by user UI based on HTML, Java, Javascript, etc. CGI/Servlet composes HTML, forwards interaction requests to business logic
BusinessLogic
BusinessLogic
User InterfaceData Store
FirewallFirewall HTTP ServersHTTP Servers
CGI / Servlets
Distributed Systems Frameworks 12
常见分布式应用模式
Peer-to-Peer Systems
ApplicationApplication
User Interface(mixed initiative)
Persistent Store
MonitorMonitor
Enterprise Applications
Requests
NotificationsMessage
queue
• 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 13
分布式应用的构成 3 layers of a distributed application:
network level (TCP/IP, network protocols) higher-level services (directory services, security protocols, etc.) application level
At the application level: processes threads objects: processes can be made up of one or more objects which can be
accessed by one or more threads within the process 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 14
分布式应用的一般技术需求 Partitioning and Distributing Data and Functions
data-driven distribution functional distribution object-based distribution
Flexible, Extendible Communication Protocols 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)
may also be dictated by legacy systems that need to be incorporated
Distributed Systems Frameworks 15
分布式应用的一般技术需求 Multi-threading Requirements
server object may need to service multiple remote clients at once
effective way to optimize resources
Security Requirements authentication of client identities define resource access levels data encryption
分布计算 How ?
理想主义: Distributed Operating System 现实主义:
操作系统提供网络通信功能 (中间件) 分布应用程序
23/4/19Institute of Computer Software
Nanjing University
16
分布计算 Socket programming in Java
23/4/19Institute of Computer Software
Nanjing University
17
17
// listen to port 5000 on the local host for socket connection requestsServerSocket s = new ServerSocket(5000);while (true) { // wait for connection request from client Socket clientConn = s.accept(); InputStream in = clientConn.getInputStream(); OutputStream out = clientConn.getOutputStream(); // now IO streams are connected to client; do something with them...
分布计算
23/4/19Institute of Computer Software
Nanjing University
18
18
// create the socketInetAddress addr =
InetAddress.getByName(“our.remote.host”);Socket s = new Socket(addr, 5000);InputStream in = s.getInputStream();OutputStream out = s.getOutputStream();// now we have IO streams to remote process; do something with them...
分布计算 Message Passing Libraries
PVM (Parallel Virtual Machine), MPI (Message Passing Interface)
Send/Recv, Multicast
Virtual Shared Memory OpenMP
23/4/19Institute of Computer Software
Nanjing University
19
分布计算 远程过程调用 (RPC , Remote Procedure
Call) 让应用程序开发者可以
象调用本地过程一样调用分布在远程节点上的过程 将结构化方法用于分布环境
实现上 Request – Response 消息传递模式 provides a function-oriented interface to
socket-level communications (sits on top of the TCP/IP transport layer)
23/4/19Institute of Computer Software
Nanjing University
20
摘要 背景
Why, What, How 一般框架 CORBA Java RMI
23/4/19Institute of Computer Software
Nanjing University
21
Distributed Systems Frameworks 22Distributed Systems Frameworks 22
General Pattern for Remote Invocation
Call: marshal arguments convert to network format locate server transmit data
Client CodeClient Code
Stub
Server CodeServer Code
Skeleton
InfrastructureInfrastructure
Serve: receive data convert & unmarshal invoke method marshal return value transmit data
Distributed Systems Frameworks 23Distributed Systems Frameworks 23
Procedural API for Remote Invocation
DCE (Distributed Computing Environment)
OSF standard for RPC provides a common set of services
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.
Distributed File Service (DFS)--An optional DCE service that provides a seamless file system that operates across all computers contained within a cell.
Distributed Time Service (DTS)--Used for synchronization. Security Service--Used for authentication and control access. DCE Threads--Similar to Java threads. They are lightweight processes
that simplify the design of client/server applications.
分布对象计算( DOC ) 让应用程序开发者可以象使用本地对象一样使
用远程对象 对象计算模型和分布计算模型的结合
自然 decentralized nature of dist. computing encapsulation required by distributed
components information hiding requirements (location
transparency, security, etc.) 优越 :
23/4/19Institute of Computer Software
Nanjing University
24
分布对象技术 Location Transparency
23/4/19Institute of Computer Software
Nanjing University
25
Machine 1 Machine 2
Caller
Proxy
Implementor
localcall remote
call
分布对象技术 Proxy Pattern
23/4/19Institute of Computer Software
Nanjing University
26
分布对象技术 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)
甚至 DbC23/4/19
Institute of Computer SoftwareNanjing University
27
Key Advantages of DOC
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.)
23/4/19Institute of Computer Software
Nanjing University
28
分布对象计算
实现分布对象计算的几个核心概念 接口 对象引用 参数传递 相关服务设施 底层通信协议
23/4/19Institute of Computer Software
Nanjing University
29
显式、抽象的对象接口定义 allow clients to access objects regardless of
implementation details allow object server flexibility in implementing objects
existing services may be incorporated via wrappers platform-independent specification languages
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
23/4/19Institute of Computer Software
Nanjing University
30
远程对象引用 对象通过相互引用来通信
本地对象引用:仅在当前地址空间有效 运行系统维护;
远程对象引用 不同地址空间? 异构? 生命周期?
需要某种“对象管理器”来支持、维护之
23/4/19Institute of Computer Software
Nanjing University
31
对象管理器( Object Manager ) 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
23/4/19Institute of Computer Software
Nanjing University
32
对象管理器 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
23/4/19Institute of Computer Software
Nanjing University
33
Registration / Naming Service 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
23/4/19Institute of Computer Software
Nanjing University
34
对象通信协议
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
23/4/19Institute of Computer Software
Nanjing University
35
分布计算的一般框架
23/4/19
36
IDL
Com
pil
ers
Registration Service
Object Skeleton
Object Storage
Object Manager
Naming Service
Client Application
ServerImplementation
Client StubInterface
Object Interface
Specification
运行时刻远程对象交互
23/4/19Institute of Computer Software
Nanjing University
37
ObjectStubs
Server ObjectImplementation Object
Skeleton
Object Manager Naming Service
Client Application
2. Resolve Object
4. Object Interactions
1. Request Object
3. Object Handle
Comparing DOC Frameworks
Cross Cross Complexity Client Server SecurityPlatform Lang. Portability Portability
CORBA yes yes medium high medium many options
DCOM limited yes high low low NT security
RMI yes no low high high add-on
23/4/19Institute of Computer Software
Nanjing University
38
Distributed Object Computing Frameworks 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
摘要 背景
Why, What, How 一般框架 CORBA Java RMI
23/4/19Institute of Computer Software
Nanjing University
39
OMG Reference Model Architecture
23/4/19Institute of Computer Software
Nanjing University
40
Object Management Architecture
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 managementEvent notification TransactionsSecurity…
23/4/19Institute of Computer Software
Nanjing University
41
Object Management Architecture
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.)
23/4/19Institute of Computer Software
Nanjing University
42
Object Management Architecture
Domain Interfaces provide domain-specific objects for vertical
application domains Examples: Finance, Healthcare, Manufacturing,
Telecom, Electronic Commerce, Transportation
Application Interfaces Thus not standardized
23/4/19Institute of Computer Software
Nanjing University
43
Common Object Request Broker Architecture
一个典型的分布对象计算架构 The architecture
对象 Objects and Clients 接口 OMG IDL “对象管理器” ORB 底层通信协议 IIOP 其他
23/4/19Institute of Computer Software
Nanjing University
44
23/4/19Institute of Computer Software
Nanjing University45
Distributed Systems Frameworks 46Distributed Systems Frameworks
Overview of CORBA Objects CORBA Object
<identity, interface, implementation>
CORBA objects differ from typical programming language objects: CORBA objects can be located anywhere on a network. CORBA objects (like Java objects) can run on any platform. CORBA objects can be written in any of several languages.
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. CORBA objects approach universal accessibility.
Distributed Systems Frameworks 47Distributed Systems Frameworks
Overview of CORBA Objects 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”)
A client of an object has access to an object reference for the object, and invokes operations on the object. A client knows only the logical structure of the object according to its
interface and experiences the behavior of the object through invocations.
Client code has no knowledge of the implementation of the object or which ORB is used to access the implementation.
Distributed Systems Frameworks 48
Role of OMG IDL
Distributed Systems Frameworks
ORB
C
C++
Ada
I D L
I D L
I D L
I D L
I D L
I D L
Client Side Object Implementation
Side
COBOL
C
Ada
C++
Smalltalk
JAVA
I D L
I D L
I D L
I D L
I D L
I D L
ORB
C++
COBOL
Smalltalk
JAVA
Internet InterORB
Protocol (IIOP)
Distributed Systems Frameworks 49Distributed Systems Frameworks
OMG IDL OMG Interface Definition Language (IDL):
mappings for many languages/compilers; independent of any particular language/compiler; multiple-inheritance, public interface-structured
specification language; not for implementation. primary support for interoperability between static and
dynamic requests mechanisms.
Distributed Systems Frameworks 50Distributed Systems Frameworks
OMG IDL IDL Structure
Module a namespace
Interface abstract type multiple inheritance
Struct structured data
Module auction { exception NotAllowed {};
struct Sale { int price; string item; }
interface Auction { void bid (in long price) raises NotAllowed; }}
Module auction { exception NotAllowed {};
struct Sale { int price; string item; }
interface Auction { void bid (in long price) raises NotAllowed; }}
Distributed Systems Frameworks 51Distributed Systems Frameworks
ClientClient Object ImplementationObject Implementation
ORB
RequestRequest
A Request A request consists of:
Target object (target object identified by a unique object reference) Operation Parameters (the input, output and in-out parameters defined for the
operation; may be specified individually or as a list) Optional request context
Skeletoncode
Skeletoncode
Client Proxy(stub code)
Client Proxy(stub code)
Distributed Systems Frameworks 52
CORBA Framework Elements
Object Request Broker (ORB) This is the object manager in CORBA
Mechanisms for specifying interfaces Interface Definition Language (IDL) - for static interface definitions Dynamic Invocation Interface (DII) - lets clients access interfaces as
first-class objects at run-time from an Interface Repository.
Internet Inter-Orb Protocol (IIOP) A binary protocol for communication between ORBs. Was added in CORBA 2.0
Distributed Systems Frameworks 53
Object Request Broker (ORB) The Object Manager in CORBA Both on the client side and the server side (allows user programs
to act as both clients and servers of remote objects) On client side the ORB is responsible for
accepting requests for a remote object finding implementation of the object accepting client-side reference to the remote object(converted to a language
specific form, e.g., a Java stub object) routing client method calls through the object reference to the object
implementation
On server side the ORB lets object servers register new objects receives requests from the client ORB uses object’s skeleton interface to invoke object’s activation method creates reference for new object and sends it back to client
Distributed Systems Frameworks 54
Internet Inter-Orb Protocol (IIOP) CORBA specification is neutral with respect to network protocols
the CORBA standard specifies what is known as the General Inter-ORB Protocol (GIOP) GIOP is a high-level standard protocol for communication between ORBs not used directly; instead, it is specialized by a particular protocol that would then be
used directly
Internet Inter-ORB Protocol (IIOP) IIOP is the GIOP-based protocol for TCP/IP networks As of the 2.0 version of the CORBA specification, vendors are required to implement the
IIOP protocol
CORBA Networking Model CORBA applications are built on top of GIOP-derived protocols such as IIOP these protocols, in turn, rest on top of TCP/IP, DCE, or other underlying transport
protocol the network uses 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 55Distributed Systems Frameworks
Passing Objects by Reference In a distributed application, there are two possible methods for
an application component to obtain access to an object in another process: 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.
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.
Note: in CORBA, objects are only passed by reference (however, the new CORBA specifications include facilities for passing objects by value).
Distributed Systems Frameworks 56Distributed Systems Frameworks
Object References An Object Reference is the information needed to specify an object
within an ORB. The representation of an object reference handed to a client is only valid for the lifetime
of that client. The language mapping also provides additional ways to access object references in a
typed way for the convenience of the programmer. 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.
To invoke a CORBA object, you need a reference for the object. There are two ways to get a reference for a CORBA object: from another object, such as a factory or a name service
from a string that was specially created from an object reference
Interoperable Object References CORBA uses IOR as a “pointer” to a specific instance of a class in a distributed
environment encodes host, port, object identity may be externalized (using object_to_string)
Distributed Systems Frameworks 57Distributed Systems Frameworks
CORBA Components Client stub
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).
The stubs make calls on the rest of the ORB using interfaces that are private to Java IDL. Alternatively, a client may dynamically construct and invoke request objects which can
represent any object operation.
Implementation Skeleton Each skeleton provides the interface through which a method receives a request (dynamic
and static skeletons)
Object Adapter Purpose is to interface an object's implementation with its ORB 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.
ORB Interface 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 58Distributed Systems Frameworks
ObjectAdapter
ImplementationSkeletons
ORB Core
Client Object Implementation
ClientStubs
ORBInterface
DynamicInvocation
standard interface
One interface per object operation
One interface per object adaptor
Proprietary ORB interface
Normal call interfaceUp call interface
CORBA Components
Distributed Systems Frameworks 59Distributed Systems Frameworks
Client
ClientStubs
ORBInterface
DynamicInvocation
Clients perform requests using object references.
Clients may issue requests through object interface stubs (static) or dynamic invocation interface.
Clients may access general ORB services:
• Interface Repository.• Context Management.• List Management.• Request Management.
Client Side
Distributed Systems Frameworks 60Distributed Systems Frameworks
Object Implementation
ORBInterface
ObjectAdapter
Implementations receive requests through skeletons (without knowledge of invocation approach).
The Object Adapter provides for:• management of references;• method invocation;• authentication;• implementation registration;• activation/deactivation.
ImplementationSkeletons
Implementation Side
Distributed Systems Frameworks 61Distributed Systems Frameworks
Static v. Dynamic Invocation Static Invocation
Static interfaces are generated in form of client stubs by the IDL (pre-) compiler.
This means that the structure of the object has to be known before hand (at compile time).
Allows for better type checking; less runtime overhead; self-documentation.
Dynamic Invocation 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).
Clients must discover interface-related information at runtime (e.g., using the interface repository)
Servers can offer new services anytime without the need for recompilation on the client side.
Distributed Systems Frameworks 62Distributed Systems Frameworks
Dynamic Requests The Dynamic Invocation Interface (DII) allows clients to
dynamically: discover objects; discover objects’ interfaces; create requests; invoke requests; receive responses.
Major features of Dynamic Invocation Interface: requests appear as objects themselves; requests are reusable; invocation may be synchronous or asynchronous; requests may be generated dynamically, statically or in combination approach.
Distributed Systems Frameworks 63Distributed Systems Frameworks
CORBA Interface Repository The Interface Repository is a service that provides persistent
objects that represent the IDL information in a form available at runtime. Note: The Java IDL runtime does not include an implementation of an
Interface Repository and one is not generally required by clients at runtime. 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.
Interface Repository provides: Dynamic client access to interface definitions to construct a request. Dynamic type-checking of request signatures. Traversal of inheritance graphs. ORB-to-ORB interoperability.
Distributed Systems Frameworks 64Distributed Systems Frameworks
CORBA Implementation Repository The Implementation Repository contains information that allows the
ORB to locate and activate implementations of objects. 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.
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)
The Implementation Repository supports the implementation of object servers. It is not needed by clients in order to access servers.
Distributed Systems Frameworks 65Distributed Systems Frameworks
IDL InterfaceDefinitions
ImplementationInstallation
ClientStubs
InterfaceRepository
ImplementationRepositoryImplementation
Skeletons
Client Object Implementation
Accesses Includes DescribesIncludes
Summary of CORBA Interfaces
All objects are defined in IDL by specifying their interfaces. Object definitions (interfaces) are manifested as objects in the Interface
Repository, as client stubs, and as implementation skeletons. Descriptions of object implementations are maintained as objects in the
Implementation Repository.
Distributed Systems Frameworks 66Distributed Systems Frameworks
Summary: CORBA Remote Method Invocation
Clients use “object interfaces” through language mapping Java clients should work on any ORB that supports the Java language bindings. Clients can call any object instance remotely, so long as the object instance
implements the interface.
Clients can call remote objects statically or dynamically The server cannot tell whether the client is using static or dynamic invocation.
Objects are identified using a unique id: Interoperable Object Reference (IOR) CORBA normally passes objects by reference IOR was Introduced in CORBA 2.0 Object references can be converted to strings and back to “live” objects via
ORB interface functions.
摘要 背景
Why, What, How 一般框架 CORBA Java RMI
23/4/19Institute of Computer Software
Nanjing University
67
RMI: Java distributed object model
Remote Method Invocation Java 语言之内,充分利用这一点!
Stub 可下载! 可以传“对象”! Garbage Collection!
传“引用” java.rmi.Remote (RemoteException)
23/4/19Institute of Computer Software
Nanjing University
68
23/4/19Institute of Computer Software
Nanjing University69
作业 与 DOC (分布对象计算)相比,传统的
Socket 编程有什么优势和劣势?为什么需要DOC ?
在分布式应用中,在不同进程中传递对象有哪两种方法? COBRA 采用的是哪种?
23/4/19Institute of Computer Software
Nanjing University
70
top related