software architecture - 2 september 5, 2015september 5, 2015september 5, 2015

88
Software Architecture Software Architecture - 2 - 2 March 27, 2022 March 27, 2022

Upload: leslie-moody

Post on 26-Dec-2015

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Software Architecture Software Architecture - 2- 2

April 19, 2023April 19, 2023

Page 2: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Architectural Patterns - 2 Architectural Patterns - 2 Implicit Asynchronous Communication Implicit Asynchronous Communication

ArchitectureArchitecture– Non-buffered event-based Implicit InvocationNon-buffered event-based Implicit Invocation– Buffered messaged-basedBuffered messaged-based

Interaction-Oriented ArchitectureInteraction-Oriented Architecture– Model-View-Controller (MVC)Model-View-Controller (MVC)– Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Distributed ArchitectureDistributed Architecture– Client-serverClient-server– Broker Broker – Service-oriented architecture (SOA)Service-oriented architecture (SOA)

Component-based ArchitectureComponent-based Architecture

Page 3: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Implicit Asynchronous Implicit Asynchronous Communication ArchitectureCommunication Architecture

OverviewOverview– Asynchronous implicit invocation Asynchronous implicit invocation

communication communication Non-bufferedNon-buffered Buffered. Buffered.

– Publisher-subscriberPublisher-subscriber (producer- (producer-consumer)consumer)

Subscribers are interested in some events/messages Subscribers are interested in some events/messages issued by a publisherissued by a publisher

Subscribers register themselves with the event source. Subscribers register themselves with the event source. Once an event is fired off by an event source, all Once an event is fired off by an event source, all

corresponding subscribers are notified.corresponding subscribers are notified. It is up to the subscribers to decide on the actions to It is up to the subscribers to decide on the actions to

execute. execute.

Page 4: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Implicit Asynchronous Implicit Asynchronous Communication ArchitectureCommunication Architecture

– Publisher-subscriberPublisher-subscriber (producer- (producer-consumer)consumer)

The message queue/topic are typical buffered The message queue/topic are typical buffered asynchronous architectures asynchronous architectures

subscribers also need to register their interests subscribers also need to register their interests with; the event/message is fired off when with; the event/message is fired off when available on the buffered message queue or topic. available on the buffered message queue or topic.

Message queue Message queue one-to-one or point-to-point architecture between one-to-one or point-to-point architecture between

message senders and message receivers; message senders and message receivers; Message topic Message topic one-to-many architecture between publishers and one-to-many architecture between publishers and

subscribers. subscribers.

Page 5: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

The architecture breaks the system The architecture breaks the system into two partitions: into two partitions: – Event sourcesEvent sources– event listeners.event listeners.

The event registration process The event registration process connects these two partitions. connects these two partitions.

There is no buffer available between There is no buffer available between these two parties.these two parties.

Page 6: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

Page 7: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

: Service requester

: Service provider

service()

AsyncService ()

serviceResponse()

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

Page 8: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

+addEventListener()+removeEventListener()+notify()

Event Source

+handleEvent()

Event Listener

+notify()+getState()+setState()

-state

Concrete Event Source

+handleEvent()

-state

Concrete Listener

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

Page 9: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

The event-based implicit invocation The event-based implicit invocation is a good solution for user interaction is a good solution for user interaction in a user interface application. in a user interface application. Following are simple Java fragments Following are simple Java fragments that demonstrate how event sources that demonstrate how event sources and event targets (listeners) work and event targets (listeners) work together in an event-driven together in an event-driven architecture for a user interface architecture for a user interface application. application.

Page 10: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

ApplicationsApplications– Suitable for interactive GUI component Suitable for interactive GUI component

communicationcommunication..– Suitable for applications that require Suitable for applications that require

loose coupling between components that loose coupling between components that need to notify or trigger other need to notify or trigger other components to take actions upon components to take actions upon asynchronous notifications.asynchronous notifications.

– Suitable for the implementation of state Suitable for the implementation of state machines.machines.

– Suitable when event handlings in the Suitable when event handlings in the application are not predictable.application are not predictable.

Page 11: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

BenefitBenefit– Many vendor APIs such as Java AWT and Many vendor APIs such as Java AWT and

Swing components availableSwing components available..– Easy to plug-in new event handlers without Easy to plug-in new event handlers without

affecting the rest of the system.affecting the rest of the system.– Easy to update both of event sources and Easy to update both of event sources and

targets. targets. – Dynamic registration and deregistration can Dynamic registration and deregistration can

be done dynamically at run-time.be done dynamically at run-time.– Possibility of parallel execution of event Possibility of parallel execution of event

handlings.handlings.

Page 12: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Non-Buffered Event-Based Implicit Non-Buffered Event-Based Implicit InvocationsInvocations

LimitationsLimitations– Difficult to test and debug the system since it Difficult to test and debug the system since it

is hard to predict and verify responses and is hard to predict and verify responses and the order of responses from the listeners. the order of responses from the listeners.

– The event trigger cannot determine when a The event trigger cannot determine when a response has finished or the sequence of all response has finished or the sequence of all responsesresponses..

