Download presentation
Presentation is loading. Please wait.
Published byNelson Casey Modified over 9 years ago
1
SS ZG653Second Semester,2012-13 1 Topic Architectural Patterns Pipe and Filter
2
SS ZG653Second Semester,2012-13 2 PIPES & FILTERS Mud to Structure
3
SS ZG653Second Semester,2012-13 3 Pipes and Filters The pipes and filters architectural pattern provides a structure for systems that process a stream of data. Each processing step is encapsulated in a filter component. Data is passed through pipes between adjacent filters. Recombining filters allows you to build families of related systems.
4
SS ZG653Second Semester,2012-13 4 Pipes and Filters Type of Data Flow Architecture Filter is a component and pipe is a connector Filter has interfaces from which a set of inputs can flow in and a set of outputs can flow out. Incremental transformation of data by successive components. All data does not need to be processed for next filter to start working. Any set of filters may be combined in any order, although reasonable semantics are not guaranteed by this style.
5
SS ZG653Second Semester,2012-13 5 Pipes and Filters Filter Independent entities Does not share state with other filters. Do not know the identity to upstream and downstream filters. Pipes Stateless data stream Source end feeds filter input and sink receives output.
6
SS ZG653Second Semester,2012-13 6 Pipes and Filters
7
SS ZG653Second Semester,2012-13 7 Pipes and Filters Compilers Various “translation” systems
8
SS ZG653Second Semester,2012-13 8 Pipes and Filters – 3 part schema Pattern ContextProcessing Data Streams ProblemSystem that must process or transform a stream of input data. Expect flexibility by exchanging or reordering the processing steps. Possible to build family of such systems. Future enhancements – exchange processing steps or recombination Small processing steps – aid reuse Non adjacent processing steps do not share information Different sources of data exist Store final result in various ways Explicit storage of intermediate results should be transparent to users – is error prone if done by users Multiprocessing the steps SolutionPipes and filters – data source to data sink
9
SS ZG653Second Semester,2012-13 9 Pipes and Filters Filter component is a processing units of the pipeline Enriches, refines or transforms its input data Enriches – computing and adding information Refine – concentrating or extracting information Transforms – delivering data in some other representation Class Filter Responsibility Gets inputs data Performs a function on its input data Supplies output data Collaborators Pipe
10
SS ZG653Second Semester,2012-13 10 Pipes and Filters Pipe denotes connection between filters Data source and first filter Last filter and Data sink Synchronises two active component Class Pipe Responsibility Transfers data Buffers data Synchronizes active neighbors Collaborators Data Source Data Sink Filter
11
SS ZG653Second Semester,2012-13 11 Pipes and Filters Data source represents input to the system Sequence of data of the same structure or type Class Data Source Responsibility Delivers input to processing pipeline Collaborators Pipe
12
SS ZG653Second Semester,2012-13 12 Pipes and Filters Data sink collects results from end of the pipeline Active: pulls results from preceding processing stage Passive: allows preceding filter to push or write the results into it Class Data Sink Responsibility Consumes output Collaborators Pipe
13
SS ZG653Second Semester,2012-13 13 Dynamics Scenario I – Push pipeline [Activity starts with the Data source] – Filter activity started by writing data to the filters – Passive Filter [Use direct calls to the adjacent pipeline]
14
SS ZG653Second Semester,2012-13 14 Dynamics Scenario II – Pull pipeline – Control flow is started by the data sink calling for data
15
SS ZG653Second Semester,2012-13 15 Dynamics Scenario III – Push-pull mixed pipeline
16
SS ZG653Second Semester,2012-13 16 Dynamics Scenario IV – All filters actively pull, compute and push data in a loop – Each filter runs its own thread of control – Filters are synchronised by buffering pipe between them
17
SS ZG653Second Semester,2012-13 17 Implementation #Steps 1Divide the system’s task into a sequence of processing stages 2Define the data format to be passed along each pipe 3Decide how to implement each pipe connection 4Design and implement the filters 5Design the error handling 6Set up the processing pipeline
18
SS ZG653Second Semester,2012-13 18 1: Divide the systems tasks into sequence of processing stages Each stage must depend on the output of the predecessor All stages conceptually connected by data flow
19
SS ZG653Second Semester,2012-13 19 2: Define data format to be passed along each pipe Define a uniform format results in the highest flexibility because it makes recombination of filters easy Define the end of input marking
20
SS ZG653Second Semester,2012-13 20 3: Decide how to implement each pipe connection Decision determines active or passive filter Using a separate pipe mechanism that synchronises adjacent active filters provide a more flexible solution
21
SS ZG653Second Semester,2012-13 21 4: Design and implement the filters Depends on – Task it must perform – Adjacent pipe Active or Passive filters Performance and tradeoffs Filter reuse
22
SS ZG653Second Semester,2012-13 22 5: Design the error handling Never neglect error handling No global state shared; error handling hard to address Strategies in case of error – depend on domain
23
SS ZG653Second Semester,2012-13 23 6: Setup the processing pipeline Use of standardised main program Use of user inputs or choice
24
SS ZG653Second Semester,2012-13 24 Variants Tee and Join pipeline – Filters with more then one input and/or more than one output
25
SS ZG653Second Semester,2012-13 25 Benefits No intermediate files necessary, but possible Flexibility by filter exchange Flexibility by recombination Reuse of filter components Rapid prototyping of pipelines Efficiency by parallel processing
26
SS ZG653Second Semester,2012-13 26 Liabilities Sharing state information is expensive or inflexible Data transformation overhead Error handling
27
SS ZG653Second Semester,2012-13 27 Known Uses Find (at least 2) more popular uses and document them
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.