1 distributed systems distributed objects & remote invocation corba dr. sunny jeong....
TRANSCRIPT
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
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
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
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
CORBA Architecture
Remote Interfaces and Stubs
IDL Interface
StubRemote Object
(Server)Client Skeleton
implements implements
extends
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
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
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 VendorsIIOP based on TCP/IP by OMGORB Services
Look up (JDK1.2)Object PersistenceTransactionsMessaging
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)
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)
Copyright © 1997 Alex Chaffee
CORBA Flow
Client Virtual Machine
Client
Server Virtual Machine
Stub
Remote Object
Skeleton
Name Server Virtual Machine
“Hey”
Server
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
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
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
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); }; };
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
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
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 1050java HelloClient -ORBInitialPort 1050
-ORBInitialHost ‘hostname’