Object Interaction: RMI and RPC 1
Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products - Java RMI,CORBA,DCOM - Sun RPC - JINI
Why Middleware? 3 Location transparency - client/server need not know their location Sits on top of OS, independent of: - communication protocols: use abstract request-reply protocols over UDP,TCP - computer hardware: use external data representation e.g. CORBA CDR - operating system: use e.g. socket abstraction available in most systems - programming language: e.g. CORBA supports Java, C++
Middleware Layer 4 Applications Request-reply protocol External data representation RMI, RPC and events Operating System Middleware layer
Objects 5 Objects = data + methods Interact via interfaces: - define types of arguments and exceptions of methods Data Implementation of methods object Data Implementation of methods object interface m1 m2 m3 m4 m5
The object model 6 Programs logically partitioned into objects - distributing objects natural and easy Interfaces - the only means to access data, make them remote? Actions - via method invocation -interaction, chains of invocations -may lead to exceptions, part of interface
--exceptions system as well as programmer-defined reactions on unexpected or error situations -Garbage collection -disposal of resources (memory) that are occupied by objects that are no longer referenced and will not be needed any more in the future - reduced effort, error-free (Java, not C++)
The distributed object model 9 Objects distributed (client-server models) Extend with - Remote object reference - Remote interfaces - Remote method invocation (RMI) A B C D E REMOTE INVOCATION LOCAL INVOCATION LOCAL INVOCATION LOCAL INVOCATION F REMOTE INVOCATION
Advantages of distributed objects 11 Data encapsulation gives better protection - concurrent processes, interference Method invocations - can be remote or local Objects - can act as clients, servers, etc - can be replicated for fault-tolerance and performance
Remote Object Reference 12 Object References - used to access objects which live in processes - can be passed as arguments, stored in variables,… Remote Object References - object identifiers in a distributed system - must be unique in space and time - error returned if accessing a deleted object - can allow relocation
Remote Object Reference 13 Constructing unique remote object reference - IP address, port, interface name - time of creation, local object number (new for each object) Use the same as for local object references If used as addresses - cannot support relocation Interface of remote object Object number timePort numberInternet address 32 bit 32 bit 32 bit 32 bit
Remote Object and its interfaces 14 CORBA: Interface Definition Language (IDL) Java RMI: as other interfaces, keyword remote m1 m2 m3 Data Implementation Of method Remote object m4 m5 m6 Local interface Remote interface
if implemented over UDP, then the following failures may occur: – message omission – messages not delivered in send order – message duplication additionally, process failures are possible (crash) consequence: cannot be guaranteed, that remote operations are executed exactly once (as it can be guaranteed for local operations)