Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

Der JacORB Namensdienst

Ähnliche Präsentationen


Präsentation zum Thema: "Der JacORB Namensdienst"—  Präsentation transkript:

1 Der JacORB Namensdienst gerald.brose@xtradyne.com

2 20.06.2015 Überblick  Beteiligte Klassen/Interfaces  Realisierung der Namensdienst- Funktionalität  Beispiel für POA-Einsatz  mögliche Erweiterungen

3 20.06.2015 Beteiligte Interfaces/Klassen  IDL:  idl/omg/CosNaming.idl  Source code:  src/org/jacorb/naming JacORB-Implementierung  src/generated/org/omg/CosNaming vom IDL-Compiler aus OMG-Spezifikation generiert (Schnittstellen, Stubs, Helper/Holder)

4 20.06.2015 UML > org.jacorb.naming. NamingContextExtImpl > org.omg.CosNaming. NamingContextExtPOA > java.io.Serializable > org.omg.CosNaming. NamingContextExtOperations org.jacorb.naming. Name > NamingContextExt

5 20.06.2015 What‘s in a name? // CosNaming.idl typedef string Istring; struct NameComponent { Istring id; Istring kind; }; typedef sequence Name; interface NamingContext { Object resolve (in Name n) raises(...); }; interface NamingContextExt: NamingContext { typedef string StringName; StringName to_string(in Name n) raises(...);... }; // Name.java, JacORB utility class class Name { // c‘tors Name(); Name(NameComponent[]); Name(String); Name(NameComponent); NameComponent baseNameComponent(); String kind(); NameComponent components()[]; Name ctxName(); Name fullName(); String toString(); static NameComponent toName(String); static String toString(NameComponent[]); }

