240-322 cli/serv.: rmicorba/131 client/server distributed systems v objectives –introduce rmi and...

52
40-322 Cli/Serv.: rmiCORBA/13 Client/Server Distributed Syste Client/Server Distributed Syste ms ms Objectives Objectives introduce rmi and CORBA introduce rmi and CORBA 240-322, Semester 1, 2005-2006 13. RMI and CORBA

Upload: theresa-perkins

Post on 12-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 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

240-322 Cli/Serv.: rmiCORBA/13 1

Client/Server Distributed SystemsClient/Server Distributed Systems

ObjectivesObjectives– introduce rmi and CORBAintroduce rmi and CORBA

240-322, Semester 1, 2005-2006

13. RMI and CORBA

Page 2: 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

240-322 Cli/Serv.: rmiCORBA/13 2

1. RMI Overview1. RMI Overview

1.11.1 What is RMI?What is RMI?

1.21.2 A Typical RMI ApplicationA Typical RMI Application

1.3.1.3. Server-side FeaturesServer-side Features

1.4. 1.4. Client-side FeaturesClient-side Features

1.5.1.5. AdvantagesAdvantages

1.6.1.6. DisadvantagesDisadvantages

1.7.1.7. More Details on RMIMore Details on RMI

Page 3: 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

240-322 Cli/Serv.: rmiCORBA/13 3

RMI == Remote Method InvocationRMI == Remote Method Invocation– allows a Java object to call a method of a Java allows a Java object to call a method of a Java

object running on another machineobject running on another machine

– RMI is a modern version of RPC for RMI is a modern version of RPC for communication between Java objectscommunication between Java objects

1.1. What is RMI1.1. What is RMI??

Page 4: 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

240-322 Cli/Serv.: rmiCORBA/13 4

1.2. A Typical RMI Application 1.2. A Typical RMI Application

rmiregistry

clientserver

remoteobjects

lookupremote reference

2

store (rebind)remotereferences

1

invokemethodvia the remotestub

4

remotestub

3

1099

Page 5: 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

240-322 Cli/Serv.: rmiCORBA/13 5

1.3. Server-side Features1.3. Server-side Features

The server:The server:– creates creates remote objectsremote objects (objects that will be (objects that will be

accessible by clients)accessible by clients) the server is sometimes called a the server is sometimes called a server factoryserver factory

– places places remote referencesremote references (names) for the (names) for the objects in the objects in the rmiregistry

they can then be accessed by clientsthey can then be accessed by clients

continued

Page 6: 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

240-322 Cli/Serv.: rmiCORBA/13 6

A remote object is made from a A remote object is made from a remote remote interfaceinterface and a separate implementation class. and a separate implementation class.

A remote interface is a set of A remote interface is a set of method method prototypesprototypes– a method prototype is the name of the method and a method prototype is the name of the method and

the types of its input arguments and return typethe types of its input arguments and return type

continued

remoteinterface

impl.

Page 7: 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

240-322 Cli/Serv.: rmiCORBA/13 7

Example Remote InterfaceExample Remote Interface

import java.rmi.Remote; import java.rmi.RemoteException;

public interface Hello extends Remote { String sayHello() throws RemoteException;}

The remote object willhave this interface

Page 8: 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

240-322 Cli/Serv.: rmiCORBA/13 8

1.4. Client-side Features1.4. Client-side Features

The client gets a reference to a server's remThe client gets a reference to a server's remote object by querying the ote object by querying the rmiregistryrmiregistry..

At the programming level, this reference apAt the programming level, this reference appears to be the remote objectpears to be the remote object– in fact it refers to a in fact it refers to a remote stubremote stub which is downl which is downl

oaded invisibly from the rmiregistryoaded invisibly from the rmiregistry

Page 9: 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

240-322 Cli/Serv.: rmiCORBA/13 9

The remote stub is an ordinary Java classThe remote stub is an ordinary Java class– its purpose is to handle the low-level communicits purpose is to handle the low-level communic

ation between the client and the remote object oation between the client and the remote object on the server-side.n the server-side.

