SlideShare a Scribd company logo
1 of 147
Pattern-Oriented Software Architectures Patterns & Frameworks for  Concurrent & Distributed Systems   Dr. Douglas C. Schmidt [email_address] http://www.dre.vanderbilt.edu/~schmidt/ Professor of EECS Vanderbilt University Nashville, Tennessee
Tutorial Motivation ,[object Object],[object Object],Observations Stand-alone Architecture Networked  Architecture ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tutorial Outline ,[object Object],[object Object],[object Object],[object Object],Cover OO techniques & language features that enhance software quality ,[object Object],[object Object],[object Object],[object Object],[object Object]
Technology Trends (1/4) ,[object Object],[object Object],These advances stem largely from standard hardware & software APIs & protocols,  e.g.: ,[object Object],[object Object],[object Object],[object Object],[object Object]
Technology Trends (2/4) ,[object Object],[object Object],Process Automation Quality Control Avionics Mission Computing Modalities e.g., MRI, CT, CR, Ultrasound, etc. Electronic Medical Imaging Software Defined Radio Hot Rolling Mills
Technology Trends (3/4) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Component middleware is maturing & becoming pervasive … Security Replication Notification Persistence Scheduling A/V Streaming Load Balancing Container … … Middleware Bus Container …
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],<CONFIGURATION_PASS> <HOME>  <…>  <COMPONENT> <ID> <…></ID> <EVENT_SUPPLIER> <…events this component supplies…> </EVENT_SUPPLIER> </COMPONENT> </HOME> </CONFIGURATION_PASS> Goal is  not  to replace programmers per se – it is to provide  higher-level domain-specific languages  for middleware developers & users Model driven development is integrating generative software technologies with QoS-enabled component middleware Technology Trends (4/4) Middleware Middleware Services DRE Applications Operating Sys & Protocols Hardware &  Networks Distributed system
The Evolution of Middleware There are multiple COTS middleware layers & research/business opportunities Historically, mission-critical apps were built directly atop hardware ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],There are layers of middleware, just like there are layers of networking protocols Hardware Applications Domain-Specific Services Common Middleware Services Distribution Middleware Host Infrastructure Middleware & OS Operating Systems  & Protocols
Operating System & Protocols ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],RTP DNS HTTP UDP TCP IP TELNET Ethernet ATM FDDI Fibre Channel FTP INTERNETWORKING ARCH TFTP 20 th  Century Win2K Linux LynxOS Solaris VxWorks Middleware Middleware Services Middleware Applications MIDDLEWARE ARCH 21 st  Century
Host Infrastructure Middleware ,[object Object],[object Object],Domain-Specific Services Common Middleware Services Distribution Middleware Host Infrastructure Middleware www.cs.wustl.edu/~schmidt/ACE.html Synchronization Memory Management Physical Memory Access Asynchronous Event Handling Scheduling Asynchronous Transfer of Control www.rtj.org ,[object Object],[object Object]
Distribution Middleware ,[object Object],Domain-Specific Services Common Middleware Services Distribution Middleware Host Infrastructure Middleware ,[object Object],[object Object],[object Object]
Common Middleware Services ,[object Object],Domain-Specific Services Common Middleware Services Distribution Middleware Host Infrastructure Middleware ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Domain-Specific Middleware ,[object Object],Domain-Specific Services Common Middleware Services Distribution Middleware Host Infrastructure Middleware Modalities e.g., MRI, CT, CR, Ultrasound, etc. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Consequences of COTS  & IT Commoditization ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Not all trends bode well for long-term competitiveness of traditional R&D leaders Ultimately, competitiveness depends on success of long-term R&D on  complex  distributed real-time & embedded (DRE) systems
Why We are Succeeding Now ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Revolutionary changes in software process & methods:   Open-source, refactoring, agile methods, advanced V&V techniques, model-driven development Patterns & Pattern Languages:  Generate software architectures by capturing recurring structures & dynamics & by resolving design forces Standards-based QoS-enabled Middleware:   Pluggable service & micro-protocol components & reusable “semi-complete” application frameworks
Example: Applying COTS in Real-time Avionics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Key Results
Example: Applying COTS to Time-Critical Targets ,[object Object],[object Object],[object Object],Challenges are  also relevant to TBMD & NMD ,[object Object],[object Object],[object Object],[object Object],[object Object],Key System Characteristics Key Solution Characteristics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example:   Applying COTS to Large-scale Routers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],www.arl.wustl.edu IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM IOM BSE BSE BSE BSE BSE BSE BSE BSE BSE Key Software Solution Characteristics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example:   Applying COTS to Software Defined Radios Key Software Solution Characteristics ,[object Object],[object Object],[object Object],www.omg.org/docs/swradio   Core Framework (CF) Commercial Off-the-Shelf (COTS) Applications OE Red Hardware Bus CF Services & Applications CORBA ORB & Services (Middleware) Network Stacks & Serial Interface Services Board Support Package (Bus Layer) Black Hardware Bus CF Services & Applications CORBA ORB & Services (Middleware) Network Stacks & Serial Interface Services Board Support Package (Bus Layer) Operating System Core Framework IDL Non-CORBA Modem Components Non-CORBA Security Components Non-CORBA I/O Components RF Modem Components Link, Network Components Security Components Modem Adapter Security Adapter Security Adapter I/O Adapter I/O Components MAC API LLC/Network API LLC/Network API Link, Network Components Security API Operating System Physical  API I/O API (“Logical Software Bus” via CORBA)
Example: Applying COTS to Hot Rolling Mills ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Key Software Solution Characteristics ,[object Object],[object Object],[object Object],[object Object],[object Object],www.siroll.de
Example: Applying COTS to Real-time Image Processing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],www.krones.com Key Software Solution Characteristics ,[object Object],[object Object],[object Object],[object Object],[object Object]
Key Opportunities & Challenges in Concurrent Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Key Opportunities & Challenges in  Networked & Distributed Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overview of Patterns ,[object Object],[object Object],The Proxy Pattern 1 1 Proxy service Service service AbstractService service Client ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overview of Pattern Languages ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Taxonomy of Patterns & Idioms Active Object, Bridge, Proxy, Wrapper Façade, & Visitor Capture the static & dynamic roles & relationships in solutions that occur repeatedly  Design patterns Half-Sync/Half-Async, Layers, Proactor,  Publisher-Subscriber, & Reactor Express a fundamental structural organization for software systems that provide a set of predefined subsystems, specify their relationships, & include the rules and guidelines for organizing the relationships between them Architectural patterns Optimize for common case, pass information between layers Document rules for avoiding common design & implementation mistakes that degrade performance Optimization principle patterns Scoped locking Restricted to a particular language, system, or tool Idioms Examples Description Type
Tutorial Example: Boeing Bold Stroke Nav Sensors Weapon Management Data Links Mission Computer Vehicle Mgmt Weapons Radar ,[object Object],[object Object],[object Object],[object Object],Bold  Stroke Architecture  Hardware (CPU, Memory, I/O) Networking Interfaces Operating System Middleware Infrastructure Mission Computing Services
Tutorial Example: Boeing Bold Stroke ,[object Object],[object Object],[object Object],[object Object],[object Object],Hardware (CPU, Memory, I/O) Networking Interfaces Operating System Middleware Infrastructure Mission Computing Services
Tutorial Example: Boeing Bold Stroke ,[object Object],[object Object],[object Object],Hardware (CPU, Memory, I/O) Networking Interfaces Operating System Middleware Infrastructure Mission Computing Services
Tutorial Example: Boeing Bold Stroke ,[object Object],[object Object],[object Object],[object Object],Hardware (CPU, Memory, I/O) Networking Interfaces Operating System Middleware Infrastructure Mission Computing Services
Tutorial Example: Boeing Bold Stroke ,[object Object],[object Object],[object Object],Avionics Interfaces Operator Real World Model Infrastructure Services Push Control Flow Pull Data Flow Hardware (CPU, Memory, I/O) Networking Interfaces Operating System Middleware Infrastructure Mission Computing Services
Legacy Avionics Architectures Board 1 VME 1553 1: Sensors  generate  data Board 2 2: I/O via  interrupts 3: Sensor  proxies  process data  & pass to  missions functions 4: Mission  functions  perform  avionics  operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Legacy Avionics Architectures Board 1 VME 1553 1: Sensors  generate  data Board 2 2: I/O via  interrupts 3: Sensor  proxies  process data  & pass to  missions functions 4: Mission  functions  perform  avionics  operations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Air Frame AP Nav WTS GPS IFF FLIR Cyclic  Exec ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Decoupling Avionics Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Solution Problems Context  Event * Subscriber consume creates receives Event Channel attachPublisher  detachPublisher attachSubscriber detachSubscriber pushEvent Filter filterEvent Publisher produce Structure  attachSubscriber produce pushEvent event event pushEvent consume detachSubscriber :  Event :  Subscriber :  Event Channel :  Publisher Dynamics
Applying the Publisher-Subscriber Pattern to Bold Stroke Board 1 VME 1553 1: Sensors  generate  data Board 2 2: I/O via interrupts 4: Event Channel  pushes events  to  subscribers(s) 5: Subscribers  perform  avionics  operations GPS IFF FLIR HUD Nav WTS Air Frame Publishers   Subscribers   push(event)  push(event)  Event Channel 3: Sensor  publishers  push events  to event  channel ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ensuring Platform-neutral & Network-transparent Communication ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Solution Problems Context  message exchange message exchange * marshal unmarhal receive_result service_p Client Proxy calls * * call_service_p start_task Client 1 marshal unmarshal dispatch receive_request Server Proxy calls * start_up main_loop service_i Server 1 1 main_loop srv_registration srv_lookup xmit_message manage_QoS Broker 1 Structure
Ensuring Platform-neutral & Network-transparent Communication operation (params) connect send_request marshal unmarshal dispatch operation (params) result marshal receive_reply unmarshal result start_up register_service assigned port Dynamics  :  Broker :  Client Proxy :  Server Proxy : Client :  Server ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Solution Problems Context
Applying the Broker Pattern  to Bold Stroke Board 1 VME 1553 1: Sensors  generate  data Board 2 2: I/O via interrupts 5: Event Channel  pushes events  to  subscribers(s) 6: Subscribers  perform  avionics  operations GPS IFF FLIR HUD Nav WTS Air Frame Publishers   Subscribers   push(event)  push(event)  Event Channel 4: Sensor  publishers  push events  to event  channel ,[object Object],[object Object],[object Object],[object Object],[object Object],3: Broker handles I/O  via upcalls Broker ,[object Object],[object Object],Caveat These patterns are very useful, but having to implement them from scratch is tedious & error-prone!!!
Software Design Abstractions for  Concurrent & Networked Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],MIDDLEWARE ,[object Object],[object Object],[object Object]
Overview of Frameworks Framework Characteristics  Application-specific functionality  ,[object Object],Networking  Database GUI  ,[object Object],Mission Computing E-commerce Scientific Visualization ,[object Object]
Comparing Class Libraries,  Frameworks, & Components Class  Libraries Frameworks Macro-level Meso-level Micro-level Borrow caller’s thread Inversion of control Borrow caller’s thread Domain-specific or Domain-independent Domain-specific Domain-independent Stand-alone composition entities “ Semi-complete” applications Stand-alone language entities Components Class Library Architecture ADTs Strings Locks IPC Math LOCAL  INVOCATIONS APPLICATION- SPECIFIC FUNCTIONALITY EVENT LOOP GLUE CODE Files GUI A  class  is a unit of abstraction & implementation in an OO programming language Framework Architecture ADTs Locks Strings Files INVOKES A  framework  is an integrated set of classes that collaborate to produce a reusable architecture for a family of applications Reactor  GUI DATABASE  NETWORKING APPLICATION-SPECIFIC FUNCTIONALITY CALLBACKS Middleware Bus Component Architecture A  component  is an encapsulation unit with one or more interfaces that provide clients with access to its services Naming Locking Logging Events
Using Frameworks Effectively ,[object Object],[object Object],[object Object],[object Object],Successful projects are therefore often organized using the “funnel” model
Overview of the ACE Frameworks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Acceptor Connector Component Configurator Stream Reactor  Proactor Task  Application- specific  functionality
The Layered Architecture of ACE ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],www.cs.wustl.edu/~schmidt/ACE.html
Key Capabilities Provided by ACE Service Access & Control Event Handling Concurrency Synchronization
The POSA2 Pattern Language ,[object Object],[object Object],[object Object],[object Object]
POSA2 Pattern Abstracts Service Access & Configuration Patterns The  Wrapper Facade  design pattern encapsulates the functions and data provided by existing non-object-oriented APIs within more concise, robust, portable, maintainable, and cohesive object-oriented class interfaces. The  Component Configurator  design pattern allows an application to link and unlink its component implementations at run-time without having to modify, recompile, or statically relink the application. Component Configurator further supports the reconfiguration of components into different application processes without having to shut down and re-start running processes. The  Interceptor  architectural pattern allows services to be added transparently to a framework and triggered automatically when certain events occur. The  Extension Interface  design pattern allows multiple interfaces to be exported by a component, to prevent bloating of interfaces and breaking of client code when developers extend or modify the functionality of the component. Event Handling Patterns The  Reactor  architectural pattern allows event-driven applications to demultiplex and dispatch service requests that are delivered to an application from one or more clients. The  Proactor  architectural pattern allows event-driven applications to efficiently demultiplex and dispatch service requests triggered by the completion of asynchronous operations, to achieve the performance benefits of concurrency without incurring certain of its liabilities. The  Asynchronous Completion Token  design pattern allows an application to demultiplex and process efficiently the responses of asynchronous operations it invokes on services. The  Acceptor-Connector  design pattern decouples the connection and initialization of cooperating peer services in a networked system from the processing performed by the peer services after they are connected and initialized.
POSA2 Pattern Abstracts  (cont’d) Synchronization Patterns The  Scoped Locking  C++ idiom ensures that a lock is acquired when control enters a scope and released automatically when control leaves the scope, regardless of the return path from the scope. The  Strategized Lockin g design pattern parameterizes synchronization mechanisms that protect a component’s critical sections from concurrent access. The  Thread-Safe Interface  design pattern minimizes locking overhead and ensures that intra-component method calls do not incur ‘self-deadlock’ by trying to reacquire a lock that is held by the component already. The  Double-Checked Locking Optimization  design pattern reduces contention and synchronization overhead whenever critical sections of code must acquire locks in a thread-safe manner just once during program execution. Concurrency Patterns The  Active Object  design pattern decouples method execution from method invocation to enhance concurrency and simplify synchronized access to objects that reside in their own threads of control. The  Monitor Object  design pattern synchronizes concurrent method execution to ensure that only one method at a time runs within an object. It also allows an object’s methods to cooperatively schedule their execution sequences. The  Half-Sync/Half-Async  architectural pattern decouples asynchronous and synchronous service processing in concurrent systems, to simplify programming without unduly reducing performance. The pattern introduces two intercommunicating layers, one for asynchronous and one for synchronous service processing. The  Leader/Followers  architectural pattern provides an efficient concurrency model where multiple threads take turns sharing a set of event sources in order to detect, demultiplex, dispatch, and process service requests that occur on the event sources. The  Thread-Specific Storage  design pattern allows multiple threads to use one ‘logically global’ access point to retrieve an object that is local to a thread, without incurring locking overhead on each object access.
Implementing the Broker Pattern  for Bold Stroke Avionics ,[object Object],[object Object],www.omg.org ,[object Object],[object Object],2.  Communication  Resources ,[object Object],Request  Buffering Protocol Properties Explicit Binding Client Propagation & Server Declared Priority Models Portable Priorities Thread Pools Static Scheduling  Service Standard Synchonizers
Example of Applying Patterns & Frameworks to Middleware : Real-time CORBA & The ACE ORB (TAO) www.cs.wustl.edu/~schmidt/TAO.html ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Protocol  Properties Explicit Binding Thread  Pools Scheduling Service Standard Synchronizers Portable Priorities End-to-end Priority Propagation
Key Patterns Used in TAO www.cs.wustl.edu/~schmidt/PDF/ORB-patterns.pdf ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Enhancing ORB Flexibility  w/the Strategy Pattern   ,[object Object],[object Object],[object Object],Solution Problem Context Hook for the concurrency strategy Hook for the request demuxing strategy Hook for marshaling strategy Hook for the connection management strategy Hook for the underlying transport strategy Hook for the event demuxing strategy
Consolidating Strategies with  the Abstract Factory Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],Solution Problem Context Concrete factories create groups of strategies
Dynamically Configuring Factories  w/the Component Configurator Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],Solution Problem Context ,[object Object],[object Object]
ACE Frameworks Used in TAO ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],www.cs.wustl.edu/~schmidt/PDF/ICSE-03.pdf
Summary of Pattern, Framework,  & Middleware Synergies The technologies codify expertise of experienced researchers & developers There are now powerful feedback loops advancing these technologies ,[object Object],[object Object],Application-specific functionality  Acceptor Connector Component Configurator Stream Reactor  Proactor Task  ,[object Object]
Tutorial Example: High-performance Content Delivery Servers ,[object Object],[object Object],[object Object],Key Solution Characteristics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Graphics Adapter GUI Event Dispatcher Transfer Protocol e.g. , HTTP 1.0 Requester File Cache Protocol  Handlers HTML Parser HTTP Client HTTP Server GET /index.html HTTP/1.0 <H1>POSA page</H1>... www.posa.uci.edu TCP/IP Network OS Kernel & Protocols OS Kernel & Protocols
JAWS Content Server Framework ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Applying Patterns to Resolve Key JAWS Design Challenges Patterns help resolve the following common design challenges:   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Double-checked Locking Optimization Thread-specific Storage Component Configurator Thread-safe Interface Strategized Locking Scoped Locking Wrapper Facade Half-Sync/ Half-Async Monitor Object Acceptor-Connector Leader/Followers Proactor Reactor
Encapsulating Low-level OS APIs (1/2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Win2K Linux LynxOS Solaris VxWorks Applications
Encapsulating Low-level OS APIs (2/2) This pattern encapsulates data & functions provided by existing non-OO APIs within more concise, robust, portable, maintainable, & cohesive OO class interfaces ,[object Object],[object Object],: Application method() : Wrapper Facade : APIFunctionA functionA() : APIFunctionB functionB() Application calls methods calls API FunctionA() calls API FunctionB() calls  API FunctionC() void methodN(){ functionA(); } void method1(){ functionA(); } functionB(); Wrapper Facade data method1() … methodN()
Applying the Wrapper Façade Pattern in JAWS Other ACE wrapper facades used in JAWS encapsulate Sockets, process & thread management, memory-mapped files, explicit dynamic linking, & time operations ,[object Object],[object Object],For example, JAWS uses the  ACE_Thread_Mutex  wrapper facade in ACE to provide a portable interface to OS mutual exclusion mechanisms ACE_Thread_Mutex mutex acquire() tryacquire() release() void acquire() { calls  methods calls mutex_lock() calls mutex_trylock() calls  mutex_unlock() void release() { mutex_unlock(mutex); } mutex_lock(mutex); } JAWS The  ACE_Thread_Mutex  wrapper in the diagram is implemented using the Solaris thread API www.cs.wustl.edu/~schmidt/ACE/ ACE_Thread_Mutex  is also available for other threading APIs,  e.g.,  VxWorks, LynxOS, Windows, or POSIX threads
Pros and Cons of the Wrapper Façade Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Decoupling Event Demuxing, Connection Management, & Protocol Processing (1/2) Context if (FD_ISSET (acceptor,  &ready_handles)) { int h; do { h = accept (acceptor, 0, 0); char buf[BUFSIZ]; for (ssize_t i;  (i = read (h, buf, BUFSIZ)) > 0; )  write (1, buf, i); } while (h != -1); ,[object Object],[object Object],[object Object],[object Object],[object Object],Client Client Client HTTP GET request Connect request HTTP GET request Web Server Socket  Handles ,[object Object],Event Dispatcher Sockets   select() ,[object Object]
Decoupling Event Demuxing, Connection Management, & Protocol Processing (2/2) Solution Apply the  Reactor  architectural pattern (P2) & the  Acceptor-Connector  design pattern (P2) to separate the generic event-demultiplexing & connection-management code from the web server’s protocol code Handle owns dispatches * notifies * * handle set Reactor handle_events() register_handler() remove_handler() Event Handler handle_event () get_handle() Connector Synchronous Event Demuxer select () <<uses>> Acceptor Service  Handler
The Reactor Pattern The  Reactor  architectural pattern allows event-driven applications to demultiplex & dispatch service requests that are delivered to an application from one or more clients. Handle owns dispatches * notifies * * handle set Reactor handle_events() register_handler() remove_handler() Event Handler handle_event () get_handle() Concrete Event Handler A handle_event () get_handle() Concrete Event Handler B handle_event () get_handle() Synchronous Event Demuxer select () <<uses>>
Reactor Pattern Dynamics : Main Program : Concrete Event Handler : Reactor : Synchronous  Event Demultiplexer register_handler() get_handle() handle_events() select() handle_event() Handle Handles Handles Con. Event Handler Events service() event ,[object Object],[object Object],[object Object],[object Object],[object Object]
The Acceptor-Connector Pattern The  Acceptor-Connector  design pattern decouples the connection & initialization of cooperating peer services in a networked system from the processing performed by the peer services after being connected & initialized. <<activate>> owns * uses uses <<creates>> owns uses owns <<activate>> * * * * * * uses notifies notifies notifies Connector Connector() connect() complete() handle_event () Concrete Service Handler B Concrete Service Handler A Concrete Acceptor Concrete Connector Acceptor Acceptor() Accept() handle_event () peer_acceptor_ Service  Handler open() handle_event () set_handle() peer_stream_ Dispatcher select() handle_events() register_handler() remove_handler() Transport Handle Transport Handle Transport Handle
Acceptor Dynamics ACCEPT_ EVENT Handle1 Acceptor : Handle2 Handle2 Handle2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Service Handler Events : Application : Acceptor : Dispatcher register_handler() handle_events() accept() open() register_handler() handle_event() service() : Service Handler open()
Synchronous Connector Dynamics Motivation for Synchrony ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Handle Addr : Application : Connector : Dispatcher : Service Handler handle_events() connect() open() register_handler() handle_event() service() Service Handler Events Service Handler Handle get_handle()
Asynchronous Connector Dynamics Motivation for Asynchrony ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Addr : Application : Connector : Dispatcher : Service Handler handle_events() complete() connect() open() register_handler() handle_event() service() Service Handler Connector CONNECT EVENT Events register_handler() Service Handler Handle Handle Handle get_handle()
Applying the Reactor and Acceptor-Connector Patterns in JAWS handle_event () get_handle() handle_event () get_handle() owns dispatches * notifies * * handle set ACE_Reactor handle_events() register_handler() remove_handler() ACE_Event_Handler handle_event () get_handle() HTTP Acceptor HTTP Handler Synchronous Event Demuxer select () <<uses>> ,[object Object],[object Object],[object Object],ACE_Handle ,[object Object],[object Object],The Acceptor-Connector design pattern can use a Reactor as its  Dispatcher  in order to help decouple:
Reactive Connection Management & Data Transfer in JAWS
Pros and Cons of the Reactor Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pros & Cons of Acceptor-Connector Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overview of Concurrency & Threading ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Iterative vs. Concurrent Servers ,[object Object],[object Object],[object Object],[object Object],[object Object]
Multiprocessing vs. Multithreading ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thread Pool Eager Spawning Strategies ,[object Object],[object Object],[object Object],[object Object]
Thread-per-Request On-demand Spawning Strategy ,[object Object],[object Object],[object Object],[object Object]
The N:1 & 1:1 Threading Models ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The N:M Threading Model ,[object Object],[object Object],[object Object],[object Object],[object Object]
Scaling Up Performance via Threading  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Half-Sync/Half-Async Pattern The  Half-Sync/Half-Async  architectural pattern decouples async & sync service processing in concurrent systems, to simplify programming without unduly reducing performance ,[object Object],[object Object],[object Object],[object Object],[object Object],Sync Service Layer Async Service  Layer Queueing Layer <<read/write>> <<read/write>> <<read/write>> <<dequeue/enqueue>> <<interrupt>> Sync Service 1 Sync Service 2 Sync Service 3 External Event Source Queue Async Service
[object Object],Half-Sync/Half-Async Pattern Dynamics ,[object Object],: External Event Source : Async Service : Queue notification read() enqueue() message : Sync Service work() message read() message work() notification
Applying Half-Sync/Half-Async Pattern in JAWS <<get>> <<get>> <<get>> <<put>> <<ready to read>> Synchronous Service Layer Asynchronous Service Layer Queueing Layer Worker Thread 1 Worker Thread 3 ACE_Reactor Socket Event Sources Request Queue HTTP Acceptor HTTP Handlers,  Worker Thread 2 ,[object Object],[object Object],[object Object]
Pros & Cons of Half-Sync/Half-Async Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing a Synchronized Request Queue ,[object Object],[object Object],[object Object],[object Object],<<get>> <<get>> <<get>> <<put>> Worker  Thread 1 Worker  Thread 3 ACE_Reactor Request Queue HTTP Acceptor HTTP Handlers,  Worker  Thread 2 ,[object Object],[object Object],[object Object],[object Object]
The Monitor Object Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],2..* uses uses * Monitor Object sync_method1() sync_methodN() Monitor Lock acquire() release() Client Monitor Condition wait() notify() notify_all()
Monitor Object Pattern Dynamics the OS thread scheduler atomically reacquires the monitor lock the OS thread scheduler atomically releases the monitor lock ,[object Object],[object Object],[object Object],[object Object],: Monitor Object : Monitor Lock : Monitor Condition sync_method1() wait() dowork() : Client Thread1 : Client Thread2 acquire() dowork() acquire() sync_method2() release() notify() dowork() release() the OS thread scheduler automatically suspends the client thread the OS thread scheduler automatically  resumes  the client thread and the synchronized method
Applying Monitor Object Pattern in JAWS The JAWS synchronized request queue implements the queue’s  not-empty  and  not-full  monitor conditions via a pair of ACE wrapper facades for POSIX-style condition variables uses uses 2 Request Queue put() get() ACE_Thread_Mutex acquire() release() HTTP Handler ACE_Thread_Condition wait() signal() broadcast() Worker Thread <<put>> <<get>> ,[object Object],[object Object]
Pros & Cons of Monitor Object Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Minimizing Server Threading Overhead ,[object Object],[object Object],[object Object],[object Object],[object Object],accept() passive-mode   socket handle accept() accept() accept() accept() accept()
Drawbacks with Half-Sync/Half-Async  ,[object Object],[object Object],[object Object],[object Object],[object Object],<<get>> <<get>> <<get>> <<put>> Worker  Thread 1 Worker  Thread 3 ACE_Reactor Request Queue HTTP Acceptor HTTP Handlers,  Worker  Thread 2 ,[object Object],[object Object],[object Object],[object Object],[object Object]
The Leader/Followers Pattern This pattern eliminates the need for—& the overhead of—a separate Reactor thread & synchronized request queue used in the Half-Sync/Half-Async pattern The Leader/Followers architectural pattern (P2) provides an efficient concurrency model where multiple threads take turns sharing event sources to detect, demux, dispatch, & process service requests that occur on the event sources TCP Sockets +  select() / poll() UDP Sockets +  select() / poll() Iterative  Handle Sets TCP Sockets +  WaitForMultpleObjects() UDP Sockets +  WaitForMultipleObjects() Concurrent  Handle Sets Iterative Handles Concurrent Handles Handles Handle Sets Handle uses demultiplexes * * Handle Set handle_events() deactivate_handle() reactivate_handle() select() Event Handler handle_event () get_handle() Concrete Event Handler B handle_event () get_handle() Concrete Event Handler A handle_event () get_handle() Thread Pool join() promote_new_leader() synchronizer
Leader/Followers Pattern Dynamics handle_events() new_leader() ,[object Object],[object Object],[object Object],[object Object],promote_ : Concrete Event Handler join() handle_event() : Thread Pool  : Handle Set join() thread 2 sleeps until it becomes the leader event thread 1 sleeps until it becomes the leader deactivate_ handle() join() Thread 1 Thread 2 handle_ events() reactivate_ handle() handle_event() event thread 2 waits for a new event, thread 1 processes current event deactivate_ handle()
Applying Leader/Followers Pattern in JAWS ,[object Object],[object Object],[object Object],[object Object],[object Object],Although Leader/Followers thread pool design is highly efficient the Half-Sync/Half-Async design may be more appropriate for certain types of servers,  e.g.: ACE_Handle uses demultiplexes * * ACE_TP_Reactor handle_events() deacitivate_handle() reactivate_handle() select() ACE_Event_Handler handle_event () get_handle() HTTP Acceptor handle_event () get_handle() HTTP Handler handle_event () get_handle() Thread Pool join() promote_new_leader() synchronizer
Pros & Cons of Leader/Followers Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using Asynchronous I/O Effectively ,[object Object],[object Object],AcceptEx() AcceptEx() AcceptEx() ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],passive-mode   socket handle I/O Completion Port GetQueued CompletionStatus() GetQueued CompletionStatus() GetQueued CompletionStatus()
The Proactor Pattern ,[object Object],[object Object],[object Object],[object Object],Handle <<executes>> * <<uses>> is associated with <<enqueues>> <<dequeues>> <<uses>> <<uses>> Initiator <<demultiplexes  & dispatches>> <<invokes>> Event Queue Completion Asynchronous Operation Processor execute_async_op() Asynchronous Operation async_op() Asynchronous Event Demuxer get_completion_event() Proactor handle_events() Completion Handler handle_event() Concrete Completion Handler This pattern allows event-driven applications to efficiently demultiplex & dispatch service requests triggered by the completion of async operations, thereby achieving the performance benefits of concurrency without incurring its many liabilities
Proactor Pattern Dynamics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Result Completion Handler Completion : Asynchronous Operation : Proactor Completion Handler exec_async_ handle_ Result service() : Asynchronous Operation Processor : Initiator async_operation() Result handle_events() event event Ev. Queue operation () : Completion Event Queue Result event()
Applying the Proactor Pattern in JAWS The Proactor pattern structures the JAWS concurrent server to receive & process requests from multiple clients asynchronously  ,[object Object],[object Object],[object Object],[object Object],[object Object],ACE_Handle <<executes>> * <<uses>> is associated with <<enqueues>> <<dequeues>> <<uses>> <<uses>> Web Server <<demultiplexes  & dispatches>> <<invokes>> I/O Completion  Port Windows NT Operating System execute_async_op() Asynchronous Operation AcceptEx() ReadFile() WriteFile() Asynchronous Event Demuxer GetQueuedCompletionStatus() ACE_Proactor handle_events() ACE_Handler handle_accept() handle_write_stream() HTTP Acceptor HTTP Handler
Proactive Connection Management & Data Transfer in JAWS
Pros & Cons of Proactor Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Efficiently Demuxing Asynchronous Operations & Completions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Asynchronous Completion Token Pattern Structure and Participants Dynamic Interactions handle_event()
Applying the Asynchronous Completion Token Pattern in JAWS Detailed Interactions ( HTTP_Acceptor is both initiator & completion handler)
Pros and Cons of the Asynchronous Completion Token Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Enhancing Server (Re)Configurability (1/2) ,[object Object],[object Object],Context The implementation of certain web server components depends on a variety of factors: ,[object Object],[object Object],[object Object],[object Object],HTTP Parsing Conn Mgmt Cache Mgmt Threading Demuxing File System I/O
Enhancing Server (Re)Configurability (2/2) ,[object Object],[object Object],[object Object],[object Object],<<contains>> components * Component Configurator Component Repository Concrete Component A Concrete Component B Component init() fini() suspend() resume() info()
Component Configurator Pattern Dynamics run_component() run_component() fini() remove() remove() fini() Comp. A Concrete Comp. B Concrete Comp. A Concrete Comp. B ,[object Object],[object Object],[object Object],: Component Configurator init() : Concrete Component A : Concrete Component B : Component Repository insert() insert() init() Concrete
Applying the Component Configurator Pattern to Web Servers <<contains>> components * Component Configurator Component Repository LRU File Cache LFU File Cache Component init() fini() suspend() resume() info() ,[object Object],[object Object],Image servers can use the Component Configurator pattern to dynamically optimize, control, & reconfigure the behavior of its components at installation-time or during run-time Concrete components can be packaged into a suitable unit of configuration, such as a dynamically linked library (DLL)  Only the components that are currently in use need to be configured into a web server
Reconfiguring JAWS Web servers can also be reconfigured dynamically to support new components & new component implementations IDLE RUNNING SUSPENDED CONFIGURE init() RECONFIGURE init() fini() fini() resume() suspend() EXECUTE run_component() SUSPEND RESUME TERMINATE TERMINATE Reconfiguration State Chart LRU File Cache Web Server # Configure a web server. dynamic File_Cache Component * web_server.dll:make_File_Cache()  &quot;-t LRU&quot; INITIAL  CONFIGURATION AFTER  RECONFIGURATION LFU File Cache Web Server # Reconfigure a web server. Remove File_Cache dynamic File_Cache Component * web_server.dll:make_File_Cache()  &quot;-t LFU&quot;
Pros & Cons of Component Configurator Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Transparently Parameterizing Synchronization into Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Applying Polymorphic Strategized Locking in JAWS class  File_Cache  { public:  // Constructor. File_Cache  ( Lock  &l): lock_ (&l) { } // A method.  const void * lookup  (const string &path) const {  lock_-> acquire (); // Implement the <lookup> method. lock_-> release  ();   }  // ... private:  // The polymorphic strategized locking object.  mutable  Lock  *lock_; // Other data members and methods go here... }; Polymorphic  Strategized  Locking class  Lock  {  public: // Acquire and release the lock.  virtual void  acquire  () = 0; virtual void  release  () = 0; // ...  }; class  Thread_Mutex  : public  Lock  { // ... };
Applying Parameterized Strategized Locking in JAWS template <class  LOCK >  class  File_Cache  { public:  // A method.  const void * lookup   (const string &path) const {  lock_ . acquire  () ;  // Implement the <lookup> method. lock_. release  ();   }  // ... private:  // The polymorphic strategized locking object.  mutable  LOCK  lock_; // Other data members and methods go here... }; Parameterized  Strategized Locking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Note that the various locks need not inherit from a common base class or use virtual methods!
Pros and Cons of the Strategized Locking Pattern ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects

More Related Content

What's hot

Legacy Migration
Legacy MigrationLegacy Migration
Legacy Migration
WORPCLOUD LTD
 
Doug Heller Resume
Doug Heller ResumeDoug Heller Resume
Doug Heller Resume
Doug Heller
 
Software architecture-patterns
Software architecture-patternsSoftware architecture-patterns
Software architecture-patterns
pedro
 

What's hot (20)

[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms[2015/2016] Modern development paradigms
[2015/2016] Modern development paradigms
 
Software architecture patterns
Software architecture patternsSoftware architecture patterns
Software architecture patterns
 
Software Architecture: Introduction
Software Architecture: IntroductionSoftware Architecture: Introduction
Software Architecture: Introduction
 
L02 What is Software Architecture?
L02 What is Software Architecture?L02 What is Software Architecture?
L02 What is Software Architecture?
 
Legacy Migration
Legacy MigrationLegacy Migration
Legacy Migration
 
The Middleware technology that connects the enterprise
The Middleware technology that connects the enterpriseThe Middleware technology that connects the enterprise
The Middleware technology that connects the enterprise
 
Software architecture styles families_research_gssi_nov2013
Software architecture styles families_research_gssi_nov2013Software architecture styles families_research_gssi_nov2013
Software architecture styles families_research_gssi_nov2013
 
Framework adoption for java enterprise application development
Framework adoption for java enterprise application developmentFramework adoption for java enterprise application development
Framework adoption for java enterprise application development
 
Software Architecture Taxonomies - Behaviour: Components & Connectors
Software Architecture Taxonomies - Behaviour: Components & ConnectorsSoftware Architecture Taxonomies - Behaviour: Components & Connectors
Software Architecture Taxonomies - Behaviour: Components & Connectors
 
[2017/2018] Architectural languages
[2017/2018] Architectural languages[2017/2018] Architectural languages
[2017/2018] Architectural languages
 
[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture[2016/2017] Introduction to Software Architecture
[2016/2017] Introduction to Software Architecture
 
Building a SaaS Style Application
Building a SaaS Style ApplicationBuilding a SaaS Style Application
Building a SaaS Style Application
 
[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git
 
J2EE and layered architecture
J2EE and layered architectureJ2EE and layered architecture
J2EE and layered architecture
 
A Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software Deployment
 
Enterprise Application Framework
Enterprise Application FrameworkEnterprise Application Framework
Enterprise Application Framework
 
Chapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration TechnologiesChapter 10:Understanding Java Related Platforms and Integration Technologies
Chapter 10:Understanding Java Related Platforms and Integration Technologies
 
IT Modernization For Process Modernization
IT Modernization For Process ModernizationIT Modernization For Process Modernization
IT Modernization For Process Modernization
 
Doug Heller Resume
Doug Heller ResumeDoug Heller Resume
Doug Heller Resume
 
Software architecture-patterns
Software architecture-patternsSoftware architecture-patterns
Software architecture-patterns
 

Similar to Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects

Ibm cloud forum managing heterogenousclouds_final
Ibm cloud forum managing heterogenousclouds_finalIbm cloud forum managing heterogenousclouds_final
Ibm cloud forum managing heterogenousclouds_final
Mauricio Godoy
 
Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...
Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...
Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...
EuroCloud
 
Aberdeen Oil & Gas Event - Cloud Adoption Framework
Aberdeen Oil & Gas Event - Cloud Adoption FrameworkAberdeen Oil & Gas Event - Cloud Adoption Framework
Aberdeen Oil & Gas Event - Cloud Adoption Framework
Amazon Web Services
 
Microsoft Private Cloud Strategy
Microsoft Private Cloud StrategyMicrosoft Private Cloud Strategy
Microsoft Private Cloud Strategy
Amit Gatenyo
 
Cloud computing - dien toan dam may
Cloud computing - dien toan dam mayCloud computing - dien toan dam may
Cloud computing - dien toan dam may
Nguyen Duong
 
Legacy Migration Overview
Legacy Migration OverviewLegacy Migration Overview
Legacy Migration Overview
Bambordé Baldé
 
Remote Infrastructure Management
Remote Infrastructure ManagementRemote Infrastructure Management
Remote Infrastructure Management
Prime Infoserv
 

Similar to Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects (20)

Cloud computingintroduction
Cloud computingintroductionCloud computingintroduction
Cloud computingintroduction
 
soa1.ppt
soa1.pptsoa1.ppt
soa1.ppt
 
Ibm cloud forum managing heterogenousclouds_final
Ibm cloud forum managing heterogenousclouds_finalIbm cloud forum managing heterogenousclouds_final
Ibm cloud forum managing heterogenousclouds_final
 
Requirment anlaysis , application, device, network requirements
Requirment anlaysis , application, device, network requirementsRequirment anlaysis , application, device, network requirements
Requirment anlaysis , application, device, network requirements
 
Eniac – Lotus Consolidation 2009
Eniac – Lotus Consolidation   2009Eniac – Lotus Consolidation   2009
Eniac – Lotus Consolidation 2009
 
Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...
Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...
Virgílio Vargas Presentations / CloudViews.Org - Cloud Computing Conference 2...
 
Cloud strategy briefing 101
Cloud strategy briefing 101 Cloud strategy briefing 101
Cloud strategy briefing 101
 
Aberdeen Oil & Gas Event - Cloud Adoption Framework
Aberdeen Oil & Gas Event - Cloud Adoption FrameworkAberdeen Oil & Gas Event - Cloud Adoption Framework
Aberdeen Oil & Gas Event - Cloud Adoption Framework
 
Microsoft Private Cloud Strategy
Microsoft Private Cloud StrategyMicrosoft Private Cloud Strategy
Microsoft Private Cloud Strategy
 
Cloud computing - dien toan dam may
Cloud computing - dien toan dam mayCloud computing - dien toan dam may
Cloud computing - dien toan dam may
 
Icinga Camp Bangalore - Enterprise exceptions
Icinga Camp Bangalore - Enterprise exceptions Icinga Camp Bangalore - Enterprise exceptions
Icinga Camp Bangalore - Enterprise exceptions
 
Lec 6 (distributed processing )
Lec 6 (distributed processing )Lec 6 (distributed processing )
Lec 6 (distributed processing )
 
Legacy Migration Overview
Legacy Migration OverviewLegacy Migration Overview
Legacy Migration Overview
 
Overview of cloud computing
Overview of cloud computingOverview of cloud computing
Overview of cloud computing
 
Cloud computing by Bhavesh
Cloud computing by BhaveshCloud computing by Bhavesh
Cloud computing by Bhavesh
 
Remote Infrastructure Management
Remote Infrastructure ManagementRemote Infrastructure Management
Remote Infrastructure Management
 
MOND Semantics Integration
MOND Semantics IntegrationMOND Semantics Integration
MOND Semantics Integration
 
Cloud Computing 2010 - IBM Italia - Mariano Ammirabile
Cloud Computing 2010 - IBM Italia - Mariano AmmirabileCloud Computing 2010 - IBM Italia - Mariano Ammirabile
Cloud Computing 2010 - IBM Italia - Mariano Ammirabile
 
Cloud Computing 2010 - EMC - Bruno Melandri
Cloud Computing 2010 - EMC - Bruno MelandriCloud Computing 2010 - EMC - Bruno Melandri
Cloud Computing 2010 - EMC - Bruno Melandri
 
Yongsan presentation 3
Yongsan presentation 3Yongsan presentation 3
Yongsan presentation 3
 

Recently uploaded

CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
Wonjun Hwang
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 

Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects

  • 1. Pattern-Oriented Software Architectures Patterns & Frameworks for Concurrent & Distributed Systems Dr. Douglas C. Schmidt [email_address] http://www.dre.vanderbilt.edu/~schmidt/ Professor of EECS Vanderbilt University Nashville, Tennessee
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26. Taxonomy of Patterns & Idioms Active Object, Bridge, Proxy, Wrapper Façade, & Visitor Capture the static & dynamic roles & relationships in solutions that occur repeatedly Design patterns Half-Sync/Half-Async, Layers, Proactor, Publisher-Subscriber, & Reactor Express a fundamental structural organization for software systems that provide a set of predefined subsystems, specify their relationships, & include the rules and guidelines for organizing the relationships between them Architectural patterns Optimize for common case, pass information between layers Document rules for avoiding common design & implementation mistakes that degrade performance Optimization principle patterns Scoped locking Restricted to a particular language, system, or tool Idioms Examples Description Type
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41. Comparing Class Libraries, Frameworks, & Components Class Libraries Frameworks Macro-level Meso-level Micro-level Borrow caller’s thread Inversion of control Borrow caller’s thread Domain-specific or Domain-independent Domain-specific Domain-independent Stand-alone composition entities “ Semi-complete” applications Stand-alone language entities Components Class Library Architecture ADTs Strings Locks IPC Math LOCAL INVOCATIONS APPLICATION- SPECIFIC FUNCTIONALITY EVENT LOOP GLUE CODE Files GUI A class is a unit of abstraction & implementation in an OO programming language Framework Architecture ADTs Locks Strings Files INVOKES A framework is an integrated set of classes that collaborate to produce a reusable architecture for a family of applications Reactor GUI DATABASE NETWORKING APPLICATION-SPECIFIC FUNCTIONALITY CALLBACKS Middleware Bus Component Architecture A component is an encapsulation unit with one or more interfaces that provide clients with access to its services Naming Locking Logging Events
  • 42.
  • 43.
  • 44.
  • 45. Key Capabilities Provided by ACE Service Access & Control Event Handling Concurrency Synchronization
  • 46.
  • 47. POSA2 Pattern Abstracts Service Access & Configuration Patterns The Wrapper Facade design pattern encapsulates the functions and data provided by existing non-object-oriented APIs within more concise, robust, portable, maintainable, and cohesive object-oriented class interfaces. The Component Configurator design pattern allows an application to link and unlink its component implementations at run-time without having to modify, recompile, or statically relink the application. Component Configurator further supports the reconfiguration of components into different application processes without having to shut down and re-start running processes. The Interceptor architectural pattern allows services to be added transparently to a framework and triggered automatically when certain events occur. The Extension Interface design pattern allows multiple interfaces to be exported by a component, to prevent bloating of interfaces and breaking of client code when developers extend or modify the functionality of the component. Event Handling Patterns The Reactor architectural pattern allows event-driven applications to demultiplex and dispatch service requests that are delivered to an application from one or more clients. The Proactor architectural pattern allows event-driven applications to efficiently demultiplex and dispatch service requests triggered by the completion of asynchronous operations, to achieve the performance benefits of concurrency without incurring certain of its liabilities. The Asynchronous Completion Token design pattern allows an application to demultiplex and process efficiently the responses of asynchronous operations it invokes on services. The Acceptor-Connector design pattern decouples the connection and initialization of cooperating peer services in a networked system from the processing performed by the peer services after they are connected and initialized.
  • 48. POSA2 Pattern Abstracts (cont’d) Synchronization Patterns The Scoped Locking C++ idiom ensures that a lock is acquired when control enters a scope and released automatically when control leaves the scope, regardless of the return path from the scope. The Strategized Lockin g design pattern parameterizes synchronization mechanisms that protect a component’s critical sections from concurrent access. The Thread-Safe Interface design pattern minimizes locking overhead and ensures that intra-component method calls do not incur ‘self-deadlock’ by trying to reacquire a lock that is held by the component already. The Double-Checked Locking Optimization design pattern reduces contention and synchronization overhead whenever critical sections of code must acquire locks in a thread-safe manner just once during program execution. Concurrency Patterns The Active Object design pattern decouples method execution from method invocation to enhance concurrency and simplify synchronized access to objects that reside in their own threads of control. The Monitor Object design pattern synchronizes concurrent method execution to ensure that only one method at a time runs within an object. It also allows an object’s methods to cooperatively schedule their execution sequences. The Half-Sync/Half-Async architectural pattern decouples asynchronous and synchronous service processing in concurrent systems, to simplify programming without unduly reducing performance. The pattern introduces two intercommunicating layers, one for asynchronous and one for synchronous service processing. The Leader/Followers architectural pattern provides an efficient concurrency model where multiple threads take turns sharing a set of event sources in order to detect, demultiplex, dispatch, and process service requests that occur on the event sources. The Thread-Specific Storage design pattern allows multiple threads to use one ‘logically global’ access point to retrieve an object that is local to a thread, without incurring locking overhead on each object access.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65. Decoupling Event Demuxing, Connection Management, & Protocol Processing (2/2) Solution Apply the Reactor architectural pattern (P2) & the Acceptor-Connector design pattern (P2) to separate the generic event-demultiplexing & connection-management code from the web server’s protocol code Handle owns dispatches * notifies * * handle set Reactor handle_events() register_handler() remove_handler() Event Handler handle_event () get_handle() Connector Synchronous Event Demuxer select () <<uses>> Acceptor Service Handler
  • 66. The Reactor Pattern The Reactor architectural pattern allows event-driven applications to demultiplex & dispatch service requests that are delivered to an application from one or more clients. Handle owns dispatches * notifies * * handle set Reactor handle_events() register_handler() remove_handler() Event Handler handle_event () get_handle() Concrete Event Handler A handle_event () get_handle() Concrete Event Handler B handle_event () get_handle() Synchronous Event Demuxer select () <<uses>>
  • 67.
  • 68. The Acceptor-Connector Pattern The Acceptor-Connector design pattern decouples the connection & initialization of cooperating peer services in a networked system from the processing performed by the peer services after being connected & initialized. <<activate>> owns * uses uses <<creates>> owns uses owns <<activate>> * * * * * * uses notifies notifies notifies Connector Connector() connect() complete() handle_event () Concrete Service Handler B Concrete Service Handler A Concrete Acceptor Concrete Connector Acceptor Acceptor() Accept() handle_event () peer_acceptor_ Service Handler open() handle_event () set_handle() peer_stream_ Dispatcher select() handle_events() register_handler() remove_handler() Transport Handle Transport Handle Transport Handle
  • 69.
  • 70.
  • 71.
  • 72.
  • 73. Reactive Connection Management & Data Transfer in JAWS
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95. The Leader/Followers Pattern This pattern eliminates the need for—& the overhead of—a separate Reactor thread & synchronized request queue used in the Half-Sync/Half-Async pattern The Leader/Followers architectural pattern (P2) provides an efficient concurrency model where multiple threads take turns sharing event sources to detect, demux, dispatch, & process service requests that occur on the event sources TCP Sockets + select() / poll() UDP Sockets + select() / poll() Iterative Handle Sets TCP Sockets + WaitForMultpleObjects() UDP Sockets + WaitForMultipleObjects() Concurrent Handle Sets Iterative Handles Concurrent Handles Handles Handle Sets Handle uses demultiplexes * * Handle Set handle_events() deactivate_handle() reactivate_handle() select() Event Handler handle_event () get_handle() Concrete Event Handler B handle_event () get_handle() Concrete Event Handler A handle_event () get_handle() Thread Pool join() promote_new_leader() synchronizer
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103. Proactive Connection Management & Data Transfer in JAWS
  • 104.
  • 105.
  • 106. Asynchronous Completion Token Pattern Structure and Participants Dynamic Interactions handle_event()
  • 107. Applying the Asynchronous Completion Token Pattern in JAWS Detailed Interactions ( HTTP_Acceptor is both initiator & completion handler)
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113. Reconfiguring JAWS Web servers can also be reconfigured dynamically to support new components & new component implementations IDLE RUNNING SUSPENDED CONFIGURE init() RECONFIGURE init() fini() fini() resume() suspend() EXECUTE run_component() SUSPEND RESUME TERMINATE TERMINATE Reconfiguration State Chart LRU File Cache Web Server # Configure a web server. dynamic File_Cache Component * web_server.dll:make_File_Cache() &quot;-t LRU&quot; INITIAL CONFIGURATION AFTER RECONFIGURATION LFU File Cache Web Server # Reconfigure a web server. Remove File_Cache dynamic File_Cache Component * web_server.dll:make_File_Cache() &quot;-t LFU&quot;
  • 114.
  • 115.
  • 116. Applying Polymorphic Strategized Locking in JAWS class File_Cache { public: // Constructor. File_Cache ( Lock &l): lock_ (&l) { } // A method. const void * lookup (const string &path) const { lock_-> acquire (); // Implement the <lookup> method. lock_-> release (); } // ... private: // The polymorphic strategized locking object. mutable Lock *lock_; // Other data members and methods go here... }; Polymorphic Strategized Locking class Lock { public: // Acquire and release the lock. virtual void acquire () = 0; virtual void release () = 0; // ... }; class Thread_Mutex : public Lock { // ... };
  • 117.
  • 118.