– There is tighter coupling between event There is tighter coupling between event sources and their listeners than in message sources and their listeners than in message queue based or message topic based implicit queue based or message topic based implicit invocation.invocation.

Page 13: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Buffered Message-Based Buffered Message-Based Software ArchitectureSoftware Architecture

The architecture breaks into three partitions: The architecture breaks into three partitions: – Message producers, Message producers, – message consumers, and message consumers, and – message service providers. message service providers.

They are connected asynchronously by either They are connected asynchronously by either – a message queuea message queue– a message topic. a message topic.

This architecture is also considered data-This architecture is also considered data-centric.centric.

Page 14: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Buffered Message-Based Buffered Message-Based Software ArchitectureSoftware Architecture

What is a message? What is a message? – A message is a structured data with an id, message A message is a structured data with an id, message

header, property, and body, e.g. aheader, property, and body, e.g. an XML document. n XML document. What is messaging? What is messaging?

– A mechanism or technology that handles asynchronous or A mechanism or technology that handles asynchronous or synchronous message delivery effectively and reliably.synchronous message delivery effectively and reliably.

A messaging client can send messages to other A messaging client can send messages to other clients and receive messages from other clients. clients and receive messages from other clients.

A client must register with a messaging destination A client must register with a messaging destination in a connection session provided by a message in a connection session provided by a message service provider for creating, sending, receiving, service provider for creating, sending, receiving, reading, validating, and processing messages.reading, validating, and processing messages.

Page 15: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Point-to-Point Messaging Point-to-Point Messaging (P2P)(P2P) A P2P messaging architecture is composed of A P2P messaging architecture is composed of

message queues, senders, and receivers. message queues, senders, and receivers. Each message is sent to a specific queue Each message is sent to a specific queue

maintained by the consumermaintained by the consumer The queue retains all messages until either the The queue retains all messages until either the

messages are consumed or the messages expire. messages are consumed or the messages expire. Each message has only one consumer, i.e., the Each message has only one consumer, i.e., the

message will be message will be ““gonegone”” once it is delivered. once it is delivered. This approach allows multiple receivers but only This approach allows multiple receivers but only

one of them will get the message.one of them will get the message. P2P messaging requires every message in the P2P messaging requires every message in the

queue be processed by a consumer. queue be processed by a consumer.

Page 16: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Point-to-Point Messaging Point-to-Point Messaging (P2P)(P2P)

Page 17: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Publish-Subscribe Messaging Publish-Subscribe Messaging (P&S)(P&S)

The P&S messaging architecture is a hubThe P&S messaging architecture is a hub-like -like architecture, where publisher clients send architecture, where publisher clients send messages to a message topic that acts like a messages to a message topic that acts like a bulletin board. bulletin board.

Message topic publishers and subscribers are Message topic publishers and subscribers are not aware of each other. not aware of each other.

One difference between P&S from P2P is that One difference between P&S from P2P is that each topic message can have multiple each topic message can have multiple consumers. consumers.

The system delivers the messages to all its The system delivers the messages to all its multiple subscribers instead of single receiver as multiple subscribers instead of single receiver as in the message queue system. in the message queue system.

Normally a message topic consumer must Normally a message topic consumer must subscribe the topic before it is publishedsubscribe the topic before it is published

Page 18: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Publish-Subscribe Messaging Publish-Subscribe Messaging (P&S)(P&S)

Page 19: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Buffered Message-Based Buffered Message-Based Software ArchitectureSoftware Architecture

ApplicationsApplications– Suitable for systems where the communication Suitable for systems where the communication

needs buffered message-based asynchronous needs buffered message-based asynchronous implicit invocation for performance and distribution implicit invocation for performance and distribution purposes.purposes.

– The provider wants the components not to depend The provider wants the components not to depend on information about other components' interfaces, on information about other components' interfaces, so that components can be easily replaced.so that components can be easily replaced.

– The provider wants the application to run whether or The provider wants the application to run whether or not all other components are up and running not all other components are up and running simultaneously.simultaneously.

– A component can send information to another and A component can send information to another and continue to operate on its own without waiting for an continue to operate on its own without waiting for an immediate response.immediate response.

Page 20: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Buffered Message-Based Buffered Message-Based Software ArchitectureSoftware Architecture

BenefitsBenefits– Providing high degree of anonymity between Providing high degree of anonymity between

message producer and consumermessage producer and consumer. . – The message consumer does not know who The message consumer does not know who

produced the message (user independence), produced the message (user independence), where the producer lives on the network where the producer lives on the network (location independence), or when the message (location independence), or when the message was produced (time independence).was produced (time independence).

– Supporting for concurrency among consumers Supporting for concurrency among consumers and between producer and consumers.and between producer and consumers.

Page 21: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Buffered Message-Based Buffered Message-Based Software ArchitectureSoftware Architecture

Limitations:Limitations:– Capacity limit of message queue. This is not an Capacity limit of message queue. This is not an

inherent limitation but an implementation issue that inherent limitation but an implementation issue that can be eased if the queue is implemented as a dynamic can be eased if the queue is implemented as a dynamic data structure (e.g., linked lists). data structure (e.g., linked lists).

