1 / 22

Kap. 4.2 Das Orbix CORBA-System

Kap. 4.2 Das Orbix CORBA-System. Kurzer überblick zu der CORBA-Implementierung Orbix Unser Fahrplan: IDL Verwendungsbeispiel Zoom-In: CORBA Kommunikationsmechanismus Orbix Systemübersicht Naming Service, IORs VBS-Szenario mit Transaktionsservice, persistenten Objekten. IDL Beispiel.

cindy
Download Presentation

Kap. 4.2 Das Orbix CORBA-System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Kap. 4.2 Das Orbix CORBA-System Kurzer überblick zu der CORBA-Implementierung Orbix • Unser Fahrplan: • IDL Verwendungsbeispiel • Zoom-In: CORBA Kommunikationsmechanismus • Orbix Systemübersicht • Naming Service, IORs • VBS-Szenario mit Transaktionsservice, persistenten Objekten...

  2. IDL Beispiel Interfaces - Attribute - Operationen - Exceptions TypeDefs, Konstanten... // naming service constants const string OHOContextName = "OhO_ss2000"; module Bank { typedef long AccountID; interface Account { readonly attribute AccountID number; // account id readonly attribute float balance; // amount of money in account // thrown if not enough money on account to withdraw exception InsufficientFunds {}; // public methods to modify an account void Deposit ( in float amount ); void Withdraw ( in float amount ) raises (InsufficientFunds); }; };

  3. Verwendung des IDL Compilers C++ SourceClient.cpp C++ SourceAccountImpl.cpp idl -B Bank.idl C++ Stubs BankC.cpp C++ Header Bank.hh C++ Skeletons BankS.cpp C++ Compiler C++ Compiler Orbix DLL FinanceClient AccountServer IDLBank.idl

  4. CORBA Kommunikationsmechanismus (1) Client account->balance() Proxy-Objekt Object Request Broker

  5. Auszug aus den Account-Stubs CORBA::Float Account::balance ( ){ CORBA::Environment IT_env; CORBA::Request IT_r (this,”_get_balance",IT_env,1,0); IT_r.invoke (CORBA::Flags(0),IT_env); if ( !IT_r.isException (IT_env) ) { CORBA::Float IT_result; IT_r >> IT_result; IT_r.checkEnv (IT_env); return IT_result; } else … }

  6. CORBA Kommunikationsmechanismus (2) Server AccountImpl Client account->balance() Proxy-Objekt Objekt-Adapter Implementation Repository Request Object Request Broker

  7. Auszug aus den Account-Skeletons Account_dispatch::dispatch ( CORBA::Request & IT_r, void * IT_pp ) { const char *IT_s = IT_r.getOperation (); if ( !strcmp(IT_s,”_get_balance") ) { CORBA::Float IT_result; CORBA::Environment IT_env (IT_r); IT_result = ((Bank::Account *)IT_pp) -> balance ( IT_env ); IT_r << IT_result; ... }

  8. CORBA Kommunikationsmechanismus (3) Server AccountImpl Client account->balance() Proxy-Objekt Objekt-Skelett Request Object Request Broker Account

  9. Account-Server Implementierung CORBA::Float AccountImpl::balance ( CORBA::Environment & ) { cout << ”AccountImpl::balance() called" << endl; return this->my_balance; }

  10. CORBA Kommunikationsmechanismus (4) Client account->balance() Proxy-Objekt Objekt-Skelett Request Object Request Broker Answer Server CORBA::Float balance(…) {... } Account

  11. Komplett-Anatomie eines ORBs Client Objekt-Implementation Object Adapter Dynamic Invocation IDL Stubs ORB Interface IDL Skeleton Dynamic Skeleton Interface Repository Implemen-tation Repository Object Request Broker • Client • IDL Stubs: statisch, d.h. alle Operationen sind zur Compilezeit bekannt. • Dynamic Invocation Interface (DII) findet Objekte und Schnittstellen zur Laufzeit und konstruiert den Aufruf dynamisch, unter Verwendung des • Interface Repository (für interpretierende Werkzeuge, wie Query Browser) • Server • Object Adapter interpretiert Objektreferenzen, bildet diese aufObjektimplementierungen ab und ruft Methodenimplementierungen auf, • statisch via IDL Skeletons oder • dynamisch über Dynamic IDL Skeletons als Grundlage für die Implementierung der Anwendungslogik

  12. Was ist nun in Orbix der ORB? • Der “ORB” in Orbix besteht aus mehreren Komponenten: • Orbix Link-LibraryWird sowohl dem Client-, als auch Server hinzugelinkt.Basisfähigkeit zum Austausch von CORBA::Requests,enthält ORB-Interface und Objekt-Adapter der vorherigen Folie. • Orbix Daemon ‘orbixd’“Orbix-Vermittlung”: Lokalisiert CORBA-Objekte, leitet Requests entweder zu anderen Rechnern weiter oder startet lokal eine Implementierung, dann LOCATION_FORWARD Mechanismus.Client kommuniziert danach direkt mit CORBA-Server. • KonfigurationsdateienWo liegen die Repositories? Welches ist der Default-orbixd? ... • Weitere Link-Libraries für IFR und DII • Weitere Bestandteile des Orbix-Systems: • Verwaltungsprogramme für die Repositories, Includes, Doku

  13. VBS-Szenario - übersicht Naming Service Zürich Client Transaction Service Finance London Basel Account Account STUD STUD2

  14. Datenkapselung(1) • Speicherform der Kundendaten: relationale Tupel CREATE TYPE cust_person_type ( family_name VARCHAR2(50), pre_name VARCHAR2(50), nationality VARCHAR2(50), date_of_birth DATE ); /* Account table */ CREATE TABLE account ( account_number INTEGER PRIMARY KEY, customer_ID INTEGER, balance NUMBER; ); CREATE TYPE cust_address_type ( street VARCHAR2(50), zipCode VARCHAR2(5), city VARCHAR2(50) ); /* Customer table */ CREATE TABLE customer ( customer_ID INTEGER PRIMARY KEY, person_data CUST_PERSON_TYPE, address_data CUST_ADDRESS_TYPE );

  15. Datenkapselung (2) enum Nation { UNKNOWN, CH, D, F, GB, IR, NL }; struct Address { string<50> street; string<5> zipcode; string<50> city; }; interface Customer { readonly attribute string name; readonly attribute string firstname; readonly attribute Nation nationality; readonly attribute string birthdate; readonly attribute Address addr; readonly attribute Account account; }; interface Account { readonly attribute AccountID number; readonly attribute float balance; void Deposit ( in float amount ); void Withdraw ( in float amount ) raises (InsufficientFunds); }; • Repräsentation der Kundendaten: ”feingranulare” CORBA-Objekte

  16. VBS Szenario: Datenzugriff auf Kundendaten 1. VBS = NamingService->resolve(...) 2. VBS->Transfer(…) Finance Naming Service Zürich Client London Basel STUD STUD2

  17. Aktivierung von CORBA Objekten • Das “Münchhausen” Problem von CORBA:Wie ziehe ich mich selbst an den Haaren aus dem Sumpf? • Bei CORBA: Woher bekommt man die erste Objektreferenz? • Möglichkeiten: • ORB::resolve_initial_reference() Standardisiert für wenige zentrale Dienste wie NamingService. • ORB::string_to_object() Wandelt “stringified” IOR in ein Objektreferenz zurück.Problem: Wer nennt uns vorher den String? • NamingService::resolve() NamingService bietet Mapping von Strings auf OIDs.Again: Eintrag muss bereits vorhanden sein… • <T>::_bind() Orbix-proprietärer Weg über Orb-Konfiguration, siehe Übung.

  18. CORBA IORs (Inter-ORB-References) roehm@dblab5:7 > catns OhO_ss2000.OTSIOR:0001004a0000002b49444c3a436f735472616e73616374696f6e732f5472616e73616374696f6e466163746f72793a312e30007300000001000000000000007d000100000000000f64626c6162352e6574687a2e63680000062200000000005d3a5c64626c6162352e6574687a2e63683a436f735472616e73616374696f6e735f5472616e73616374696f6e466163746f72793a303a3a49523a436f735472616e73616374696f6e735f5472616e73616374696f6e466163746f727900 IOR V 1.74{ type_id : IDL:CosTransactions/TransactionFactory:1.0 profiles : { tag : TAG_INTERNET_IIOP data : ProfileBody of length 125 { iiop_version: 1.0 host : dblab5.ethz.ch port : 6 object_key : :\dblab5.ethz.ch:CosTransactions_TransactionFactory:0 ::IR:CosTransactions_TransactionFactory} } }

  19. Code-Beispiel Bank::Finance::Transfer() void FinanceImpl::Transfer( Bank::AccountID a1,Bank::AccountID a2, float amount, CORBA::Environment &env ) { try { tx = OTS->create(1000); source = Bank::Account::_bind(“1001@STUD:Bank_Account_OHO7”); destin = Bank::Account::_bind(“1004@STUD:Bank_Account_OHO7"); source->Withdraw(amount, env); destin->Deposit(amount, env); tx->commit(); } catch (...) { tx->rollback(); throw Bank::Finance::TransferFailed(); } }

  20. VBS Szenario: Finance-Dienst in voller Aktion VBS->Transfer(1001,1004, 4711) Finance 1. create() 4. register() 7. 2. a1 = Account::_bind(…) 3. a1->Withdraw(4711) 5. A2 = Account::_bind(...) 6. a2->Deposit(4711) Account Account Naming Service Client Transaction Service STUD STUD2

  21. Persistente CORBA Objekte • Problem: Aktivierung eines Objektes mit persistentem Zustand? • Object-Oriented Database Adapterzum direkten “Einblenden” von Objekten aus Objektbanken in die CORBA Welt, nur wir haben noch keinen gesehen... • Orbix-spezifisch: spezialisierte ObjectLoader Klasseein “Hook” im ORB, um Einfluss darauf nehmen zu können, wie ein zu aktivierendes Objekt initialisiert werden soll.Siehe Übung: Aus der Objektreferenz wird die gewünschte Kontonummer gelesen, die Datenbank angesprochen und mit den gelesenen Werten ein neues Account Objekt erzeugt. • CORBA: Persistent Object ServiceStandardisierter Dienst, um Objekte mit persistenten Zuständen zu initialisieren. Nachteil: zusätzliche Kommunikation und erneut vorherige Verknüpfung notwendig. • Neu: Portable Object Adapter (POA)aber noch nicht weit verbreitet

  22. VBS Szenario: Festschreiben der Datenänderungen Koordiniert 2PC der beteiligten Objekten 5. DONE 1. commit() 2. prepare() 4. commit() if all OK 4. COMMIT 3. UPDATE ... 3. UPDATE ... 4. COMMIT Finance Client Transaction Service Account Account STUD STUD2

More Related