Distributed Object & Remote invocation

Download Report

Transcript Distributed Object & Remote invocation

Distributed Systems
Distributed Objects & Remote
Invocation
Dr. Sunny Jeong. CORBA
[email protected]
Mr. Colin Zhang [email protected]
With Thanks to Prof. G. Coulouris, Prof. A.S. Tanenbaum and Prof. S.C Joo
1
Distributed Object & Remote invocation
Request
Reply
Local Data Format
Marshalling
% rmic 클래스명
Laptop
desktop
Unmarshalling
Network
Unmarshalling
Local Data Format
Marshalling
Global Data Format
(ex, XDR, CDR, Java object serialization )
PDA
2
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
3
Introduction-CORBA
Technology for Distributed Objects
Similar in function to Java RMI
Not Java-centric
Any language with IDL specification
IDL is a language-neutral interface
definition language
Object Requst Broker (ORB) enables lowlevel communication between CORBA
Objects
CORBA Architecture
Remote Interfaces and Stubs
IDL Interface
implements
implements
extends
Client
Stub
Skeleton
Remote Object
(Server)
CORBA Architecture
Client and Server Relationships common to
CORBA and RMI
Server provides remote interface
Client calls remote interface
Object level interaction rather than application
level interaction (sockets)
Objects can fulfill both roles
Client Side
Client has reference to remote object
Object reference has a stub method
Stand-in for remote method
Stub wired into ORB
Call on stub invokes ORB’s low-level
communication routines
ORB forwards invocation to server
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)
ORB
Different Vendors
IIOP based on TCP/IP by OMG
ORB Services
Look up (JDK1.2)
Object Persistence
Transactions
Messaging
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)
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)
Java IDL Execution (ctd)
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.
CORBA Flow
Client Virtual Machine
Server Virtual Machine
Client
Remote
Object
Skeleton
Stub
Server
“Hey”
Name Server Virtual Machine
Copyright © 1997 Alex Chaffee
CORBA Flow
1. Server Creates Remote Object
Client Virtual Machine
2. Server Registers Remote Object
Client
Server Virtual Machine
Remote
Object
1
Skeleton
Stub
Server
2
“Fred”
Name Server Virtual Machine
Copyright © 1997 Alex Chaffee
CORBA Flow
Client Virtual Machine
Client
3. Client requests object fromRemote
Name Server
4. Name Server returns remote
reference
Object
(and stub gets created)
Skeleton
Stub
3
Server Virtual Machine
Server
4
“Fred”
Name Server Virtual Machine
Copyright © 1997 Alex Chaffee
RMI Flow
Client Virtual Machine
Server Virtual Machine
Client
Remote
Object
5
7
6
Stub
Skeleton
Server
5. Client invokes stub method
6. Stub talks to skeleton
7. Skeleton invokes remote object
“Fred”
method
Name Server Virtual Machine
Copyright © 1997 Alex Chaffee
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
Hello.idl
module HelloApp
{
interface Hello
{
string sayHello();
long sum(in long x);
};
};
Hello.idl - module
 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 - HellApp
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.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
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 1050
java HelloClient -ORBInitialPort 1050
-ORBInitialHost ‘hostname’