– However, there is an absolute limit based on available However, there is an absolute limit based on available memory. It is also difficult to determine the numbers of memory. It is also difficult to determine the numbers of agents needed to satisfy the loose couplings between agents needed to satisfy the loose couplings between agents.agents.

– Complete separation of presentation and abstraction by Complete separation of presentation and abstraction by control in each agent generate development control in each agent generate development complexity since communications between agents only complexity since communications between agents only take place between the control of agents.take place between the control of agents.

– Increased complexity of the system design and Increased complexity of the system design and implementationimplementation

Page 22: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Chapter 9Chapter 9INTERACTION ORIENTED INTERACTION ORIENTED SOFTWARE ARCHITECTURESSOFTWARE ARCHITECTURES

Page 23: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

INTERACTION ORIENTED SOFTWARE INTERACTION ORIENTED SOFTWARE ARCHITECTURESARCHITECTURES

The key point - the separation of user interactions The key point - the separation of user interactions from data from data abstraction and business data processing.abstraction and business data processing.

The interaction oriented software architecture decomposes the The interaction oriented software architecture decomposes the system into three major partitions: system into three major partitions: – Data module Data module – Control moduleControl module– View presentation moduleView presentation module

The The data module data module provides the data abstraction & all business provides the data abstraction & all business logic. logic.

The The view presentation module view presentation module is responsible for data output is responsible for data output presentation and it may provide an input interface for user presentation and it may provide an input interface for user input.input.

The control module determines the flow of control involving view The control module determines the flow of control involving view selections, communications between modules, job dispatching, selections, communications between modules, job dispatching, and certain data initialization and system configuration actions. and certain data initialization and system configuration actions.

Multiple view presentations in different formats are allowedMultiple view presentations in different formats are allowed

Page 24: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Two major styleTwo major style– Model-View-Controller (MVC)Model-View-Controller (MVC)– Presentation-Abstraction-Control (PAC) Presentation-Abstraction-Control (PAC)

Both of MVC and PAC are used for interactive Both of MVC and PAC are used for interactive applications multiple talks and user applications multiple talks and user interactions. interactions.

They are different in their flow of control and They are different in their flow of control and organization.organization.

The PAC is an agent based hierarchical The PAC is an agent based hierarchical architecturearchitecture

The MVC does not have a clear hierarchical The MVC does not have a clear hierarchical structure and all three modules are connected structure and all three modules are connected together. together.

INTERACTION ORIENTED SOFTWARE INTERACTION ORIENTED SOFTWARE ARCHITECTURESARCHITECTURES

Page 25: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Model-View-Controller (MVC)Model-View-Controller (MVC)

Objects of different classes take over the operations related Objects of different classes take over the operations related to the application domain (the model), the display of the to the application domain (the model), the display of the application's state (the view), and the user interaction with application's state (the view), and the user interaction with the model and the view (The controller). the model and the view (The controller).

Models: Models: – The model of an application is the domain-specific software The model of an application is the domain-specific software

simulation or implementation of the application's central simulation or implementation of the application's central structure.structure.

Views: Views: – In this metaphor, views deal with everything graphical: they In this metaphor, views deal with everything graphical: they

request data from their model and display the data.request data from their model and display the data. Controllers: Controllers:

– Controllers contain the interface between their associated Controllers contain the interface between their associated models and views and the input devices (e.g., keyboard, models and views and the input devices (e.g., keyboard, pointing device, time)pointing device, time)

Page 26: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVC-IMVC-I

The MVC-I is a simple version of MVC The MVC-I is a simple version of MVC architecture where the system is simply architecture where the system is simply decomposed into two sub-systems: The decomposed into two sub-systems: The Controller-View and the Model. Controller-View and the Model.

Basically, the Controller-View takes care Basically, the Controller-View takes care of input and output processing and their of input and output processing and their interfaces; the Model module copes with interfaces; the Model module copes with all core functionality and the data. all core functionality and the data.

The Controller-View module registers with The Controller-View module registers with (attaches to) the data module.(attaches to) the data module.

Page 27: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

The Model module notifies the Controller-The Model module notifies the Controller-View module of any data changes so that View module of any data changes so that any graphics data display will be changed any graphics data display will be changed accordingly; the controller also takes accordingly; the controller also takes appropriate action upon the changes. appropriate action upon the changes.

The connection between the Controller-The connection between the Controller-View and the Model can be designed in a View and the Model can be designed in a pattern of subscribe-notify whereby the pattern of subscribe-notify whereby the Controller-View subscribes to the Model Controller-View subscribes to the Model and the Model notifies the Controller-View and the Model notifies the Controller-View of any changes. of any changes.

In other words, the Controller-View is an In other words, the Controller-View is an observer of the data in the Model module. observer of the data in the Model module.

MVC-IMVC-I

Page 28: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVC-IMVC-I

Page 29: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Simple GUI example designed in MVC-I. Simple GUI example designed in MVC-I. The View has a GUI interface with two The View has a GUI interface with two

text fields, for the user to enter a new text fields, for the user to enter a new number in one of the text fields and the number in one of the text fields and the accumulated summation is displayed in accumulated summation is displayed in the other text field. the other text field.

The summation is held in the Model The summation is held in the Model module. module.

