42
Robb Myer CPSC611 Common Object Request Broker Architecture (CORBA) Free Flight Simulation Laboratory NASA Langley Research Center

Robb Myer CPSC611 Common Object Request Broker Architecture (CORBA) Free Flight Simulation Laboratory NASA Langley Research Center

Embed Size (px)

Citation preview

Robb Myer CPSC611

Common Object Request Broker Architecture

(CORBA)

Free Flight Simulation Laboratory

NASA Langley Research Center

Robb Myer CPSC611

• Introduction• CORBA Fundamentals• Interface Definitions• CORBA Implementation• Tools• CORBA Update• Concluding Remarks

Flight Plan

Robb Myer CPSC611

Introduction

LaRC’s Free Flight Simulation Laboratory

Robb Myer CPSC611

Introduction

LaRC’s Free Flight Simulation Laboratory

• Flight Deck - Pilot Station (NT)

- Pilot DST (NT)

• Pseudo Pilot - Up to 10 Aircraft (Sun)

• Controller - ATC (Sun)

- ATSP DST (NT)

AT = Air Traffic

DST = Decision Support Tool

Robb Myer CPSC611

object bus

Simulation ManagerSimulation ManagerNT

DATABASEDATABASENT

Pilot StationPilot Station

NT

Pseudo PilotPseudo PilotSun ULTRA

Pseudo PilotPseudo Pilot

Sun ULTRA

CTASCTASSun ULTRA

Pilot DSTPilot DSTNT

Air Traffic ControllerAir Traffic Controller

Sun ULTRAPilot ManagerPilot Manager

Sun ULTRA

ATC DSTATC DSTNT

DST = Decision Support Tool

LaRC’s Free Flight Simulation Laboratory

Introduction

Robb Myer CPSC611

Common Object Request Broker Architecture (CORBA) is a method of using distributed objects in applications. The CORBA standard is used on many platforms, so writing CORBA applications allows you to make use of programs that are running under a different OS and programming language. Remote Procedure Call (RPC) works well in point-to-point communications but interoperates poorly in a fully distributed model.

Introduction

Robb Myer CPSC611

• Distributed Systems arise naturally.

• Make use of available resources to distribute work load.

• Many applications often require more than one machine.

• Each machine type and programming language has it’s own

advantage.

• CORBA is the middleware to establish relationships between

objects.

Why CORBA?

Introduction

Robb Myer CPSC611

• New software components/applications interact:

- Across networks.

- Operating Systems.

- Programming languages.

• Application integration is a natural implication.• Component Reuse in future applications.

Why CORBA?

Introduction

Robb Myer CPSC611

CORBA Speak

• OMG - Object Management Group• ORB - Object Request Broker (object bus)• GIOP - General Inter-ORB Protocol• IIOP - Internet Inter-ORB Protocol• BOA - Basic Object Adapters • IDL - Interface Definition Language• DII - Dynamic Invocation Interface

Introduction

Robb Myer CPSC611

• Standards (Blueprints): OMG (www.omg.org) – CORBA v2.3.1– 800+ international members.• ORB Implementations (Products):– Iona Technologies - Orbix (www.iona.com)– Borland/Inprise. - VisiBroker (www.inprise.com)– ExperSoft - PowerBroker (www.expersoft.com)– Sun - Java IDL + Java Beans (www.sun.com)– Camros - Oak (www.camros.com)– Free ORBs - (adams.patriot.net/~tvalesky/freecorba.html)• Every ORB must be able to talk IIOP

Unlike with Microsoft, you have a choice

CORBA Fundamentals

Robb Myer CPSC611

• Client-Server paradigm.• Client needs to know only an “interface” for requesting services.• Server does bulk of the work in providing this service.• Client is not required to know:

– How the service is provided,– Language the services are implemented in,– Where the service resides (host name or platform).

CORBA Fundamentals

Robb Myer CPSC611

Step One

ORB

Network

ORB

Client Server

ORB Resolution of Object Request

ORB Locates Server

Client Host Server Host

Send Object Reference to Server

ORB is a software component that mediates transfer of messages. Hides the underlying complexity of network programming.

CORBA Fundamentals

Robb Myer CPSC611

Step Two

ORB Resolution of Object Request

ORB

Network

ORB

Client Server

Method Invocation

Marshals Parameters

Unmarshals Parameters