Object data is passed between the client and Object data is passed between the client and server using a standard feature of Java calleserver using a standard feature of Java called d object serializationobject serialization..

Page 10: 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

240-322 Cli/Serv.: rmiCORBA/13 10

Diagram of CommunicationDiagram of Communication

clientremoteobject

hi.sayHello()is really...

remotestub

1. serializethe call

2. stream of bytesserver

3. call 4. result

5. stream of bytes

6. result

Page 11: 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

240-322 Cli/Serv.: rmiCORBA/13 11

1.5. Advantages1.5. Advantages Dynamic code loadingDynamic code loading

– a client does not need to contain any a client does not need to contain any communication code when written -- that is communication code when written -- that is downloaded when the remote stub is retrieveddownloaded when the remote stub is retrieved

– a client can dynamically download other classes a client can dynamically download other classes e.g. those used by the remote stube.g. those used by the remote stub

– the server can also download code from the clientthe server can also download code from the client

continued

Page 12: 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

240-322 Cli/Serv.: rmiCORBA/13 12

The programmer doesn't write any The programmer doesn't write any communication codecommunication code– the remote stub is generated automatically by the remote stub is generated automatically by

passing the remote interface to the RMI passing the remote interface to the RMI compiler (compiler (rmicrmic) )

Page 13: 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

240-322 Cli/Serv.: rmiCORBA/13 13

1.6. Disadvantages1.6. Disadvantages

Not easy to integrate RMI Java code with Not easy to integrate RMI Java code with legacy applications in other languages (e.g. legacy applications in other languages (e.g. C, C++).C, C++).

Page 14: 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

240-322 Cli/Serv.: rmiCORBA/13 14

1.7. More Details on RMI1.7. More Details on RMI

The Java RMI tutorialThe Java RMI tutorialhttp://java.sun.com/docs/http://java.sun.com/docs/

A starting point for RMI information:A starting point for RMI information:http://java.sun.com/products/jdk/rmihttp://java.sun.com/products/jdk/rmi

Page 15: 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

240-322 Cli/Serv.: rmiCORBA/13 15

2. CORBA Overview2. CORBA Overview

2.1. What is CORBA?2.1. What is CORBA?

2.2. Important CORBA Features2.2. Important CORBA Features

2.3. Why use CORBA?2.3. Why use CORBA?

2.4. CORBA/Java Advantages2.4. CORBA/Java Advantages

2.5. A CORBA Application2.5. A CORBA Application

2.6. Other CORBA Coding Styles2.6. Other CORBA Coding Styles

2.7. Comparisons with Other Approaches2.7. Comparisons with Other Approaches

2.8. More Details on CORBA2.8. More Details on CORBA

Page 16: 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

240-322 Cli/Serv.: rmiCORBA/13 16

2.1. What is CORBA?2.1. What is CORBA?

The Common Object Request Broker The Common Object Request Broker Architecture (CORBA)Architecture (CORBA)– a a specificationspecification, not an implementation, not an implementation

The Object Management Group’s (OMG) The Object Management Group’s (OMG) aim:aim:– specify a distributed computing environment specify a distributed computing environment

within an object-oriented frameworkwithin an object-oriented framework i.e. using objects, methods, message passing, etc.i.e. using objects, methods, message passing, etc.

Page 17: 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

240-322 Cli/Serv.: rmiCORBA/13 17

Using CORBA (simple view)Using CORBA (simple view)

Clientobject

ORB

call a method in an objectmanaged by the server byusing an object reference

network

Server

ORB

methodcall & result

objectsmanaged by

the server

Page 18: 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

240-322 Cli/Serv.: rmiCORBA/13 18

ORBsORBs An Object Request Broker (ORB) implements the An Object Request Broker (ORB) implements the

features specified by CORBA.features specified by CORBA.

An ORB can be coded in An ORB can be coded in anyany language language– so long as it supports CORBA’s functionalityso long as it supports CORBA’s functionality

