Date post: | 21-Dec-2015 |
Category: |
Documents |
Upload: | albert-barrett |
View: | 222 times |
Download: | 1 times |
Naming Service 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
Naming Service 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
Naming Service 3
Common Principles: Naming Contexts
Cup
Winners
Cup
Winners
1.FC
Ka
iser
slau
tern
1.FC
Ka
iser
slau
tern
Pre
mie
rP
rem
ier First
First
M
an
Uni
ted
M
an
Uni
ted
Chelsea
Chelsea
QP
RQ
PR
South End
United
South End
United
EnglandEnglandGermany
Germany
1. L
iga
1. L
iga 2. Liga
2. Liga
BV
BB
VB
Bayern
Bayern B
ochu
mB
ochu
m
LauternLautern
UEFAUEFA
Manchester
United
Manchester
United
Naming Service 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").
Naming Service 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
Naming Service 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
Naming Service 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
Naming Service 8
Naming Service
Naming Service
Client Server
1. Create binding
2. resolve
3. Use target object
Naming Service 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
London. regionNew_York.region
Frankfurt.region
Bankup.failoverMain.failover
StockExchange BrokerService
Naming Service 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
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.
Naming Service 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 sequence<NameComponent> Name;
…
};
Naming Service 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: ././.
Naming Service 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.
Naming Service 15
Binding
Module cosNaming{
enum BindingType{nobject, ncontext};
struct Binding{
Name binding_name;
BindingType binding_type;
};
typedef sequence<Binding> BindingList;
};
Naming Service 16
Binding and Unbinding OperationsModule 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);
};};
Naming Service 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
Naming Service 18
bind_context() and rebind_context()
Parameter is context Similar semantics as bind() and re_bind()
Naming Service 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.
Naming Service 20
Before Binding
Context1
Context5Context4
Context3Context2
Naming Service 21
After Binding
Context1
Context5Context4
Context3Context2
MyName
IOR of Object
Naming Service 22
Naming Scenario: Binding
Promote Bielefeld to German '1. Liga' and relegate Frankfurt
1L=resolve("UEFA","Germany","1. Liga")1L=resolve("UEFA","Germany","1. Liga")
root: Namingroot: NamingContextContextc:Clientc:Client 1L:Naming1L:Naming
ContextContext
bind("Arm. Bielefeld", bielefeld)bind("Arm. Bielefeld", bielefeld)
unbind("Eintr. Frankfurt")unbind("Eintr. Frankfurt")
Naming Service 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
Naming Service 24
NotFound ExceptionModule cosNaming{
…
interface NamingContext{…
enum NotFoundReason {missing_node, not_context, not_object};
exception NotFound {
NotFoundReason why;
Name rest_of_name;
};
};
};
Naming Service 25
Browsing ContextsModule 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);
//};
};
Naming Service 26
Converting Names: NamingContextExt
Module cosNaming{interface NamingContextExt:NamingContext{
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);
};};
Naming Service 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
Naming Service 28
Federated Naming Service
A
B
C
Naming Service X
Naming Service Y
Naming Service 29
Federated Naming Service
A
BU
V
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
Naming Service 30
Building Applications Using CORBA Room booking system:
Booking rooms for meetings for a duration (from 9:00 am to 4:00 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
Naming Service 31
Room Booking System
MeetingFactoryImpl
MeetingImpl MeetingImpl
MeetingImpl
MeetingImplMeetingFactoryServer
NamingContext
CORBA Naming ServiceRoomImpl
RoomServer
RoomImpl
RoomServer
RoomImpl
RoomServer
Proxy
Client Application
CreateMeeting()
bind()
resolve()
resolve() view()book()cancelBooking()
bind()
Naming Service 32
Room Booking Naming Convention
Root Naming Context
BuildingApplications
Rooms
Context Object
Board Room
Meeting Room
Chairmen’s Office
Object Name
Meeting Factory
Naming Service 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
Naming Service 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
Naming Service 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( args[0] ) );
– Register with naming service
NamingContextExt root = NamingContextExtHelper.narrow (
orb.resolve_initial_references("NameService"));
root.bind_new_context( root.to_name( context_name ));
str_name = context_name + "/" + args[0];
root.bind( root.to_name( str_name), room_obj );
– Wait for request
orb.run();
Naming Service 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
Naming Service 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 = NamingContextExtHelper.narrow (
orb.resolve_initial_references("NameService"));
root.bind_new_context( root.to_name( context_name ));
str_name = context_name + "/" + args[0];
root.bind( root.to_name( str_name), meeting_factory_obj );
– Wait for request
orb.run();
Naming Service 38
Source Code Server
MeetingFactory MeetingFactoryImpl.java
– Inherit from MeetingFactoryPOA
public class MeetingFactoryImpl extends MeetingFactoryPOA
– Implement all the operations declared in the idl:
» createMeetingMeetingImpl meetingImpl =
new MeetingImpl(purpose, participants);try{ org.omg.CORBA.Object obj = _poa().servant_to_reference(meetingImpl); Meeting meeting = MeetingHelper.narrow(obj); return meeting; }…
Naming Service 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)
Naming Service 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.