SlideShare a Scribd company logo
1 of 19
Architectural Patterns
[PART 2]
Architectural Patterns
Interactive System Patterns – It describes architecture that
support the adaptation of user interface parts without causing
major effect to Application specific functionality or the
underlying data model.
• Model-View-Controller
Model-View-Controller
This pattern can be used to divide system’s task to three
different components - Model, View and Controller.
• Model contains the core functionality and data. It is
independent of the data received or presented in the views.
There can be multiple view for same Model.
• View displays information to the user. It may allow user to
edit the data from the application’s model.
• Controller handles user input. It can also perform set-up and
coordinating tasks for an application.
Views and Controllers together comprise the user interface.
A change-propagation mechanism (e.g. Subscriber-obsever)
ensures consistency between the user interface and the model.
Model-View-Controller
Example – Web browser
Invoke
Result

Request

HTTP
Browser
(User)

Response

Model

Servlet
(Controller)

JSP
(View)

Database
Architectural Patterns
Event Handling Patterns – It describes how to initiate, receive,
demultiplex, dispatch and process events in networked systems.
• Proactor
• Reactor
• Asynchronous Completion Token
• Acceptor-Connector
Proactor
This pattern can be used for the demultiplexing and dispatching
of multiple event handlers which are triggered by the completion
of asynchronous events.
It requires a dedicated thread for each connected client.
In this pattern application issues an asynchronous operation to
the OS and registers a callback with a Completion Dispatcher
that will notify the Application when the operation completes.
The OS then performs the operation on behalf of the application
and subsequently queues the result in a well-known location.
The Completion Dispatcher is responsible for dequeueing
completion notifications and executing the appropriate
callback that contains application-specific code.
Proactor
Client
(Web Server)

OS

Completion
Despatcher

HTTP Get request
Read complete

Handler

File
System

Read complete
Parse
request
Read File(sync)

Write file data to client connection
(Async)
Write complete
Write complete
Proactor
Components –
Proactive Initiator: Any entity in the application that initiates an
Asynchronous Operation. The Proactive Initiator registers a Completion
Handler and a Completion Dispatcher with a Asynchronous Operation
Processor, which notifies it when the operation completes.
Completion Handler (Acceptor ) : interfaces that are implemented by
the application for Asynchronous Operation completion notification.
Asynchronous Operations : it is used to execute requests (such as I/O
and timer operations) on behalf of applications.
Asynchronous Operation Processor : When Asynchronous Operations
complete, the Asynchronous Operation Processor delegates application
notifications to a Completion Dispatcher
Completion Dispatcher (the Notification Queue) : it is responsible for
calling back to the application’s Completion Handlers when
Asynchronous Operations complete.
Reactor
This can be used for handling service requests delivered concurrently to a
service handler by one or more clients by demultiplexes and despathching
the incoming requests to the associated request handlers.
A reactor defines an interface that allows applications to register or remove
event handlers and their associated handles, and run the application's event
loop. It uses its synchronous event demultiplexer to wait for indication events
to occur on its handle set. When this occurs, the reactor first demultiplexes
each indication event from the handle on which it occurs to its associated
event handler. Then it dispatches the appropriate hook method on the
handler to process the event.
Reactor pattern can not support many simultaneous users and/or longduration user requests as it serializes all processing at the event
demultiplexing layer. As a result only one request can be dispatched and
processed iteratively at any given time.
Reactor
Components –
Resources: Any resource that can provide input to or consume
output from the system.
Synchronous Event Demultiplexer: Uses an event loop to block
on all resources. When it is possible to start a synchronous
operation on a resource without blocking, the demultiplexer
sends the resource to the dispatcher.
Dispatcher: Handles registering and unregistering of request
handlers. Dispatches resources from the demultiplexer to the
associated request handler.
Request Handler: An application defined request handler and its
associated resource
Reactor
Client

Reactor

Demultiplexer

Instantiate event handler
register event handler
Select(…)
handles

Dispatch

handleEvent(…)

Demultiplex

handleEvents()

