340 likes | 531 Views
Trading Service. Outline What is trading service How to use trading service Printer Example. Motivation. Locating objects in location transparent way Naming simple but may not be suitable when clients do not know server there are multiple servers to choose from
E N D
Trading Service • Outline • What is trading service • How to use trading service • Printer Example Trading Service
Motivation • Locating objects in location transparent way • Naming simple but may not be suitable when • clients do not know server • there are multiple servers to choose from • Trading supports locating servers based on service functionality and quality • Naming « White pages • Trading « Yellow Pages Trading Service
Trading Characteristics • Trader operates as broker between client and server. • Enables client to change perspective from ´who?´ to ´what?´ Trader 1:export 2: Query 3: invoke Exporter Importer • Similar ideas in: • mortgage broker • insurance broker • stock brokerage Trading Service
Trading Characteristics • Common language between client and server: • Service types • Qualities of service • Server registers service with trader. • Server defines assured quality of service: • Static QoS definition • Dynamic QoS definition. Trading Service
Trading Characteristics • Clients ask trader for • a service of a certain type • at a certain level of quality • Trader supports • service matching • service shopping Trading Service
Example • Hongkong Telecom video-on-demand server: Server Video-on- demand provider MGM User Warner Trader Independent Trading Service
CORBA Trading Service Server Client Application objectImpl proxy export() modify() withdraw() Query() CORBA Trading Service lookup register link proxy Admin Trading Service
The Trading Process • Example: Video-on-demand server :Client :Trader MGM:VoDS Warner:VoDS export( ) export( ) Query( ) modify( ) download( ) Trading Service
Trading Service Interface • Service type repository • Trader components • Iterators • Dynamic properties • Lookup: importers make queries • Register: exporters advertise new service offers • Link: admins federate traders • Admin: admins set policies • Proxy: legacy mechanisms for advertising services Trading Service
Service Type Definition • Service types define • Functionality provided by a service and • Qualities of Service (QoS) provision. • Functionality defined by object type • QoS defined based on properties, i.e. • property name • property type • property value • property mode • mandatory/optional • readonly/modifiable Trading Service
Service Type Example typedef enum {VGA,SVGA,XGA} Resolution; service video_on_demand { interface VideoServer; readonly mandatory property float fee; readonly mandatory property Resolution res; modifiable optional property float bandwidth; } Trading Service
Service Type Hierarchy • An object type might have several implementations with different QoS. • Same object type might be used in different service types. • Service type S is subtype of service S’ iff • object type of S is identical or subtype of object type of S’ • S has at least all properties defined for S’ • Subtype relationship can be exploited by trader for service matching purposes Trading Service
Constraint Definition • Importer defines the desired qualities of service as part of the query: • Example: fee<10 AND res >=SGA AND bandwidth>=256 • In a query, trader matches only those offers that meet the constraint Trading Service
Trading Policies • Depending on constraint and available services, a large set of offer might be returned by a query. • Trading policies are used to restrict the size of the matched offers • Specification of an upper limit • Restriction on service replacements • Restriction on modifiable properties (these might change between match making and service requests) Trading Service
Federated Traders • Scalability demands federation of traders • A trader participating in a federation • offers the services it knows about to other traders • forwards queries it cannot satisfy to other traders • Problems • Non-termination of import • Duplication of matched offers Trading Service
Trading Graph query.hop_count=4 T1 def_follow_policy=always max_hop_count=5 max_hop_count=1 T2 T3 Service Offer query.hop_count=0 T4 Trader Attribute Link Trading Service
CORBA Trading Service Application Objects Domain Interfaces CORBA facilities Object Request Broker Object Trader CORBAservices Trading Service
CORBA Trading Interfaces Admin list_offers() … TraderComponents LinkAttributes Support Attributes ImportAttributes Link Lookup Register add_link() query() export() remove_link() withdraw() describe_link() modify() modify_link() Trading Service
Defining Quality of Service typedef Istring PropertyName; typedef sequence<PropertyName> PropertyNameSeq; typedef any PropertyValue; struct Property { PropertyName name; PropertyValue value; }; typedef sequence<Property> PropertySeq; enum HowManyProps {none, some, all} union SpecifiedProps switch (HowManyProps) { case some : PropertyNameSeq prop_names; }; Trading Service
Trader Interface for Exporters interface Register { OfferId export(in Object reference, in ServiceTypeName type, in PropertySeq properties) raises(...); OfferId withdraw(in OfferId id) raises(...); void modify(in OfferId id, in PropertyNameSeq del_list, in PropertySeq modify_list) raises (...); }; Trading Service
Trader Interface for Importers interface Lookup { void query(in ServiceTypeName type, in Constraint const, in Preference pref, in PolicySeq policies, in SpecifiedProps desired_props, in unsigned long how_many, out OfferSeq offers, out OfferIterator offer_itr, out PolicyNameSeq Limits_applied) raises (...); }; Trading Service
Service Type Repository • Service type • Name • Interfact type • Set of properties • Name • Typecode • Read-only/modifiable • Mandatory/optional Trading Service
Service Type Repository • Substitutability of service types • The interface type of a derived service type may be a subtype of the interface type in the base service type • The property set may be extended in a derived service type with new property name (and their associated type and mode specification) • Inherited properties may be strengthened • Optional mandatory • Modifiable read-only Trading Service
Service Type Repository • creating service type // operation signatures IncarnationNumber add_type ( in CosTrading::ServiceTypeName name, in Identifier if_name, in PropStructSeq props, in ServiceTypeNameSeq super_types ) raises ( CosTrading::IllegalServiceType, ServiceTypeExists, InterfaceTypeMismatch, CosTrading::IllegalPropertyName, CosTrading::DuplicatePropertyName, ValueTypeRedefinition, CosTrading::UnknownServiceType, DuplicateServiceTypeName ); Trading Service
Service Type Repository • Removing service type void remove_type ( in CosTrading::ServiceTypeName name ) raises ( CosTrading::IllegalServiceType, CosTrading::UnknownServiceType, HasSubTypes ); Trading Service
Service Type Repository • Obtaining service type info ServiceTypeNameSeq list_types ( in SpecifiedServiceTypes which_types ); TypeStruct describe_type ( in CosTrading::ServiceTypeName name ) raises ( CosTrading::IllegalServiceType, CosTrading::UnknownServiceType ); TypeStruct fully_describe_type ( in CosTrading::ServiceTypeName name ) raises ( CosTrading::IllegalServiceType, CosTrading::UnknownServiceType ); Trading Service
Service Type Repository • Masking/unmasking types void mask_type ( in CosTrading::ServiceTypeName name ) raises ( CosTrading::IllegalServiceType, CosTrading::UnknownServiceType, AlreadyMasked ); void unmask_type ( in CosTrading::ServiceTypeName name ) raises ( CosTrading::IllegalServiceType, CosTrading::UnknownServiceType, NotMasked ); Trading Service
Service Type Repository • properties interface ServiceTypeRepository { enum PropertyMode { PROP_NORMAL, PROP_READONLY, PROP_MANDATORY, PROP_MANDATORY_READONLY }; struct PropStruct { CosTrading::PropertyName name; CORBA::TypeCode value_type; PropertyMode mode; }; }; Trading Service
Printer Example • Printer interface Printer { typedef string filename; exception PrinterOffLine { short code; }; void print_file(in filename fn) raises(PrinterOffLine); short queue_length() raises(PrinterOffLine); }; interface TradingPrinter : Printer, CosTradingDynamic::DynamicPropEval {}; }; Trading Service
Printer Example • Printer property • Building “A Block”, “A Block” ; “ A Block” • Floor 2, 3, 7 • Language PostScript, PostScript, PostScript • Resolution 300, 600, 600 • Color black, black, 256color • Queue_len - [PrinterObjectRef]->queue_length() • Name “12ps”, “monster”, “rib” Trading Service
Printer Example • Implementing the Printer Interface • void print_file(string fn); • Short queue_length(); • Any evalDP(string name, TypeCode returned_type, Any extra_info); Trading Service
Printer Example • Implementing the Printer Server • ORB initialization • Get trader reference • Find service type repository • Check for service type existence, if not exist, create it: • Create a prop struct ist with the property name for a printer service type • Add the new service type • Create service offer property seq to use for export • Create printers (use command-line arguments) and making them available to ORB • Update the template service offer to advertise them Trading Service
Printer Example • Implementing the Printer Client • Arguments: • Name of the file to print • Constraint expression for searching criteria • Preference expression to order the printer service offers returned • Implementation: • Check for arguments • Find Lookup object • Process the commend-line arguments • Establish basic policies for a trader query • Make the query • The returned Printer object are tried in order until the file is successfully printed Trading Service
Key Points • Distributed objects can be located by naming and trading • Naming binds externally known names to an object reference and supports name resolution to reveal the object reference • Trading supports locating objects based on the functionality that they offer and the quality of service that they guarantee Trading Service