ORBs communicate using the Internet Inter-ORB ORBs communicate using the Internet Inter-ORB Protocol (IIOP)Protocol (IIOP)– an extension of TCPan extension of TCP

Page 19: 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

240-322 Cli/Serv.: rmiCORBA/13 19

Major ORB ComponentsMajor ORB Components

DynamicInvocation

IDLStubs

ORBInterface

IDLSkeleton

Object Adapter

ORB Core

Client Object Implementation

Page 20: 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

240-322 Cli/Serv.: rmiCORBA/13 20

Using CORBA (more detail)Using CORBA (more detail)

Client

IDL client stub

ORB interface

ORB internals

ORB interface

ORB internals

Server

IDL server skeleton

Network

Page 21: 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

240-322 Cli/Serv.: rmiCORBA/13 21

IDL:IDL: Interface Definition LanguageInterface Definition Language

– for defining OO data and methodsfor defining OO data and methods

The J2SE The J2SE idltojavaidltojava compiler generates client compiler generates client stubs and server skeletons for work with any stubs and server skeletons for work with any CORBA ORB.CORBA ORB.

J2SE includes a simple (free) ORB.J2SE includes a simple (free) ORB.

(Java) IDL(Java) IDL

Page 22: 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

240-322 Cli/Serv.: rmiCORBA/13 22

IDL ExamplesIDL Examples

module HelloAppmodule HelloApp{{ interface Hello { interface Hello { string sayHello(); string sayHello(); }; };};};

continued

Page 23: 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

240-322 Cli/Serv.: rmiCORBA/13 23

module Appliance module Appliance {{ interface TV { interface TV { readonly attribute string SerialNo; readonly attribute string SerialNo; attribute short Vol; attribute short Vol; attribute short Channel; attribute short Channel; void operate(); void operate(); }; };

interface WebTV : TV { interface WebTV : TV { void surfTo(in URL url); void surfTo(in URL url); }; };};};

Page 24: 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

240-322 Cli/Serv.: rmiCORBA/13 24

2.2. Important CORBA Features2.2. Important CORBA Features

An object’s interface (An object’s interface (serviceservice) is completely ) is completely separated from its implementation.separated from its implementation.

An object’s location is completely hidden. An object’s location is completely hidden. Consequently, CORBA provides:Consequently, CORBA provides:– a naming servicea naming service (white pages)(white pages)– a trading servicea trading service (yellow pages)(yellow pages)– an interface Repository (IR)an interface Repository (IR)

continued

Page 25: 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

240-322 Cli/Serv.: rmiCORBA/13 25

Object communication is greatly simplified:Object communication is greatly simplified:– messages, written in IDLmessages, written in IDL

An object can find other objects at run-time An object can find other objects at run-time by using the Dynamic Invocation Interface by using the Dynamic Invocation Interface (DII):(DII):– but the usual approach is to already know the but the usual approach is to already know the

location of the other objectlocation of the other object

continued

Page 26: 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

240-322 Cli/Serv.: rmiCORBA/13 26

Objects can be built more easily by using Objects can be built more easily by using pre-existing CORBA services for:pre-existing CORBA services for:– message encoding, object locating, security, etc.message encoding, object locating, security, etc.

Advanced services:Advanced services:– persistent objects, transactions, concurrency persistent objects, transactions, concurrency

control, etc.control, etc.

continued

Page 27: 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

240-322 Cli/Serv.: rmiCORBA/13 27

CORBA facilities:CORBA facilities:– horizontal and vertical application frameworkshorizontal and vertical application frameworks– e.g. printing, mobile agentse.g. printing, mobile agents

Convert legacy code in Basic, C, etc. into Convert legacy code in Basic, C, etc. into objectsobjects– uses CORBA object adaptorsuses CORBA object adaptors

Page 28: 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

240-322 Cli/Serv.: rmiCORBA/13 28

2.3. Why Use CORBA?2.3. Why Use CORBA?

It provides a powerful OO mechanism for It provides a powerful OO mechanism for defining the interfaces between distributed defining the interfaces between distributed objects.objects.