Method Invocation

Marshalling translates input values to a format that can be transmitted across a network, while Unmarshalling is the reverse.

Client Host Server Host

CORBA Fundamentals

Robb Myer CPSC611

The entire marshalling process takes place without any programmer intervention

Step Three

ORB Resolution of Object Request

ORB

Network

ORB

Client Server

Unmarshals

Return Value

Marshals

Return Value

Client Host Server Host

CORBA Fundamentals

Robb Myer CPSC611

• ORB Functions: – Copys the data out of local memory. – Marshalls it. – Transmits it. – Allocating space in the remote object. – Populating this object with the data. – Providing a pointer for the remote object to use. • Typical ORB 50,000 lines of verified code.

CORBA Fundamentals

Robb Myer CPSC611

• Each CORBA object has a well defined interface.

• Interfaces written in Interface Definition Language (IDL).

• IDL key to interworking across networks, OSs, languages.

• Interfaces are application specific - objects can be any size.– Structure– Database

– Spreadsheet– Spell checker

Interface Definitions

Robb Myer CPSC611

•Primitives Types: boolean, float, integer, string.

•Constructed Types: enum, struct, typedef, exceptions, interfaces.

•Interfaces describe the services provide by the CORBA object, in the form of operations, methods or functions (i.e. - behavior).

•Parameter declarations: in, out, inout, oneway (non-blocking).

•Attributes: public visibility, may be readonly.

Interface Definitions

Robb Myer CPSC611

• Basic Object Adapter (BOA)

– CORBA object’s interface to the ORB objects.

– Common set of methods for accessing ORB functions.

• Stub is code makes CORBA server interface available to a client.

• Skeleton is framework code to build server implementation interface.

Interface Definitions

Robb Myer CPSC611

Client Stubs and Server Skeletons are Generated by the IDL compiler

Client Stub

Network

Client Implementation

Client Host

Server Skeleton

Server Implementation

Server Host

Client Stub

Client Implementation

Client Host

Server Skeleton

Server Implementation

Server Host

Interface Definitions

Robb Myer CPSC611

class AircraftId{// Data typespublic: typedef long SimulationId;

//friend classes and functions friend ostream& operator<<(ostream&,const AircraftId&);

// Constructorspublic:AircraftId(); AircraftId(SimulationId simulationId, const std::string& callSign, const std::string& type, long equipageLevel=0); AircraftId(SimulationId simulationId, const char* callSign, const char* type, long equipageLevel=0); AircraftId(const AircraftId&); //Copy constructorprivate:

// Destructorpublic: virtual ~AircraftId();

C++ header file: aircraftId.h

CORBA Implementation

Robb Myer CPSC611

// Operatorsprivate:public:// assignment AircraftId& operator=(const AircraftId&);// comparison bool operator==(const AircraftId&) const; bool operator!=(const AircraftId&) const;// Exceptionspublic:protected:// Data member

private: SimulationId m_SimulationId; std::string m_CallSign; std::string m_Type; long m_EquipageLevel;

C++ header file: aircraftId.h (cont.) 2

// Member functionspublic: SimulationId getSimulationId() const; void setSimulationId(SimulationId simulationId) { m_SimulationId=simulationId;}

std::string getCallSign() const; void setCallSign(const std::string& callSign) { m_CallSign=callSign;}

std::string getType() const; void setType(const std::string& type) {m_Type=type;}

long getEquipageLevel() const; void setEquipageLevel(long equipageLevel) {m_EquipageLevel=equipageLevel;}};

CORBA Implementation

Robb Myer CPSC611

• Four attributes refer to variables available in object • Six operations • Parameters can be in, inout, out• Arrays, structs, user-defined types, and inheritance

Analogous to a C/C++ Header File

aircraft.idl

CORBA Implementation

Robb Myer CPSC611

module Aircraft{ struct Id { long simulation_id; string call_sign; string type; long equipage; };

interface IdService{ exception Unavailable {}; // no id

Id get_id() raises (Unavailable);

void set_id( in Id aircraft_id );

// individual sets void set_simulation_id( in long simulation_id ); void set_call_sign( in string call_sign ); void set_type( in string type ); void set_equipage( in long equipage);

}; // end IdService

}; // end module Aircraft

Interface written in IDL defines object to user: aircraft.idl

CORBA Implementation

Robb Myer CPSC611

