Distributed Systems Lecture 13 Case study: CORBA Josva Kleist - - PowerPoint PPT Presentation

distributed systems lecture 13 case study corba
SMART_READER_LITE
LIVE PREVIEW

Distributed Systems Lecture 13 Case study: CORBA Josva Kleist - - PowerPoint PPT Presentation

Distributed Systems Lecture 13 Case study: CORBA Josva Kleist Unit for Distributed Systems and Semantics Aalborg University DS E02 Lec13 1 CORBA main points CORBA consists of generic services as well as a language- independent RMI


slide-1
SLIDE 1

DS E02 Lec13 1

Distributed Systems Lecture 13 Case study: CORBA

Josva Kleist Unit for Distributed Systems and Semantics Aalborg University

slide-2
SLIDE 2

DS E02 Lec13 2

CORBA main points

  • CORBA consists of generic services as well as a language-

independent RMI framework.

  • The RMI framework defines an architecture, an IDL, an external

data representation and a standard for remote object references.

  • CORBA objects have IDL interfaces and remote object

references, but may be implemented in any language, even non-

  • bject-oriented languages (e.g. C).
  • CORBA IDL (unlike Java) cannot define classes. Therefore,

instances cannot be passed as arguments, although complex data structures and remote object references can.

  • The CORBA architecture is similar to the general RMI
  • architecture. But CORBA adds the object adaptor,

implementation repository and interface repository.

slide-3
SLIDE 3

DS E02 Lec13 3

Challenges for interlingua RMI

  • Communication between different run-time systems.
  • What is an object?
  • What about classes and inheritance?
  • Parameter passing – remote refs vs. marshalling.
  • How do we locate remote objects?
slide-4
SLIDE 4

DS E02 Lec13 4

CORBA RMI main components

  • An interface definition language (IDL).
  • An architecture.
  • An external data representation format.
  • A standard format for object references.
  • A naming service.
slide-5
SLIDE 5

DS E02 Lec13 5

CORBA IDL

  • Specifies a name and set of methods that clients can

request.

  • In method specifications each parameter is marked as

either in, out, or inout allowing more than one result values to be passed.

  • Parameter passing:

– by object reference for parameters of an IDL interface. – by value for CORBA primitive and constructed types.

slide-6
SLIDE 6

DS E02 Lec13 6

IDL interfaces Shape and ShapeList