Model provides all business logics Model provides all business logics including all getter and setter methods.including all getter and setter methods.

MVC-IMVC-I

Page 30: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Whenever the data in the Model is updated it Whenever the data in the Model is updated it will notify the registered GUI components of will notify the registered GUI components of changes, and then the GUI components will changes, and then the GUI components will update their displays. update their displays.

This is why we say that the data in the Model This is why we say that the data in the Model of MVC architecture is active rather than of MVC architecture is active rather than passive. passive.

Actually, for this specific example there is no Actually, for this specific example there is no need to have separated Model to notify the need to have separated Model to notify the change change because because actionPerformed()actionPerformed() can take can take care all necessary changes. care all necessary changes.

We just want to use this example to see how We just want to use this example to see how MVC-I architecture works. MVC-I architecture works.

MVC-IMVC-I

Page 31: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVC-IIMVC-II

Page 32: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

The MVC in figure 9.2 is the same as MVC-I in figure 9.1 The MVC in figure 9.2 is the same as MVC-I in figure 9.1 except that the controller and the view are separatedexcept that the controller and the view are separated..

MVC-IIMVC-II

Page 33: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVC-IIMVC-II

Page 34: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Fig 9.4 depicts a sequence diagram for a generic MVC architecture.Fig 9.4 depicts a sequence diagram for a generic MVC architecture.

MVC-IIMVC-II

Page 35: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