It offers many services and facilities.It offers many services and facilities. Platform/language independent.Platform/language independent. An open standard:An open standard:

– ensures its continued innovation and evolutionensures its continued innovation and evolution

Page 29: 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

240-322 Cli/Serv.: rmiCORBA/13 29

2.4. CORBA/Java Advantages2.4. CORBA/Java Advantages

CORBA’s advantages for Java:CORBA’s advantages for Java:– CORBA supports object method calling from CORBA supports object method calling from

anywhereanywhere

– CORBA allows Java to work with objects coded in CORBA allows Java to work with objects coded in other (non-OO) languagesother (non-OO) languages

– CORBA augments Java’s networking featuresCORBA augments Java’s networking features e.g. it encourages multi-host applicationse.g. it encourages multi-host applications

continued

Page 30: 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

240-322 Cli/Serv.: rmiCORBA/13 30

Java’s advantages for CORBAJava’s advantages for CORBA– Java’s OO features match those in CORBAJava’s OO features match those in CORBA

e.g. separation of interface (service) and impl.e.g. separation of interface (service) and impl.

– Java has many useful features for implementing Java has many useful features for implementing CORBA services and facilities:CORBA services and facilities: multi-threading, exceptions, GUI, packages,multi-threading, exceptions, GUI, packages,

automatic garbage collectionautomatic garbage collection

Page 31: 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

240-322 Cli/Serv.: rmiCORBA/13 31

2.5. A CORBA Application2.5. A CORBA Application

1. Write an IDL interface for the remote objects 1. Write an IDL interface for the remote objects managed by the server.managed by the server.

2.2. Compile the IDL interfaceCompile the IDL interface– it generates a Java version of the interfaceit generates a Java version of the interface– it generates stub and skeleton code for the client and serverit generates stub and skeleton code for the client and server

continued

Page 32: 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

240-322 Cli/Serv.: rmiCORBA/13 32

3. Write the server, which has two parts3. Write the server, which has two parts– the the server (factory)server (factory)

it creates remote objectsit creates remote objects

– the remote object implementation (of the IDL the remote object implementation (of the IDL interface)interface)

4. Implement the client4. Implement the client– it contacts and uses a remote objectit contacts and uses a remote object

Page 33: 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

240-322 Cli/Serv.: rmiCORBA/13 33

Running the ApplicationRunning the Application

tnameserv

client

serverfactory

remoteobjects

lookupremote referenceto an object

2

store (rebind)remotereferencesfor objects

1

invoke methodvia the remotereference and stub

4

ORB

O R B

network

3

remote stub

Page 34: 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

240-322 Cli/Serv.: rmiCORBA/13 34

Using a Remote ObjectUsing a Remote Object

Client(object)

objectref

server

objectmethod invocation

continued

Client

objectref

server

object

execution

4

Page 35: 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

240-322 Cli/Serv.: rmiCORBA/13 35

Client

objectref

server

objectreturn method result

Client

objectref

server

objectgarbage collect

Page 36: 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

240-322 Cli/Serv.: rmiCORBA/13 36

Client CallbackClient Callback

Client

objectref B

method invocationobject A

Server

object B objectref A

objectref A

continued

4

Page 37: 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

240-322 Cli/Serv.: rmiCORBA/13 37

Client

objectref B

method invocation(callback)

object A

Server

object B objectref A

Page 38: 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

240-322 Cli/Serv.: rmiCORBA/13 38

2.6. Other CORBA Coding 2.6. Other CORBA Coding StylesStyles

2.6.1. Single-threaded server2.6.1. Single-threaded server

2.6.2. Multi-threaded server2.6.2. Multi-threaded server

2.6.3. Being a client and a server2.6.3. Being a client and a server

2.6.4. Blocking vs. one-way2.6.4. Blocking vs. one-way

2.6.5. Pass by reference vs. pass by value2.6.5. Pass by reference vs. pass by value

Page 39: 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

240-322 Cli/Serv.: rmiCORBA/13 39