6 20.06.2015 CosNaming.idl module CosNaming { interface NamingContext { //... void bind( in Name n, in Object obj) raises( NotFound, CannotProceed, InvalidName, AlreadyBound ); Object resolve (in Name n) raises( NotFound, CannotProceed, InvalidName ); }; //... };

7 20.06.2015 NamingContextImpl.bind() void bind( NameComponent[] nc, org.omg.CORBA.Object obj ) throws NotFound, CannotProceed, InvalidName, AlreadyBound { Name n = new Name( nc ); Name ctx = n.ctxName(); NameComponent nb = n.baseNameComponent(); if( ctx == null ) { // bind here... } else { // bind in a nested context NameComponent[] ncx = new NameComponent[1]; ncx[0] = nb; NamingContextExtHelper.narrow( resolve(ctx.components())). bind(ncx,obj); } if( names.containsKey( n )) { throw new AlreadyBound(); } else if( contexts.containsKey( n )) { throw new AlreadyBound(); } names.put( n, obj ); }

8 20.06.2015 resolve() public org.omg.CORBA.Object resolve( NameComponent[] nc ) throws NotFound, CannotProceed, InvalidName { Name n = new Name( nc[0] ); if( nc.length > 1 ) { // resolve in nested context } else { org.omg.CORBA.Object result = null; result = (org.omg.CORBA.Object)contexts.get(n); if( result == null ) result = (org.omg.CORBA.Object)names.get(n); if( result == null || result._non_existent()) throw new NotFound( NotFoundReason.missing_node, n.components()); return result; } NamingContextExt next_context = NamingContextExtHelper.narrow( (org.omg.CORBA.Object)contexts.get(n)); if ((next_context == null)||(next_context._non_existent())) { throw new NotFound( NotFoundReason.missing_node, nc ); } NameComponent[] nc_prime = new NameComponent[nc.length-1]; for( int i = 1; i < nc.length; i++) nc_prime[i-1] = nc[i]; return next_context.resolve(nc_prime); }....

9 20.06.2015 POA Policies im Namensdienst  Namensdienst soll runterfahren können, ohne daß es jemand merkt (Implementation Rep.)  Context-Objekte müssen persistente Lebenszeit haben  LifespanPolicyValue.PERSISTENT  Beim Hochfahren sollen Objekte automatisch aktiviert werden  RequestProcessingPolicyValue.USE_SERVANT_MANAGER  Zustand aller Context-Objekte im Graph muß persistent in Dateien gehalten werden  IdAssignmentPolicyValue.USER_ID  NamingContextImpl ist Serializable

10 20.06.2015NameServer.main() public static void main( String args[] ) { // ORB and POA initialization orb = org.omg.CORBA.ORB.init( args, props ); POA rootPOA = POAHelper.narrow( orb.resolve_initial_references("RootPOA")); org.omg.CORBA.Policy [] policies = new org.omg.CORBA.Policy[3]; policies[0] = rootPOA.create_id_assignment_policy( IdAssignmentPolicyValue.USER_ID); policies[1] = rootPOA.create_lifespan_policy( LifespanPolicyValue.PERSISTENT); policies[2] = rootPOA.create_request_processing_policy( RequestProcessingPolicyValue.USE_SERVANT_MANAGER); POA nsPOA = rootPOA.create_POA("NameServer-POA", rootPOA.the_POAManager(), policies);...

11 20.06.2015 main() continued NameServantActivatorImpl servantActivator = new NameServantActivatorImpl( orb ); nsPOA.set_servant_manager( servantActivator._this(orb) ); nsPOA.the_POAManager().activate(); /* export the root context's reference to a file */ byte[] oid = ( new String("_root").getBytes() ); try { org.omg.CORBA.Object obj = nsPOA.create_reference_with_id( oid, "IDL:omg.org/CosNaming/NamingContextExt:1.0"); PrintWriter out = new PrintWriter( new FileOutputStream( args[0] ), true); out.println( orb.object_to_string( obj ) ); out.close(); } catch ( Exception e ) {...} Thread.sleep(time_out); orb.shutdown(true);

12 20.06.2015 Servant Activator class NameServantActivatorImpl extends ServantActivatorPOA { private org.omg.CORBA.ORB orb = null; public NameServantActivatorImpl(org.omg.CORBA.ORB orb) { this.orb = orb; } public Servant incarnate(byte[] oid, POA adapter) throws ForwardRequest {} public void etherealize(byte[] oid, POA adapter, Servant servant, boolean cleanup_in_progress, boolean remaining_activations ) {} }

13 20.06.2015incarnate() public Servant incarnate(byte[] oid, POA adapter) throws ForwardRequest { String oidStr = new String( oid ); NamingContextImpl n = null; try { File f = new File( „_nsdb“ + oidStr ); if( f.exists() ) { FileInputStream f_in = new FileInputStream(f); if( f_in.available() > 0 ) { ObjectInputStream in = new ObjectInputStream(f_in); n = (NamingContextImpl)in.readObject(); in.close(); } f_in.close(); } catch( IOException io ){} catch( java.lang.ClassNotFoundException c ) { } if( n == null ) n = new NamingContextImpl(); n.init( orb, adapter); return n; }

14 20.06.2015etherealize() public void etherealize( byte[] object_id, POA adapter, Servant servant, // NamingContextImpl boolean cleanup_in_progress, boolean remaining_activations) { String oidStr = new String( object_id ); try { File file = new File("_nsdb" + oidStr); FileOutputStream fout = new FileOutputStream( file ); ObjectOutputStream out = new ObjectOutputStream( fout ); out.writeObject( (NamingContextImpl)servant ); } catch( IOException io ) { } }

15 20.06.2015 Erweiterungsmöglichkeiten  Load Balancing (nicht Standard)  mehrere Objekte unter einem Namen anmelden, bei resolve() jedesmal eine andere Referenz herausgeben  Skalierbarkeit  bei wieviel Bindings/Clients/Anfragen liegt die Grenze, wie kann man sie verschieben?  Performance  keine systematischen Untersuchungen

16 20.06.2015 Aufruf zur Mitarbeit an JacORB  „Ruhm und Ehre“  Präsenz auf Mailinglisten, Newsgroups, etc.  Forschen und Lernen  Studien- und Diplomarbeiten  Echte Software im industriellen Einsatz  Evtl. Praktikum bei PrismTech in Newcastle, UK  Open Source und Werkverträge  Ideell: LGPL  Kommerziell: Werkverträge möglich  Relevanz für Arbeitsmarkt!  JacORB an der FU halten!

17 20.06.2015 Was tun?  Kernentwicklung, Wartung  CORBA-Kern, IDL/Java Language Mapping  Asynchronous Message Invocation (AMI)  Extensible Transport Framework (ETF)  Fault Tolerance  Security  DFG-Projekt Raccoon  Common Secure Interoperability (CSIv2)  Services  Notification, Persistence, etc.  Support, Testen, Bug Fixes, Dokumentation  Mailinglisten, Bugzilla, Testsuite (COST)

18 20.06.2015 Wo anfangen?  Website http://www.jacorb.org  Buch: „Java Programming with CORBA“  Mailingliste: jacorb-developer  AG SS  DFG-Projekt Raccoon  Studien- und Diplomarbeitsthemen  Code und OMG-Spezifikationen lesen  Nachfragen  Werkverträge, Industriepraktika  JacORB-Tutorial


Herunterladen ppt "Der JacORB Namensdienst"

Ähnliche Präsentationen


Google-Anzeigen