EventHandler
Asynchronous Completion Token
This pattern can be used to demultiplex and process
efficiently the responses of asynchronous operations
it invokes on services.
• For every asynchronous operation that a client
invokes on a service, an asynchronous completion
token (ACT) is created and Passed to the service
together with the operation, which holds but does
not modify the ACT.
• When the service replies to the initiator, its
response includes the ACT that was sent originally.
• The initiator can then use the ACT to identify the
completion handler that will process the response
from the original asynchronous operation
Asynchronous Completion Token
ACT – It contains information that uniquely identifies the
completion handler, which is the function or object responsible
for processing the operation's response.
Components –
Service - Provides functionality that can be accessed
asynchronously.
Completion handler – It is a function or object within an
application that is responsible for processing service responses.
Client initiator - Invokes operations on a service asynchronously.
It also demultiplexes the response returned by these operations
to a designated completion handler.
Asynchronous Completion Token
Client
Initiator

Completion
Handler

ACT

Create an ACT
Invoke a service including ACT
Do some other operation /
Process response from other services
Response including same ACT
Completion_Action

Process Result

Service
Acceptor-Connector
This pattern can be used to decouple service tasks
performed by a service from the steps required to initialize
the service.
It is beneficial for an application which receives a large
number of concurrent connections with peers residing
across long-latency networks and not able to perform
blocking or continuous polling for incoming connections on
any individual peer due to latency.
Components Reactor - The Reactor allows multiple Acceptors to listen
for connections from different peers efficiently within a
single thread of control. The Reactor allows multiple Service
Handlers to have their connections initiated and completed
asynchronously by a Connector configured within a single
thread of control.
Acceptor-Connector
Service Handler It contains a communication endpoint (peer stream ) that encapsulates an I/O handle
(I/O descriptor). This endpoint is initialized by the Acceptor/Connector and is
subsequently used by the Service Handler to exchange data with its connected peer.
Acceptor This implements the strategy for passively initializing a Service Handler which
communicates with the peer. The Reactor calls back to the Acceptor’s accept method
when a connection arrives on the passive-mode peer acceptor endpoint. The accept
method uses this passive-mode endpoint to accept connections into the Service
Handler’s peer stream and then activate a Service Handler.
Connector This implements the strategy for actively initializing a Service Handler which
communicates with the peer. The Connector activates a connected Service after
initialization is complete. The complete method finishes activating Service Handlers
whose connections were initiated and completed asynchronously. the Reactor calls
back the complete method automatically when an asynchronous connection is
established.
Acceptor
Acceptor component initialization and service processing : Server

Acceptor

Initialize end points

Service
Handler

Reactor

Register handler
Get handle

Handle events ( Loop for events)
Handle Connection Event
Create and Register Service handler
Register handler for Client I/O
Initialization Complete and ready for service processing
Get handle
Handle Data Event

Service (process msg)
Connector
Acceptor component initialization and service processing : Server

Acceptor

Initiate connection

Service
Handler

Reactor

Register handler

Handle events ( Loop for events)
Handle Connection event
Connection Complete
Perform service-specific initialization
Register service handler
Initialization Complete and ready for service processing
Get handle
Handle Data Event

Service (process msg)
Thank You

Your suggestions and comments are always welcome.
Please send me your feedback at
a_s_sinha@yahoo.com

More Related Content

What's hot

What's hot (20)

Hci
HciHci
Hci
 
Operating system 02 os as an extended machine
Operating system 02 os as an extended machineOperating system 02 os as an extended machine
Operating system 02 os as an extended machine
 
First order predicate logic (fopl)
First order predicate logic (fopl)First order predicate logic (fopl)
First order predicate logic (fopl)
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Case tools
Case toolsCase tools
Case tools
 
Software Engineering (Project Scheduling)
Software Engineering (Project Scheduling)Software Engineering (Project Scheduling)
Software Engineering (Project Scheduling)
 
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddelCHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
CHAPTER 6 REQUIREMENTS MODELING: SCENARIO based Model , Class based moddel
 
Unit 2
Unit 2Unit 2
Unit 2
 
Open mp directives
Open mp directivesOpen mp directives
Open mp directives
 