struct Rectangle{ 1 long width; long height; long x; long y; } ; struct GraphicalObject { 2 string type; Rectangle enclosing; boolean isFilled; }; struct Rectangle{ 1 long width; long height; long x; long y; } ; struct GraphicalObject { 2 string type; Rectangle enclosing; boolean isFilled; }; interface Shape { 3 long getVersion() ; GraphicalObject getAllState() ; // returns state of the GraphicalObject }; interface Shape { 3 long getVersion() ; GraphicalObject getAllState() ; // returns state of the GraphicalObject }; typedef sequence <Shape, 100> All; 4 interface ShapeList { 5 exception FullException{ }; 6 Shape newShape(in GraphicalObject g) raises (FullException); 7 All allShapes(); // returns seq of remote obj refes 8 long getVersion() ; }; typedef sequence <Shape, 100> All; 4 interface ShapeList { 5 exception FullException{ }; 6 Shape newShape(in GraphicalObject g) raises (FullException); 7 All allShapes(); // returns seq of remote obj refes 8 long getVersion() ; };

slide-7
SLIDE 7

DS E02 Lec13 7

Java interface ShapeList generated from CORBA interface ShapeList

public interface ShapeList extends org.omg.CORBA.Object { Shape newShape(GraphicalObject g) throws ShapeListPackage.FullException; Shape[ ] allShapes(); int getVersion(); }

slide-8
SLIDE 8

DS E02 Lec13 8

Java RMI Remote interfaces Shape and ShapeList

import java.rmi.*; import java.util.Vector; public interface Shape extends Remote { int getVersion( ) throws RemoteException; GraphicalObject getAllState() throws RemoteException; } public interface ShapeList extends Remote { Shape newShape(GraphicalObject g) throws RemoteException; Vector allShapes( ) throws RemoteException; int getVersion( ) throws RemoteException; } 1 2

slide-9
SLIDE 9

DS E02 Lec13 9

ShapeListServant class for CORBA interface ShapeList

import org.omg.CORBA.*; class ShapeListServant extends _ShapeListImplBase { ORB theOrb; private Shape theList[]; private int version; private static int n=0; public ShapeListServant(ORB orb){ theOrb = orb; // initialize the other instance variables } public Shape newShape(GraphicalObject g) throws ShapeListPackage.FullException { version++; Shape s = new ShapeServant( g, version); if(n >=100) throw new ShapeListPackage.FullException(); theList[n++] = s; 2 theOrb.connect(s); return s; } public Shape[] allShapes(){ ... } public int getVersion() { ... } }

slide-10
SLIDE 10

DS E02 Lec13 10

Java RMI class ShapeListServant implements interface ShapeList

import java.rmi.*; import java.rmi.server.UnicastRemoteObject; import java.util.Vector; public class ShapeListServant extends UnicastRemoteObject implements ShapeList { private Vector theList; // contains the list of Shapes private int version; public ShapeListServant()throws RemoteException{...} public Shape newShape(GraphicalObject g) throws RemoteException { version++; Shape s = new ShapeServant( g, version); theList.addElement(s); return s; } public Vector allShapes()throws RemoteException{...} public int getVersion() throws RemoteException { ... } }

slide-11
SLIDE 11

DS E02 Lec13 11

Java class ShapeListServer

import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; public class ShapeListServer { public static void main(String args[]) { try{ ORB orb = ORB.init(args, null); 1 ShapeListServant shapeRef = new ShapeListServant(orb); 2

  • rb.connect(shapeRef);

3

  • rg.omg.CORBA.Object objRef =
  • rb.resolve_initial_references("NameService");

4 NamingContext ncRef = NamingContextHelper.narrow(objRef); NameComponent nc = new NameComponent("ShapeList", ""); 5 NameComponent path[] = {nc}; 6 ncRef.rebind(path, shapeRef); 7 java.lang.Object sync = new java.lang.Object(); synchronized (sync) { sync.wait();} } catch (Exception e) { ... } } }

slide-12
SLIDE 12

DS E02 Lec13 12

Java RMI class ShapeListServer with main method

import java.rmi.*; public class ShapeListServer{ public static void main(String args[]){ System.setSecurityManager(new RMISecurityManager()); try{ ShapeList aShapeList = new ShapeListServant(); Naming.rebind("Shape List", aShapeList ); System.out.println("ShapeList server ready"); }catch(Exception e) { System.out.println("ShapeList server main " + e.getMessage());} } } 1 2

slide-13
SLIDE 13

DS E02 Lec13 13

Java client program for CORBA interfaces Shape and ShapeList

import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; public class ShapeListClient{ public static void main(String args[]) { try{ ORB orb = ORB.init(args, null); 1

  • rg.omg.CORBA.Object objRef =
  • rb.resolve_initial_references("NameService");

NamingContext ncRef = NamingContextHelper.narrow(objRef); NameComponent nc = new NameComponent("ShapeList", ""); NameComponent path [] = { nc }; ShapeList shapeListRef = ShapeListHelper.narrow(ncRef.resolve(path)); 2 Shape[] sList = shapeListRef.allShapes(); 3 GraphicalObject g = sList[0].getAllState(); 4 } catch(org.omg.CORBA.SystemException e) {...} }

slide-14
SLIDE 14

DS E02 Lec13 14

Java RMI client of ShapeList

import java.rmi.*; import java.rmi.server.*; import java.util.Vector; public class ShapeListClient{ public static void main(String args[]){ System.setSecurityManager(new RMISecurityManager()); ShapeList aShapeList = null; try{ aShapeList = (ShapeList) Naming.lookup("//bruno.ShapeList") ; Vector sList = aShapeList.allShapes(); } catch(RemoteException e) {System.out.println(e.getMessage()); }catch(Exception e) {System.out.println("Client: " + e.getMessage());} } } 1 2

slide-15
SLIDE 15

DS E02 Lec13 15

The main components of the CORBA architecture

client server proxy

  • r dynamic invocation

implementation repository

  • bject

adapter ORB ORB skeleton

  • r dynamic skeleton

client program interface repository

Request Reply

core core for A Servant A Like a communication module, plus

  • ops. enabling it to be started and stopped,
  • ops. to convert between remote obj refs and strings,
  • ops. for handling dynamic invocations

Bridge the gap between IDL interfaces and implementation language:

  • create remote obj. refs. for CORBA objects,
  • dispatch each RMI via skeleton to appropriate servant,
  • activate objects.

Generated by IDL compiler. It unmarshals/unmarshals the arguments, results and exceptions for a method. Responsible for activating servers on demand and for locating currently running servers. Maps names of objects adapters to storage of object implementations, and for active servers also to hostname and port number. Provide information about registered IDL interfaces. For a given interface information about methods and the methods names, argument, result types and exceptions can be returned. Provide facilities for reflection.

slide-16
SLIDE 16

DS E02 Lec13 16

Additional architectural elements

  • Dynamic invocation interface.

– allows a client to call remote methods without having a corresponding proxy class.

  • Dynamic skeleton interface.

– allows a CORBA object to accept invocations on an interface for which it has no skeleton.

  • Support for legacy code.

– allows for code not designed for CORBA to be used.

slide-17
SLIDE 17

DS E02 Lec13 17

Interface Definition Lanuguage (IDL)

  • Resembles C++ type definitions with additional

keywords (interface, any, in, out, inout, attribute, readonly, raises).

  • Modules allow for naming scopes.
  • Interfaces describe the methods that are available in

CORBA objects.

slide-18
SLIDE 18

DS E02 Lec13 18

Method definition

[oneway] <return type> <method name> (parm*) [raises (except*)] [context(name*)]

  • Parameters are label in, out, inout.
  • The oneway keyword indicates that a client invoking

the method will no be blocked.

  • The raises keyword indicates what user defined

exceptions the method can raise.

  • The context keyword is used supply mappings from

string names to string values.

slide-19
SLIDE 19

DS E02 Lec13 19

More IDL

  • Basic data types: 15 primitive, plus constructed.
  • IDL attributes: Like public variables in Java.
  • Inheritance allows extension of IDL interfaces.
slide-20
SLIDE 20

DS E02 Lec13 20

IDL modules

Allows definitions to be groups into logical unites, e.g.

module Whiteboard { struct Rectangle{ ...} ; struct GraphicalObject { ...}; interface Shape { ...}; typedef sequence <Shape, 100> All; interface ShapeList { ...}; };

slide-21
SLIDE 21

DS E02 Lec13 21

IDL constructed types – 1

Type Examples Use Defines a type for a variable-length sequence of elements of a specified IDL type. An upper bound on the length may be specified. sequence typedef sequence <Shape, 100> All; typedef sequence <Shape> All bounded and unbounded sequences

  • f Shapes

Defines a sequences of characters, terminated by the null character. An upper bound on the length may be specified. string String name; typedef string<8> SmallString; unbounded and bounded sequences of characters Defines a type for a multi-dimensional fixed-length sequence of elements of a specified IDL type. array typedef octet uniqueId[12]; typedef GraphicalObject GO[10][8] this figure continues on the next slide

slide-22
SLIDE 22

DS E02 Lec13 22

IDL constructed types – 2

Type Examples Use record Defines a type for a record containing a group of related entities. Structs are passed by value in arguments and results. struct GraphicalObject { string type; Rectangle enclosing; boolean isFilled; }; The enumerated type in IDL maps a type name onto a small set of integer values. enumerated enum Rand (Exp, Number, Name); The IDL discriminated union allows

  • ne of a given set of types to be passed

as an argument. The header is parameterized by an enum, which specifies which member is in use. union union Exp switch (Rand) { case Exp: string vote; case Number: long n; case Name: string s; };

slide-23
SLIDE 23

DS E02 Lec13 23

CORBA interoperable object references

IOR format

host domain name IDL interface type name Protocol and address details Object key interface repository IIOP port number adapter name object name identifier Specifies the type name

  • f the IDL interface of

the CORBA object specifies transport protocol and details required by the protocol to identify the server. Used by the ORB to identify a CORBA object

slide-24
SLIDE 24

DS E02 Lec13 24

CORBA Services

  • Naming service.
  • Event and Notification services.
  • Trading service.
  • Transaction and Concurrency control services.
  • Persistent object service.
slide-25
SLIDE 25

DS E02 Lec13 25

Naming service

  • Allows names within a naming context to be

associated with either an object reference for a CORBA object or another naming context.

  • Names consist of two parts:

– A string for the name. – A string for the kind of the object (for descriptive information).

  • Several roots (called initial naming contexts) may

exist.

slide-26
SLIDE 26

DS E02 Lec13 26

Naming graph in CORBA Naming Service

initial naming context initial naming context initial naming context ShapeList C D E B P R S T Q U XX V

slide-27
SLIDE 27

DS E02 Lec13 27

Part of the CORBA Naming Service NamingContext interface in IDL

struct NameComponent { string id; string kind; }; typedef sequence <NameComponent> Name; interface NamingContext { void bind (in Name n, in Object obj); binds the given name and remote object reference in my context. void unbind (in Name n); removes an existing binding with the given name. void bind_new_context(in Name n); creates a new naming context and binds it to a given name in my context. Object resolve (in Name n); looks up the name in my context and returns its remote object reference. void list (in unsigned long how_many, out BindingList bl, out BindingIterator bi); returns the names in the bindings in my context. };

slide-28
SLIDE 28

DS E02 Lec13 28

The Naming class of Java RMIregistry

void rebind (String name, Remote obj) This method is used by a server to register the identifier of a remote

  • bject by name, as shown in Figure 15.13, line 3.

void bind (String name, Remote obj) This method can alternatively be used by a server to register a remote

  • bject by name, but if the name is already bound to a remote object

reference an exception is thrown. void unbind (String name, Remote obj) This method removes a binding. Remote lookup(String name) This method is used by clients to look up a remote object by name, as shown in Figure 15.15 line 1. A remote object reference is returned. String [] list() This method returns an array of Strings containing the names bound in the registry.

slide-29
SLIDE 29

DS E02 Lec13 29

Event service

  • Allows suppliers to communicate with consumers.
  • Notifications are communicated as arguments or

results of ordinary synchronous CORBA RMI.

  • Allows both a push or pull scheme.
  • Asynchronous notifications are supported through

event channels.

slide-30
SLIDE 30

DS E02 Lec13 30

CORBA event channels

consumer supplier proxy consumer notification proxy supplier event channel notification notification

slide-31
SLIDE 31

DS E02 Lec13 31

Notification service

Extends the event service with:

  • Notifications may be defined as data structures.
  • Event consumers bay use filters to specify exactly

which events they want to receive.

  • Provide means for event suppliers to discover which

events consumers are interested in.

  • Event consumers can discover which event types

suppliers offer.

  • The possibility to configure the properties of a channel,

a proxy or a particular event.

  • An event type repository (optional).
slide-32
SLIDE 32

DS E02 Lec13 32

Structured events

Event header

domain type event type event name requirements “home” “burglar alarm” “21 Mar at 2pm” “priority”, 1000

Event body

name, value name, value name, value remainder “bell”,”ringing” “door”,”open” “cat”,”outside” filterable part

slide-33
SLIDE 33

DS E02 Lec13 33

Security service

Provide the following:

  • Authentication of principals
  • Generation of credentials for principals.
  • Delegation of credentials.
  • Access control on CORBA objects.
  • Auditing by servers of remote method invocations.
  • Facilities for non-repudiation.