Distributed Systems Concepts and Programming
Distributed Systems Concepts and Programming Cpt S 464
Popular in Course
Popular in ComputerScienence
This 32 page Class Notes was uploaded by Mrs. Malinda Zulauf on Thursday September 17, 2015. The Class Notes belongs to Cpt S 464 at Washington State University taught by Staff in Fall. Since its upload, it has received 90 views. For similar materials see /class/205998/cpt-s-464-washington-state-university in ComputerScienence at Washington State University.
Reviews for Distributed Systems Concepts and Programming
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 09/17/15
CORBAIV Prof Dave Bakken Prof Carl Hauser Cpt 8 464564 Lecture October 28 2004 Administrative Notes Project 3 will be given out Tuesday Nov 2 Will be due Tues Nov 30 Will use CORBA Event Services discussed today If you are concerned about finishing this project START TODAY on familiarizing with Event Services Most of this lecture is on generic CORBA Event Services but ORBACUS has some proprietary extensions we will use factory to allow multiple instances of an event channeD Project 4 will overlap with Proj 3 SIDES 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser On Device Discovery and Mobile Compufing aVI a en ar auser VHS 4b4bb4 Iall 2004 LdR39B39AIv 20 Different Interaction Styles Synchronous Invocation Client actively invokes requests on passive server Client blocks until reply arrives Note clients are aware of their servers This style is too restrictive for some kinds of apps Even asynchronous invocations only help some Desirable flexibility Spatial decouplinq clients and servers do not have to know each other s identities Temporal decouplinq clients and servers do not have to have overlapping lifetimes Another kind of Middleware eventbased MessageOriented Middleware MOM pubsub Provides spatial decoupling more flexibility sometimes even temporal decoupling if have persistent queues upls 4b4bb4 laII 2004 U 5 DaVla Bakken ZUU4 Larl Hauser CORBA amp Events Supplier entity producing the information of interest AKA publishers Consumer entity receiving and using the information of interest AKA subscribers Q which is a client which is a server Why Suppliers can send messages to one or more consumers with a single call Suppliers and Consumers are decoupled spatially they are not aware of each other s identity opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser PublishSubscribe Event Architectures i39 O publish O O O O dissemination f 9 Bus 5 65 4b4bb4 iall 2004 LUH39B39AIV ZUUd DEMO B39Rk39a en 2004 Larl Hauser Cnnvrinhf m onm Vpriccimn and Rndmmmq Invocations and Events Contrasted Topology Invocations have a single target Events can be delivered to multiple consumers with one call by a supplier Coupling Invocations require the client to be aware of the server Events keep the supplier and consumer decoupled spatially unaware of each other not referring to each other opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser lnvocations and Events Contrasted cont Blocking Synchronous invocation blocks until invocation returns so client and server are loosely synchronized at some time Events are nonblocking supplier does not block until all messages have reached all consumers lnvocations syntactic checking and type safety lnvocations are type checked because method s lDL describes all data Events data needs to be selfdescribing So types not checked while being passed Consumers have to establish the type Case 1 consumers know what type of data to expect Case 2 consumers inspect the selfdescribing object to see type Use lDL any type UDES 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld Bakken 2004 Carl Hauser Event Service Basics Orbacus man Ch 13 and Adv CORBA w C Ch 20 OMG has Event service Both suppliers and consumers connect to an event channel Two models push and pull 4 variants models supported ush ush Consumer 390 Event Channel 390 Supplier client server Direction of Event Flow A lt ull ull Consumer 390 Event Channel 390 Supplier server Client Direction of Event Flow A lt UDES 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser 1 Canonical Push Model Suppliers are initiators of events Consumers passively wait to receive them Event channel plays role of notifier Most commonly used event delivery model W M ush W5 push Supplier pUSh Supplier Supplier Event Channel Direction of Event Flow upls 4b4bb4 iaII 2004 LUH39B39AIV 2003 uawo I ma en 2004 Larl Hauser 2 Canonical Pull Model Consumers are initiators of events Suppliers passively wait to get events pulled from them They must buffer events Event channel plays role of procurer ppquot W Supplier ull ull Event Channel p Suppller W ppquot Supplier A Direction of Event Flow UDES 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld l BaRRen 2004 Larl Hauser 3 Hybrid PushPull Model Suppliers push events to the event channel Consumers pull events from the event channel Both suppliers and consumers are thus active Event channel plays role of a queue Consumer PU uH W push Supplier pUSh Supplier Supplier EventChannel push Direction of Event Flow SIDES 4b4bb4 laII 2004 LUH39B39AIV ZUUd uawo I ma en 2004 Lari Hauser SIDES 4b4bb4 laII 2004 A lt 4 Hybrid PullPush Model Event channel pulls events from suppliers Event channel pushes events to consumers Both supplier and consumer are passive Event channel functions as an intelligent agent Needs to know info about the supplier how often events produced etc Consumer ush Supplier pu Supplier Supplier EventChannel PUSh puH Direction of Event Flow LUH39B39AIV ZUUd uawo I ma en 2004 Lari Hauser Comparison Model Action EC Role Producer Consumer Canonical Supplier pushes to EC Noti er Active Passive Push EC pushes to Consumer Canonical Consumers pull from EC Procurer Passive Active Pull EC pulls from Supplier Hybrid Supplier pushes to EC Queue Active Active pushpull Consumer pulls from EC Hybrid EC pulls from supplier Intelligent Passive Passive pullpush EC pushes to Consumer Agent upis 4b4bb4 IaII 2004 LUH39B39AIv ZUUd uawo I ma en 2004 can Hauser Notes on Event Service A single event channel can support all four models simultaneously Note each consumer receives a events provided by a suppliers OMG Notification Services has much fancier filtering ORBACUS has nonstandartized ie proprietary Event Channel Factories interface EventChannelFactory Sec 1344 in ORBACUS manual that allow creation of different instances of an Event Service UDES 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser Event Service Interfaces CosEventComm interface provides IDL to interact with event channels Note most interfaces deal with suppliers and consumers notEC Event Channel Proxy Supplier Interface Proxy Consumer Interface opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser Interfaces for the Push Model Push consumer implements the PushConsumer interface and registers for it with a supplier details later module CosEventComm exception Disconnected interface pushConsumer void pushin any data raises Disconnected void disconnectpushconsumer interface PushSuppIier void disconectpushsuppier UDES 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVId l BaRRen 2004 Larl Hauser Interfaces for the Pull Model module CosEventComm interface PullSupplier any pu raises Disconnected any trypuout boolean hasevent raises Disconnected void disconnectpusuppier interface PuIIConsumer void disconnectpuconsumer UDES 4b4bb4 iaII 2004 LUHBAIVZ ZUUd UaVId BaRRen 2004 Larl Hauser mgggngsgggnnel Adrninistrative Interfaces hanneIAdmIn interface ProxyPushSupplier interface ProxyPuIISupplier interface ProxyPushConsumer interface ProxyPuIIConsumer interface ConsumerAdmin ProxyPushSupplier obtainpushsupplier ProxyPuIISupplier obtainpullsupplier interface SupplierAdmin ProxyPushConsumer obtainpushconsumerO ProxyPuIIConsumer obtainpullconsumerO interface EventChannel ConsumerAdmin forconsumers SupplierAdmin forsuppliers void destroy up 4b4bb4 IaII 2004 LUHBAIVZ ZUUd UaVId BaRRen 2004 Larl Hauser Using The Event Channel Consumers Invoke forconsumers on EC to obtain ConsumerAdmin object reference If push consumer invoke ConsumerAdmingtobtainpushsupplier If pull consumer invoke ConsumerAdmingtobtainpullsuppier Suppliers Invoke forsuppliers on EC to obtain SupplierAdmin object reference If push supplier invoke SupplierAdmingtobtainpushconsumer If pu supplier invoke SupplierAdmingtobtainpullconsumer opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld l Bakken 2004 can Hauser CORBA any A CORBA any can contain a value of any CORBA type Selfdescribing implementation contains value plus typecode describing the type of the value Analogous to Java Object type Purpose send and recv values who s type is not known at compile time Dynamic strong typing addition flexibility additional risk Won t use a value incorrectly May suffer runtime type error opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser Using CORBA Any Using any use operations insert ltlt extract gtgt Example CORBAAny a a ltlt CORBALong 99 insert 99 into a CORBALong val if a gtgt val abort extract value from a to val exact type match req d a ltlt Hello World deep copy delete prev value const char msg if l a gtgt msg abort extract a still owns string opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld l BaRRen 2004 Larl Hauser CORBA Any and C Ambiguity Problem some CORBA types may be mapped onto same C type Solution use the Any Helper types defined in C CORBAAny a CORBABooIean b 0 CORBAChar c z CORBAOctet o Oxff a ltlt CORBAAnyfrombooleanb works a ltlt CORBAAnyfromcharc works a ltlt CORBAAnyfromocteto works a ltlt CORBAAnyfrombooleanc works no compiler complaints but will not do what you want Corresponding helpers for extraction opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld Bakken 2004 Larl Hauser What if you don39t know the type Typecase pattern CORBALong I if a gtgt i it was a long ese if a gtgt CORBAAnytocharc it was a char ese if a gtgt CORBAAnytoocteto it was an octet This will be a key to programming your sniffers in Project 3 UDES 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser UserDefined Types and Any IDL compiler generates insertion and extraction operators for userdefined types enumerations structures unions and sequences Enumeration example FooColor c Foobue FooColor cout altltq if lagt gtcout abort cout should equal Fooblue No storage mgmt issues for enumerations all by value Structures unions sequences raise issues like strings opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser Any and Strucutur39es Given IDL struct myData long L1 string msg Compiler generates operations for C void operatorlt ltCORBAAny amp const myData amp by ref void operatorlt ltCORBAAny amp myData by pointer CORBABooean operatorgt gtconst CORBAAny amp myData amp First insertion by reference copies value and Any now owns the location second insertion by reference myData md mdp assume mdp pointed to something real a lt lt md copies containing procedure still owns md s memory a ltlt mdp copies pointer Any owns the memory and will dealloc when the Any variable a goes out of scope warning do not delete mdp here Extraction always by pointer Any owns readonly so no delete opts 4b4bb4 laII 2004 LUHBAIVZ ZUUd UaVld BaRRen 2004 Larl Hauser More on Any Can insert object references just like a userdefined type Can insert an Any into another Any Similar memory management issues will arise Consult Chapter 15 Advanced CORBA Programming with C if want to use Any defined in netnifaborbacusOB412obincludeOBAnyh Some operations dangerous without type checking const void value Extracts C void generic pointer but then you can cast it to any other type unsafer opts 4b4bb4 IaII 2004 LUHBAIVZ ZUUd UaVId BaRRen 2004 Larl Hauser Example Evem Service and Any Push Supplier CosEventChannelAdminEventChanneIvar e W CORBAObjectvar obj orb gt resolveinitiareferencesquotEventServicequot e CosEventChannelAdminEventChannelnarrowobj catchconst CORBAORBnvaidNameamp cerr lt lt prog lt lt quot can t resolve EventServicequot39 lt lt endl exit1 ifCORBAisnile cerr lt lt prog lt lt quot EventService is not an EventChannel object quot lt lt quotreferencequot lt lt endl exit1 UDES 4b4bb4 IaII 2004 LUHBAIVZ ZUUd UaVId BaRRen 2004 Larl Hauser Example Event Svc and Any Push Supplier cont Get a SupplierAdmin object from the EventChanneI CosEventChannelAdminSupplierAdminvar supplierAdmin egtforsuppliers Get a ProxyPushConsumer from the SupplierAdmin CosEventChannelAdminProxyPushConsumervar consumer supplierAdmingtobtainpushconsumer Connect to the ProxyPushConsumer as a PushSupplier passing a nil PushSupplier object reference to it because we don t care to be notified about disconnects consumer gtconnectpushsupplierCosEventCommPushSuppIierni Create an event just a string in this case const CORBAStringvar eventData CORBAstringdupquotHeo worldquot while 1 Insert the event data into an any CORBAAny any any lt lt eventData Now push the event to the consumer consumergtpushany sleep opts 4b4bb4 iaII 2004 LUHBAIVZ ZUUd UaVId BaRRen 2004 Larl Hauser Example of Event Service and Any PushConsumer Derive any consumer from POACosEventCommPushConsumer class EventConsumerimpI public virtual POACosEventCommPushConsumer void EventConsumerimppush const CORBAAny amp data th rowCO R BA System Exception Extract event data from the any assume string const char eventDataStr if data gt gt eventDataStr else opts 4b4bb4 IaII 2004 cout lt lt quotpush received event lt lt eventDataStr lt lt endl cout lt lt quotReceived something other than a stringquot lt lt endl LUH39B39AIV ac ZUUd uawo I ma en 2004 Larl Hauser Example of Event Svc amp Any PushConsumer cont In main have to instantiate an EventConsumerimpl object and hook it up to supplier EventConsumerimpl consumerlmpl new EventConsumerimpl EventConsumervar consumer consumerlmpl gt this Get a ConsumerAdmin object from the EventChanneI CosEventChannelAdminConsumerAdminvar consumerAdmin egtforconsumers Get a ProxyPushSupplier from the ConsumerAdmin CosEventChannelAdminProxyPushSuppliervar supplier consumerAdmingtobtainpushsupplier opts 4b4bb4 IaII 2004 LUHBAIVZ ZUUd UaVId BaRRen 2004 Larl Hauser Example of Event Svc amp Any PushConsumer cont Connect to the ProxyPushSupplier passing our PushConsumer object reference to it suppliergtconnectpushconsumerconsumer Activate the POA via its POAManager PortableServerPOAManagervar poamanager poagtthePOAManager poamanagergtactivate cout lt lt quotReady to receive eventsquot lt lt endl Enter the ORB event loop orbgtrun UDES 4b4bb4 IaII 2004 LUHBAIVZ ZUUd UaVId BaRRen 2004 Larl Hauser
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'