Managment spectrum
Managment spectrumManagment spectrum
Managment spectrum
 
Design Concepts in Software Engineering-1.pptx
Design Concepts in Software Engineering-1.pptxDesign Concepts in Software Engineering-1.pptx
Design Concepts in Software Engineering-1.pptx
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 
Software Coding- Software Coding
Software Coding- Software CodingSoftware Coding- Software Coding
Software Coding- Software Coding
 
page replacement.pptx
page replacement.pptxpage replacement.pptx
page replacement.pptx
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 

Viewers also liked

2. how does your media product represent particular social groups
2. how does your media product represent particular social groups2. how does your media product represent particular social groups
2. how does your media product represent particular social groups
wownoway
 
50 Days of ideas to use with theUltranet Message Boards
50 Days of ideas to use with theUltranet Message Boards50 Days of ideas to use with theUltranet Message Boards
50 Days of ideas to use with theUltranet Message Boards
dmgregg
 
Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...
Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...
Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...
frankrd
 
Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11
koolkampus
 
Types of natural disasters tam-2014-01
Types of natural disasters   tam-2014-01Types of natural disasters   tam-2014-01
Types of natural disasters tam-2014-01
Vijay Kumar
 
Apollo Hospital case study
Apollo Hospital case studyApollo Hospital case study
Apollo Hospital case study
Pulkit Yadav
 
Hospital project report
Hospital project reportHospital project report
Hospital project report
jssclinic
 

Viewers also liked (20)

2. how does your media product represent particular social groups
2. how does your media product represent particular social groups2. how does your media product represent particular social groups
2. how does your media product represent particular social groups
 
50 Days of ideas to use with theUltranet Message Boards
50 Days of ideas to use with theUltranet Message Boards50 Days of ideas to use with theUltranet Message Boards
50 Days of ideas to use with theUltranet Message Boards
 
Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...
Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...
Preparing for the Worst: Disaster Planning at the Art, Architecture, and Engi...
 
Desaster Mgt
Desaster MgtDesaster Mgt
Desaster Mgt
 
D.R.I.P.S, LLC.
D.R.I.P.S, LLC.D.R.I.P.S, LLC.
D.R.I.P.S, LLC.
 
Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11Distributed Systems Architecture in Software Engineering SE11
Distributed Systems Architecture in Software Engineering SE11
 
Natural Disasters Lecture 1 (Introduction)
Natural Disasters Lecture 1 (Introduction)Natural Disasters Lecture 1 (Introduction)
Natural Disasters Lecture 1 (Introduction)
 
Site analysis parameters
Site analysis  parametersSite analysis  parameters
Site analysis parameters
 
Greg Young on Architectural Innovation: Eventing, Event Sourcing
Greg Young on Architectural Innovation: Eventing, Event SourcingGreg Young on Architectural Innovation: Eventing, Event Sourcing
Greg Young on Architectural Innovation: Eventing, Event Sourcing
 
Timeline Of Modernist Architecture 30.11.2009
Timeline Of Modernist Architecture 30.11.2009Timeline Of Modernist Architecture 30.11.2009
Timeline Of Modernist Architecture 30.11.2009
 
Architecture as a Catalyst for Sustainable Development, Anna HERINGER
Architecture as a Catalyst for Sustainable Development, Anna HERINGERArchitecture as a Catalyst for Sustainable Development, Anna HERINGER
Architecture as a Catalyst for Sustainable Development, Anna HERINGER
 
A Holistic Approach Towards International Disaster Resilient Architecture by ...
A Holistic Approach Towards International Disaster Resilient Architecture by ...A Holistic Approach Towards International Disaster Resilient Architecture by ...
A Holistic Approach Towards International Disaster Resilient Architecture by ...
 
Types of natural disasters tam-2014-01
Types of natural disasters   tam-2014-01Types of natural disasters   tam-2014-01
Types of natural disasters tam-2014-01
 
Kohinoor Hospital the Sustainable Hospital
Kohinoor Hospital the Sustainable HospitalKohinoor Hospital the Sustainable Hospital
Kohinoor Hospital the Sustainable Hospital
 
