Common Principles - PowerPoint PPT Presentation

About This Presentation
Title:

Common Principles

Description:

United. England. Germany. 1. Liga. 2. Liga. BVB. Bayern. Bochum. Lautern. UEFA. Manchester. United. Naming Service. 4. Common Principles: Composite Names ... – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 41
Provided by: shangp
Learn more at: http://www.cs.iit.edu
Category:

less

Transcript and Presenter's Notes

Title: Common Principles


1
Common Principles
  • Object-oriented middleware uses object references
    to address server objects
  • We need to find a way to get hold of these object
    references without assuming physical locations
  • A name is a sequence of character strings that
    can be bound to an object reference
  • A name binding can be resolved to obtain the
    object reference

2
Common Principles
  • There may be many server objects in a distributed
    object system
  • Server objects may have several names
  • Leads to large number of name bindings
  • Name space has to be arranged in a hierarchy to
    avoid
  • Name clashes
  • Poor performance when binding/resolving names
  • Hierarchy achieved by naming contexts

3
Common Principles Naming Contexts

UEFA
England
Germany
Cup Winners
2. Liga
First
1. Liga
Premier
Lautern
Manchester United
Bochum
QPR
South End United
1.FC Kaiserslautern
Man United
BVB
Bayern
Chelsea
4
Common Principles Composite Names
  • Names are composed of possibly more than one
    component
  • Used to describe traversals across several naming
    contexts
  • Example
  • ("UEFA","England","Premier","Chelsea").

5
Common Principles Name Server Behaviour
  • Name bindings are managed by name servers
  • Not every server object needs a name
  • Server objects may have several names (aliases)
  • Name servers must store bindings persistently
  • Name servers should be tuned towards efficiently
    resolving name bindings
  • Name server may itself be distributed

6
CORBA Naming Service
  • Supports bindings of names to CORBA object
    references.
  • Names are scoped in naming contexts.
  • Multiple names can be defined for object
    references.
  • Not all object references need names.
  • The CORBA naming service is used by
  • Clients to locate CORBA objects
  • Servers to advertise specific CORBA objects
  • Bootstrap service, enabling clients to find other
    services
  • Facilitate the initial connections between
    clients and servers
  • Basic function association of names with object
    references

7
Naming Service
  • Server creates associations between names and
    object references for the CORBA objects (object
    binding)
  • Client retrieve the object references by querying
    the naming service and using the name as the key.
  • NS a database of object bindings

8
Naming Service

Naming Service
2. resolve
1. Create binding
Server
Client
3. Use target object
9
Binding Hierarchy
  • Context binding an association between a name
    and a naming context
  • Object binding an association between a name and
    an object reference

Initial Naming Service
New_York.region
London. region
Frankfurt.region
Main.failover
Bankup.failover
StockExchange
BrokerService
10
Components of a Stringified Name
  • Stringified Name Binds to
  • Empty string Initial naming context
  • London.region Naming context
  • London.region/Main.failover Naming context
  • London.region/Main.failover/StockExchange Object
    reference
  • Initial naming context is always present and
    serves as the entry point to the naming service

11
CORBA Names
  • Names are composed of simple names.
  • Simple names are value-kind pairs.
  • Value attribute is used for resolving names.
  • Kind attribute is used to provide information
    about the role of the object.

12
CORBA Name
  • Name has two format
  • Stringified name format intuitive format that is
    easy to read and pass from place to place
  • London.region/Main.failover/StockExchange
  • Raw name format defined in terms of IDL complex
    types and can be used only within a CORBA program
  • Module CosNaming
  • typedef string Istring
  • struct NameComponent
  • Istring id
  • Istring kind
  • typedef sequenceltNameComponentgt Name

13
CORBA Name
  • Kind field is intended to describe how a name
    component is used (similar to the file extension,
    client.exe)
  • Special cases
  • empty kind field (omitting kind and kind
    separator .)
  • Empty id field (starting the name component with
    .)
  • Empty id field and empty kind field (denoted by
    .)
  • Example ././.

14
The IDL Interfaces
  • Naming Service is specified by two IDL
    interfaces
  • NamingContext defines operations to bind objects
    to names and resolve name bindings.
  • BindingInterator defines operations to iterate
    over a set of names defined in a naming context.

15
Binding
  • Module cosNaming
  • enum BindingTypenobject, ncontext
  • struct Binding
  • Name binding_name
  • BindingType binding_type
  • typedef sequenceltBindinggt BindingList