• (C++) VisiBroker - % idl2cpp aircraft.idl–aircraft_c.hh (client)–aircraft_c.cc (client) –aircraft_s.hh (server) –aircraft_s.cc (server)

• ( C++) Orbix - % idl aircraft.idl–aircraft.hh (client and server)–aircraftC.cpp (client)–aircraftS.cpp (server)

IDL compilation output and mappings - C++

CORBA Implementation

Robb Myer CPSC611

• ( Java) Orbix - % idl aircraft.idl –aircraftStub.java (client)–aircraftSketeton.java (server) –aircraftImplBase.java (server) –aircraftHelper.java (client and server) –aircraftHolder.java (client and server)

IDL compilation output and mappings -Java

CORBA Implementation

Robb Myer CPSC611

class Aircraft {public: struct Id { CORBA::Long simulation_id; CORBA::String_var call_sign; CORBA::String_var type; CORBA::Long equipage; #if defined(MSVCNEWDLL_BUG) void *operator new(size_t ts); void *operator new(size_t ts, char*, int) {return operator new(ts);} void operator delete(void *p); #endif }; friend VISostream& operator<<(VISostream&, const Id& ); friend VISistream& operator>>(VISistream&, Id& );

typedef Id* Id_ptr; inline friend VISistream&

operator>>(VISistream& _strm, Id_ptr & _obj) { _obj = new Id; _strm >> *_obj; return _strm; } friend Ostream& operator<<(Ostream&, const Id& ); inline friend Istream& operator>>(Istream& _strm, Id& _obj) { VISistream _istrm(_stream); _istrm >> _obj; return _strm; }

IDL output - aircraft_c.hh

CORBA Implementation

Robb Myer CPSC611

inline friend Istream& operator>>(Istream& _strm, Id_ptr & _obj) { _obj = new Id; _strm >> *_obj; return _strm; } class Id_out; class Id_var { friend class Id_out; private: Id* _ptr; public: Id_var() { _ptr = (Id*)NULL;} Id_var(Id *_p) { _ptr = _p; }

IDL output - aircraft_c.hh (cont.) 2

Id_var(const Id_var& _var) { if (_var._ptr) _ptr = new Id(*_var._ptr); else _ptr = (Id *)NULL; } ~Id_var() { if (_ptr != (Id *)NULL) delete _ptr; } Id_var& operator=(Id *_p) { if (_ptr != (Id *)NULL) delete _ptr; _ptr = _p; return *this; }

CORBA Implementation

Robb Myer CPSC611

IDL output - aircraft_c.hh (cont.) 3

Id_var& operator=(const Id_var& _var) { if (_ptr != (Id *)NULL) delete _ptr; if (_var._ptr) _ptr = new Id(*_var._ptr); else _ptr = (Id *)NULL; return *this; } Id *operator->() { return _ptr; } operator Id *() const { return _ptr; } operator Id& () { return *_ptr; } const Id& in() const { return *_ptr; } Id& inout() { return *_ptr; } Id_ptr & out(); Id* _retn() { Id* temp_ptr; temp_ptr = _ptr; _ptr = (Id *)NULL; return temp_ptr; }

inline friend VISostream& operator<<( VISostream& _strm, const Id_var& _var) { if (_var._ptr == (Id *)NULL) throw CORBA::BAD_PARAM(); else _strm << *_var._ptr; return _strm; } inline friend VISistream& operator>>( VISistream& _strm,

CORBA Implementation

Robb Myer CPSC611

class Id_out { private: Id_ptr & _ptr; static Id* _nil() { return (Id*)NULL; } void operator=(const Id_out&); void operator=(const Id_var&); public: Id_out(const Id_out& _o) : _ptr(_o._ptr) {} Id_out(Id_ptr & _p) : _ptr(_p) { _ptr = _nil(); } Id_out(Id_var& _v) : _ptr(_v._ptr) { delete _ptr; _ptr = _nil(); } Id_out& operator=(Id* _p) { _ptr = _p; return *this; }

operator Id_ptr &() { return _ptr; } Id_ptr & ptr() { return _ptr; } Id* operator->() { return _ptr; } }; #ifndef _Aircraft_IdService_var_#define _Aircraft_IdService_var_

class IdService; typedef IdService* IdService_ptr; typedef IdService_ptr IdServiceRef; friend VISistream& operator>>(VISistream&, IdService_ptr&); friend VISostream& operator<<(VISostream&, const IdService_ptr);

IDL output - aircraft_c.hh (cont.) 4

CORBA Implementation

Robb Myer CPSC611

class IdService_out; class IdService_var: public CORBA::_var { friend class IdService_out; private: IdService_ptr _ptr; public: void operator=(const IdService_var&_v) { if ( _ptr ) _release(_ptr); if ( _v._ptr ) _ptr = _duplicate(_v._ptr); else _ptr = (IdService_ptr)NULL; }

IDL output - aircraft_c.hh (cont.) 5

static IdService_ptr _duplicate(IdService_ptr); static void _release(IdService_ptr); IdService_var(); IdService_var(IdService_ptr); IdService_var(const IdService_var&); ~IdService_var(); IdService_var& operator=(IdService_ptr); operator IdService_ptr() const { return _ptr; } IdService_ptr operator->() const { return _ptr; } IdService_ptr in() const { return _ptr; } IdService_ptr& inout() { return _ptr; } IdService_ptr& out(); IdService_ptr _retn() { IdService_ptr _tmp_ptr; _tmp_ptr = _ptr; _ptr = (Aircraft::IdService_ptr)NULL; return _tmp_ptr; }

CORBA Implementation

Robb Myer CPSC611

friend VISistream& operator>>(VISistream&, IdService_var&); friend VISostream& operator<<(VISostream&, const IdService_var&); friend Istream& operator>>(Istream&, IdService_var&); friend Ostream& operator<<(Ostream&, const IdService_var&); }; class IdService_out { private: IdService_ptr & _ptr; static IdService* _nil() { return (IdService*)NULL; } void operator=(const IdService_out&); void operator=(const IdService_var&); public: IdService_out(const IdService_out& _o) : _ptr(_o._ptr) {} IdService_out(IdService_ptr & _p) : _ptr(_p) { _ptr = _nil(); }

IdService_out(IdService_var& _v) : _ptr(_v._ptr) { IdService_var::_release(_ptr); _ptr = _nil(); } ~IdService_out() {} IdService_out& operator=(IdService_ptr _p) { _ptr = _p; return *this; } operator IdService_ptr& () { return _ptr; } IdService_ptr& ptr() { return _ptr; } IdService_ptr operator->() { return _ptr; } }; #endif class IdService : public virtual CORBA_Object { private: static const CORBA::TypeInfo _class_info; IdService(const IdService&){ ___root = this; } void operator=(const IdService&){} protected: IdService_ptr ___root; void set_root(IdService_ptr root) { ___root = root; }

IDL output - aircraft_c.hh (cont.) 6

CORBA Implementation

Robb Myer CPSC611

public: class Unavailable : public CORBA_UserException { public: #if defined(MSVCNEWDLL_BUG) void *operator new(size_t ts); void *operator new(size_t ts, char*, int) {return operator new(ts);} void operator delete(void *p); #endif static const CORBA_Exception::Description _description; Unavailable() {} static CORBA::Exception *_factory() { return new

Unavailable(); } ~Unavailable() {} virtual const CORBA_Exception::Description& _desc() const; static Unavailable *_narrow(CORBA::Exception *_exc); CORBA::Exception *_deep_copy() const { return new Unavailable(*this); } void _throw() const { throw *this; } void _write(VISostream&) const; void _copy(VISistream&); void _pretty_print(VISostream&) const; inline friend VISistream& operator>>(VISistream& _strm, Unavailable& _e) { CORBA::String_var _exp_name; _strm >> _exp_name; _e._copy(_strm); return _strm; } };

IDL output - aircraft_c.hh (cont.) 7

CORBA Implementation

Robb Myer CPSC611

static const CORBA::TypeInfo *_desc(); virtual const CORBA::TypeInfo *_type_info() const; virtual void *_safe_narrow(const CORBA::TypeInfo& ) const; static CORBA::Object *_factory(); IdService_ptr _this(); protected: IdService(const char *obj_name = NULL): CORBA_Object(obj_name, 1) { ___root = this; } public: virtual ~IdService() {} static IdService_ptr _duplicate(IdService_ptr _obj) { if ( _obj ) _obj->_ref(); return _obj; }

static IdService_ptr _nil() { return (IdService_ptr)NULL; } static IdService_ptr _narrow(CORBA::Object *_obj); static IdService_ptr _clone(IdService_ptr _obj) { CORBA::Object_var _obj_var(__clone(_obj)); #if defined(_HPCC_BUG) return _narrow(_obj_var.operator CORBA::Object_ptr()); #else return _narrow(_obj_var); #endif }

IDL output - aircraft_c.hh (cont.) 8

CORBA Implementation

Robb Myer CPSC611

static IdService_ptr _bind( const char *_object_name = NULL, const char *_host_name = NULL, const CORBA::BindOptions* _opt = NULL, CORBA::ORB_ptr _orb = NULL); virtual void set_type( const char* _type ); virtual void set_equipage( CORBA::Long _equipage );

virtual Id* get_id( ); virtual void set_id( const Id& _aircraft_id ); virtual void set_call_sign( const char* _call_sign ); virtual void set_simulation_id( CORBA::Long _simulation_id );

IDL output - aircraft_c.hh (cont.) 9

CORBA Implementation

Robb Myer CPSC611

friend VISistream& operator>>(VISistream& _strm, IdService_ptr& _obj); friend VISostream& operator<<(VISostream& _strm, const IdService_ptr _obj); friend Ostream& operator<<(Ostream& _strm, const IdService_ptr _obj) { _strm << (CORBA::Object_ptr)_obj; return _strm; } friend Istream& operator>>(Istream& _strm, IdService_ptr& _obj) { VISistream _istrm(_strm); _istrm >> _obj; return _strm; } };};#include "vpost.h"#endif

Id_var& _var) { if ( !_var._ptr ) _var._ptr = new Id; _strm >> *_var._ptr; return _strm;

IDL output - aircraft_c.hh (cont.) 10

CORBA Implementation

Robb Myer CPSC611

int main (int argc, char** argv) { CORBA::ORB_ptr orb = CORBA_ORB::_nil(); try { orb = CORBA::ORB_init( argc, argv); CORBA::Object_ptr obj = Orb->resolve_initial_references( “IdService” ); IdService_ptr ID_ptr = IdService::_narrow(obj); Id_ptr->getId( );

CORBA::release(Id_ptr); CORBA::release(obj); } catch (const CORBA::SystemException& exc) { .... } CORBA::release(orb); return 0; }

getAircraftIDImpl.cppThe only user method is getId(), which is the server object's method called by the client.

CORBA Implementation

Robb Myer CPSC611

• Running the daemon on the server host.– Example % orbixd (Iona Technologies)• Registering Servers with the Corba Implementation Object Repository (IOR)– Allow the server to be launched automatically by the daemon.– Format: % putit -h hostname <servername> <serverpath>– Example % putit -h america3 Aircraft1 /ffsim/servers/aircraftID.exe • Run the Client–When a client binds to an object in the IOR, the daemon automatically launches the server executable file (i.e. aircraftIDImpl.exe)–Example % getAircraftIDImpl.exe

Running an Application (Orbix example)

CORBA Implementation

Robb Myer CPSC611

• ORB Performance – Benchmarking– Jitter (worst case/ best case request respone time delta).– Priority inversion (incorrect scheduling of ORB tasks).• ORB Scalability – Response time - linear increase with number of requests.– Server Stability & Reliability (abrupt failure).

Concerns - Especially with Real-Time Systems

CORBA Implementation

Robb Myer CPSC611

Iona Technologies Configuration Explorer

Tools

Robb Myer CPSC611

Iona Techologies OrbixNames Browser

Tools

Robb Myer CPSC611

• Portable Object Adapter (POA) • Asynchronous Method Invocation(AMI) • Persistent State Service • Notification Service• Java Remote Method Invocation/IIOP (RMI/IIOP)• Objects-by-Value (OBV)• Portable Interceptors• CORBA Component Model (CCM)

• Portable Object Adapter (POA) • Asynchronous Method Invocation(AMI) • Persistent State Service • Notification Service• Java Remote Method Invocation/IIOP (RMI/IIOP)• Objects-by-Value (OBV)• Portable Interceptors• CORBA Component Model (CCM)

CORBA Update

The Next Major Release - CORBA 3.0

Robb Myer CPSC611

• Distributed Client Server• ORB is an Object Bus.• User spared the complexity of network programming.• Easy to configure and use via graphical interface tools.• More to Come

Concluding Remarks