Earthquake and earthquake resistant design
Earthquake and earthquake resistant designEarthquake and earthquake resistant design
Earthquake and earthquake resistant design
 
Case study
Case studyCase study
Case study
 
Earthquake resistant construction
Earthquake resistant constructionEarthquake resistant construction
Earthquake resistant construction
 
Apollo Hospital case study
Apollo Hospital case studyApollo Hospital case study
Apollo Hospital case study
 
Hospital project report
Hospital project reportHospital project report
Hospital project report
 
Natural disasters' Impacts & Prevention
Natural disasters' Impacts & PreventionNatural disasters' Impacts & Prevention
Natural disasters' Impacts & Prevention
 

Similar to Architectural Patterns - Interactive and Event Handling Patterns

Design patterns - ICIN 2010
Design patterns - ICIN 2010Design patterns - ICIN 2010
Design patterns - ICIN 2010
steccami
 
24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMS24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMS
koolkampus
 
Restate: Event-driven Asynchronous Services, Easy as Synchronous RPC
Restate: Event-driven Asynchronous Services, Easy as Synchronous RPCRestate: Event-driven Asynchronous Services, Easy as Synchronous RPC
Restate: Event-driven Asynchronous Services, Easy as Synchronous RPC
HostedbyConfluent
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
guest61205606
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
guest61205606
 
iiwas 2010
iiwas 2010iiwas 2010
iiwas 2010
steccami
 
Architecture for monitoring applications in Cloud
Architecture for monitoring applications in CloudArchitecture for monitoring applications in Cloud
Architecture for monitoring applications in Cloud
Onkar Kadam
 

Similar to Architectural Patterns - Interactive and Event Handling Patterns (20)

Design patterns - ICIN 2010
Design patterns - ICIN 2010Design patterns - ICIN 2010
Design patterns - ICIN 2010
 
Remoting and serialization
Remoting and serializationRemoting and serialization
Remoting and serialization
 
Reactors.io
Reactors.ioReactors.io
Reactors.io
 
24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMS24. Advanced Transaction Processing in DBMS
24. Advanced Transaction Processing in DBMS
 
Multi-service reactive streams using Spring, Reactor, RSocket
Multi-service reactive streams using Spring, Reactor, RSocketMulti-service reactive streams using Spring, Reactor, RSocket
Multi-service reactive streams using Spring, Reactor, RSocket
 
Listeners and filters in servlet
Listeners and filters in servletListeners and filters in servlet
Listeners and filters in servlet
 
Functional reactive programming
Functional reactive programmingFunctional reactive programming
Functional reactive programming
 
Restate: Event-driven Asynchronous Services, Easy as Synchronous RPC
Restate: Event-driven Asynchronous Services, Easy as Synchronous RPCRestate: Event-driven Asynchronous Services, Easy as Synchronous RPC
Restate: Event-driven Asynchronous Services, Easy as Synchronous RPC
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
 
Distributed Systems
Distributed SystemsDistributed Systems
Distributed Systems
 
Communication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed SystemsCommunication And Synchronization In Distributed Systems
Communication And Synchronization In Distributed Systems
 
Guide to Spring Reactive Programming using WebFlux
Guide to Spring Reactive Programming using WebFluxGuide to Spring Reactive Programming using WebFlux
Guide to Spring Reactive Programming using WebFlux
 
iiwas 2010
iiwas 2010iiwas 2010
iiwas 2010
 
Servlets - filter, listeners, wrapper, internationalization
Servlets -  filter, listeners, wrapper, internationalizationServlets -  filter, listeners, wrapper, internationalization
Servlets - filter, listeners, wrapper, internationalization
 
Architectural patterns part 4
Architectural patterns part 4Architectural patterns part 4
Architectural patterns part 4
 
Introduction to reactive programming
Introduction to reactive programmingIntroduction to reactive programming
Introduction to reactive programming
 
Vert.x for Microservices Architecture
Vert.x for Microservices ArchitectureVert.x for Microservices Architecture
Vert.x for Microservices Architecture
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactor
 
Architecture for monitoring applications in Cloud
Architecture for monitoring applications in CloudArchitecture for monitoring applications in Cloud
Architecture for monitoring applications in Cloud
 
