Presentation is loading. Please wait.

Presentation is loading. Please wait.

240-322 Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA 240-322, Semester 1, 2005-2006 13. RMI and CORBA.

Similar presentations

Presentation on theme: "240-322 Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA 240-322, Semester 1, 2005-2006 13. RMI and CORBA."— Presentation transcript:

1 240-322 Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA 240-322, Semester 1, 2005-2006 13. RMI and CORBA

2 240-322 Cli/Serv.: rmiCORBA/132 1. RMI Overview 1.1What is RMI? 1.2A Typical RMI Application 1.3.Server-side Features 1.4. Client-side Features 1.5.Advantages 1.6.Disadvantages 1.7.More Details on RMI

3 240-322 Cli/Serv.: rmiCORBA/133 v RMI == Remote Method Invocation –allows a Java object to call a method of a Java object running on another machine –RMI is a modern version of RPC for communication between Java objects 1.1. What is RMI ?

4 240-322 Cli/Serv.: rmiCORBA/134 1.2. A Typical RMI Application rmiregistry client server remote objects lookup remote reference 2 store (rebind) remote references 1 invoke method via the remote stub 4 remote stub 3 1099

5 240-322 Cli/Serv.: rmiCORBA/135 1.3. Server-side Features v The server: –creates remote objects (objects that will be accessible by clients) u the server is sometimes called a server factory –places remote references (names) for the objects in the –places remote references (names) for the objects in the rmiregistry u they can then be accessed by clients continued

6 240-322 Cli/Serv.: rmiCORBA/136 v A remote object is made from a remote interface and a separate implementation class. v A remote interface is a set of method prototypes –a method prototype is the name of the method and the types of its input arguments and return type continued remote interface impl.

7 240-322 Cli/Serv.: rmiCORBA/137 Example Remote Interface import java.rmi.Remote; import java.rmi.RemoteException; public interface Hello extends Remote { String sayHello() throws RemoteException; } The remote object will have this interface

8 240-322 Cli/Serv.: rmiCORBA/138 1.4. Client-side Features  The client gets a reference to a server's remote object by querying the rmiregistry. v At the programming level, this reference appears to be the remote object –in fact it refers to a remote stub which is downloaded invisibly from the rmiregistry

9 240-322 Cli/Serv.: rmiCORBA/139 v The remote stub is an ordinary Java class –its purpose is to handle the low-level communication between the client and the remote object on the server-side. v Object data is passed between the client and server using a standard feature of Java called object serialization.

10 240-322 Cli/Serv.: rmiCORBA/1310 Diagram of Communication client remote object hi.sayHello() is really... remote stub 1. serialize the call 2. stream of bytes server 3. call 4. result 5. stream of bytes 6. result

11 240-322 Cli/Serv.: rmiCORBA/1311 1.5. Advantages v Dynamic code loading –a client does not need to contain any communication code when written -- that is downloaded when the remote stub is retrieved –a client can dynamically download other classes u e.g. those used by the remote stub –the server can also download code from the client continued

12 240-322 Cli/Serv.: rmiCORBA/1312 v The programmer doesn't write any communication code –the remote stub is generated automatically by passing the remote interface to the RMI compiler ( rmic )

13 240-322 Cli/Serv.: rmiCORBA/1313 1.6. Disadvantages v Not easy to integrate RMI Java code with legacy applications in other languages (e.g. C, C++).

14 240-322 Cli/Serv.: rmiCORBA/1314 1.7. More Details on RMI v The Java RMI tutorial v A starting point for RMI information:

15 240-322 Cli/Serv.: rmiCORBA/1315 2. CORBA Overview 2.1. What is CORBA? 2.2. Important CORBA Features 2.3. Why use CORBA? 2.4. CORBA/Java Advantages 2.5. A CORBA Application 2.6. Other CORBA Coding Styles 2.7. Comparisons with Other Approaches 2.8. More Details on CORBA