16
Binding and Unbinding Operations
  • Module cosNaming
  • interface NamingContext
  • void bind(in Name n, in Object obj)
  • raise(NotFound, InvalidName, AlreadyBound,
  • CannotProceed)
  • void rebind( in Name n, in Object obj)
  • raise(NotFound, InvalidName, CannotProceed)
  • void bind_context(in Name n, in NamingContext
    nc)
  • raise(NotFound, InvalidName, AlreadyBound,
  • CannotProceed)
  • void rebind_context(in Name n, in NamingContext
    nc)
  • raise(NotFound, InvalidName, CannotProceed)
  • void unbind(in Name n)
  • raise(NotFound, InvalidName, CannotProceed)

17
bind() and rebind()
  • Both operations create an object binding that
    associates the name n (in raw format) with the
    naming context nc.
  • Rebind() it creates a new object binding for the
    given name n or if a binding already exists with
    that name, overwrites the existing binding.
  • Bind() it creates a new object binding for the
    given name n as long as there is no existing
    binding with that name. If a binding already
    exists, an AlreadyBound exception is thrown.
  • These operations create object bindings relative
    to the naming context on which they are invoked.
  • Example A/B/C/MyObj on initial naming context,
    or MyObj on A/B/C naming context

18
bind_context() and rebind_context()
  • Parameter is context
  • Similar semantics as bind() and re_bind()

19
Create Context
  • Module cosNaming
  • //interface NamingContext
  • NamingContext new_context()
  • NamingContext bind_new_context(in Name n)
  • raise(NotFound, InvalidName, AlreadyBound,
  • CannotProceed)
  • //
  • A naming context can be created (new_context())
    and then be binded (bind_context())
  • Bind_new_context() creates a new context and
    binds it as a subcontext of the context on which
    the operation is invoked.

20
Before Binding

Context1
Context3
Context2
Context5
Context4
21
After Binding

Context1
Context3
Context2
Context5
Context4
MyName
IOR of Object
22
Naming Scenario Binding
  • Promote Bielefeld to German '1. Liga' and
    relegate Frankfurt

23
Resolve Names
  • Module cosNaming
  • //interface NamingContext
  • Object resolve(in Name n)
  • raise(NotFound, InvalidName, CannotProceed)
  • //
  • It resolves the first component of the name to an
    object reference.
  • If there are no remaining components, it returns
    this object reference to the caller.
  • Otherwise, it narrows the object reference to a
    NamingContext and passes the reminder of the name
    to its resolve operation

24
NotFound Exception
  • Module cosNaming
  • interface NamingContext
  • enum NotFoundReason missing_node, not_context,
    not_object
  • exception NotFound
  • NotFoundReason why
  • Name rest_of_name

25
Browsing Contexts
  • Module cosNaming
  • //interface NamingContext
  • interface BindingIterator
  • boolean next_one(out Binding b)
  • boolean next_n(in unsigned long how_many,
  • out BindingList bl)
  • void destroy()
  • void list (in unsigned long how_many, out
    BindlingList bl,
  • out BindingIterator bi)
  • //

26
Converting Names NamingContextExt
  • Module cosNaming
  • interface NamingContextExtNamingContext
  • typedef string StringName
  • typedef string Address
  • typedef string URLString
  • StringName to_string(in Name n) raises
    (InvalidName)
  • Name to_name(in StringName sn) raises
    (InvalidNames)
  • URLString to_url(in Address addrKey, in
    StringName sn)
  • raises(InvalidAddress, InvalidName)
  • Object resolve_str(in StringName sn)
  • raises(NotFound, CannotProceed, InvalidName)

27
Federated Naming Service
  • Naming service supports federation distinct
    naming servers can be linked together to create a
    single naming graph.
  • A client can then navigate seamlessly throughout
    the naming graph without being aware that it is
    federated.
  • The support is through bind_context()
  • Graph or hierarchy?
  • Cycles in the graph

28
Federated Naming Service

Naming Service X
Naming Service Y
A
B
C
29
Federated Naming Service

V
A
B
U
Context A can be accessed by A, A/B/V/U/A, or
A/B/V/U/A/B/U/V/A Avoid infinite loop
30
Building Applications Using CORBA
  • Room booking system
  • Booking rooms for meetings for a duration (from
    900 am to 400 pm by hour)
  • Canceling the bookings
  • The number and names of rooms can change
  • When booking a room, a purpose and the name of
    the person making the booking should be given
  • System design decisions
  • Rooms and meetings are CORBA objects
  • A meeting object defines a purpose and the person
    responsible for the meeting
  • A meeting factory creates meeting objects
  • A room stores meetings indexed by time slots
  • Room have a name and register themselves under
    this name with the Naming Service

31
Room Booking System
Client Application