Middleware in Distributed System-RPC,RMI
Middleware in Distributed System-RPC,RMIMiddleware in Distributed System-RPC,RMI
Middleware in Distributed System-RPC,RMI
 

More from assinha

More from assinha (9)

Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...
Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...
Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...
 
SNMP AT a GLANCE
SNMP AT a GLANCESNMP AT a GLANCE
SNMP AT a GLANCE
 
Layer3protocols
Layer3protocolsLayer3protocols
Layer3protocols
 
Umts explained
Umts explainedUmts explained
Umts explained
 
Architectural patterns part 3
Architectural patterns part 3Architectural patterns part 3
Architectural patterns part 3
 
Architectural patterns part 1
Architectural patterns part 1Architectural patterns part 1
Architectural patterns part 1
 
Data Structures used in Linux kernel
Data Structures used in Linux kernel Data Structures used in Linux kernel
Data Structures used in Linux kernel
 
E nodeb handover procedure
E nodeb handover procedureE nodeb handover procedure
E nodeb handover procedure
 
Initial LTE call Setup Flow
Initial LTE call Setup FlowInitial LTE call Setup Flow
Initial LTE call Setup Flow
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 

Architectural Patterns - Interactive and Event Handling Patterns

  • 2. Architectural Patterns Interactive System Patterns – It describes architecture that support the adaptation of user interface parts without causing major effect to Application specific functionality or the underlying data model. • Model-View-Controller
  • 3. Model-View-Controller This pattern can be used to divide system’s task to three different components - Model, View and Controller. • Model contains the core functionality and data. It is independent of the data received or presented in the views. There can be multiple view for same Model. • View displays information to the user. It may allow user to edit the data from the application’s model. • Controller handles user input. It can also perform set-up and coordinating tasks for an application. Views and Controllers together comprise the user interface. A change-propagation mechanism (e.g. Subscriber-obsever) ensures consistency between the user interface and the model.
  • 4. Model-View-Controller Example – Web browser Invoke Result Request HTTP Browser (User) Response Model Servlet (Controller) JSP (View) Database
  • 5. Architectural Patterns Event Handling Patterns – It describes how to initiate, receive, demultiplex, dispatch and process events in networked systems. • Proactor • Reactor • Asynchronous Completion Token • Acceptor-Connector
  • 6. Proactor This pattern can be used for the demultiplexing and dispatching of multiple event handlers which are triggered by the completion of asynchronous events. It requires a dedicated thread for each connected client. In this pattern application issues an asynchronous operation to the OS and registers a callback with a Completion Dispatcher that will notify the Application when the operation completes. The OS then performs the operation on behalf of the application and subsequently queues the result in a well-known location. The Completion Dispatcher is responsible for dequeueing completion notifications and executing the appropriate callback that contains application-specific code.
  • 7. Proactor Client (Web Server) OS Completion Despatcher HTTP Get request Read complete Handler File System Read complete Parse request Read File(sync) Write file data to client connection (Async) Write complete Write complete
  • 8. Proactor Components – Proactive Initiator: Any entity in the application that initiates an Asynchronous Operation. The Proactive Initiator registers a Completion Handler and a Completion Dispatcher with a Asynchronous Operation Processor, which notifies it when the operation completes. Completion Handler (Acceptor ) : interfaces that are implemented by the application for Asynchronous Operation completion notification. Asynchronous Operations : it is used to execute requests (such as I/O and timer operations) on behalf of applications. Asynchronous Operation Processor : When Asynchronous Operations complete, the Asynchronous Operation Processor delegates application notifications to a Completion Dispatcher Completion Dispatcher (the Notification Queue) : it is responsible for calling back to the application’s Completion Handlers when Asynchronous Operations complete.
  • 9. Reactor This can be used for handling service requests delivered concurrently to a service handler by one or more clients by demultiplexes and despathching the incoming requests to the associated request handlers. A reactor defines an interface that allows applications to register or remove event handlers and their associated handles, and run the application's event loop. It uses its synchronous event demultiplexer to wait for indication events to occur on its handle set. When this occurs, the reactor first demultiplexes each indication event from the handle on which it occurs to its associated event handler. Then it dispatches the appropriate hook method on the handler to process the event. Reactor pattern can not support many simultaneous users and/or longduration user requests as it serializes all processing at the event demultiplexing layer. As a result only one request can be dispatched and processed iteratively at any given time.
  • 10. Reactor Components – Resources: Any resource that can provide input to or consume output from the system. Synchronous Event Demultiplexer: Uses an event loop to block on all resources. When it is possible to start a synchronous operation on a resource without blocking, the demultiplexer sends the resource to the dispatcher. Dispatcher: Handles registering and unregistering of request handlers. Dispatches resources from the demultiplexer to the associated request handler. Request Handler: An application defined request handler and its associated resource
  • 11. Reactor Client Reactor Demultiplexer Instantiate event handler register event handler Select(…) handles Dispatch handleEvent(…) Demultiplex handleEvents() EventHandler
  • 12. Asynchronous Completion Token This pattern can be used to demultiplex and process efficiently the responses of asynchronous operations it invokes on services. • For every asynchronous operation that a client invokes on a service, an asynchronous completion token (ACT) is created and Passed to the service together with the operation, which holds but does not modify the ACT. • When the service replies to the initiator, its response includes the ACT that was sent originally. • The initiator can then use the ACT to identify the completion handler that will process the response from the original asynchronous operation
  • 13. Asynchronous Completion Token ACT – It contains information that uniquely identifies the completion handler, which is the function or object responsible for processing the operation's response. Components – Service - Provides functionality that can be accessed asynchronously. Completion handler – It is a function or object within an application that is responsible for processing service responses. Client initiator - Invokes operations on a service asynchronously. It also demultiplexes the response returned by these operations to a designated completion handler.
  • 14. Asynchronous Completion Token Client Initiator Completion Handler ACT Create an ACT Invoke a service including ACT Do some other operation / Process response from other services Response including same ACT Completion_Action Process Result Service
  • 15. Acceptor-Connector This pattern can be used to decouple service tasks performed by a service from the steps required to initialize the service. It is beneficial for an application which receives a large number of concurrent connections with peers residing across long-latency networks and not able to perform blocking or continuous polling for incoming connections on any individual peer due to latency. Components Reactor - The Reactor allows multiple Acceptors to listen for connections from different peers efficiently within a single thread of control. The Reactor allows multiple Service Handlers to have their connections initiated and completed asynchronously by a Connector configured within a single thread of control.
  • 16. Acceptor-Connector Service Handler It contains a communication endpoint (peer stream ) that encapsulates an I/O handle (I/O descriptor). This endpoint is initialized by the Acceptor/Connector and is subsequently used by the Service Handler to exchange data with its connected peer. Acceptor This implements the strategy for passively initializing a Service Handler which communicates with the peer. The Reactor calls back to the Acceptor’s accept method when a connection arrives on the passive-mode peer acceptor endpoint. The accept method uses this passive-mode endpoint to accept connections into the Service Handler’s peer stream and then activate a Service Handler. Connector This implements the strategy for actively initializing a Service Handler which communicates with the peer. The Connector activates a connected Service after initialization is complete. The complete method finishes activating Service Handlers whose connections were initiated and completed asynchronously. the Reactor calls back the complete method automatically when an asynchronous connection is established.
  • 17. Acceptor Acceptor component initialization and service processing : Server Acceptor Initialize end points Service Handler Reactor Register handler Get handle Handle events ( Loop for events) Handle Connection Event Create and Register Service handler Register handler for Client I/O Initialization Complete and ready for service processing Get handle Handle Data Event Service (process msg)
  • 18. Connector Acceptor component initialization and service processing : Server Acceptor Initiate connection Service Handler Reactor Register handler Handle events ( Loop for events) Handle Connection event Connection Complete Perform service-specific initialization Register service handler Initialization Complete and ready for service processing Get handle Handle Data Event Service (process msg)
  • 19. Thank You Your suggestions and comments are always welcome. Please send me your feedback at a_s_sinha@yahoo.com