16 240-322 Cli/Serv.: rmiCORBA/1316 2.1. What is CORBA? v The Common Object Request Broker Architecture (CORBA) –a specification, not an implementation v The Object Management Group’s (OMG) aim: –specify a distributed computing environment within an object-oriented framework u i.e. using objects, methods, message passing, etc.

17 240-322 Cli/Serv.: rmiCORBA/1317 Using CORBA (simple view) Client object ORB call a method in an object managed by the server by using an object reference network Server ORB method call & result objects managed by the server

18 240-322 Cli/Serv.: rmiCORBA/1318 ORBs v An Object Request Broker (ORB) implements the features specified by CORBA. v An ORB can be coded in any language –so long as it supports CORBA’s functionality v ORBs communicate using the Internet Inter- ORB Protocol (IIOP) –an extension of TCP

19 240-322 Cli/Serv.: rmiCORBA/1319 Major ORB Components Dynamic Invocation IDL Stubs ORB Interface IDL Skeleton Object Adapter ORB Core ClientObject Implementation

20 240-322 Cli/Serv.: rmiCORBA/1320 Using CORBA (more detail) Client IDL client stub ORB interface ORB internals ORB interface ORB internals Server IDL server skeleton Network

21 240-322 Cli/Serv.: rmiCORBA/1321 v IDL: Interface Definition Language –for defining OO data and methods  The J2SE idltojava compiler generates client stubs and server skeletons for work with any CORBA ORB. v J2SE includes a simple (free) ORB. (Java) IDL

22 240-322 Cli/Serv.: rmiCORBA/1322 IDL Examples module HelloApp { interface Hello { string sayHello(); }; }; continued

23 240-322 Cli/Serv.: rmiCORBA/1323 module Appliance { interface TV { readonly attribute string SerialNo; attribute short Vol; attribute short Channel; void operate(); }; interface WebTV : TV { void surfTo(in URL url); }; };

24 240-322 Cli/Serv.: rmiCORBA/1324 2.2. Important CORBA Features v An object’s interface (service) is completely separated from its implementation. v An object’s location is completely hidden. Consequently, CORBA provides: –a naming service(white pages) –a trading service(yellow pages) –an interface Repository (IR) continued

25 240-322 Cli/Serv.: rmiCORBA/1325 v Object communication is greatly simplified: –messages, written in IDL v An object can find other objects at run-time by using the Dynamic Invocation Interface (DII): –but the usual approach is to already know the location of the other object continued

26 240-322 Cli/Serv.: rmiCORBA/1326 v Objects can be built more easily by using pre-existing CORBA services for: –message encoding, object locating, security, etc. v Advanced services: –persistent objects, transactions, concurrency control, etc. continued

27 240-322 Cli/Serv.: rmiCORBA/1327 v CORBA facilities: –horizontal and vertical application frameworks –e.g. printing, mobile agents v Convert legacy code in Basic, C, etc. into objects –uses CORBA object adaptors

28 240-322 Cli/Serv.: rmiCORBA/1328 2.3. Why Use CORBA? v It provides a powerful OO mechanism for defining the interfaces between distributed objects. v It offers many services and facilities. v Platform/language independent. v An open standard: –ensures its continued innovation and evolution

29 240-322 Cli/Serv.: rmiCORBA/1329 2.4. CORBA/Java Advantages v CORBA’s advantages for Java: –CORBA supports object method calling from anywhere –CORBA allows Java to work with objects coded in other (non-OO) languages –CORBA augments Java’s networking features u e.g. it encourages multi-host applications continued

30 240-322 Cli/Serv.: rmiCORBA/1330 v Java’s advantages for CORBA –Java’s OO features match those in CORBA u e.g. separation of interface (service) and impl. –Java has many useful features for implementing CORBA services and facilities: u multi-threading, exceptions, GUI, packages, automatic garbage collection

31 240-322 Cli/Serv.: rmiCORBA/1331 2.5. A CORBA Application v 1. Write an IDL interface for the remote objects managed by the server. v 2.Compile the IDL interface –it generates a Java version of the interface –it generates stub and skeleton code for the client and server continued