Proxy
RoomServer
resolve()
view() book() cancelBooking()
RoomImpl
RoomServer
CORBA Naming Service
RoomServer
RoomImpl
NamingContext
RoomImpl
bind()
resolve()
CreateMeeting()
bind()
MeetingFactoryServer
MeetingImpl
MeetingFactoryImpl
MeetingImpl
MeetingImpl
MeetingImpl
32
Room Booking Naming Convention

Root Naming Context
BuildingApplications
Rooms
Meeting Factory
Board Room
Meeting Room
Chairmens Office
Context Object
Object Name
33
Source Code
  • Chapter 8
  • Client
  • ClientApplication.java (main)
  • RoomBookingClient.java (Impl)
  • Server
  • Room
  • RoomServer.java
  • RoomImpl.java
  • MeetingFactory
  • MeetingFactoryServer.java
  • MeetingFactoryImpl.java
  • Meeting
  • MeetingImpl.java

34
Source Code
  • Client
  • ClientApplication.java (main)
  • Create impl client RoomBookingClient()
  • Initialize NS client.init_from_ns()
  • View existing bookings client.view()
  • RoomBookingClient (impl)
  • Private
  • orb, root_context, room_context, meeting_factory,
    rooms, meetings, booked, ior
  • Constructor
  • Initialize orb
  • Get root_context
  • Init_from_ns
  • From root_context get room_context
  • From root_context get meeting_factory
  • View
  • Get rooms,
  • List meetings

35
Source Code
  • Server
  • Room
  • RoomServer.java
  • Initialize
  • ORB orb ORB.init( args, null )
  • POA poa POAHelper.narrow(
    orb.resolve_initial_references( "RootPOA"))
  • poa.the_POAManager().activate()
  • Create room object and export the object
    reference
  • org.omg.CORBA.Object room_obj
  • poa.servant_to_reference
    ( new RoomImpl( args0 ) )
  • Register with naming service
  • NamingContextExt root NamingContextExtHelp
    er.narrow (
  • orb.resolve_initial_refer
    ences("NameService"))
  • root.bind_new_context( root.to_name(
    context_name ))
  • str_name context_name "/" args0
  • root.bind( root.to_name( str_name), room_obj
    )
  • Wait for request
  • orb.run()

36
Source Code
  • Server
  • Room
  • RoomImpl.java
  • Inherit from RoomPOA
  • public class RoomImpl extends RoomPOA
  • Implement all the operations declared in the idl
  • Attributes
  • View
  • Book
  • Cancelbooking

37
Source Code
  • Server
  • MeetingFactory
  • MeetingFactoryServer.java
  • Initialize
  • ORB orb ORB.init( args, null )
  • POA poa POAHelper.narrow(
    orb.resolve_initial_references( "RootPOA"))
  • poa.the_POAManager().activate()
  • Create room object and export the object
    reference
  • org.omg.CORBA.Object meeting_factory_obj
  • poa.servant_to_reference
    ( new MeetingFactoryImpl( ) )
  • Register with naming service
  • NamingContextExt root NamingContextExtHelp
    er.narrow (
  • orb.resolve_initial_refer
    ences("NameService"))
  • root.bind_new_context( root.to_name(
    context_name ))
  • str_name context_name "/" args0
  • root.bind( root.to_name( str_name),
    meeting_factory_obj )
  • Wait for request
  • orb.run()

38
Source Code
  • Server
  • MeetingFactory
  • MeetingFactoryImpl.java
  • Inherit from MeetingFactoryPOA
  • public class MeetingFactoryImpl extends
    MeetingFactoryPOA
  • Implement all the operations declared in the idl
  • createMeeting
  • MeetingImpl meetingImpl
  • new MeetingImpl(purpose, participants)
  • try
  • org.omg.CORBA.Object obj
    _poa().servant_to_reference(meetingImpl)
  • Meeting meeting MeetingHelper.narrow(obj)
  • return meeting

39
Source Code
  • Server
  • Meeting
  • MeetingImpl.java
  • Inherit from MeetingPOA
  • public class MeetingImpl extends MeetingPOA
  • Implement all the operations declared in the idl
  • Attributes
  • Destory
  • Not all Corba objects need to be registered with
    NS
  • servant_to_reference(meetingImpl) is done by
    other entity (MeetingFactoryImpl)

40
Limitations of Naming Service
  • Limitation of Naming in all approaches Client
    always has to identify the server by name.
  • Inappropriate if client just wants to use a
    service at a certain quality but does not know
    from who
  • Automatic cinema ticketing,
  • Video on demand,
  • Electronic commerce.
Write a Comment
User Comments (0)
About PowerShow.com