1.6.1. Single-threaded Server1.6.1. Single-threaded Server

client 1 server client 2

method call

resultsuspended busy

method call

call proceeds

busysuspended

result

wait

Page 40: 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

240-322 Cli/Serv.: rmiCORBA/13 40

2.6.2. Multi-threaded Server2.6.2. Multi-threaded Server

client 1 server client 2

method call

result

suspendedmethod call

suspendedresult

threadexits thread

exits

Page 41: 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

240-322 Cli/Serv.: rmiCORBA/13 41

Object Factory PatternObject Factory Pattern

client 1 server client 2request object

resultresult

return ref

object

method call

object

method call

request objectreturn ref

Page 42: 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

240-322 Cli/Serv.: rmiCORBA/13 42

2.6.3. Being a Client and a Server2.6.3. Being a Client and a Server

Client B

Client/Server C

Server D

Server E

Client A

continued

Page 43: 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

240-322 Cli/Serv.: rmiCORBA/13 43

Usually, a client can be single-threaded, Usually, a client can be single-threaded, and a server should be multi-threaded.and a server should be multi-threaded.

In mixed-mode, the client may need to In mixed-mode, the client may need to be multi-threaded to handle its server be multi-threaded to handle its server role.role.

Page 44: 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

240-322 Cli/Serv.: rmiCORBA/13 44

A Mixed-mode single-threaded A Mixed-mode single-threaded ProblemProblem

client/server 1

method call

method call

client/server 2

suspended

suspended

X

deadlock

waits forever

Page 45: 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

240-322 Cli/Serv.: rmiCORBA/13 45

Multi-threaded SolutionMulti-threaded Solution

method call

suspendedresult

threadexits

client/server 1

client/server 2

method call

resultthreadexits

Page 46: 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

240-322 Cli/Serv.: rmiCORBA/13 46

2.6.4. Blocking vs. One-way2.6.4. Blocking vs. One-way

client server

method call

resultsuspended busy

Blocking

processingresumes

Page 47: 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

240-322 Cli/Serv.: rmiCORBA/13 47

client serveroneway

method call

busyone-way

processingcontinues

method callfinishes

ProblemProblem: the client has no way of knowing : the client has no way of knowing if the method call has succeeded.if the method call has succeeded.

Page 48: 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

240-322 Cli/Serv.: rmiCORBA/13 48

2.6.5. Pass by Reference vs. 2.6.5. Pass by Reference vs. ValueValue

client server

request object

result

return ref

object

method call

Pass an objectby reference.

Page 49: 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

240-322 Cli/Serv.: rmiCORBA/13 49

client server

request object

returncopy of

object

object

Pass an objectby value.

createobject

object

continued

Page 50: 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

240-322 Cli/Serv.: rmiCORBA/13 50

If a client invokes many methods in an If a client invokes many methods in an object, it may be better, in terms of object, it may be better, in terms of efficiency, to copy it to the client.efficiency, to copy it to the client.

Page 51: 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

240-322 Cli/Serv.: rmiCORBA/13 51

2.7. More Details on CORBA2.7. More Details on CORBA

Beginners Java and CORBA tutorial:Beginners Java and CORBA tutorial:http://java.sun.com/developer/http://java.sun.com/developer/onlineTraining/corba/corba.htmlonlineTraining/corba/corba.html

More technical Java & CORBA tutorial:More technical Java & CORBA tutorial:http://java.sun.com/j2se/1.5.0/docs/http://java.sun.com/j2se/1.5.0/docs/ guide/idl/ guide/idl/

OMG Site:OMG Site:http://www.omg.orghttp://www.omg.org

continued

Page 52: 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

240-322 Cli/Serv.: rmiCORBA/13 52

Java Programming with CORBAJava Programming with CORBAGerald Brose and othersGerald Brose and othersJohn Wiley, 2001, 3rd ed.John Wiley, 2001, 3rd ed.http://java.coe.psu.ac.th/ForMember/http://java.coe.psu.ac.th/ForMember/ Books.html#Network Books.html#Network