After clients start up the MVC application, the After clients start up the MVC application, the controller initializes the Model and View, and controller initializes the Model and View, and attaches the View and itself to the Model (this attaches the View and itself to the Model (this is called registration with the Model.is called registration with the Model.

Later, the Controller intercepts a user request Later, the Controller intercepts a user request either directly from command line or through either directly from command line or through the View interface, and forwards the request to the View interface, and forwards the request to the Model to update the data in the Model.the Model to update the data in the Model.

The changes in the Model will trigger the The changes in the Model will trigger the Model to notify all attached or registered Model to notify all attached or registered listeners of all changes, and the interface in listeners of all changes, and the interface in the View will also be updated right way.the View will also be updated right way.

MVC-IIMVC-II

Page 36: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVC-IIMVC-II

Page 37: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

The The myServletmyServlet Servlet sets an item value Servlet sets an item value and stores this item in a JavaBean named and stores this item in a JavaBean named myBeanmyBean, then transfers the control to a JSP , then transfers the control to a JSP page named page named fromServlet.jspfromServlet.jsp which which retrieves the item from the retrieves the item from the myBeanmyBean and and displays it on a Web page. displays it on a Web page.

Whenever the data is changed the display Whenever the data is changed the display is also changed. is also changed.

The following Java classes show a MVC-II The following Java classes show a MVC-II template to provide more detailed template to provide more detailed explanations on the MVC-II architecture. explanations on the MVC-II architecture.

MVC-IIMVC-II

Page 38: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVCMVC

Applications:Applications:– Suitable for interactive applications where Suitable for interactive applications where

multiple views are needed for a single multiple views are needed for a single data model and the interfaces are prone to data model and the interfaces are prone to data changes frequently.data changes frequently.

– Suitable for applications where there are Suitable for applications where there are clear divisions between controller, view, clear divisions between controller, view, and data modules so that different and data modules so that different professionals can be assigned to work on professionals can be assigned to work on different aspects of such applications different aspects of such applications concurrently.concurrently.

Page 39: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVCMVC

Benefits:Benefits:– There are many MVC vendor framework There are many MVC vendor framework

toolkits available.toolkits available.– Multiple views synchronized with same data Multiple views synchronized with same data

model model – Easy to plug-in new or change interface Easy to plug-in new or change interface

views, views, – Very effective for developments if Graphics Very effective for developments if Graphics

expertise professionals, programming expertise professionals, programming professionals, and data base development professionals, and data base development professionals are working in a team in a professionals are working in a team in a designed project.designed project.

Page 40: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

MVCMVC Does not fit well agent-oriented Does not fit well agent-oriented

applications such as interactive mobile applications such as interactive mobile and robotics applicationsand robotics applications..

Multiple pairs of controllers and views Multiple pairs of controllers and views based on the same data model make based on the same data model make any data model change expensive. any data model change expensive.

The division between the View and the The division between the View and the Controller is not clear in some cases.Controller is not clear in some cases.

Page 41: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

The PAC architecture is similar to MVC The PAC architecture is similar to MVC but with some important differences. but with some important differences.

The PAC was developed from MVC to The PAC was developed from MVC to support the application requirement of support the application requirement of multiple agents in addition to multiple agents in addition to interactive requirements. interactive requirements.

In PAC, the system is decomposed into In PAC, the system is decomposed into a hierarchy of many cooperating a hierarchy of many cooperating agents.agents.

Page 42: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Each agent has three components (Presentation, Each agent has three components (Presentation, Abstraction, and Control).Abstraction, and Control).

The Control component in each agent is in charge The Control component in each agent is in charge of communications with other agents. of communications with other agents.

The top-level agent provides core data and The top-level agent provides core data and business logics. business logics.

The bottom level agents provide detailed specific The bottom level agents provide detailed specific data and presentations. data and presentations.

A middle level agent may play a role of A middle level agent may play a role of coordinator of low-level agents. coordinator of low-level agents.

There are no direct connections between There are no direct connections between Abstraction component and Presentation Abstraction component and Presentation component in each agent.component in each agent.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 43: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

The PAC three components concepts are applied The PAC three components concepts are applied to all concrete sub-system architectures. to all concrete sub-system architectures.

It is very suitable for any distributed system It is very suitable for any distributed system where all the agents are distantly distributed where all the agents are distantly distributed and each of them has its own functionalities and each of them has its own functionalities with data and interactive interface. with data and interactive interface.

In such a system, all agents need to In such a system, all agents need to communicate with other agents in a well-communicate with other agents in a well-structured manner. structured manner.

The PAC is also used in applications with rich The PAC is also used in applications with rich GUI components where each of them keeps its GUI components where each of them keeps its own current data and interactive interface and own current data and interactive interface and needs to communicate with other components. needs to communicate with other components.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 44: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Of course, some concrete agent needs all Of course, some concrete agent needs all three components and some other agents three components and some other agents do not. do not.

For some middle level agents the For some middle level agents the interactive presentations are not required, interactive presentations are not required, so they do not have a Presentation so they do not have a Presentation component. component.

The control component is required for all The control component is required for all agents because this is the only way for an agents because this is the only way for an agent to talk to another agent. agent to talk to another agent.

Figure 9.6 shows a block diagram for a Figure 9.6 shows a block diagram for a single agent in PAC design.single agent in PAC design.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 45: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

The Control component is a mediator between The Control component is a mediator between the Presentation component and the Abstraction the Presentation component and the Abstraction component within the agent, and also a bridge component within the agent, and also a bridge between the agent itself and other agents as well. between the agent itself and other agents as well.

The Presentation component and the Abstraction The Presentation component and the Abstraction component are loosely coupled. component are loosely coupled.

The Presentation component is responsible for The Presentation component is responsible for both data input and data output in GUI interfaces both data input and data output in GUI interfaces where the data come from the Abstraction where the data come from the Abstraction component. component.

The Abstraction component is responsible for The Abstraction component is responsible for providing logical data concepts and services and providing logical data concepts and services and encapsulating all detailed data manipulation.encapsulating all detailed data manipulation.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 46: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 47: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Assume that the current page is the second Assume that the current page is the second to last page in the document at this time. to last page in the document at this time.

If the user clicks on the next button, the If the user clicks on the next button, the control agent C4 informs agent P4 to control agent C4 informs agent P4 to update its presentation, in this case, it also update its presentation, in this case, it also hides the next button since there is no next hides the next button since there is no next page after last page. page after last page.

Agent C4 also informs agent A4 to update Agent C4 also informs agent A4 to update the data on next button.the data on next button.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 48: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

After C4 handles all local processing, it After C4 handles all local processing, it contacts its parent agent, C1, to let it take contacts its parent agent, C1, to let it take over. over.

After C1 gets the message from C4, it tells After C1 gets the message from C4, it tells A1 to move the next page, which is the last A1 to move the next page, which is the last page in the document, and then asks P1 to page in the document, and then asks P1 to display that page. display that page.

C1 also informs C5 to hide the last button C1 also informs C5 to hide the last button since the current page is since the current page is the last page (or the last page (or let the last button stay based on the let the last button stay based on the requirement specification).requirement specification).

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 49: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

We can see that all the agents We can see that all the agents communicate via the controls. communicate via the controls.

The data structure shown on the upper-The data structure shown on the upper-right corner of Figure 9.7 indicates the right corner of Figure 9.7 indicates the pointer and data. pointer and data.

Since PAC2, PAC3, PAC4, and PAC5 are all Since PAC2, PAC3, PAC4, and PAC5 are all buttons, they have very similar data and buttons, they have very similar data and presentation functionality such as hide, presentation functionality such as hide, move-over, gray-out features; their move-over, gray-out features; their controls, however, are different. controls, however, are different.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 50: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 51: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

The sequence diagram in Figure 9.9 shows the The sequence diagram in Figure 9.9 shows the interaction sequence in the example we discussed interaction sequence in the example we discussed above. above.

When the next button is pressed to display the last When the next button is pressed to display the last page in the document PAC4 and PAC1 react as page in the document PAC4 and PAC1 react as follows:follows:P4 informs C4 that the “next” button was pressed;P4 informs C4 that the “next” button was pressed;C4 sends update to A4;C4 sends update to A4;C4 informs P4 to update its presentation or shape;C4 informs P4 to update its presentation or shape;C4 contacts C1 (a top level agent).C4 contacts C1 (a top level agent).C1 sends update to A1 to move the pointer to nextC1 sends update to A1 to move the pointer to next (last page)(last page)C1 instructs P1 to display the last page.C1 instructs P1 to display the last page.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 52: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 53: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 54: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Applications:Applications:– Suitable for an interactive system where the Suitable for an interactive system where the

system can be divided into many system can be divided into many cooperating agents in a hierarchical cooperating agents in a hierarchical manner. manner.

– Each agent has its own specific assigned Each agent has its own specific assigned job. job.

– Suitable when the coupling among the Suitable when the coupling among the agents is expected to be loose so that agents is expected to be loose so that changes on an agent does not affect others.changes on an agent does not affect others.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 55: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Benefit:Benefit:– Support of multi-tasking and multi-Support of multi-tasking and multi-

viewingviewing..– Support agent reusability and Support agent reusability and

extensibility.extensibility.– Easy to plug-in new agent or replace an Easy to plug-in new agent or replace an

existing one.existing one.– Support for concurrency where multiple Support for concurrency where multiple

agents are running in parallel in different agents are running in parallel in different threads or different devices or computers.threads or different devices or computers.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 56: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Limitations:Limitations:– Overhead due to the control bridge between Overhead due to the control bridge between

presentation and abstraction and the presentation and abstraction and the communication of controls among agents.communication of controls among agents.

– Difficult to determine the right number of the Difficult to determine the right number of the agents due to the loose coupling and high agents due to the loose coupling and high independence between agentsindependence between agents

– Complete separation of presentation and Complete separation of presentation and abstraction by control in each agent generate abstraction by control in each agent generate development complexity since development complexity since communications between agents only take communications between agents only take place between the controls of agents.place between the controls of agents.

Presentation-Abstraction-Control (PAC)Presentation-Abstraction-Control (PAC)

Page 57: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Presentation-Abstraction-Presentation-Abstraction-ControlControl ContextContext

– Development of an interactive system with the help Development of an interactive system with the help of agentsof agents

ProblemProblem– A system consists of a set cooperating agents.A system consists of a set cooperating agents.– Each agent is responsible for one particular taskEach agent is responsible for one particular task

SolutionSolution– Structure the application as a tree-like hierarchy of Structure the application as a tree-like hierarchy of

PAC agent.PAC agent.– Each agent is responsible for one aspect of the Each agent is responsible for one aspect of the

system’s functionalitysystem’s functionality

Page 58: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Presentation-Abstraction-Presentation-Abstraction-ControlControl

– Each agent consists of three components: presentation, Each agent consists of three components: presentation, abstraction, and controlabstraction, and control

The presentation component provides the visible behavior The presentation component provides the visible behavior of the agentof the agent

The abstraction component maintains the data model and The abstraction component maintains the data model and operations on the data modeloperations on the data model

Control component connects the presentation and Control component connects the presentation and abstraction and communication with other agents.abstraction and communication with other agents.

– The top level agent provides the functional core of the The top level agent provides the functional core of the systemsystem

– Bottom level agents represent self-contained semantic Bottom level agents represent self-contained semantic concepts on which the user can act, such as a concepts on which the user can act, such as a spreadsheetspreadsheet

– Intermediate level agents represent either combinations Intermediate level agents represent either combinations of, or relationships between, low level agents. of, or relationships between, low level agents.

Known usesKnown uses– Network Traffic ManagementNetwork Traffic Management– Mobile RobotMobile Robot

Page 59: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

PAC Pattern - StructurePAC Pattern - Structure

RepositoryDatasendMsgreceiveMsg

ViewMediatorviewDatasendMsgreceiveMsgopenViewcloseView

ErrorHandlererrorDatasendMsgreceiveMsgdisplayErrorhandleError

SpreadsheetelectionDatasendMsgreceiveMsgOpenCloseenterData

BarChartchartDatasendMsgreceiveMsgopenclose

PieChartpieDatasendMsgreceiveMsgopenclose

Page 60: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

PAC Pattern - StructurePAC Pattern - Structure

ViewMediator Agent

ControlinteractionDatasendMsgreceiveMsggetData

AbstractionchartDatasetChartDatagetChartData

PresentationpresentDataUpdateOpenCloseZoomprint

BarChart Agent

Page 61: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Chapter 10Chapter 10DISTRIBUTED DISTRIBUTED ARCHITECTUREARCHITECTURE

Page 62: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

OverviewOverview

A distributed system can be modeled by A distributed system can be modeled by the client-the client-server architecture, and this forms the basis for multi-server architecture, and this forms the basis for multi-tier architectures; alternatives are the broker tier architectures; alternatives are the broker architecture such as CORB, and the Service-Oriented architecture such as CORB, and the Service-Oriented Architecture (SOA). Architecture (SOA).

The important features of a distributed architecture are The important features of a distributed architecture are its service location transparency, and its services its service location transparency, and its services reliability and availability.reliability and availability.

Additionally, there are several technology frameworks Additionally, there are several technology frameworks to support distributed architectures, including .NET, to support distributed architectures, including .NET, J2EE, CORBA, .NET Web services, AXIS Java Web J2EE, CORBA, .NET Web services, AXIS Java Web services, and GloBus Grid servicesservices, and GloBus Grid services..

Page 63: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Client-Client-Server Server

Page 64: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Client-Client-Server Server

Page 65: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

AdvantagesAdvantages:: Separation of responsibilities such as user interface Separation of responsibilities such as user interface

presentation and business logic processing. presentation and business logic processing. Reusability of server components.Reusability of server components.DisadvantagesDisadvantages:: Lack of heterogeneous infrastructure to deal with Lack of heterogeneous infrastructure to deal with

the requirement changes.the requirement changes. Security complications.Security complications. Server availability and reliability.Server availability and reliability. Testability and scalability.Testability and scalability. Fat clients with presentation and business logic Fat clients with presentation and business logic

together.together.

Client-Client-Server Server

Page 66: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Multi-tiersMulti-tiers

Page 67: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Multi-tiersMulti-tiers

Page 68: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Broker Architectural Broker Architectural StyleStyle OverviewOverview

– The broker architecture is a middleware architecture used in The broker architecture is a middleware architecture used in distributed computing to coordinate and facilitate distributed computing to coordinate and facilitate communication between registered servers and clients.communication between registered servers and clients.

– It can be used to structure distributed software systems with It can be used to structure distributed software systems with decoupled components that interact by remote service decoupled components that interact by remote service invocations.invocations.

– A broker component is responsible for coordinating A broker component is responsible for coordinating communication, such as forwarding requests, as well as for communication, such as forwarding requests, as well as for transmitting results and exceptions.transmitting results and exceptions.

– A broker can be either an invocation-oriented service, to which A broker can be either an invocation-oriented service, to which clients send invocation requests for brokering, or a document clients send invocation requests for brokering, or a document or message- oriented broker to which clients send a message or message- oriented broker to which clients send a message (such as an XML document). (such as an XML document).

– Client and the server never interact with each other directly. Client and the server never interact with each other directly. – A broker system is also called the proxy-based system.A broker system is also called the proxy-based system.

Page 69: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

– Servers make their services available to their Servers make their services available to their clients by registering and publishing their clients by registering and publishing their interfaces with the broker. interfaces with the broker.

– Clients can request the services of servers from Clients can request the services of servers from the broker statically or dynamically by look-up.the broker statically or dynamically by look-up.

– A broker component is responsible for coordinating A broker component is responsible for coordinating communications communications –– brokering the service requests, brokering the service requests, locating a proper server, forwarding and locating a proper server, forwarding and dispatching requests, and sending responses or dispatching requests, and sending responses or exceptions back to clients. exceptions back to clients.

– CORBA (Common Object Request Broker CORBA (Common Object Request Broker Architecture) is a good implementation example of Architecture) is a good implementation example of the broker architecture.the broker architecture.

Broker Architectural Broker Architectural StyleStyle

Page 70: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

– In addition, the clients can dynamically In addition, the clients can dynamically invoke the remote methods even if the invoke the remote methods even if the interfaces of the remote objects are not interfaces of the remote objects are not available at the compilation time. available at the compilation time.

– Client has a direct connection to its Client has a direct connection to its client-proxy and server has direct client-proxy and server has direct connection to its server-proxy. connection to its server-proxy.

– The proxy talks to the mediator-broker.The proxy talks to the mediator-broker.

Broker Architectural Broker Architectural StyleStyle

Page 71: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Components:Components: Broker StubStub SkeletonSkeleton BridgeBridge NetworkNetwork

Broker Architectural Broker Architectural StyleStyle

Page 72: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Co-ordinates communications – Co-ordinates communications – passes on requests and returns passes on requests and returns replies. replies.

The broker keeps all servers The broker keeps all servers registration information including their registration information including their functionality and servicesfunctionality and services as well as as well as location information. location information.

The broker provides APIs for clients to The broker provides APIs for clients to request, servers to respond, request, servers to respond, registering or unregistering server registering or unregistering server components, transferring messages, components, transferring messages, and locating servers.and locating servers.

Broker ComponentBroker Component

Page 73: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Client-side proxy: It mediates between client Client-side proxy: It mediates between client and broker and provides additional and broker and provides additional transparency between them. transparency between them.

To the client, a remote object appears like a To the client, a remote object appears like a local one. local one.

The proxy hides the inter-process The proxy hides the inter-process communication at protocol level and performs communication at protocol level and performs marshalling of parameter values and marshalling of parameter values and unmarshaling of results from the server. unmarshaling of results from the server.

The stub is generated at the static compilation The stub is generated at the static compilation time and deployed to the client side to be used time and deployed to the client side to be used as a proxy for the client. as a proxy for the client.

Stub ComponentStub Component

Page 74: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

SServer-side proxy: It is also statically generated by the erver-side proxy: It is also statically generated by the service interface compilation and then deployed to the service interface compilation and then deployed to the server side.server side.

It encapsulates low-level system-specific networking It encapsulates low-level system-specific networking functions like what client-proxy does and provides functions like what client-proxy does and provides high-level APIs to mediate between the server and the high-level APIs to mediate between the server and the broker. broker.

It receives the requests, unpacks the requests, It receives the requests, unpacks the requests, unmarshals the method arguments, and calls the unmarshals the method arguments, and calls the appropriate service. appropriate service.

When it receives the result back from the server it also When it receives the result back from the server it also marshals the result before sending it back to the client.marshals the result before sending it back to the client.

Skeleton ComponentSkeleton Component

Page 75: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

These optional components are used to hide These optional components are used to hide implementation details when two brokers implementation details when two brokers interoperate. interoperate.

It encapsulates underlying network detail It encapsulates underlying network detail implementation and mediates different implementation and mediates different brokers such as DCOM, .NET Remote and Java brokers such as DCOM, .NET Remote and Java CORBA brokers. CORBA brokers.

They can take requests and parameters in one They can take requests and parameters in one format and translate them to another format. format and translate them to another format.

A bridge can connect two different networks A bridge can connect two different networks based on different communication protocols.based on different communication protocols.

BridgesBridges

Page 76: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Network: The connections between the Network: The connections between the components are the network with components are the network with designated protocol standards such as designated protocol standards such as TCP/IP OIIP or SOAP. TCP/IP OIIP or SOAP.

The request carries data in a format of The request carries data in a format of message document or method message document or method invocationinvocation. .

Network ComponentNetwork Component

Page 77: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Broker modelBroker model

request

response

Service 1

Service 2

Service 3

1

2

3

4

5

Broker 1

Broker 2

Page 78: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Brokers with client-server Brokers with client-server proxyproxy

Client proxy

Broker-1Server

proxy

bridges Broker -2Server

proxy

Broker -3

Server

proxy

Client

proxy

Client proxy

Page 79: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Brokers with client-server Brokers with client-server proxyproxy

Page 80: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Brokers with client-server Brokers with client-server proxyproxy

Page 81: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

AdvantagesAdvantages Server component implementation and location Server component implementation and location

transparencytransparency.. Changeability and extensibility.Changeability and extensibility. Simplicity for clients to access server and server Simplicity for clients to access server and server

portability.portability. Interoperability via broker bridges.Interoperability via broker bridges. Reusability.Reusability. Feasibility of runtime changes of server components Feasibility of runtime changes of server components

(add or remove server components on the fly).(add or remove server components on the fly).

DisadvantagesDisadvantages:: Inefficiency due to the overhead of proxiesInefficiency due to the overhead of proxies Low fault-toleranceLow fault-tolerance Difficulty in testing due to the amount of proxiesDifficulty in testing due to the amount of proxies

Brokers with client-server Brokers with client-server proxyproxy

Page 82: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

CORBACORBA

Page 83: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Service-Oriented ArchitectureService-Oriented Architecture (SOA)(SOA) OverviewOverview

– A Service Oriented Architecture (SOA) starts A Service Oriented Architecture (SOA) starts with a businesses process. with a businesses process.

– A service is a business functionality A service is a business functionality that is that is well-defined, self-contained, independent from well-defined, self-contained, independent from other services, and published and available to other services, and published and available to be used via a standard programming interface. be used via a standard programming interface.

– Software manages business processes through Software manages business processes through a SOA with well-defined and standard a SOA with well-defined and standard interfaces that can build, enhance, and expand interfaces that can build, enhance, and expand their existing infrastructure more flexible.their existing infrastructure more flexible.

Page 84: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

– SOA services can be extensively reused within a SOA services can be extensively reused within a given domain or product line, and even among given domain or product line, and even among legacy systems.legacy systems.

– Loose coupling of serviceLoose coupling of service––orientation provide great orientation provide great flexibility for enterprises to make use of all available flexibility for enterprises to make use of all available service recourses regardless of platform and service recourses regardless of platform and technology restrictions. technology restrictions.

– The connections between services are conducted by The connections between services are conducted by common and universal message oriented protocols common and universal message oriented protocols such as the SOAP Web service protocol, which can such as the SOAP Web service protocol, which can deliver requests and responses between services deliver requests and responses between services loosely. loosely.

– A connection can be established statically or A connection can be established statically or dynamically. dynamically.

Service-Oriented ArchitectureService-Oriented Architecture (SOA)(SOA)

Page 85: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Service-Oriented ArchitectureService-Oriented Architecture (SOA)(SOA)

Page 86: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

Service-Oriented ArchitectureService-Oriented Architecture (SOA)(SOA)

Page 87: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

SOA Implementation in Web SOA Implementation in Web ServicesServices

Page 88: Software Architecture - 2 September 5, 2015September 5, 2015September 5, 2015

AdvantagesAdvantages:: Loose-coupling is the key attribute of SOA. Loose-coupling is the key attribute of SOA. Each service component is independent from other services Each service component is independent from other services

due to the stateless service featuredue to the stateless service feature. . The implementation of a service will not affect the application The implementation of a service will not affect the application

of the service as long as the exposed interface is not changed. of the service as long as the exposed interface is not changed. A client or any service can access other services regardless of A client or any service can access other services regardless of

their platform, technology, vendors, or language their platform, technology, vendors, or language implementations. implementations.

Any service can be reused by any other service. Because Any service can be reused by any other service. Because clients of a service only need to know its public interfaces, clients of a service only need to know its public interfaces, service composition and integration become much easier. service composition and integration become much easier.

SOA based business application development comes much SOA based business application development comes much more efficient in term of time and cost.more efficient in term of time and cost.

Loosely coupled services make themselves easy to scale. Loosely coupled services make themselves easy to scale. The coarse-grained, document-oriented, and asynchronous The coarse-grained, document-oriented, and asynchronous

service features enhance the scalability attribute. service features enhance the scalability attribute.

Service-Oriented ArchitectureService-Oriented Architecture (SOA)(SOA)