32 240-322 Cli/Serv.: rmiCORBA/1332 v 3. Write the server, which has two parts –the server (factory) u it creates remote objects –the remote object implementation (of the IDL interface) v 4. Implement the client –it contacts and uses a remote object

33 240-322 Cli/Serv.: rmiCORBA/1333 Running the Application tnameserv client server factory remote objects lookup remote reference to an object 2 store (rebind) remote references for objects 1 invoke method via the remote reference and stub 4 ORBORB O R B network 3 remote stub

34 240-322 Cli/Serv.: rmiCORBA/1334 Using a Remote Object Client (object) object ref server object method invocation continued Client object ref server object execution 4

35 240-322 Cli/Serv.: rmiCORBA/1335 Client object ref server object return method result Client object ref server object garbage collect

36 240-322 Cli/Serv.: rmiCORBA/1336 Client Callback Client object ref B method invocation object A Server object B object ref A continued 4

37 240-322 Cli/Serv.: rmiCORBA/1337 Client object ref B method invocation (callback) object A Server object B object ref A

38 240-322 Cli/Serv.: rmiCORBA/1338 2.6. Other CORBA Coding Styles 2.6.1. Single-threaded server 2.6.2. Multi-threaded server 2.6.3. Being a client and a server 2.6.4. Blocking vs. one-way 2.6.5. Pass by reference vs. pass by value

39 240-322 Cli/Serv.: rmiCORBA/1339 1.6.1. Single-threaded Server client 1 server client 2 method call result suspended busy method call call proceeds busy suspended result wait

40 240-322 Cli/Serv.: rmiCORBA/1340 2.6.2. Multi-threaded Server client 1 server client 2 method call result suspended method call suspended result thread exits thread exits

41 240-322 Cli/Serv.: rmiCORBA/1341 Object Factory Pattern client 1 server client 2 request object result return ref object method call object method call request object return ref

42 240-322 Cli/Serv.: rmiCORBA/1342 2.6.3. Being a Client and a Server Client B Client/ Server C Server D Server E Client A continued

43 240-322 Cli/Serv.: rmiCORBA/1343 v Usually, a client can be single-threaded, and a server should be multi-threaded. v In mixed-mode, the client may need to be multi-threaded to handle its server role.

44 240-322 Cli/Serv.: rmiCORBA/1344 A Mixed-mode single-threaded Problem client/ server 1 method call client/ server 2 suspended X deadlock waits forever

45 240-322 Cli/Serv.: rmiCORBA/1345 Multi-threaded Solution method call suspended result thread exits client/ server 1 client/ server 2 method call result thread exits

46 240-322 Cli/Serv.: rmiCORBA/1346 2.6.4. Blocking vs. One-way client server method call result suspended busy Blocking processing resumes

47 240-322 Cli/Serv.: rmiCORBA/1347 client server oneway method call busy one-way processing continues method call finishes v Problem: the client has no way of knowing if the method call has succeeded.

48 240-322 Cli/Serv.: rmiCORBA/1348 2.6.5. Pass by Reference vs. Value client server request object result return ref object method call Pass an object by reference.

49 240-322 Cli/Serv.: rmiCORBA/1349 client server request object return copy of object Pass an object by value. create object continued

50 240-322 Cli/Serv.: rmiCORBA/1350 v If a client invokes many methods in an object, it may be better, in terms of efficiency, to copy it to the client.

51 240-322 Cli/Serv.: rmiCORBA/1351 2.7. More Details on CORBA v Beginners Java and CORBA tutorial: onlineTraining/corba/corba.html v More technical Java & CORBA tutorial: guide/idl/ v OMG Site: continued

52 240-322 Cli/Serv.: rmiCORBA/1352 v Java Programming with CORBA Gerald Brose and others John Wiley, 2001, 3rd ed. Books.html#Network

Download ppt "240-322 Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA 240-322, Semester 1, 2005-2006 13. RMI and CORBA."

Similar presentations

Ads by Google