1 distributed systems distributed objects & remote invocation corba dr. sunny jeong....

23
1 Distributed Systems Distributed Objects & Remote Distributed Objects & Remote Invocation Invocation CORBA CORBA Dr. Sunny Jeong. [email protected] Mr. Colin Zhang [email protected] With Thanks to Prof. G. Coulouris, Prof. A.S. Tanenbaum and Prof. S.C Joo

Upload: marlene-young

Post on 18-Dec-2015

224 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

1

Distributed Systems

Distributed Objects & Remote Distributed Objects & Remote InvocationInvocation

CORBACORBADr. Sunny Jeong. [email protected]

Mr. Colin Zhang [email protected] Thanks to Prof. G. Coulouris, Prof. A.S. Tanenbaum and Prof.

S.C Joo

Page 2: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

2

Distributed Object & Remote invocation

% rmic 클래스명Laptop

PDA

desktop

Local Data Format

Global Data Format(ex, XDR, CDR, Java object serialization )

Local Data FormatMarshalling Unmarshalling

MarshallingUnmarshallingNetwork

RequestReply

Page 3: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

3

Overviews

Common Object Resource Broker Architecture

Interface Definition Language (IDL)

Object Management Group (OMG) (http://www.omg.org) Specification

Java IDL (jdk1.2) use CORBA objects with Java Programming Language

Page 4: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Introduction-CORBA

Technology for Distributed ObjectsSimilar in function to Java RMINot Java-centricAny language with IDL specificationIDL is a language-neutral interface

definition languageObject Requst Broker (ORB) enables

low-level communication between CORBA Objects

Page 5: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

CORBA Architecture

Page 6: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Remote Interfaces and Stubs

IDL Interface

StubRemote Object

(Server)Client Skeleton

implements implements

extends

Page 7: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

CORBA Architecture

Client and Server Relationships common to CORBA and RMI

Server provides remote interfaceClient calls remote interfaceObject level interaction rather than

application level interaction (sockets)Objects can fulfill both roles

Page 8: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Client Side

Client has reference to remote objectObject reference has a stub methodStand-in for remote methodStub wired into ORBCall on stub invokes ORB’s low-level

communication routinesORB forwards invocation to server

Page 9: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Server Side

ORB on Server Side uses Skeleton Code to translate remote invocation into call on the local object

Skeleton transforms results or errors and returns to ORB for delivery to client

ORB-ORB communication with IIOP (Internet Inter-ORB Protocol)

Page 10: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

ORB

Different VendorsIIOP based on TCP/IP by OMGORB Services

Look up (JDK1.2)Object PersistenceTransactionsMessaging

Page 11: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Java IDL Development

Define interface to Remote Object with IDL

idlj or idltojava compiler generates stub and skeleton source, and code to interface with ORB

IDL interface can be implemented in any CORBA compliant language (C, C++, Smalltalk, COBOL, Ada)

Page 12: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Java IDL Development

Define interface to Remote Object with IDL

Idltojava(idlj) compiler generates stub and skeleton source, and code to interface with ORB

IDL interface can be implemented in any CORBA compliant language (C, C++, Smalltalk, COBOL, Ada)

Page 13: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Compile remote interface (idltojava or idlj)

Implement the server. It should start ORB and wait on invocations from clients, as well as implement remote methods.

Implement client. Start ORB, look up server, obtain remote reference, and call remote method (

Start applications.

Java IDL Execution (ctd)

Page 14: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Copyright © 1997 Alex Chaffee

CORBA Flow

Client Virtual Machine

Client

Server Virtual Machine

Stub

Remote Object

Skeleton

Name Server Virtual Machine

“Hey”

Server

Page 15: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

CORBA Flow

Client Virtual Machine

Client

Server Virtual Machine

Stub

Remote Object

Skeleton

Name Server Virtual Machine

“Fred”

Server

1

2

1. Server Creates Remote Object2. Server Registers Remote Object

Copyright © 1997 Alex Chaffee

Page 16: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

CORBA Flow

Client Virtual Machine

Client

Server Virtual Machine

Stub

Remote Object

Skeleton

Name Server Virtual Machine

“Fred”

Server

4

3. Client requests object from Name Server4. Name Server returns remote reference(and stub gets created)

3

Copyright © 1997 Alex Chaffee

Page 17: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

RMI Flow

Client Virtual Machine

Client

Server Virtual Machine

Stub

Remote Object

Skeleton

Name Server Virtual Machine

“Fred”

Server

6

5. Client invokes stub method6. Stub talks to skeleton7. Skeleton invokes remote object method

5 7

Copyright © 1997 Alex Chaffee

Page 18: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Example

Hello World has two remote methods that returns a string & summation to be displayed.

Client invokes sayHello and sum on Hello server

ORB transfers invocation to servant object registered for interface

Servant’s sayHello and sum runs, returns String and summation

ORB transfers String and summation back to client

Client Displays String and summation

Page 19: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Hello.idl

module HelloApp { interface Hello { string sayHello();

long sum(in long x); }; };

Page 20: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

CORBA module is name space that is a container for related interfaces and definitions.

Like a Java Package module statement mapped to java package

statement interface specifies contract object has with

other objects interface to interface in java

Hello.idl - module

Page 21: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

CORBA operations are behaviors that server promises to do on client’s behalf

operation to method in java idlj (idltojava) Hello.idl creates a HelloApp

directory, and six files.HelloPOA.java: Abstract class is the server

skeloton. It implements Hello.java. Server class will extend this class.

_HelloStub.java: Client stub. Implements Hello.java

Hello.idl - HellApp

Page 22: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Hello.java: Java version of IDL interface. Subclasses org.omg.CORBA.Object to provide base CORBA functionality.

HelloHelper.java: Provides other functionality. narrow method cast CORBA object reference to proper type.

HelloHolder.java: final class provides out and inout arguments .

HelloOperations.java: contains all the methods from IDL for stub and skeleton

Page 23: 1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. spjeong@uic.edu.hk Mr. Colin Zhang colinzhang@uic.edu.hk With Thanks

Running the Example

Compile IDL by (idlj –fall __.idl) Compile every files HellApp Compile client and server start name service:

tnameserv -ORBInitialPort 1050 (ref. 0-1023) (or with demon : start orbd –ORBInitialPort 1050) start client and server

java HelloServer -ORBInitialPort 1050java HelloClient -ORBInitialPort 1050

-ORBInitialHost ‘hostname’