Lecture Notes in Computer Science Commenced Publication in 1973 Founding and Former Series Editors: Gerhard Goos, Juris Hartmanis, and Jan van Leeuwen
Editorial Board David Hutchison Lancaster University, UK Takeo Kanade Carnegie Mellon University, Pittsburgh, PA, USA Josef Kittler University of Surrey, Guildford, UK Jon M. Kleinberg Cornell University, Ithaca, NY, USA Alfred Kobsa University of California, Irvine, CA, USA Friedemann Mattern ETH Zurich, Switzerland John C. Mitchell Stanford University, CA, USA Moni Naor Weizmann Institute of Science, Rehovot, Israel Oscar Nierstrasz University of Bern, Switzerland C. Pandu Rangan Indian Institute of Technology, Madras, India Bernhard Steffen TU Dortmund University, Germany Madhu Sudan Microsoft Research, Cambridge, MA, USA Demetri Terzopoulos University of California, Los Angeles, CA, USA Doug Tygar University of California, Berkeley, CA, USA Gerhard Weikum Max Planck Institute for Informatics, Saarbruecken, Germany
6598
Frank Alexander Kraemer Peter Herrmann (Eds.)
System Analysis and Modeling: About Models 6th International Workshop, SAM 2010 Oslo, Norway, October 4-5, 2010 Revised Selected Papers
13
Volume Editors Frank Alexander Kraemer Peter Herrmann Norwegian University of Science and Technology (NTNU) Department of Telematics O.S. Bragstads plass 2a, 7491 Trondheim, Norway E-mail: {kraemer, herrmann}@item.ntnu.no
ISSN 0302-9743 e-ISSN 1611-3349 ISBN 978-3-642-21651-0 e-ISBN 978-3-642-21652-7 DOI 10.1007/978-3-642-21652-7 Springer Heidelberg Dordrecht London New York Library of Congress Control Number: 2011929390 CR Subject Classification (1998): C.2, D.2, D.3, F.3, C.3, H.4 LNCS Sublibrary: SL 5 – Computer Communication Networks and Telecommunications
© Springer-Verlag Berlin Heidelberg 2011 This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, re-use of illustrations, recitation, broadcasting, reproduction on microfilms or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. The use of general descriptive names, registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. Typesetting: Camera-ready by author, data conversion by Scientific Publishing Services, Chennai, India Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com)
Preface
These are the proceedings of the sixth edition of SAM, the Workshop on System Analysis and Modeling. The workshop provides an open arena for participants from academia and industry to present and discuss the most recent innovations, trends, experiences and concerns in modeling, specification and analysis of distributed, communication and real-time systems. In 2010, SAM was co-located with the 13th ACM/IEEE International Conference on Model-Driven Engineering Languages and Systems (MODELS) and held in Oslo, Norway, during October 4–5. The workshop was attended by around 75 participants from 18 countries. Of the 32 manuscripts submitted initially, 16 were selected for presentation at the workshop in a thorough initial reviewing round in which most of the papers were checked by four reviewers and several were improved using shepherds. Taking the feedback from the reviewers and the workshop audience into account, revised versions of 15 manuscripts were collected in this volume after a second in-depth round of reviews. The program was completed by a keynote address on “Service High-Availability” by Ferhat Khendek from Concordia University in Montreal, Canada, and a tutorial by Rick Reed from the SDL Forum Society on SDL-2010. This workshop would of course not have been possible without the dedicated work of the Program Committee members that did a tremendous job in reviewing all submissions thoroughly and acting as shepherds. We would also like to express our gratitude to Øystein Haugen and the entire Organizing Committee of the MODELS conference for enabling the co-location of SAM and taking care of all local arrangements in the Oslo congress centre. Finally, we would like to thank all authors, keynote speakers, session chairs and sponsors, as well as the SDL Forum Society and the Department of Telematics of the Norwegian University of Science and Technology (NTNU). March 2011
Frank Alexander Kraemer Peter Herrmann
Organization
Workshop Co-chairs Frank Alexander Kraemer Peter Herrmann
Norwegian University of Science and Technology (NTNU) Norwegian University of Science and Technology (NTNU)
SDL Forum Society Chairman Secretary Treasurer
Rick Reed Reinhard Gotzhein Martin von L¨ owis
ACM/IEEE/MODELS 2010 Øystein Haugen
SINTEF, University of Oslo, Norway
Program Committee Daniel Amyot Attila Bilgic Rolv Bræk Reinhard Brocks Laurent Doldi Anders Ek Stein-Erik Ellevseth Joachim Fischer Jacqueline Floch Pau Fonseca i Casas Emmanuel Gaudin Abdelouahed Gherbi Reinhard Gotzhein Jens Grabowski Peter Graubmann Øystein Haugen Lo¨ıc Hlou¨et Peter Herrmann
University of Ottawa, Canada University of Bochum, Germany Norwegian University of Science and Technology, Norway HTW Saarland, Germany Isoscope, France IBM, Sweden ABB Corporate Research, Norway Humboldt-Universit¨ at zu Berlin, Germany SINTEF, Norway Universitat Polit`ecnia de Catalunya, Spain Pragmadev, France ´ Ecole de Technologie Sup´erieure, University of Quebec, Canada University of Kaiserslautern, Germany Universit¨ at G¨ottingen, Germany Siemens, Germany SINTEF, University of Oslo, Norway INRIA Rennes, France Norwegian University of Science and Technology, Norway
VIII
Organization
Dieter Hogrefe Clive Jervis Ferhat Khendek Hartmut K¨ onig Alexander Kraas Frank Alexander Kraemer Finn Kristoffersen Thomas Kuhn Anna Medve Pedro Merino Tommi Mikkonen Ostap Monkewich Gunter Mussbacher Birger Møller-Pedersen Ileana Ober Javier Poncela Gonz´ alez Andreas Prinz Rick Reed Manuel Rodr´ıguez-Cayetano Richard Sanders Amardeo Sarma Ina Schieferdecker Bran Selic Edel Sherratt Martin von L¨ owis Thomas Weigert Frank Weil Edith Werner
University of G¨ottingen, Germany Motorola, USA Concordia University, Canada BTU Cottbus, Germany Fraunhofer Institute for Communication Systems (ESK), Germany Norwegian University of Science and Technology, Norway Cinderella ApS, Denmark Fraunhofer IESE, Germany University of Pannonia, Hungary University of Malaga, Spain Tampere University of Technology, Finland OMCI, Canada University of Ottawa, Canada University of Oslo, Norway IRIT University of Toulouse, France University of Malaga, Spain University of Agder, Norway TSE, UK University of Valladolid, Spain SINTEF, Norway NEC Laboratories Europe, Germany TU Berlin/Fraunhofer FOKUS, Germany Malina Software Corp., Canada University of Wales, Aberystwyth, UK Hasso-Plattner Institute, Germany University of Missouri-Rolla, USA UniqueSoft, USA Universit¨ at G¨ottingen, Germany
Sponsoring Institutions IEEE Computer Society ACM Sigsoft SDL Forum Society amsys www.eit.uni-kl.de/amsys
Additional Organizers Norwegian University of Science and Technology (NTNU) MODELS 2010
Table of Contents
Modularity, Composition, Choreography SDL Modules – Concepts and Tool Support . . . . . . . . . . . . . . . . . . . . . . . . . Philipp Becker and Marc Kr¨ amer
1
A Developer-Friendly Approach for the Validation of Dynamic Compositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jacqueline Floch and Cyril Carrez
18
From Flow-Global Choreography to Component Types . . . . . . . . . . . . . . . Surya Bahadur Kathayat and Rolv Bræk
36
Application of SDL and UML Integration of FlexRay into the SDL-Model-Driven Development Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tobias Braun, Reinhard Gotzhein, and Matthias Wiebel
56
Design and Development of a CPU Scheduler Simulator for Educational Purposes Using SDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Manuel Rodr´ıguez-Cayetano
72
UML-Based Specification and Generation of Executable Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wafi Dahman and Jens Grabowski
91
SDL Language Profiles The SDL-UML Profile Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Alexander Kraas
108
Code Generation and Model Transformations A Model Driven Approach for AMF Configuration Generation . . . . . . . . . Pejman Salehi, Pietro Colombo, Abdelwahab Hamou-Lhadj, and Ferhat Khendek
124
SDL Code Generation for Network Simulators . . . . . . . . . . . . . . . . . . . . . . . Mihal Brumbulli and Joachim Fischer
144
A Case Study on API Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Uwe Jugel and Andr´e Preußner
156
X
Table of Contents
Verification and Analysis UOST: UML/OCL Aggressive Slicing Technique for Efficient Verification of Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Asadullah Shaikh, Uffe Kock Wiil, and Nasrullah Memon
173
Extensible and Automated Model-Evaluations with INProVE . . . . . . . . . . S¨ oren Kemmann, Thomas Kuhn, and Mario Trapp
193
Requirements and Solutions for Timing Analysis of Automotive Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Saoussen Anssi, S´ebastien G´erard, Arnaud Albinet, and Fran¸cois Terrier
209
User Requirements Notation Analysing the Cognitive Effectiveness of the UCM Visual Notation . . . . . Nicolas Genon, Daniel Amyot, and Patrick Heymans
221
Towards a Taxonomy of Syntactic and Semantic Matching Mechanisms for Aspect-Oriented Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Gunter Mussbacher, Daniele Barone, and Daniel Amyot
241
Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
257
SDL Modules – Concepts and Tool Support Philipp Becker and Marc Krämer Networked Systems Group University of Kaiserslautern, Germany {pbecker,kraemer}@cs.uni-kl.de
Abstract. SDL, ITU’s Specification and Description Language, supports developing systems in a modular and hierarchical way, based on structural type definitions and their instantiations. Also, reuse is supported by the possibility to define collections of type definitions, e.g., as SDL packages, that can be used in different systems. Another important development task that can be supported by packages is the replacement of system parts, i.e., structural instances. This can be achieved, for instance, by replacing the type definition to which an instantiation refers by using another package containing a compatible type. However, we have found that this apparently elegant solution reveals some intricacies in practice. To fully exploit the benefits of packages for the development of complex systems and system versioning, type definitions are typically collected in a considerable number of packages. Moreover, there usually are numerous dependencies among packages, which make their management an error-prone task. Finally, it is not clear which types are compatible such that they can be used as mutual replacements. In this paper, we propose a clean solution for the replacement of system parts. Therefore, we introduce a concept that we call SDL module, which we use to capture compatibility of structural type definitions and replacement rules. We illustrate the applicability of our approach by presenting an in-house development tool to automate the replacement process. This tool can be utilized to speed up the development process, and adapt SDL systems to different platforms and scenarios. Keywords: SDL, MDD, Modules, Components, Interfaces, Packages, Tool Support.
1
Introduction
Developing systems with SDL, ITU’s Specification and Description Language [1], has certain well-known advantages over conventional development processes. One of these advantages is SDL’s inherent feature to structure and develop systems in a modular and hierarchical way. The hierarchical structure allows us to design a system by creating only a few representative blocks in the beginning, depicting the overall system structure. Then the system can be refined iteratively, becoming more complex with every step. During this refinement process, new structures, type definitions, and functionalities are added and encapsulated in various types of SDLs structural units on different layers. F.A. Kraemer and P. Herrmann (Eds.): SAM 2010, LNCS 6598, pp. 1–17, 2011. c Springer-Verlag Berlin Heidelberg 2011
2
P. Becker and M. Krämer
The encapsulation process is also supported by the way interaction is realized in an SDL system between such structural units as blocks, processes, or services. As these units normally only interact by means of signals transported over signal routes and channels, the internal structure of other connected units can remain hidden. Therefore, SDLs structural units are mostly following the black box principle, providing functionality to other parts of the system over a defined, unitdependent interface (signals, gates, etc), but hiding their inner details. We say that the units are “mostly” following that principle, because they are not necessarily self-contained, for they can still have dependencies on other structural units they are using, e.g. via USE statements in SDL packages. Exchanging such structural units is simple in theory: Remove the unit from the system, and instead insert another one of the same type, ideally with the same name and interface, and a similar behavior against other connected units. In practice, however, severe problems may arise. In this paper, we address these problems and how they can be overcome. The remainder of this paper is structured as follows: Section 2 describes the problems that can occur when exchanging structural units in SDL. In Sect. 3, we take a closer look at already existing SDL language mechanisms and tool support to cope with these problems, and give reasons why they are not sufficient. Section 4 introduces the SDL module concept that we propose to handle these problems. In Sect. 5, we present our tool SPaSs that supports the application of our module concept. Finally, Sect. 6 concludes this paper and points out future work.
2
Motivation
During the development of complex systems with SDL, there are various reasons for replacing parts of SDL systems by other ones. In this section, we want to point out two of these reasons, and then take a close look at the problems that can arise during this process. With increasing size, SDLs specifications tend to become utterly complex over time, an observation that is not limited to SDL. The effect is intensified with a growing number of structural units contained in a system, and the dependencies among these units. This renders system development difficult, especially if multiple developers are working on the same system at a time. Here, complexity can be reduced by splitting up the system into parts that are developed separately. These parts can be structured as SDL packages, using the type concept of SDL. Nevertheless, the introduced packages have dependencies with other packages, and the complexity of the system rises. To illustrate the complexity that can already occur on package level, we use MacZ as an example, one of our in-house developed MAC protocols, that has grown over time by adding new functionality. Yet, it has ended up with a very large number of different units with various dependencies that have become difficult to manage, although organized in packages. Figure 1 shows the package
SDL Modules – Concepts and Tool Support
3
dependency graph of MacZ, where each of the 35 packages is represented as a box and each of the 197 edges represents a dependency relation between two packages. In system designs where MacZ is used, the system designer has to add all these packages and identify duplicates brought in by dependency relations of different packages by hand. If MacZ is modified during further development, and packages are added or removed, all SDL systems using MacZ must be updated as well. Second, although SDL specifications are intended to be platform-independent, it can still be necessary to have different specifications for different platforms. Take, e.g., a system providing voice communication over arbitrary network media. Here, the choice of the MAC layer depends, amongst other things, on the target platform and whether the communication is done wired (e.g., Ethernet), wireless (e.g., WLAN), or inside a simulation environment, where debugging information is written to log files. One possibility to overcome this problem is to keep one SDL system per configuration (i.e., desired combination of existing structural units). This approach is only applicable as long as there are only few units that need to be replaced. Otherwise, the number of resulting SDL systems may grow exponentially, making it harder to maintain all systems and keeping them in a consistent state of development. Another possibility is to keep only one SDL system and switch to the adequate SDL units in the system specification whenever code for a different platform is generated. Depending on the system structure, the necessary changes may be spread over several structural layers and units, e.g., USE statements that have to be adjusted in various SDL packages. Replacing SDLs structural units and adjusting related dependency statements currently can not be done automatically by means of SDL’s own mechanisms or any program known to us. Therefore, we propose a concept called SDL module that provides a way to replace structural units in SDL systems along with their dependencies, and also allows us to do so in an automated way. Managing multiple SDL specifications in a way that they can be exchanged against each other can be done in different ways. Here, we want to concentrate on two of them: using a single SDL package, and using multiple packages. Figure 2 shows one possibility to organize some structural units in one SDL package. As
Fig. 1. Dependency graph of the MAC protocol MacZ
4
P. Becker and M. Krämer USE myMac1Package1; USE myMac1Package2; USE myMac2Package1; USE myMac2Package2;USE myMac2Package3; USE dummyMacPackage1; USE myMacSimulationPackageX; USE generalPackage1; USE globalPackage2; USE dataTypesMac1; USE dataTypesMac2; USE dataTypes;
USE Application; USE MiddleWare; USE Routing; USE MAC;
system main
package MAC
middleware: myMiddleware g2 a
(App2Mw)
g3
(Mw2Rt) (Rt2Mw)
b
routing: myRouting g5
g4
c
(Mw2App)
myMac1
dummyMac
myMac2
myMacSimulation
(Mac2Rt) (Rt2Mac)
g1 application: myApplication
g6 mac: myMac1 g7 (Env2Mac)
d
SIGNALLIST Env2Mac= (MacInSignals);
SIGNALLIST Mac2Env= (MacOutSignals);
(Mac2Env)
(a) Typical communication architecture (b) Package with different MAC protocol specifications Fig. 2. Several SDL specifications organized in one package
example, we take an SDL system with a typical communication architecture as shown in Fig. 2(a), consisting of four top level blocks. Package MAC, as shown in Fig. 2(b), contains four different exchangeable specifications that may be instantiated by the mac block from the system in Fig. 2(a). In Fig. 2(b), all MAC layer specifications are located in the same SDL package, each realized as a block type. The signals used to interact with other parts of the system are specified once in package MAC and are used by all included block types. The list of 12 USE statements is the union of all included block types’ dependencies. To use one of these MAC specifications, the package is referenced in the system diagram (Fig. 2(a)). The currently used specification is chosen by instantiating the appropriate block type, which is myMac1 in the given example. The other possibility to organize different specifications is shown in Fig. 3. Here, we show how a system is organized and prepared for different MAC layers using one SDL package per exchangeable specification. As shown, every specification is identified by its SDL package name, and includes only its own dependencies. For the exchange of functionality in the system, only the USE statement needs to be replaced. Note that the same signal lists and block types have to be defined in each MAC package, since it is not possible to inherit other packages nor is it possible for the other MAC packages to USE MACIF, because then we would have a double definition of block type MAC. Summing up, both approaches have advantages and disadvantages: In the first approach, the SDL package gives an overview over the existing exchangeable specifications and the interface is only specified once. Also, several of the specified block types can be instantiated at the same time in one system. Here, the complete dependencies of all available specifications are included in the package and have to be met in the system. On the other hand, using the second approach, each package only includes the dependencies that are required for the particular specification. This allows SDL packages to be smaller and have a clearer structure. Even though both approaches allow multiple developers to work concurrently
SDL Modules – Concepts and Tool Support
5
USE ApplicationIF; USE MiddleWareIF; USE RoutingIF; USE MACIF;
system main middleware: Middleware g2 a
g3
(Mw2Rt)
b
routing: Routing g5
g4
(Rt2Mw)
(App2Mw)
c
(Mw2App)
(Mac2Rt)
package MACIF
(Rt2Mac)
g6
g1 application: Application
mac: MAC
SIGNALLIST Env2Mac= (MacInSignals);
MAC
g7
SIGNALLIST Mac2Env=(MacOutSignals);
(Env2Mac)
d (Mac2Env)
(a) Communication architecture, adapted (b) Common interface for all MAC layers to one specification per package USE myMac1Package1; USE myMac1Package2; USE generalPackage1; USE globalPackage2; USE dataTypesMac1; USE dataTypes;
USE myMacSimulationPackageX; USE generalPackage1; USE globalPackage2; USE dataTypesMac1; USE dataTypes;
package myMac1
package myMacSimulation SIGNALLIST Env2Mac= (MacInSignals);
MAC
SIGNALLIST Mac2Env=(MacOutSignals);
(c) Specification of myMac1
SIGNALLIST Env2Mac= (MacInSignals);
MAC
SIGNALLIST Mac2Env=(MacOutSignals);
(d) Specification of myMacSimulation
Fig. 3. Single specification per package, basis for our SDL module concept
on different exchangeable specifications, we favor the second approach, because SDL specifications may be in a syntactically inconsistent state while developers are working on them. As a result, using the first approach means that none of the other specifications can be used during that time as well, as a syntax check of the complete system would fail. For our SDL module concept, we follow the second approach, where each exchangeable SDL specification is included in its own SDL package.
3
Related Work
According to the SDL standard [1] and a common SDL text book [2], we identified a few techniques from SDL for the exchange of functionality. One technique often used in SDL is to convert blocks to block types and processes to process types, then move them to SDL packages and use instantiations in the rest of the system. Additionally, the package has to be included in the (Tau) organizer and a USE statement has to be added to the system diagram. To exchange the functionality, two strategies exist: replace the USE statement, or rename the block type to the desired specification. Both tasks require adding the intended packages to the organizer, and updating all instantiated type names to the new unit type
6
P. Becker and M. Krämer
names specified in the included packages. For large and distributed SDL designs, the organizer view becomes confusing and the update process is error-prone. Via the IBM Rational Tau-specific [3] keyword /*#include ...*/, it is possible to include additional PR files at arbitrary places throughout the system. But this inclusion is limited, since the Tau Analyzer does not recognize PR definitions (e.g., packages, block types) in this file and thus reports non-existing errors like unfulfilled dependencies. As a side-effect, this can lead to multiple occurrences of the same package definition in a system, which results in error messages by the Tau code generator. Another approach for the design of exchangeable structures is presented in [4]. These so-called Micro Protocols are specified in SDL, and bundled into packages. To use a micro protocol, the package is added to the organizer, as well as a matching USE statement and a block instance of the specific type. Although all micro protocols of the same type have a defined interface, and a documentation of their functionality is available, the problems pointed out before still apply. For Java [5], there exists the build tool Maven [6], created by the Apache Software Foundation, which is in fact a build tool like GNU make [7]. This tool faces the fact that one project consists of other projects in specific versions that are needed for the build process. Maven reads its configuration file, fetches all required projects, builds them and links them together. For SDL, a tool with similar functionality as Maven regarding different projects and versions, paired with a defined interface of the subprojects conforming to the SDL standard, integrated in tools like IBM Rational Tau, and supporting splitting work to different persons is needed. This leads directly to our approach, consisting of the SDL module concept and the tool SPaSs, which we are presenting in this paper.
4
Exchangeable Modules in SDL
In this section, we present our concepts of SDL module and SDL module interface, along with some explanatory examples of their usage. 4.1
Concept of SDL Modules
We define an SDL module interface as a minimal structural SDL unit that contains SDL type definitions for, e.g., block types, process types, signal types, and data types. The purpose of an SDL module interface is to provide a description for the minimal requirements other SDL units of the same type have to fulfill to provide the same interface. An SDL module interface is syntactically complete and provides minimal SDL specifications for all included type definitions. A minimal specification defines a name and interface for each included type definition, but omits as much functionality as possible. The interface of SDL types like, e.g., block types, includes not only the list of in- and outgoing signals, but also the names of the SDL gates and the correlation between signals and gates. An SDL module interface may also include a detailed informal description of the intended functionality in form of SDL comments.
SDL Modules – Concepts and Tool Support
7
In SDL systems, module interfaces can be used as placeholders, e.g. during the development process, to be replaced later by other SDL units of the same type that specify the same interface with full functionality. As an SDL module interface is syntactically complete and also provides the expected interface, SDL syntax checkers (e.g., IBM Rational Tau Analyzer [3]) should not trigger any additional warnings. Listing 1.1. Example of an SDL module interface in SDL-PR representation 1 2 3 4 5 6 7 8 9 10 11 12 13 14
PACKAGE MiddleWareIF ; SIGNAL i n S i g n a l ; BLOCK TYPE MiddleWare ; GATE inGate IN WITH i n S i g n a l ; SIGNALROUTE r t FROM env TO emptyProc WITH i n S i g n a l ; PROCESS emptyProc ; start ; NEXTSTATE i d l e ; STATE i d l e ; ENDPROCESS emptyProc ; ENDBLOCK TYPE MiddleWare ; ENDPACKAGE MiddleWareIF ;
An example of an SDL module interface is given in List. 1.1. Here, our SDL module interface is the SDL package MiddleWareIF, specified in SDL-PR. We specify a block type MiddleWare with a single gate inGate that only takes signals of signal type inSignal. To make this specification syntactically complete, we also specify a process emptyProc that is connected to the gate and only contains the start state connected to an additional state idle. An SDL module is defined as a set of SDLs structural units that forms a transitive closure w.r.t. the units’ dependencies. This means that all dependencies of all included units are also part of this SDL module. We say that an SDL module complies to an SDL module interface iff the SDL module contains a structural unit of the same type as the interface and this unit provides specifications for all type definitions included in the interface. As a result, different SDL modules that comply to the same SDL module interface can be exchanged against each other. An SDL module may comply to more than one SDL module interface. In Fig. 4, we give an example for a dependency graph of some structural units to explain our module concept. On the left side of the figure, we have some structural unit and their dependency relations. On the right side, we have identified all possible SDL modules in this dependency graph, along with the SDL module interfaces they comply to. Take, e.g., the set of units S1 = {B, D, E}. This set forms an SDL module, because the dependencies of all included units are also part of this set. In the figure, this is labeled as SDL module M4 . As this module includes unit B, which complies to interface Y , and unit D, which complies to interfaces V and W , the SDL module complies to SDL module interfaces Y , V , and W . On the other hand, the set of units S2 = {A, C, D} does not form an SDL module, since unit D depends on unit E that is not part of set S2 .
8
P. Becker and M. Krämer
Fig. 4. Exemplary dependency graph for some SDL units
Following the definition, an SDL system could be defined as a single SDL module that complies to all used SDL module interfaces. But we want SDL modules to be exchangeable units, and exchanging the entire system is not very reasonable. Therefore, we introduce the notion of minimal SDL modules. We define an SDL module to be minimal for a given SDL module interface iff there exists an SDL unit within this module that complies to the given SDL module interface, and all other SDL units included in this SDL module are direct or indirect dependencies of that unit. An equivalent definition is that there exists no strict subset of included SDL units that still forms a transitive closure w.r.t. the dependencies and also complies to the given SDL module interface. In the example of Fig. 4, module M2 is a minimal SDL module for SDL module interface X , M4 is minimal for Y , and M6 is minimal for interfaces V and W . The definition of minimal SDL modules avoids having multiple structural units in a single SDL module that comply to different SDL module interfaces, but do not have any direct or indirect dependency relation to each other. An important point here is that minimal SDL modules for a given interface can be constructed automatically by taking the interface-compliant structural unit as starting point and recursively adding all dependencies. 4.2
Usage of SDL Modules
In the following, we will specify SDL modules only on SDL package level. This means that all following SDL modules solely consist of (sets of) SDL packages. Additionally, when speaking of SDL modules for a given SDL module interface, we always mean minimal SDL modules for this interface. Figure 5 shows an example for the development of a routing protocol for a communication system. Following good practice, the routing protocol is placed between middleware and MAC layer. By using the SDL module interfaces Mid_ dleWareIF and MACIF as placeholders and instantiating the provided block types MAC and MiddleWare, we can continue to develop our routing protocol even if
SDL Modules – Concepts and Tool Support
9
no functionally complete SDL specifications for MAC layer and middleware are present. This way, our system is kept small and reduced to what is absolutely necessary during development. The developer is not bothered with warnings or errors from other specification parts and can therefore concentrate on his part. As a positive side effect, system analysis, e.g. done by the Tau Analyzer, is sped up. Both block types provided by the interfaces MiddleWareIF and MACIF contain a single empty process, emptyProc (cf. Fig. 5), which is functionally incomplete (cf. List. 1.1, lines 7–11), but syntactically complete and connected to the block types’ gates to satisfy SDL syntax checking tools. USE ConcreteRouting1; USE MiddleWareIF; USE MACIF;
system RoutingDevelopment
myMiddleWare: MiddleWare toRT MwRt
(RTtoMW)
MiddleWareIF MiddleWare emptyProc MACIF MAC emptyProc
(MWtoRT)
toUPPER myRouting: Routing toMAC RtMac
(MACtoRT)
(RTtoMAC)
ConcreteRouting1 Routing Multiplexer RoutingStatus RouteDiscovery PacketForwarder
toUPPER myMAC: MAC toEnv MacEnv
(EnvtoMAC) (MACtoEnv)
RoutingDevelopment myMAC : MAC x:y myMiddleWare : MiddleWare x:y myRouting : Routing x:y
Fig. 5. System overview during the development of a routing protocol module
To simulate SDL modules under development, we have two options. One possibility would be to insert the module into other, functionally complete systems to perform functional simulations. But simulating a complete system when we are only interested in the behavior of a single SDL module has some disadvantages and often only complicates the validation process. This leads us to the second possibility: Setting up a dedicated simulation environment for single SDL modules. To realize this, we can develop special SDL modules solely for simulation purposes. In the example given in Fig. 5, MACIF and MiddleWareIF can be replaced by such simulation modules. These SDL modules can specify black box test environments for the connected modules under development. Of course, the simulation modules also have to comply to the appropriate SDL module interfaces. As modules should be exchangeable, this does not only provide a
10
P. Becker and M. Krämer
simulation environment for a single SDL module, but for the whole SDL module interface. Different modules can be inserted into this environment to see if they comply to a given module interface and provide the expected behavior.
5
The SDL Package Substitution Tool
To support the process of managing and exchanging SDL modules that comply to the same module interface, we have developed the platform-independent SDL Package Substitution tool (SPaSs). SPaSs is publicly available from our homepage [8]. It works directly on regular SDL-PR files as well as on all files following SDLs Common Interchange Format (CIF) specification [9], and is therefore independent of SDL development environments. Often, these development environments provide some kind of export functionality to produce PR or CIF files out of the SDL-GR specifications, and vice versa via CIF import. To suit our needs and simplify the task of exchanging SDL modules, we have limited their use to sets of SDL packages, i.e., each SDL module consists of one or multiple SDL packages. 5.1
Overview
As input, SPaSs takes an SDL-PR file, optionally with included CIF annotations, that contains a system specification and its dependent packages, together with a set of mapping instructions contained in a separate configuration file. The mapping instructions specify which modules should be replaced and in which PR files the new modules can be found. As a result, a new PR file is produced which can be processed by arbitrary SDL-PR processing tools, e.g., code generators. In detail, starting from the SDL system contained in the given PR file, a recursive process begins where the dependencies of all major SDL units (system, packages) are identified via their USE statements. Following these statements, we successively build a dependency graph that includes the SDL system and all related SDL packages. After that, the mapping instructions from the configuration file are applied to this graph to perform the substitution of SDL modules contained in this graph. Configuration files follow a naming convention that allows us to have a bijective mapping between SDL-PR file and configuration file. Each configuration file may include an arbitrary number of so-called mapping targets. Mapping targets are named sets of mapping instructions. They can be used to define different mappings for the same SDL system, and allow us to keep mappings for different purposes (e.g., simulations, platform) in one place and easily switch between them. The name of the mapping target that should be used during the substitution process can be passed to the tool on the command line. There may also exist one unnamed mapping target, which is the default target. The entries from this target will be inherited by all other mapping targets. We have currently abstained from including additional syntax checks in the tool to see whether exchanged SDL modules comply to the same SDL module
SDL Modules – Concepts and Tool Support
11
Listing 1.2. System configuration 1 2 3 4 5 6 7
< ! - - D e f i n i t i o n o f g l o b a l d a t a s o u r c e s f o r t h e m a p p i n g s e c t i o n - -> <s r c name=" g l o b a l D i r " t y p e=" f i l e " s r c=" /home/ k r a e m e r/SDL" /> <s r c name="svnSDL" t y p e=" svn " s r c=" h t t p : // s v n s e r v e r / svn /SDL" b r a n c h=" dev " r e v=" 123 " u s e r=" g u e s t " pwd=" g u e s t " /> Global>
8
< ! - - D e f a u l t m a p p i n g w h e n u s i n g t h i s c o n f i g f i l e , a l w a y s a p p l i e d - -> <Mapping> <entry s e a r c h=" MiddleWareIF " r e p l a c e="WNCS_MW" f i l e ="wncs_mw . p r " s r c=" svnSDL" /> <entry s e a r c h=" R o u t i n g I F " r e p l a c e="AODV" f i l e =" R o u t i n g / aodv . p r " s r c="svnSDL" r e v=" " b r a n c h=" t r u n k " /> <entry s e a r c h="MACIF" r e p l a c e="CSMA_CA" f i l e ="MAC/ csma . p r " s r c="svnSDL" r e v=" " b r a n c h=" t r u n k " t a r g e t=" v e r b o s e " />
9 10 11 12 13 14 15 16 17 18 19 20 21
< ! - - N a m e d m a p p i n g t a r g e t - -> < ! - - E n t r i e s m a y o v e r w r i t e o t h e r e n t r i e s f r o m D e f a u l t m a p p i n g - -> <Mapping t a r g e t=" debug "> <entry s e a r c h=" A p p l i c a t i o n " r e p l a c e="WNCS_Simple" f i l e ="App/ wncs_simple_app . p r " s r c=" g l o b a l D i r " t a r g e t=" debug " /> Config>
interface. Although this should be possible, a final syntax check will normally be done anyways during code generation, in our case by our code generator ConTraST [10]. 5.2
Configuration Files
We will now show in detail how a configuration looks like and how the tool works with a given configuration. For better maintainability, we have defined three configuration levels: system-wide, user-wide and SDL module-specific. System-wide configuration is maintained by the computer system administrator and has the lowest precedence. User-wide configuration is maintained by the developer, and is located in his or her home directory. The SDL module-specific configuration is maintained by the developer of an SDL module and has the highest precedence. The configuration files are written in XML notation for ease of use and flexibility. In List. 1.2, we show a configuration file that can be used for the routing protocol example in Fig. 5. The mapping between a PR file and the respective configuration file is done by following a naming convention, where the name of the configuration file must be «pr-filename».cfg. The first line of the configuration file is for compliance to XML specifications. Next follows a section named Config, encapsulating sections named Global and Mapping. The Global section contains src-entries, specifying multiple data sources where the required SDL modules can be found. The Mapping section consists of entry elements. Each entry element specifies the replacement of a single SDL module.
12
P. Becker and M. Krämer
Listing 1.3. MAC layer configuration 1 2 3 4 5
<s r c name="svnSDL" t y p e=" svn " s r c=" h t t p : // r n s 3 / svn /SDL" b r a n c h=" t r u n k " u s e r=" g u e s t " pwd=" g u e s t " /> Global>
6 7 8 9 10
<Mapping> <entry s e a r c h=" S y n c h r o n i z a t i o n " r e p l a c e="BBS" f i l e =" bbs . p r " s r c="svnSDL" /> <entry s e a r c h=" L o g g e r I F " r e p l a c e=" N u l l L o g g e r " f i l e =" l o g g e r . p r " s r c="svnSDL" />
11 12 13 14 15
<Mapping t a r g e t=" v e r b o s e "> <entry s e a r c h=" L o g g e r I F " r e p l a c e=" V e r b o s e L o g g e r " f i l e =" l o g g e r . p r " t a r g e t=" debug " s r c="svnSDL" /> Config>
Now, we will take a closer look at the two main configuration sections, Global and Mapping: Global: Currently we support two different source types in the Global section, file and svn. Each entry must have at least three attributes: name, type and src. The name attribute identifies the source location and must be unique for the configuration file, but can override entries from user-wide or system-wide configuration files. The type attribute specifies the source type, e.g., file or svn, and src specifies the location of the files. For version control types like svn (subversion [11]), we have defined specific attributes like rev for a version number, branch for the repository branch, as well as user and pwd, which might be needed to log into the version control system. Mapping: Each mapping section optionally specifies its name with the attribute target. There may be at most one unnamed mapping section in a config file, the default mapping section. The mapping target for the main SDL system can be passed to the tool on the command line. If no target is specified, the default mapping is used, else the default mapping is inherited and specialized by the specified mapping target. Inside each Mapping section, entry entries are located. Each entry has at least the four attributes search, replace, file and src. The attributes search and replace each contain the name of a single SDL package. The minimal SDL modules for these packages are automatically determined as described in Sect. 4.1. The search module will be replaced later by the replace module. The new module is located in file, which is found in the referenced data src that was specified in the Global section. Additionally, an entry can overwrite specific attributes of the src definition. An example for this is shown in line 12 of List. 1.2, where another revision and branch are specified for the svnSDL source. Control over the replacement is gathered by the target attribute of entry (cf. line 13). This line chooses the target verbose for MacZ.
SDL Modules – Concepts and Tool Support
13
The complete MAC layer configuration example is shown in List. 1.3. It can be seen that there is a target verbose in the Mapping section which resolves the requested target from List. 1.2, line 13. 5.3
SPaSs Main Substitution Algorithm
The algorithm used for the substitution of the SDL module interfaces by the concrete SDL modules is structured as shown in List. 1.4. The shown substitution algorithm consists of a main() method (lines 1–10) to start the substitution process, and a substitute() method (lines 12–43) that contains the substitution algorithm in a recursive form. Lines 2–5 initialize the variables with arguments given to the tool on the command line. These variables are used for the initial call to the substitute() method in line 7. Finally, the result from the substitution is written to an output file as shown in line 9. The substitute() method first determines which packages from the given set need to be replaced. These packages are determined by reading the mapping entries included in the mapping target section from the given config file (line 16). All packages that will be replaced are then processed in the loop starting at line 20. Here, we first read the mapping entry associated with the current package and target (line 24). This mapping entry is used to read and parse all SDL packages from the replacement PR file (line 27), and perform the recursive substitution process on this new set of packages (line 29). The recursion will stop as soon as the tool processes a PR file where no substitutions are necessary, e.g., because there is no config file for this PR file. In line 33 the original package is removed from the result set of packages, which is then merged with the new set of packages (line 34). As only single packages have been removed from the result set in line 33, there may still exist packages in this set that have no direct or indirect dependency relation to the main unit (which is the main SDL system in the initial method call, cf. lines 3 and 7) and thus can be removed from the set. Therefore, we use the current set of packages included in result to build a new transitive closure for the main unit in line 40 after the foreach loop has finished. Packages that are directly or indirectly referenced by the main unit are included in the new set, all other packages are left out. The resulting set of packages is returned to the caller and, as stated above, written to a file after the substitute() call from the main() method is finished. An example of using SPaSs on a given system and its result is shown in Fig. 6. In Fig. 6 (a), we have a system only consisting of three placeholders, for middleware, MAC layer, and routing protocol, together with the USE statement from the main system. After using SPaSs with the configuration given in List. 1.2, we get the system shown in Fig. 6 (b). Here, the three placeholder packages were replaced with existing, fully specified packages, together with their dependencies. Additionally, the USE statement from the main system was also automatically adjusted to the new system structure.
14
P. Becker and M. Krämer Listing 1.4. Substitution algorithm in pseudo code
1 2 3 4 5
main ( ) { Pack ageSet p a c k a g e s = parsePR ( cmdLine . g e t I n p u t F i l e ( ) ) ; U n it sy stem = p a c k a g e s . getSy stem ( ) ; C o n f i g c f g = getConfigForPR ( cmdLine . g e t I n p u t F i l e ( ) ) ; Target t a r g e t = cmdLine . g e t T a r g e t ( ) ;
6
p a c k a g e s = s u b s t i t u t e ( pack ages , system , c f g , t a r g e t ) ;
7 8
cmdLine . g e t O u t p u t F i l e ( ) . w r i t e ( p a c k a g e s ) ;
9 10
}
11 12 13
s u b s t i t u t e ( Pack ageSet pack ages , Unit mainUnit , C o n f i g c f g , Target t a r g e t ) {
14
// r e a d c o n f i g t o f i n d o u t whi ch p a c k a g e s w i l l be r e p l a c e d Pack ageSet r e p l a c e = p a c k a g e s . getPack age sT o R e pl a ce ( c f g , t a r g e t ) ;
15 16
17
Pack ageSet r e s u l t = p a c k a g e s ; // don ’ t modi f y o r i g i n a l s e t
18 19
foreach ( Unit o l d : r e p l a c e ) {
20 21
// A MappingEntry c o n t a i n s a l l n e c e s s a r y i n f o r m a t i o n // a b o u t t h e e x c h a n g e o f a s i n g l e SDL p a c k a g e MappingEntry me = c f g . getMappingEntry ( old , t a r g e t ) ;
22 23 24
25
// g e t new p a c k a g e s from a s s o c i a t e d PR f i l e Pack ageSet newSet = parsePR (me . g e t F i l e ( ) ) ;
26 27
// r e c u r s i v e s u b s t i t u t i o n i n new p a c k a g e s i f n e c e s s a r y newSet = s u b s t i t u t e ( newSet , me . g e t R e p l a c e ( ) ,
28 29
me . g e t C o n f i g ( ) , me . g e t T a r g e t ( ) ) ;
30 31
33
// merge r e s u l t s from r e c u r s i v e r e s u l t . remove ( o l d ) ;
34
r e s u l t . merge ( newSet ) ;
32
call
}
35 36
// removes a l l p a c k a g e s t h a t have no d i r e c t or i n d i r e c t // dependency r e l a t i o n t o t h e main u n i t ( p a c k a g e or // s y s t e m ) r e s u l t = r e s u l t . b u i l d T r a n s i t i v e C l o s u r e ( mainUnit ) ;
37 38 39 40
41
return resu lt ;
42 43
}
SDL Modules – Concepts and Tool Support USE MiddleWareIF; USE RoutingIF; USE MACIF;
MiddleWareIF MiddleWare emptyProc MACIF MAC emptyProc RoutingIF Routing emptyProc RoutingDevelopment myMAC:MAC x:y myMiddleWare:MiddleWare x:y myRouting:Routing x:y
USE WNCS_MW; USE AODV; USE CSMA_CA; USE CC2420Signals; USE CC2420_Driver; USE SenfPhy; USE O_String;
WNCS_MW MiddleWare ReservationManager StatusManager StatusComm Multiplexer Distributor ConnectionManager RoutingInteraction RequestHook ResponseHook TimeoutHook Multiplexer CSMA_CA MAC PhyComm RTS_CTS ConflictHandling ConflictDetection StatusReaction CalcTimer Multiplexer CalcNAV
(a) System before substitution
15
AODV Routing Multiplexer RoutingStatus RouteDiscovery PacketForwarder CC2420Signals CC2420Driver GenericADTFixed O_String SenfPhy Logger LogIF RoutingDevelopment myMAC : MAC x:y myMiddleWare : MiddleWare x:y myRouting : Routing x:y
(b) System after substitution
Fig. 6. Placeholder system with system structure and main system’s USE statement before and after module substitution using the configuration from List. 1.2
6
Conclusions and Future Work
We have presented a practical approach to structure SDL designs into smaller and reusable SDL modules, and realized the approach based on existing language features. For that, we came up with the concept of SDL modules as units, which are exchangeable if they comply to the same SDL module interface. Since no new language feature was introduced, we realized an SDL module interface as minimal, syntactically complete, but functionally incomplete SDL specification. The SDL module concept allows developers to concentrate on specific small tasks. System designers, on the other hand, can use SDL modules to design structural units on a high abstraction level, independent of the current development status of each module. The introduction of minimal SDL modules allows us to automatically derive SDL modules from a given SDL package, which is then utilized in our SPaSs tool. SPaSs is publicly available for download from our home page [8]. It allows us to easily exchange SDL modules on the SDL package level and thus gives us high flexibility during system development. Via the target concept, known from tools like make [7], the system designer is able to choose which module interfaces are replaced by a specific implementation for the desired target. Using this approach, we have shown a way to provide black box test environments by specifying special SDL modules for simulation purposes.
16
P. Becker and M. Krämer
SDL’s current ability to exchange its structural units could be improved further by adding new language features for the use of interfaces. Currently, there exists no possibility to natively define interfaces in SDL such that SDL units as, e.g., block types have to comply to this interface. What is possible, though, is to declare some of SDL’s type definitions as virtual to specialize or redefine them later, which could be seen as some kind of interface definition. However, using virtual in practice is cumbersome without adding much to our task, so we have refrained from using it. Besides, in SDL inheritance cannot be used on package level, so it is not possible to specify all signals and empty type definitions with a defined interface in one package, inherit from it, and just add redefinitions of the included types. In the future, some improvements to the tool are planned. At the moment it is only capable of replacing SDL units at package level. This ability could be extended to replace other things as well, e.g. signal types. Thus, we can avoid SDL processes whose only purpose is signal type conversion, which may sometimes happen between different design layers. Also, we consider adding an interface checker to the tool that can compare the interface specifications of different SDL modules to check if they comply to the same interface. This could be done by means of special annotations in form of SDL comments that specify to which SDL module interface an SDL module should comply. When exchanging SDLs structural units, we can check if both comply to the same module interface, according to the comments, and also check against the SDL module interface specification to ensure that all required specifications are present. Conditional exchange is also something we are currently considering. Here, module exchange is bound to certain conditions or limited to certain areas of the SDL system. Finally, although SPaSs is written to work with any SDL-PR file and on any (Java-supported [5]) platform, it has so far only been tested with PR code generated by IBM Rational Tau [3] and on Linux.
References 1. International Telecommunication Union: Recommendation Z.100, Specification and Description Language (SDL) (November 2007), http://www.itu.int/rec/T-REC-Z.100/en 2. Ellsberger, J., Hogrefe, D., Sarma, A.: SDL– Formal Object-oriented Language for Communication Systems. Prentice-Hall, Englewood Cliffs (1997) 3. IBM: Rational SDL Suite (2011), http://www-01.ibm.com/software/awdtools/sdlsuite 4. Fliege, I., Geraldy, A., Gotzhein, R., Schaible, P.: A Flexible Micro Protocol Framework. In: Amyot, D., Williams, A.W. (eds.) SAM 2004. LNCS, vol. 3319, pp. 224– 236. Springer, Heidelberg (2005) 5. Oracle Corporation: Java (2011), http://java.sun.com 6. Apache Software Foundation: Maven (2011 ), http://maven.apache.org/ 7. Free Software Foundation, Inc.: GNU Make (2011), http://www.gnu.org/software/make/ 8. Networked Systems Group: SPaSs Tool Home Page (2011), http://vs.cs.uni-kl.de/activities/spass/
SDL Modules – Concepts and Tool Support
17
9. International Telecommunication Union: Recommendation Z.106: Common Interchange Format for SDL (August 2002), http://www.itu.int/rec/T-REC-Z.106/en 10. Fliege, I., Grammes, R., Weber, C.: ConTraST - A Configurable SDL Transpiler and Runtime Environment. In: Gotzhein, R., Reed, R. (eds.) SAM 2006. LNCS, vol. 4320, pp. 216–228. Springer, Heidelberg (2006); Revised Selected Papers 11. Apache Software Foundation: Subversion (2011), http://subversion.apache.org/
A Developer-Friendly Approach for the Validation of Dynamic Compositions Jacqueline Floch1 and Cyril Carrez1,2 1
SINTEF ICT NO-7465 Trondheim, Norway {jacqueline.floch,cyril.carrez}@sintef.no 2 Norwegian University of Science and Technology Department of Telematics NO-7491 Trondheim, Norway
Abstract. A major challenge of dynamic composition is to find ways to model components and analyze their composition in order to guarantee that the composition is free from interaction errors and deadlocks. Existing techniques for validation typically require expert knowledge in formal modelling and reasoning, and do not lend themselves to be used at runtime. However, we find that a coarse-grained description of a composition can be sufficient to ensure the consistency of compositions and to detect potential deadlocks. Our approach requires software developers to specify component models from which the properties needed for validation at runtime can be derived, and to perform some well-formedness and compliancy checks at design time. The new development tasks are integrated in a UML-based development process using concepts that developers are familiar with. The assessment of the approach indicates that developers with ordinary modelling skills are able to detect problems in composition at an early stage, and thereby design safe systems in an efficient manner. Keywords: validation, service modelling, dynamic composition, safe composition.
1
Introduction
The composition of applications and services out of independent, reusable software units is no longer an activity that is solely performed at design time. Composition is increasingly applied at runtime. For example, context-awareness, ubiquitous computing and autonomic computing all require support for dynamic composition, i.e., composition at runtime. A major challenge of dynamic composition is to find ways to model components and analyze their composition in order to guarantee that the composition is safe, i.e., that interaction errors or deadlocks will not occur. Several model checking-based approaches have been developed for the validation of the safety properties of component-based systems [1]. However, these F.A. Kraemer and P. Herrmann (Eds.): SAM 2010, LNCS 6598, pp. 18–35, 2011. c Springer-Verlag Berlin Heidelberg 2011
A Developer-Friendly Approach for the Validation of Dynamic Compositions
19
approaches typically require expert knowledge, and reasoning uses detailed behavioural specifications and is time-consuming. This makes them inadequate for runtime where discovery and assembly should be performed in a time-effective way. In particular cases, e.g., mobile and ubiquitous computing, execution platforms such as handheld mobile devices also set constraints on the size of the runtime component representations and the complexity of algorithms. In this paper, we propose a validation approach for the detection of safety violations in dynamic compositions. The validation algorithms are applied on a set of external component properties: the interface behavioural description and what we call interface dependencies. No detailed component behavioural description is needed, and the complexity of the validation algorithms is either kept low, or applies to small state spaces. The approach requires the software developers to provide component models from which the properties needed for validation can be derived. It also requires the developers to perform some well-formedness and compliancy checks at design time. Therefore, beyond the constraints set by runtime, a major concern in our work has been to provide techniques that are easy to use and understand by developers. To that aim, our techniques are integrated in a UML-based development process and use concepts that developers are familiar with. Our work has been applied and assessed as part of the service engineering framework developed in the SIMS project [2]. The structure of this paper is as follows: in Section 2 we present the concepts and research challenges addressed in our approach. It also provides an overview of the modelling and validation techniques, and introduces a service example that will be revisited in the subsequent sections. Section 3 defines safe service composition. Section 4 is about the validation of pairs of interacting interfaces. It summarizes earlier work essential for the understanding of the validation approach. In particular, we explain the concept of well-formedness and emphasize how avoiding poorly designed interfaces contributes to simplifying validation. Section 5 introduces the concept of interface dependencies, which is the novelty of this paper. Interface dependencies capture the temporal relations between the interfaces of a component, and are used to validate a composition. The section also explains how dependencies are extracted from component behaviours specified by the software developers. Section 6 positions our approach to related work. Finally, Section 7 discusses our results with respect to our two main concerns: developer-friendliness and application at runtime.
2
Concepts, Assumptions and Overall Approach
The proposed validation approach was developed as part of an engineering framework for the modelling and validation of collaborative services [3]. Collaborative services entail collaborations between several autonomous entities that may behave in a proactive manner, meaning that entities may concurrently take initiatives towards each other. This is typical for telecom services, but also for a large class of services such as notification services and ambient intelligence. In the rest
20
J. Floch and C. Carrez
of this paper, we simply use the term service, and we define dynamic composition as the runtime assembly of a set of autonomous entities that collaborate in a service. To facilitate understanding this concept of service, this section introduces a conceptual service model that describes service entities, their properties and relationships between them. We also present the communication scheme adopted in our approach and introduce a service example that illustrates how services are modelled using UML2. Finally we explain the assumptions and research challenges in our work and provide an overall description of our approach.
Composite collaboration
is modelled by
1..* is used in involves
Service
1..*
runs on
is defined in
contains 2
Service role
1..*
1..* 1..*
*
has
Elementary collaboration
is compliant with
can be played by
Computing node
2..*
is used in
2..*
2..*
performs in
references 1..*
plays
Service component
Interface 1..*
has
references
Interface dependency
Fig. 1. Service model
2.1
Conceptual Service Model
The service model adopted in our approach is described in Fig. 1. A service results from the collaboration of several distributed service roles. Service roles collaborate through interfaces. An interface specifies the visible behaviour of a service role at a connection endpoint. Interface dependencies capture the temporal dependencies between the interfaces of a service role. They will be further explained in Section 5. The structure of a service is modelled by a composite collaboration that describes which service roles co-operate in the service and the relationships between them. Composite collaborations are composed of elementary collaborations that describe a co-operation between a pair of interfaces. Elementary collaborations also define which interface takes the initiative to start a co-operation: interfaces are classified as initiating, responding, or both. In [4], we have explained how interfaces and collaborations are enriched with goals and goal sequences in order to provide a high-level semantic description of the intention of the service. These concepts are not included in this paper as they are not relevant for the validation of safety properties. A service component is an implementation entity that realizes a partial service behaviour described by a service role. A service component also realizes a
A Developer-Friendly Approach for the Validation of Dynamic Compositions
21
platform dependent behaviour, e.g., support for binding service role interfaces. The validation approach proposed in this paper focuses on the service behaviour, i.e., it aims at ensuring the safe composition of service roles. 2.2
Communication Scheme
We have adopted asynchronous communication, with message passing semantics. This paradigm supports communication flows in both directions and concurrently and is well suited to realize collaborative services in which service roles execute autonomous behaviours and may take initiative independently. Our validation approach assumes that communication channels maintain the order of messages and do not lose messages. Each service role is associated a set of input ports (one for each interface) with FIFO queues that may retain any number of input messages. 2.3
Service Example
A service example, a travel reservation service, is shown in Fig. 2 to illustrate the concepts introduced in the service model. This example will be modified and extended later in this article when discussing violation of safety properties. As proposed by Sanders et al. [5], our service engineering framework exploits UML2 collaborations to model services. The travel reservation service in Fig. 2 is modelled by a composite collaboration that involves three service roles: Traveller, Hotel and Plane. Elementary collaborations are two-party collaborations between exactly two interfaces. For example, the elementary collaboration ReserveHotel defines two interfaces: iResHotel and iHotel. Composite collaborations are in fact composed of UML2 collaboration uses, where each collaboration use is typed by an elementary collaboration. A service role can be bound to a number of interfaces. One benefit of modelling collaboration between interfaces in separate diagrams is that the specification of elementary collaborations and interfaces can be reused. In addition, as explained later in this paper, validation can be applied incrementally. The detailed behaviour of interfaces is specified using UML state machines, with message passing semantics. Triggers and effects specify respectively a Initiating Interface
iResHotel
TravelReservation rh:ReserveHotel
t: Traveller iResPlane
Service role
rp:ReservePlane
iHotel
h: Hotel p:
iPlane Plane
Collaboration use
Fig. 2. Travel service modelled using collaborations and collaboration uses
22
J. Floch and C. Carrez
signal reception
signal sending
Reference&Dates
iHotel_statemachine VerifyOption
exit condition
/OK
/AvailableRooms /AvailableRooms
Idle
Dates
CheckRooms
ReserveRoom
/Reference
RoomReserved
WaitConfirm Dates
state
Reserve
TakeOption
MakeOpt Reservation
/Reference
Abort
OptionOnRoom
NoRoom
Fig. 3. Interface behaviour modelled using a state machine
reception or a sending of a signal, thus specifying how to interact with the interface. For example, Fig. 3 shows the state machine of the interface iHotel of the elementary collaboration ReserveHotel presented in Fig. 2. The detailed behaviour of service roles is also specified using state machines, with message passing semantics. Ports on which messages are sent or received must be specified. The use of timers and deferred messages (i.e., whose consumption is postponed to a later state) is allowed. Examples of this can be found in [6]. 2.4
Assumptions, Research Challenges and Overall Approach
We distinguish between the specification of a service (defining the service structure, interfaces and goal sequences), the design of service roles and the realization of a service in terms of deployable components. Service execution is realized through the instantiation of components and their dynamic composition. We assume that different stakeholders can contribute to the different activities in service development. This means that service roles in a service might be designed by different parties, and components developed by independent parties. In order to provide such flexibility, and at the same time to guarantee that services execute in a safe manner, we propose to apply a set of validation techniques for checking well-formedness of entities (to remove symptom of errors), compliancy between detailed and abstract specifications, and compatibility between interacting entities. Figure 4 illustrates these techniques and indicates whether they are applied at runtime or not. Note that when a service realisation is completely determined at design time, all techniques can be applied at design time. When components developed by different parties are composed dynamically, validation has to be applied at runtime. The proposed runtime validation techniques are applied during component discovery, i.e., when looking for components that can interact together. When symptoms of errors in a potential composition are detected at runtime, the composition is discarded. Alternative discovered service roles, if any, might be selected. In that way, we ensure that only compatible components are bound together. As illustrated in Fig. 4, two checks are
A Developer-Friendly Approach for the Validation of Dynamic Compositions
Models
Validation
Overall service specification
Composite collaboration
NB. All runtime techniques can also be applied at design time.
Elementary collaboration √
Interface specification
Interface well- formedness √
State machine diagram
Service role specification
Compatibility between interfaces
design time
runtime
√
State machine diagram Compliancy between service role and interfaces Component
Component
role
Composition
23
role Component role
i1
i3
2
i4
Consistency of interface dependencies
design time
runtime
Fig. 4. Overall modelling and validation techniques
applied: checking the compatibility between pairs of interfaces and checking the consistency of interface dependencies in a composition. They will be presented in Section 5. Validation at runtime can be simplified if some of the checks are performed at design time. We require the interfaces to be well-formed and the service roles to be compliant with these interfaces. This will be explained in Section 4. We follow a model-driven engineering approach meaning that: a) models have to be provided by developers, and thus analysis can be naturally applied at design time, b) the runtime system is derived from the design models, and thus compliant to the models. The runtime system includes the models needed for validation at runtime. Note that when a system evolves, new models are provided or existing ones revised; further, as the approach supports modularity, evolution does not require re-modelling of the complete system. In order to simplify, the derivation of the runtime system and associated models is not represented in Fig. 4.
3
Safe Service Composition
Based on the definition of safety properties of Alpern et al. [7], i.e., “bad things that should never happen,” we define a service composition to be safe if no logical errors occur during the collaboration between service roles. We restrict
24
J. Floch and C. Carrez
our validation approach to the avoidance and detection of logical interaction errors. Conflicting non-functional requirements or physical errors (e.g., signal loss, network and node failure) are not considered. We define three kinds of violation of safety properties: – An unspecified signal reception occurs when an interface receives a signal that is not specified as input in the current interface state; – An improper termination occurs between two interfaces when: 1. the interfaces do not terminate in a coordinated manner, e.g., no signal should be sent to an interface that has terminated; or 2. they terminate through different exit conditions; – A deadlock between a set of entities (either interfaces or service roles) occurs when the entities cannot proceed because they wait endlessly for signals from each other. Unspecified signal reception and deadlock are illustrated in Fig. 5. In (a), the Traveller sends a message Hello, which the Hotel cannot process. As this kind of unspecified signal reception is a symptom of error, we require that all signals sent by an interface are explicitly consumed by the complementary interface. In (b), a deadlock between three service roles occurs: they all endlessly wait for each other (possibly for a confirmation, i.e., the Traveller waits for the Hotel to confirm before answering to the Bank ). Such deadlocks can be detected at design time using model-checking when a detailed internal behaviour is available. At run-time where the internal behaviour specification is not available, detecting potential deadlocks in a composition is complex, or not supported.
?? I dont know how to handle that message!
Traveller
Hello
Hotel
Traveller
waiting Hotel circular wait => deadlock
waiting
waiting Bank
a) message not understood
b) deadlock
Fig. 5. Checking for errors in compositions
4
Interface Compatibility and Well-Formedness
Ensuring the consistency of interactions between two service roles is the first validation step when composing service roles. Validation of pairs of interfaces has been addressed in the earlier work of one of the authors [8,9], and similar theory can be found in [10]. The main points of which are repeated here, as they are fundamental for our new contribution.
A Developer-Friendly Approach for the Validation of Dynamic Compositions
25
We say that two interfaces are compatible when their interactions do not lead to any unspecified signal reception, deadlock between them, or improper termination. To check the compatibility of two interfaces, we use reachabilitybased validation algorithms for compatibility checking of state machines [11]. As analysis is applied on small state machines (∼10 states) and with the assumption that signals are not deferred on interfaces, the total number of states is kept low, avoiding state space explosion. In order to prevent poorly designed service roles, we require service roles and interfaces to be designed such that anomalous behaviours are removed. An interface is well-formed if and only if it does not exhibit ambiguous or conflicting behaviours: – Ambiguous behaviours occur when at some stage of the behaviour an external observer cannot detect what next behaviour might happen. Ambiguous behaviours typically result from an internal choice in a service role or behaviours triggered by interactions on other interfaces of the service role. Unspecified signal reception or improper termination might occur, as the interface behaviour is not predictable; – Conflicting behaviours occur in the case where two interacting state machines simultaneously take an initiative to send, and the initiated behaviours diverge. For instance in Fig. 6, the state FrequentTraveller can both send and receive an event. To be well-behaved, the successor state MakeOptReservation must be input consistent with the state FrequentTraveller, i.e., it must be able to receive the same events. Otherwise a deadlock might occur, the machine being waiting for Confirm.
iPlane_statemachine (with conflict) Idle
Reference& Dates
Frequent Traveller
/Available Flights
Confirm
MakeOpt Reservation Cancel
mixed initiative state
Cancel
CancelRoom
MakeOpt Reservation
/Reference
conflict detection
/CancelACK
conflict resolution
Fig. 6. Conflicting behaviours
The enforcement of well-formedness rules out special cases of behaviour, allowing a simplified algorithm for compatibility checking [8]. To support the developer, our approach includes the set of design rules and algorithms for checking well-formedness also proposed in [8]. As demonstrated by the development of case studies in SIMS [12], the design rules do not restrict the possibilities to make useful designs. While checking the well-formedness of interfaces is performed at design time, checking the compatibility of two interfaces can be applied at runtime. Interface compatibility only guarantees consistency of interactions between pairs of service
26
J. Floch and C. Carrez
roles if the interfaces truly represent the behaviours of the service roles. To ensure compliancy between service roles and the specified interfaces, we apply the projection technique of [9] to service roles, and check that extracted behaviours are equivalent to the specified interfaces. Checking the compliancy of service roles and the specified interfaces is performed at design time.
5
Interface Dependencies and Safe Composition
Interface compatibility as described in the previous section does not by itself guarantee that a service composition is safe. As service roles might collaborate through multiple interfaces with other service roles, we need to check that service roles coordinate their collaborations on interfaces consistently, and that no deadlock (as illustrated in Fig. 5b) can happen between these service roles. To that end, we introduce the concept of interface dependencies that capture the temporal relations between interfaces. 5.1
Interface Dependency Types
We distinguish between three types of dependency between interfaces provided by a service role: – Two interfaces are in sequence, noted I1 → I2 , when their behaviours are sequenced: I2 is executed just after I1 . A sequence can be annotated with an exit condition, noted I1 → I1 Exit1 I2 , meaning I2 starts only if I1 terminated with condition I1 Exit1 ; – Two interfaces are interdependent, noted I1 ↔ I2 , when one interface is, at one point of its behaviour, waiting for an action to happen on the other interface; – Two interfaces are in parallel, noted I1 I2 , when the interfaces depend neither on an action nor on the termination of the other interface. While the first type enforces behaviour ordering, the two others support simultaneous behaviours on interfaces. These three types are illustrated in Fig. 7 for the service role Traveller that was introduced in Fig. 2. As will be explained in Section 5.3, the two kinds of check needed to validate a composition require differentiation between sequence and interdependency. Beyond interface dependencies internal to a service role, we introduce a dependency to represent the external interaction between two interfaces: an external dependency, noted I1 <−−> I2 , occurs when I1 and I2 take part in the same elementary collaboration. 5.2
Dependency Graph
In order to validate the safety of a service composition, we check the consistency of interface dependencies among the service roles involved in the composition. To do so, we build a model that represents the relations between the different
A Developer-Friendly Approach for the Validation of Dynamic Compositions
iResHotel
iResHotel
iResHotel
iResPlane
iResPlane
iResPlane
iResHotel Travel Agency iResPlane
1. Check Room Avail. 2. Reserve Room 3. Check Seat Avail. 4. Reserve Seat
iResHotel Travel Agency iResPlane
TravelAgency first interacts with the Hotel, and then with the Plane.
a) Sequence
1. Check Room Avail. 3a. Reserve Room
iResHotel Travel Agency
2. Check Seat Avail. 3b. Reserve Seat
iResPlane
27
a. Check Room Avail. b. Reserve Room A. Check Seat Avail. B. Reserve Seat
TravelAgency pauses the interaction with Hotel to check seats with Plane.
TravelAgency interacts with the Hotel and the Plane in parallel, with no pause during the interaction.
b) Interdependency
c) Parallel
Fig. 7. Interface dependencies
interfaces. This model, the composition dependency graph, is a directed graph which represents all the dependencies between the semantic interfaces present in the composition. Figure 8 shows an example of a dependency graph for a service composition involving two service roles, Traveller and TravelAgency. These two service roles sequence their interfaces. Initiating interfaces in the dependency graph are annotated with an arrow. Note that this is a property of the interface, not a property of the external dependency (i.e., this arrow does not represent any direction in the graph).
iResHotel
ReserveHotel
Traveller ReservePlane iResPlane dependencies
iHotel Travel Agency iPlane
Dependency graph
External dependency
iResHotel
iHotel
iResPlane
iPlane
dependencies
iResHotel
iHotel
iResPlane
iPlane
a) Semantic interface dependencies
b) Dependency graph
Fig. 8. Dependency graph
5.3
Validating Service Compositions
We assume that interacting interfaces are compatible; this can be ensured using the techniques described in Section 4. Thus, there are two cases that introduce safety violations. The first case occurs when interfaces do not start interacting in a coordinated way, e.g., one interface sends an event to an interface that is not yet active, leading to unspecified signal reception. This happens when the service roles do not sequence their interfaces consistently. The second case
28
J. Floch and C. Carrez
occurs when service roles wait for each other to send a message, hence producing a deadlock. This situation happens when an interface interaction, inside a service role, is unable to proceed because the service role is waiting for some event to happen on another interface. In the following we present techniques for detecting these two cases. When detected at runtime, symptoms of errors can hardly be corrected. Using our approach, the composition is discarded, and alternative service roles, if any were discovered, are considered. Checking Interface Sequences between Two Service Roles. When two service roles collaborate in a service, they should coordinate their interfaces such that they start consistently. Interface dependencies are used to check that semantic interfaces are sequenced in a safe manner: – Two collaborating service roles should sequence their connected interfaces in the same order, and with the same exit conditions (if there is any); – Assume a sequence A → B where B is responding: Then the connected interfaces A and B should be in the same service role and follow the same sequence; – All interfaces following a choice (i.e., an internal decision) must be initiating, and the connected interfaces must start in parallel. Indeed checking the interface sequences is similar to checking the consistency of state machines. Each interface is as a state in a state machine and thus the check applies on composite state machines. The same consistency rules apply as on “elementary” state machines [6]. The first condition above is already illustrated in Fig. 8: Traveller and TravelAgency sequence the interfaces in the same order. Note that in this case, the termination of each interface in the first elementary collaboration can be observed from both sides. There is no restriction on the initiating or responding property of the second interface. The second condition is exemplified in Fig. 9. In (a), the service role Traveller is sequencing iResHotel and iResPlane, with iResPlane being responding; the service role is connected to two service roles Hotel and Plane. We observe that Plane is not sequencing the interfaces in the same manner as Traveller : iPlane might send the first message while iResPlane has not started yet. In (b), Traveller differs with iResPlane taking initiative, meaning that Traveller informs Plane that the interaction can start. The third condition, i.e., with the internal choice, is illustrated in Fig. 9 (c): the Traveller decides which transportation mode to use, with the corresponding interfaces iResTrain and iResPlane being initiating. The TravelAgency needs to start the complementary interfaces in parallel, to be able to honour the choice of the Traveller. Ensuring Deadlock-Freedom. Ensuring deadlock freedom is not a trivial task. We exploit the formal results developed earlier by one of the authors [13]: a
A Developer-Friendly Approach for the Validation of Dynamic Compositions
29
Internal choice: Traveller decides on transportation mode. Traveller
Hotel
Traveller
Hotel
Traveller
TravelAgency
iResHotel
iHotel
iResHotel
iHotel
iResHotel
iHotel
iResPlane
iPlane
iResPlane
iPlane
iResTrain
iResPlane
iPlane
||
iTrain
Plane
Plane iResPlane is responding, an error may occur.
iResPlane is initiating
(a) X
(b) √
TravelAgency must be able to receive any message from iTrain or iPlane
(c) √
Fig. 9. Checking sequences of interfaces
configuration of components that expose non-reentrant server ports is deadlockfree if those server ports are not involved in a cycle in a (port) dependency graph. Based on this constraint, we require that: – The dependency graph of a configuration of service roles should not contain cycles that involve external dependencies. As the dependency graph indicates which interface potentially waits for another, a cycle in the graph is a characterization that a deadlock may occur. However a cycle in the dependency graph of a composition does not necessarily mean that a composition has a deadlock. Our constraint might, of course, rule out service compositions that actually do not have any deadlocks, but validation of such compositions requires more detailed specifications than the description of interface dependencies that we propose to exploit at runtime. At a first glance, as it is quite common that interfaces of a service role wait for each other, one may think that the occurrence of a cycle in a dependency graph is frequent. However one must recall that such interdependent interfaces are often connected to interfaces of different and independent (i.e., non-interacting) service roles, meaning that the interdependency in such common cases does not lead to a cycle in the dependency graph. Note that the cycle in the dependency graph does not take into account if an interface is initiating or responding. Indeed, the deadlock might occur in the middle of the behaviour of an interface, so which side initiated the interaction has little consequence. One may argue that the interdependency relation is itself a cycle. However, as we assume that the analysis of service roles and interfaces has been applied (see Section 4), interaction between the two interdependent interfaces is deadlock free. Thus, the interdependency relation is not a cycle. Figure 10 illustrates cycles in the composition dependency graph. In (a), the Traveler and the TravelAgency have interdependent interfaces, thus resulting in a cycle when the service roles are connected; indeed the Traveler might wait for a confirmation of a room before confirming the seat, while the TravelAgency might want the opposite confirmation (first the seat, then the room). In (b),
30
J. Floch and C. Carrez
although the Traveler is sequencing the semantic interfaces, a cycle remains. Indeed, iHotel may wait for iPlane to receive an answer from iResPlane, which has not started yet. In both cases, the composition should be ruled out and search for other service roles should take place. For instance, in case (b) a TravelAgency that sequences the interfaces in the same order can be used, or in cases (a) and (b) two separate service roles, one realizing iHotel and the other iPlane can be used. Traveller
TravelAgency
Traveller
TravelAgency
iResHotel
iHotel
iResHotel
iHotel
iResPlane
iPlane
iResPlane
iPlane
(a)
(b)
Fig. 10. Cycle in a composition dependency graph
The size of the dependency graph is normally kept small, as its nodes represent only the interfaces of the system. Moreover, the complexity of finding a cycle in a directed graph is in linear time of O(V+E), with V the number of nodes (i.e., interfaces) and E the number of edges (i.e., dependencies) [14]. For example, the meeting place service developed in SIMS [15] has 4 service roles and 20 semantic interfaces. This is representative of a specification of a typical service. The algorithm can however also be applied to much larger systems without introducing state explosion. 5.4
Extracting Interface Dependencies from Service Role Specifications
Interface dependencies need not be provided by the developer, but can be extracted automatically from the service role behaviour. Service roles are first analysed to find when they start and stop interacting through interfaces. A service role starts to interact through an interface as soon as it sends, receives or defers a signal of that interface. The following algorithm is used to extract interdependencies: /* Assume interfaces sequences have been identified */ For all interfaces I of the service role S: Between the start and the stop of I, for each state s: - if some signals from I are deferred; or - if no reception for I takes place at that state, Then I has an interdependency with all the interfaces that involve a reception at state s. For all interfaces I, J of S with I!= J: - if no dependency exists between I and J, then I and J are in parallel.
A Developer-Friendly Approach for the Validation of Dynamic Compositions iTravel
iResPlane
iResTrain
1
1
1
BookTravel / NOK
2
/ BookPlane
/OK
exit1
p_NOK
2
exitP1
exit2
31
/ BookTrain
p_OK
2
t_NOK
t_OK
exitT1
exitP2
exitT2
Fig. 11. Simple semantic interfaces used as examples to extract interface dependencies
TravelAgency1 Start of iTravel & iResPlane
Stop of iTravel & iResPlane
1 BookTravel / BookPlane
iTravel is not active, and iResPlane receives some signals: interdependency
2
p_NOK / NOK
p_OK / OK
dependencies iResPlane
iTravel
TravelAgency2 1
BookTravel / OK / BookPlane p_NOK
2
/ BookTrain t_NOK
p_OK
exitP1 exitP2 The service role stops with dependencies exit2 and chooses to start exit2 iResPlane or iResTrain iTravel (internal decision)
a)
BookTravel / NOK exit1
3
exitT1
t_OK exitT2
iResPlane iResTrain
b)
Fig. 12. Extracting interface interdependency
To illustrate this algorithm, we define three interfaces that we exploit below in different service role specifications. The interfaces are shown on Fig. 11. Figure 12 (a) illustrates a service role with interdependent interfaces. In state 2, between the start and the stop of iTravel, no action involving iTravel is performed, and iResPlane receives some signals: we deduce that iTravel and iResPlane are interdependent. Figure 12 (b) illustrates sequences of interfaces. The service role starts with interface iTravel. After sending OK (i.e., interaction on iTravel is then finished), the service role reaches an internal choice to start iResPlane or iResTrain. The equivalent exit condition is extracted (exit2 ). This gives the dependencies shown at the bottom.
6
Related Work
Similarly to us, the authors of [16] propose a service engineering framework that exploits UML2 collaborations for specifying the service structural properties. Instead of state machines, they use UML2 activities for describing the collaborative composition behaviours. As semantic foundation to reason about the correctness of specifications, they formalize collaborations using cTLA (compositional Temporal Logic of Actions) [17]. The approach allows for incremental verification of systems. The authors solely address verification at design time.
32
J. Floch and C. Carrez
Proving the absence of deadlock when assembling components is a difficult task. Deadlock avoidance is undecidable, as this problem is similar to the halting problem of Turing machines. Most of the approaches make use of dependency cycles and locks on resources, for instance in [18], but those approaches are often based on a deep analysis of the software, and are hard to use at runtime. In our work, we have aimed at detecting deadlock using a coarse-grained description of the composition of the service. As a consequence, our approach can be applied to any composition, even though it is at the price of ruling out configurations that possibly will not deadlock. Concerning the runtime verification of sound compositions, the approaches of recent works are often based on runtime monitoring of properties [19,20]. The components (or Web Services, depending on the approach) are monitored at runtime according to a predefined specification. Our approach is preventive, i.e., we aim at avoiding errors and thus validate components before they are assembled, while monitoring approaches are corrective, i.e., verify that running and bound components behave according to the specification and potentially correct detected errors. Several other approaches have also been developed for web services such as those described in [21,22]. Web services focus on consumer-provider services. Our component model differs as we allow components to coordinate their behaviour in a collaborative manner. The work closest to our idea of interface dependencies is, to our knowledge, the one of [23]. The authors have the interesting approach to specify compositions using Open Petri Nets (i.e., Petri Nets extended with input and output places). They are able to detect deadlock configurations. However, their work is focused on service trees, where components may invoke other components and wait for their answer, hence producing a service tree. Our component model is more flexible, as we allow components to coordinate their behaviour in a collaborative manner. This permits more complex composition patterns, and thus a larger scope of service composition.
7
Discussion and Conclusion
One first concern has been to provide techniques that do not require knowledge of formal methods, and are easy to use and understand by ordinary developers. The assessment of our framework was undertaken through the development of a trial service by a telecom software vendor in the SIMS project [12]. None in the assessment team had prior knowledge of the theory developed in SIMS. The team was given the development guidelines developed within the project [6], in addition to a one-day introduction course and on-site support from one of the technology providers the first two days. The members consisted of an experienced software engineer (leader), an experienced developer with strength in programming (not modelling), and two juniors in their last year of MSc study, both eager programmers. With respect to our first concern on friendliness, some of the main conclusions from this experiment are:
A Developer-Friendly Approach for the Validation of Dynamic Compositions
33
– The proposed use of UML2 is simple; designers with some experience of using UML and state machines found it easy to use for modelling the service. – The design rules associated to the validation approach were not found restrictive and did not make the design of the service more complex. – The support provided to identify errors concerning mixed initiatives was useful. Despite the simple service design, logical errors were nonetheless made in the design. The approach makes it easy to identify such easy-to-commit design errors and to eliminate them at early design stages. Although the assessment was limited to a single organisation over a short period of time (with a total effort of 835 hours), it indicates positive results regarding the usability and usefulness of the methods for modelling and validation. The second concern in our work to has been to provide validation techniques that can be applied at runtime. As the tools for extracting interface dependencies were not available at the time of assessment, the validation techniques were assessed through prototyping. However we argue that the analysis performed at design time, i.e., ensuring the well-formedness of interfaces and the compliancy between service roles and their interfaces, contributes to reduce and simplify the analysis at runtime. The risk of state explosion is avoided by 1) decomposing the system into small entities that can be checked using simple algorithms, 2) applying consistency checking on pairs of interfaces represented by state machines of small size and 3) checking the consistency of compositions using a linear algorithm for the detection of cycles in a graph. As the complexity of the analysis is kept small, the approach is well-suited for validation during the discovery of components: validation can be applied to alternative potential components in a composition, allowing the discovery mechanisms to discard components for which the composition is not safe. A drawback of the approach is that correct compositions might be ruled out. In future work, we plan to refine the interdependency relation such that it is possible to express which interface is waiting for the other. If only one interface has to wait for the other, there is no need to indicate a two-way dependency between interfaces. Thus a cycle currently inferred by a two-way relation might disappear if that relation is replaced by a one-way relation. Acknowledgement. Our research has been performed in the project SIMS supported by the EU IST 6th framework programme. The Norwegian project UbiCompForAll and the EU IST project SHAPE have supported us in writing this paper. We would like to thank Dr. Richard Sanders for encouraging and thorough comments.
References 1. Baier, C., Katoen, J.-P.: Principles of Model Checking. MIT Press, Cambridge (2008) 2. Floch, J., Carrez, C., Cie´slak, P., R´ oj, M., Sanders, R.T., Shiaa, M.M.: A Comprehensive Engineering Framework for Guaranteeing Component Compatibility. Journal of Systems and Software 83(10), 1759–1779 (2010)
34
J. Floch and C. Carrez
3. Floch, J., Sanders, R.T., Bræk, R.: Compositional Service Engineering using Semantic Interfaces. In: di Nitto, E., Sassen, E., Traverso, P., Zwegers, A. (eds.) At Your Service: Service-Oriented Computing from an EU Perspective, pp. 101–128. MIT Press, Cambridge (2009) 4. Carrez, C., Floch, J., Sanders, R.T.: Describing Component Collaboration Using Goal Sequences. In: Meier, R., Terzis, S. (eds.) DAIS 2008. LNCS, vol. 5053, pp. 16–29. Springer, Heidelberg (2008) 5. Sanders, R.T., Castej´ on, H.N., Kraemer, F.A., Bræk, R.: Using UML 2.0 Collaborations for Compositional Service Specification. In: Briand, L.C., Williams, C. (eds.) MoDELS 2005. LNCS, vol. 3713, pp. 460–475. Springer, Heidelberg (2005) 6. Carrez, C. (ed.): SIMS Deliverable D2.3, SIMS Principles and Techniques for Service Engineering (2008), www.ist-sims.org 7. Alpern, B., Schneider, F.: Recognizing Safety and Liveness. Journal of Distributed Computing 2, 117–126 (1987) 8. Floch, J.: Towards Plug-and-Play Services: Design and Validation using Roles. Dr. Ing thesis. Norwegian University of Science and Technology (2003) 9. Floch, J., Bræk, R.: Using Projections for the Detection of Anomalous Behaviours. In: Reed, R., Reed, J. (eds.) SDL 2003. LNCS, vol. 2708, pp. 251–268. Springer, Heidelberg (2003) 10. Carrez, C., Fantechi, A., Najm, E.: Assembling components with Behavioural Contracts. Annales des Telecommunications 60(7-8), 989–1022 (2005) 11. Holzmann, G.J.: Design and Validation of Computer Protocols. Prentice-Hall, Englewood Cliffs (1991) 12. Shiaa, M.M. (ed.): SIMS Deliverable D6.5, Trial Services, final version (2008), www.ist-sims.org 13. Carrez, C.: Contrats Comportementaux pour Composants. Doctoral Thesis, ENST (2003) 14. Tarjan, T.: Depth-First Search and Linear Graph Algorithms. SIAM Journal on Computing 1(2), 146–160 (1972) 15. Sanders, R.T., Meland, P.H. (eds.): SIMS Deliverable D1.2, Scenarios and Requirements for Methods, Tools and Middleware - final version (2007), www.ist-sims.org 16. Kraemer, F.A., Sl˚ atten, V., Herrmann, P.: Tool Support for Rapid Composition, Analysis and Implementation of Reactive Services. Journal of Systems and Software 82(12), 2068–2080 (2009) 17. Herrmann, P., Krumm, H.: A Framework for Modelling Transfer Protocols. Computer Networks 34(2), 317–337 (2002) 18. Nir-Buchbinder, Y., Tzoref, R., Ur, S.: Deadlocks: From Exhibiting to Healing. In: Leucker, M. (ed.) RV 2008. LNCS, vol. 5289, pp. 104–118. Springer, Heidelberg (2008) 19. Baresi, L., Bianculli, D., Guinea, S., Spoletini, P.: Keep It Small, Keep It Real: Efficient Run-Time Verification of Web Service Compositions. In: Lee, D., Lopes, A., Poetzsch-Heffter, A. (eds.) FMOODS 2009. LNCS, vol. 5522, pp. 26–40. Springer, Heidelberg (2009) 20. Dong, W., Leucker, M., Schallhart, C.: Impartial Anticipation in RuntimeVerification. In: Cha, S(S.), Choi, J.-Y., Kim, M., Lee, I., Viswanathan, M. (eds.) ATVA 2008. LNCS, vol. 5311, pp. 386–396. Springer, Heidelberg (2008) 21. Narayanan, S., McIlraith, S.A.: Simulation, Verification and Automated Composition of Web Services. In: Proceedings of the 11th International Conference on World Wide Web, pp. 77–88. ACM, New York (2002)
A Developer-Friendly Approach for the Validation of Dynamic Compositions
35
22. Ding, J., Zhu, H., Zhu, H., Li, Q.: Formal Modeling and Verifications of Deadlock Prevention Solutions in Web Service Oriented System. In: Proceedings of 17th IEEE International Conference and Workshops on the Engineering of ComputerBased Systems, pp. 335–343. IEEE, Los Alamitos (2010) 23. van der Aalst, W.M.P., van Hee, K.M., Massuthe, P., Sidorova, N., van der Werf, J.M.: Compositional Service Trees. In: Franceschinis, G., Wolf, K. (eds.) PETRI NETS 2009. LNCS, vol. 5606, pp. 283–302. Springer, Heidelberg (2009)
From Flow-Global Choreography to Component Types Surya Bahadur Kathayat and Rolv Bræk Norwegian University of Science and Technology, Department of Telematics, N-7491 Trondheim, Norway {surya,rolv.braek}@item.ntnu.no
Abstract. The need for global behavior definitions is well established both in the domain of embedded reactive systems and service-oriented (business) systems. The problem has been to define the global behavior with sufficient, rigor and completeness to fully cover the intended behavior and not just some scenarios, and to enable automatic synthesis of component behaviors in practical systems and service development. In this paper we build on previous work where UML collaborations are used to structure systems and services into reusable building blocks, and UML activities to model global behavior, called choreography in the following. We identify two forms of choreography: one where all flows are localized to the roles participating in collaborations and another where the flows are not localized and thus more abstract. We propose a novel approach to map the flow-global choreography to a flow-localized choreography and further to distributed component behaviors (orchestrations) with well-defined interfaces from which implementation code can be generated using existing techniques. The overall approach combines the merits of global choreographies and collaborative building blocks with the flexibility of component-oriented designs. The approach is illustrated using a city guiding system as case study. Keywords: Service choreography, component design, model-driven development.
1
Introduction
In reactive as well as in business systems there is a need to define global collaborative behavior as well as local component behavior. We use the term choreography to denote global collaborative behavior involving two or more participants, in contrast to orchestration that denotes the local behavior of each participant. Choreography is needed to define and analyze the overall service behavior, whereas the orchestration is needed to completely define component behaviors for implementation. These terms come from the domain of business services and SOA and are in accordance with common use in that domain, see, for instance [1]. Ideally, the choreography should be sufficiently precise and complete that component behaviors can be automatically synthesized. This would enable the service engineer to work mainly on the level of choreography, focusing on the F.A. Kraemer and P. Herrmann (Eds.): SAM 2010, LNCS 6598, pp. 36–55, 2011. c Springer-Verlag Berlin Heidelberg 2011
From Flow-Global Choreography to Component Types
Service Library
City Guide Service act
Re-plan p ::lead :l le er
37
City guide service
st:Start tour
Start tour :grp
:usr srr
:user
:serve r
poi :poi
:grp
grp
nm:Next move
poi
grp grp
Compose
q:Quiz
pu:Position update
Analyze
Localize
Global Structure & Flow-Global Choreography
cp:Connect poi grp
grp
usr usr
:svr :sv vr
:gr :grp :g grp p
usr
Analyze Localize ARCTIS SUPPORT
act C City ity guide ide service servi rvice oup p qui quiz q z act Group user use u ser qqs:Question qs: sQ Que Qu u ue est sti s ttiion ion on g grrp grp rp leader llea le eader e der
Re-plan Re plan Start S a tour ou
::lead :l le er
{{us us u ser} errr}} e {user} sugg sugg
:serve r
:grp
:usr srr
S
:svr :sv vr
:gr :grp :g grp p
{{llle eader} d } {leader} submit s t
s.i.in s.i niit nit it s.init s.w wins ns s.wins
p iniiitt p.i p.init
MI MIS M ISS IS MISS
P
p wins s p.wins
Flow-Localized Choreography
p wins p.wi p.w ins s p.wins
Compose ssg g:Sug Sugg sg:Sugg
grrp grp g rp
user ss:Show sss:Show le eade der d e er leader su sug su ug gg sugg
grrp p grp
use user
leader lea lle ead ea de der e err sb:Submit sb: sb s b b::Submiit grp
Analyze Analyze, Resolve
Synthesize Synthesize
Component Library «system» City Guide System
«ComponentType» Group u
3.s3
g
«ComponentType» User
u u
g
4.s4
c
g
5.s5
p
c[1]: CGS
Orchestration 1:S1 2:s2
g c
Compose
u[*]: User
g[+]: g[ g [+]: G p Group
p[+]: POI
Fig. 1. Overview of the proposed approach
intended global behavior, and not the detailed component behavior. For this to be possible, one needs suitable building blocks and composition mechanisms for defining the intended global behavior completely and precisely, and one needs a systematic way to go from global behavior to distributed local behaviors such that all the coordination problems of distributed realizations are properly handled. UML collaborations provide a structural framework to do this. They define a structure of participating roles where collaborations taking place among the roles may be represented as collaboration uses referring to separately defined collaborations with associated behavior. We distinguish between elementary collaborations that are not further decomposed into collaboration uses, and composite collaborations. In this paper we use UML activity diagrams for the choreography of both elementary collaborations and composite collaborations as well as for orchestration. Motivation for this choice and comparison with alternatives such as sequence diagrams and interaction overview diagrams is given in Sect. 6. Notation and semantics are in accordance with the UML definition except for a small notational addition that will be explained. The overall approach we address in this paper is illustrated in Fig. 1.
38
S.B. Kathayat and R. Bræk
– Flow-global choreography is used to define the intended global behavior of composite collaborations on a high level of abstraction avoiding details of localization and resolution of coordination problems that may occur at the level of orchestration. The behavior is defined by an activity diagram connecting actions by flows that are not localized to any particular role. Actions may either represent the behavior of a collaboration or a local activity. This is the right level for discussing the intended behavior with end-users and other stakeholders. It is also a useful first step in the formalization of requirements. – Flow-localized choreography is used to define global behavior in sufficient detail to allow extensive analysis and to automatically synthesize the behavior of component types providing orchestration. The behavior is defined by an activity diagram connecting actions, that either represent the behavior of a collaboration or a local activity, by flows that are localized to the roles. – Component types define the local activity flow, the orchestration, of each component. They are derived using a projection of the flow-localized choreography to include only local actions performed by the component. Information about the collaborations it participates in and the ordering imposed by external activity flows are retained in order to support automatic realization as well as compatibility checks during subsequent composition of components into working systems. Tool support for parts of this approach is provided by Arctis [2], as indicated by the grey area in Fig. 1. It enables compositional development of reactive systems where building blocks representing collaborative behavior are defined separately using the “swim-lane” like notation for UML activity diagrams, put into libraries, and then composed in different ways. The Arctis tool provides extensive support on the flow-localized choreography level. It supports model checking and can synthesize complete system behavior in the form of communicating state machines that are automatically implemented using code generation. In this paper, we elaborate on the parts not supported by Arctis, i.e., the flow-global choreography, the mapping to a flow-localized choreography and the derivation of component types that may be used in subsequent system composition. When deriving component types it is necessary to detect and resolve the realizability problems that may occur. When a choreography is mapped to a composition of component behaviors and the global behavior emerging from the composition differs from the global behavior specified in the choreography, we say there is a realizability problem. It may for instance happen that messages are received in a different order than specified or that additional messages are needed to ensure the specified ordering. Realizability problems have been extensively studied in the context of interaction diagrams where they sometimes are referred to as implied scenarios or races. Similar realization problems may also occur when activity diagrams are used, and are therefore discussed in this paper. In the domain of embedded, reactive systems, components will often be linked to physical objects like users with autonomous behavior that may take independent initiatives needing to be coordinated and resolved. In business systems it is more common that services are provided by passive components that only
From Flow-Global Choreography to Component Types
39
respond to requests, and never take autonomous initiatives. This is, however, gradually changing with services becoming more pro-active and “pushing.” Dealing with mixed initiatives is therefore one of the fundamental coordination problems to be addressed in distributed reactive service systems. We therefore consider the case where components in general may be active and take independent initiatives either triggered by user actions, time or other events. In our approach we seek to identify all such problems and to resolve them either in the choreography or the orchestration. The rest of the paper is structured as follows: A case study is introduced in Sect. 2 and used throughout the paper to illustrate our approach. Section 3, 4, and 5 describe our proposed approach for the choreography representation, flow-localization and component design, respectively. Related work is discussed in Sect. 6. Finally, concluding remarks are given in Sect. 7.
2
Service Structure
We illustrate our approach using a city guide service example, which has been implemented in previous work [3, 4]. It is a complex and challenging example, and therefore provides a realistic basis for evaluation. The users are students that have just arrived in a city and want to learn about different places of interest. They use GPS enabled hand held devices and may create profiles specifying their preferences and interests. Based on their locations and profile information, the users participate in different groups and social activities. For instance, when a user is trying to find a particular point of interest (e.g., a historic building), the user may interact with other users having similar interests. Users may have a peer-to-peer chat, group chat and discussions. When users are in the vicinity of a point-of-interest (POI), they may participate in a group quiz provided by a particular POI. Fig. 2 shows the city guide service as a UML collaboration with four different roles that will map to corresponding component types: the user role that represents a user of the system; the group role that represents a group of users and support group functionalities; the poi role that represents a point-of-interest and provide quizzes and finally, the cgs role (city guide manager) that provides a guided tour to the users. A number of collaborations uses represent sub-services that are defined separately: – Start tour performs the tour initiation triggered by the lead user. It has two roles: leadr that is bound to user and grp bound to group. – Get plan fetches a plan which is a list of points of interests. – Re-planning is a composite activity that stores the plan and allows the lead user to re-plan for the group (details are not discussed in this paper). – Position update is used to continuously update the current position as users are moving. – Connect poi will inform the POI to initiate a Quiz session with the group. – Group quiz performs a quiz session where each group member may suggest answers and the lead user may submit an answer.
40
S.B. Kathayat and R. Bræk
Cityy Guide Service act
City guide service
st:Start tour
leaderr user,leader aderr :user[*] leader
user,leader user,leader
user,leader
gq:Group quiz nm:Next n nm m:N :Nex ex xt xt m move pu:P pu:Position on update up u pdate p e
cp:Connect cp p:Con onne nect ctt poi poi gp gr grp grp gr p grp grp
grp p
grp
:group[*] :g :gro gro oup[*] o p ] p[
poii p po grp
q:Quiz q:Qu q: Quiz iz
p i poi :poi[*] :p poi[*
grp
grp p grp gr rp
gp:Get plan
et:End tour e cgs cgs rp:Re-planning lann niing ning
:cgs[1] :cg g gs[1
Fig. 2. Roles and sub-collaborations in a City guide service
– Tour manager manages the city guide tour. It holds a plan in the form of a list of POIs. It provides the next POI to be located when a current POI is finished. – Proximity detector checks if the users (using their positions) in a group are within a defined proximity of a POI and initiate Connect poi when this is the case. We assume that the behavior of each of these collaborations is defined by an activity diagram having the same name as the collaboration. For example, the activity diagram for the Position update collaboration is shown in Fig. 3(a) using flow-localized choreography. Such diagrams are easily derived from corresponding sequence diagrams, if one is starting from a set of sequence diagrams rather than activity diagrams. Each collaboration encapsulate interactions across an interface between two or more participating roles and is used as a collaborative building block in the following. They are referenced by the actions nodes in a choreography model (discussed in Sect. 3) according to the notation given in Fig. 3(b).
3
Flow-Global Choreography Models
The flow-global choreography defines the desired global execution ordering of collaboration uses in a composite collaboration. For example, the flow-global choreography of the City Guide service is shown in Fig. 4 using UML activity diagrams.
From Flow-Global Choreography to Component Types
Position Update Collaboration grp role
user role
41
notation for collaborative action
start stopUpdate
getPos :Position
stop
starting pin
streaming input pin
stopped
role t
streaming output pin
updatePos :Position position
(a)
service name
terminating pin
alternative starting pin
role alternative terminating pin
(b)
Fig. 3. Elementary service model and Service notation used in choreography
All actions in the diagram call activities defined separately. The called activities are either local to a role called local activities (here the prox. detector and tour manager) or defining the choreography of a collaboration (the rest). For example, the start tour action st.Start tour and the position update action pu.Position update in Fig. 4 call the activity given for the st:Start tour and pu:Position update collaborations in Fig. 2 respectively. In this way, the diagram defines the choreography of, possibly nested, collaboration behaviors. The gq.Group quiz call behavior action calls the group quiz activity represented in Fig. 5. Note that the participating roles of collaborations are indicated by partitions defined by solid lines in the action symbols. The initiating and terminating roles of the collaborations are indicated using dots and squares, respectively. This (dot and square) notation is not part of UML, but may be provided by additional profiling. An action can have all the different types of pins that UML allows, such as initiating, streaming and terminating pins. An initiating pin will start the called activity if it is not started yet. Terminating pins will terminate the called activity. Streaming pins can pass tokens while the called activity is active, i.e., a flow between two actions connected by streaming pins allows the called activities to interact without being stopped. For example, the streaming flow from quiz to group quiz in Fig. 4 means that the quiz action, without being terminated, may interact with the group quiz i.e., they overlap. A question is sent from the quiz service via the streaming pin to the group quiz service (quiz is still active and group quiz is started). Using the group quiz service, the members of the group may discuss the possible answers and agree on one solution before a leader submits the answer. Note that variables and data are omitted in Fig. 4. However, it is possible to define and use data in the normal way defined for UML activity diagrams. The particular case of initiative choices are modeled using interruptible regions (denoted by a dashed box) and interrupting flows as shown in Fig. 5. In a group quiz service, there may arise a situation where a user is proposing an answer at the same time as the leader is submitting an answer. What we want is to choose either one or the other as specified in Fig. 5, but in a distributed realization
42
S.B. Kathayat and R. Bræk
act
CIty Guide Service leader
cgs
st.Start tour
gp.Get plan
grp
grp
{leader}
tm.Tour manager
user leader
et.End tour
grp
user, leader
nm.Next move
replan
grp leader rp.Replan
cgs
grp user, leader
pu.Position update
grp
pd.Proximity detector
poi
poi
user, leader
cp.Connect poi
grp
q.Quiz
grp
gq.Group quiz
grp
Fig. 4. Flow-Global choreography model
they may occur nearly simultaneously and require additional coordination to resolve which initiative to select. More on this is in Sect. 4.5. Optional behavior triggered by external events may be modeled in a similar way. A leader may for example opt to re-plan while the other users are using a current plan, triggered by the replan event in Fig. 4. We note that there is a certain amount of concurrency in the choreography in Fig. 4, that follows explicitly from the parallel forks and implicitly from the streaming pins. It is important to note here that this concurrency reflects the nature of the problem and is not imposed by the notation as such. In simpler cases, activities have only starting and terminating pins. Connecting such pins will result in a normal sequential ordering. We use streaming pins where we want activities to interact without being stopped.
From Flow-Global Choreography to Component Types
act
43
Group quiz
user leader
qs.Question
{user} sugg
user
sg.Sugg
grp
user leader
ss.Show sugg
grp
grp
{leader} submit
leader
sb.Submit
grp
Fig. 5. Flow-global specification of Group quiz service
4
Flow Localization
At the flow-global level we define the intended ordering including streaming pins, interruptible regions and initiative choices. At the flow-localized level we need to ensure the ordering in terms of local flows. In Sect. 4.1 and 4.2, we first consider direct flows with no control elements between the action nodes. In Sect. 4.3, the localization of the control nodes and notion of path is introduced. Streaming and interruptions are then discussed in the following sections. 4.1
Strong Sequence Localization
In this step we ensure the strong sequencing semantics of UML activity diagram, i.e., that leaving an activity through an activity final node terminates the entire activity. It means that there will be no overlap or concurrency among activities that follow each other sequentially according to the flow-global choreography, and hence realization problems caused by overlaps are avoided. We now assume that the collaborations on the lowest level of decomposition have only one initiating role and one terminating role, with a starting input pin assigned to the initiating role and a terminating output pin to the terminating role. In the case of parameter sets, all alternative pins need to be assigned to the same role. This is summarized in Fig. 6(a). The global flows are then localized in the following way: – A global edge directly from collaboration action C1 to C2 is attached to the corresponding terminating output pin or parameter output pin of C1 and the starting pin or parameter input pin of C2.
44
S.B. Kathayat and R. Bræk
A
C1
place in B
place in B
place in B B
A
C1
B
A
B
C1
place in B or C
C1
A
B
D
C2
C
place in A (a) localization of pins
ev1
A
C1
B
{B}
(b) localized join
(c) localized merge
ev2 {C}
D
(d) localized fork
place in B C2
C
A
C1
B
D
C3
B
(f) localized local choice
(e) initiative choices
A
C1
B place in A or B
place in B,C
A
C1
B
D
C1
place in B
C
D
(g) non-local choice needing resolution
C3
B
C
C4
B
C
C5
A
(h) localized cascaded control nodes
Fig. 6. Summary of the rules for localizing pins and control nodes
– Every external event is localized to a single role, as illustrated in Fig. 6(e). For example, the replan event within the interruptible region in Fig. 4 is assigned to a lead user. Two cases are possible after this: – Natural strong sequence: the flow between two collaborations C1 and C2 is completely localized to one role, as shown in Fig. 7(a). This means that strong sequence is ensured by the global flow directly. In the city guide choreography (Fig. 4) there is a natural strong sequence between most activities. – Enforced strong sequence: the flow between two collaborations C1 and C2 is not completely localized to one role and therefore implies a coordination message being passed to enforce the strong sequence. This is shown in Fig. 7(b) where the terminating pin of service C1 is connected to the initiating pin of C2. Flows linking pins on different roles imply interaction using send and receiving events at the terminating and initiating roles respectively. Although this ensures a strong sequence, it adds a communication overhead. 4.2
Weak Sequence Localization
Flows with enforced strong sequence require additional communication that sometimes is neither desirable for performance reasons nor necessary for realizability reasons. In such cases we consider using weak sequencing instead. Weak
From Flow-Global Choreography to Component Types
A A
C1
B
A
C1
C2
B
A
(a) natural strong sequence
C2
B
C1
B m
m
A
45
B
A
B
C2
(b) enforced strong sequence
Fig. 7. Strong sequence localization
C1
A A
C1
{weak}
A
C2
B
A
m1
B
B
B
A
(a) weak sequence
C2
{weak} B
m1
m1
m2
m2
m2
m1
A m2
B
(b) possible message re-ordering problem
Fig. 8. Weak sequence localization
sequencing is the normal semantics of Sequence diagrams, and distributed system in general. This means that a component may initiate C2 as soon as it is finished with its role in C1, even if messages may still be in transfer so that all roles of C1 are not completely finished. It means that there may be some overlaps between collaborations that potentially may cause realizability problems such as races. In order to model the weak sequencing, we attach a local terminating pin to the role in C1 that initiates C2. This is modeled as a streaming pin with the property {weak}, as indicated in Fig. 7 and 8. So far we have considered flows that connect to the initiating role of the next collaboration, what we call initiating flows. For the non-initiating roles, the implication of these flows is that they must be ready to respond as indicated by the dashed lines in Fig. 8(a). This represents what we call responding flows, to be elaborated in Sect. 5. Interestingly, the presence of a weak responding flow implies overlap between role behaviors, and thus it serves to indicate a potential realization problem. The problem is that events in overlapping roles may interleave in ways not specified in the choreography. Whether this is possible or not depends on the underlying communication medium linking the roles. As we can see in Fig. 8(b), since A initiates C2 only after it finishes its role in C1, m2 is always sent after m1. However, if the communication link between
46
S.B. Kathayat and R. Bræk
components A and B may reorder the messages, the messages m1 and m2 may arrive in any order at B. This is a realizability problem that must be resolved. In order to resolve this kind of realizability problems we have three options: – Resolve the problem on the level of orchestration (component design), i.e., deal with overlapping behavior in the component design, or use a communication medium that conserves the sending order. – Modify the choreography to ensure, natural strong sequence. – Enforce the strong sequence by additional communication. In general, according to [5], when a composite role participates in two consecutive collaborations that are not strongly sequenced and plays a non-initiating sub-role in the second one there will be overlap and potential message ordering problems like in Fig. 8(b). If, for example, the component B in C2 in Fig. 8 is replaced with another component D, then there will be no message ordering problem due to overlapping roles in C1 and C2. In the choreography of the city guide given in Fig. 4, there is no case of weak sequence localization. 4.3
Control Nodes and Paths Localization
Flows connecting a source action node C1 and target action node C2 may contain intermediate control nodes such as decisions, merges, forks and joins. In such cases, we say that two action nodes C1 and C2 are linked by a flow-path through a number of intermediate control nodes linked by direct flow-steps. Each intermediate flow-step and control node may be part of several flow-paths. The intermediate control nodes are localized according to the following rules: 1. Each flow-path from Ci to Cj is first localized to the initiating role of Cj. 2. Find all the flow-paths through each intermediate control node. 3. If all paths through a node are local to the same component, localize the node to that component. 4. If some paths involve an interaction to enforce strong sequencing, the node can be localized to either the source component or the target component of the path as long as all paths through the node can be localized to the same component. 5. If the node is a choice node, it must be localized to the target component of the path and it must be possible to make the choice based on information local to that component. 6. If localization according to steps 3, 4 and 5 above is impossible, then there is a realization problem to resolve. Fig. 6(b), 6(c) and 6(f) illustrate cases where the control nodes can be localized to component B. In 6(g), there is a non-local choice which is not directly realizable and must be resolved as explained in Sect. 4.5. In the case in Fig. 6(d), the flow-paths though the fork node may be localized to either B or C if the additional communication also is needed to enforce strong sequencing. The fork
From Flow-Global Choreography to Component Types
C1
A
B
{stream}
A
m1
B
m1
m2
m1
m2
m2
m1
m2
m1
{stream}
B
C2
A
A
m2
47
B
ne activity (a) service overlapping due to streaming pins when a streaming flow initiates next
A
C1
B
{stream}
from other service
{stream} A
C2
A
m1
B
m3
m2
m1
m1
m3
m2
m1
m3
m2
m2
m1
m3
m2
m1
m3
m3
m2
m1
B
A
m2 m3
B
(b) service overlapping due to streaming pins provided vided that next activity has already a started
Fig. 9. Message ordering problems due to the overlapping of services
node may either be localized to B with an interaction flow to C or the other way around. In more complex cases having more than one intermediate node, as in Fig. 6(h), we can use the same approach. For example, the fork node may either be localized to A or B. However, in this case we also need to make sure that all the nodes in a path should be localized to the same component, and if that is not the case a interaction flow is needed. When the fork node in Fig. 6(h) is localized to A, then we may need to use an interaction flow from the fork node to the choice node. 4.4
Streaming Flow Localization
Streaming pins must be assigned to roles such that output pins are assigned to the role that generates the output token, and input pins assigned to the role that receives the input token. Once the streaming pins have been localized, the flows and intermediate control nodes are localized in the same general manner as control flows, explained above. We now classify flows initiating from and/or ending on streaming pins as streaming flows. The following cases are possible: – Streaming output to starting input: This kind of situation exists, for example, between the quiz and group quiz services in Fig. 4. Due to the streaming pins, we may have overlapping service roles, and this may cause problems as illustrated in Fig. 9(a). This kind of flow is akin to the weak sequencing discussed above and is indicated by the {stream} property on the corresponding responding flow.
48
S.B. Kathayat and R. Bræk
– Streaming output to streaming input: This means that both activities will be running in parallel and that streaming inputs may interleave with other events. This may lead to overlapping roles, like in Fig. 9(b), causing realizability problem. As we can see, m1 is the last message from B to A in C1. However, B may send m3 to A before m1 provided that C2 has been already started by some service other than C1. Therefore there is a possibility that B may send messages m1, m2 and m3 in any order and eventually that A receives them in any order also. This may or may not be what the composer wants to specify. – Terminating output to streaming input: This type of flow causes no overlaps and is directly realizable as long as C2 is ready to accept the token from C1. For streaming flows we distinguish two main cases: – Local streaming: the flows are entirely within one component (composite role). This can be coordinated within the component and will be unproblematic in most of the cases. We note here that it is desirable that streaming flows are local to one role. – Global streaming: a flow that implies communication. This may be problematic and needs careful consideration. As a method guideline global streaming flows should preferably be encapsulated in collaborations. 4.5
Initiative Choice Localization
Fig. 5 defines the intended behavior of an initiative choice. There is no way to prevent the initiatives from happening simultaneously, so-called mixed initiatives. This requires additional resolution behavior and therefore initiative choices are not directly realizable. The resolution strategy will depend on the problem at hand and is difficult to solve in a general way. Instead, one may develop a library of alternative solutions to select from. One way to handle such situations is to assign primary and secondary priorities to the conflicting partners and let an initiative from the primary side be accepted in all cases. For the secondary side, this means that it must be prepared to receive a primary initiative even after it has issued an initiative itself, and obey the primary one; the secondary is in this case discarded. This feature can be modeled in a flow-localized choreography using a mixed initiative resolution building block, called MISS in [2]. The MISS building block is used in the group quiz service as shown in Fig. 10 (in terms of flow-localized choreography). Fig. 11 illustrates the same using the UML swim-lane style supported by Arctis. In the cases of conflicts, a priority is given to the leader. In the Arctis-style choreography, we have chosen to represent the lead-user and ordinary users as distinct roles in order to show the difference, we have also included user interface blocks [4] where the sugg and submit events are captured. The group quiz service is started when a group receives a question via the ques starting pin. The question is then forwarded via the question service to all users (shown by multi-session in Fig. 11) and also to the leader. When users
From Flow-Global Choreography to Component Types
act
49
Group quiz
user leader
qs:Question
{user} sugg
grp
{leader} submit
s.init
p.init MISS
S s.wins
p.wins
user
sg:Sugg
grp
user leader
ss:Show sugg
grp
P p.wins
leader
sb:Submit
grp
Fig. 10. Mixed initiatives resolution in flow-localized choreography
start suggesting answers to the question via the suggestion service, the group forwards the suggestions to the other users (shown by session select statement, for detail refer [6]) and to the leader. In the case of conflicting initiatives, i.e., the user is suggesting an answer at the same time as the leader is submitting, priority is given to the submitted answer (the group is given a primary role in the MISS service) and the user role is prevented from suggesting any further answers via the p.wins pin at the user role.
5
Deriving Components
Given a flow-localized choreography with all realizability problems resolved, the next step is to derive a local activity flow for each component type, the so-called orchestration, consisting of the actions and control nodes that are local to the component, i.e., the collaborative actions and local action as well as the fork, join, decisions and merge nodes. This is done by making a projection of the flow-localized choreography onto the components in the following way: – For each component make a copy of the flow-localized choreography. – Replace each collaboration action and local action where the component is not participating by a no-operation node, and keep all the collaborations and local actions where it participates.
50
S.B. Kathayat and R. Bræk
Fig. 11. Arctis style modeling of the Group quiz service
– Include all the flows that are completely localized to the component type. These types of flows are called local flows (local initiating and local streaming flows). Note that local actions and control nodes will be associated with such flows. – Flows that cross the component boundary and therefore involve communication are called interaction flows. Such flows map to send event actions on the sending side and accept event actions on the receiving end. – Flows that are completely external to the component, are marked as responding flows. The responding flows determine when the component must be ready to participate in collaborations initiated by other components, i.e., collaborations where the component plays a non-initiating role. The resulting component types for group and leader are shown in Fig. 12 and Fig. 13, respectively. Note that we have kept reference to the external collaborations for later use during composition. Inside the role actions there will be send actions and receive actions for the interaction flows of the collaborations. The component models have local flows representing local control flows and responding flows (denoted by dashed lines) representing flows external to the component. A responding flow may be a simple edge or a complex flow involving external control nodes as well as no-op nodes representing collaborations and local actions where the component is not participating. Responding flows in the group component type are mostly simple responding flows. A responding flow between cp.grp and q.grp specifies that the group should be ready to participate in a quiz session with a POI once the group has initiated a connect poi collaboration. A responding flow between nm.grp and pu.grp represents the case where the group informs the user about a next move, and then should be ready to participate in position update collaborations.
From Flow-Global Choreography to Component Types
51
«roletype» City Guide Group st. leader
st:Start tour
st.grp
et. user, leader
et:End tour
et.grp
end
tm.Tour manager
move nm. user, leader
nm:Next move nm.grp
pu. user, leader
pu:Pos. update pu.grp
gp:Get plan
gp.grp
gp.cgs
next cp.grp
cp:Connect poi cp.poi
next poi
q:Quiz
q.poi
gq:Group quiz
gq. user, leader
q.grp
pd.Prox detector pos
ques
ans
gq.grp
stop
Fig. 12. The city guide group component models
There are several responding flows in the Leader component type in Fig. 13 representing flows involving external control nodes as well as no-op nodes that have been removed from the diagram. For example, a responding flow between pu.Pos update and gq.Group quiz involves three no-operation nodes (pd.Prox detector, cp.Connect poi and q.Quiz, c.f. Fig. 4) and one external fork. Responding flows that have {weak} or {streaming} properties need special attention since they may cause activity overlaps and thus potential race situations that must be resolved. Note that there may be several possible responding flows ending on a collaboration activity. This means that tokens can arrive along the different paths in different order. Each responding path may be shortened and simplified into the shortest and most direct path representing the earliest situations when a token may arrive. For the detailed algorithm on simplifying a responding path, see. [7]. The resulting component models may now be used to compose more composite components and systems. They may also be translated separately into equivalent UML state machines from which corresponding application code can be generated using existing tools such as Arctis.
6
Discussion and Related Work
In the domain of reactive systems it has been common to use interaction diagrams in one form or another to define global behaviors. UML interaction overview diagrams (IOD), or high level MSC diagrams may then be used for flow-global choreography [8]. Compared to the IODs, activity diagrams allow
52
S.B. Kathayat and R. Bræk
«roletype» City Guide Leader
st.grp
et.grp
st:Start tour
st. leader
et:End tour
et. leader
nm. leader
nm:Next move nm.grp
pu. leader
pu:Pos update pu.grp
{stream} gq. leader
gq:Group quiz
gq.grp
Fig. 13. The city guide leader component models
the representation of roles as partitions of activities which is useful information that helps to understand and analyze the global behavior at the level of choreography. According to the UML specifications in [9, p. 512], IODs are specialization of activity diagram that show control flow between set of interactions. IODs can define sequential and parallel composition of interactions, as well as loops and alternatives. However, IODs excludes many rich modeling constructs available in activity diagram such as interruptible regions, flow final nodes, and streaming nodes [10]. Interruptible regions of activities are useful for modeling initiative choices, exception handling and external priority interrupts. Note that there is an interaction operator break in UML, but it can only be applied in a sequence diagram not at the interaction overview level. Streaming pins are useful to model interactions among concurrent actions at a high level (as discussed in Sect. 3 between quiz and group quiz ). In principle it is possible to use sequence diagrams for elementary collaborations and activity diagrams for choreography, since call behavior actions can call behavior defined by interactions. This has been done in [5], but exactly how to combine the two forms is not fully defined in UML. The realizability problems associated with weak sequencing and initiative choices we have discussed here are the same as those identified in [5] and therefore not particular to activity diagrams. We have found activities to provide a good combination of readability, completeness, and automation potential. This combined with the benefit of staying within one notation are the main reasons for our decision to use activity diagrams throughout. The authors in [11] identify the needs to encapsulate the interaction behavior of distributed components by so-called collaboration modules. They have suggested collaboration based design with a tighter integration between interaction and state diagram models, and created a specific language called CoSDL to
From Flow-Global Choreography to Component Types
53
define collaborations. The global behavior specified by the composition of such collaborations modules in CoSDL is at the flow-localized level. CoSDL is aligned to SDL [12]. Use Case Maps can be used for both flow-global and flow-localized choreography [13, 14]. Related work in the embedded systems and web-services domains [18–21] has concentrated on flow-localized choreography using interactions and activity diagrams. Most of this work assumes a manual derivation of components. Unlike most approaches [18–21], we encapsulate interactions in collaborative building blocks. Most of the approaches are only control flow oriented, except [15] which considers data as well. Initiative choices, called mixed initiatives in [22], which are normal and unavoidable cases in many reactive systems are handled only by us and [15]. There are different techniques to check the conformance between choreography and orchestration. In [18], behavioral equivalence is used. The equivalence is checked between the labeled transition system (LTS) for the parallel composition of orchestrators and the LTS of the choreography. The authors in [15, 16] use the notion of bisimulation [23] for the conformance and trace equivalence is used in [17]. Some of our previous work has been concentrated on choreography where all flows are localized to praticipating roles [6] which is supported in the Arctis tool [2]. Note that our flow-localized choreography is semantically equivalent to Arctis models, and therefore Arctis can provide a tool basis for further analysis and state machine synthesis. However, the Arctis tool currently generates complete systems and not component types that may be used in subsequent component based system composition at the modeling level. The flow-global choreography avoids the layout restriction of the swim-lane notation by representing the participating roles inside the actions as proposed in [24]. In [5], the authors suggested a classification of realizability problems and some criteria for detecting them at the flow-global level. In this paper we elaborate on localization i.e., how flow-global choreography is mapped to flowlocalized choreography and further to orchestration of distributed component types with external interfaces. We believe the concept of responding flows is novel and that {weak} responding flows provides a new way to identify potential realization problem. This will be addressed in future work.
7
Conclusion
A general approach for the definition of flow-global choreography of services is presented where the global behavior of a service is specified by linking together actions representing collaborative and local behavior. From the flow-global choreography we derive flow-localized choreography models that may be extensively analyzed using existing tools such as Arctis. Distributed component implementations may then be automatically generated. Our work is unique in its combination of: 1) the development trajectory it covers; 2) the use of the full power of activity diagrams; 3) the support for reusable building blocks both on the level of collaborations and on the level of components.
54
S.B. Kathayat and R. Bræk
Responding flows are introduced to represent flows external to a component. This makes it possible to synthesize state machines and implementations for each component separately, and also provides a key to identify a class of realization problems. Components may be stored in libraries and reused in subsequent system composition. Component types provide information about their interface collaborations that may be utilized for compatibility checks, dynamic linking and binding of component instances. In this way our approach supports reuse and composition both on the level of collaborative building blocks and on the level of components. Further work is planned to provide full tool support and to elaborate on component composition.
References 1. Erl, T.: SOA: Principles of Service Design. Prentice Hall Press, Englewood Cliffs (2007) 2. Kraemer, F.A., Sl˚ atten, V., Herrmann, P.: Tool Support for the Rapid Composition, Analysis and Implementation of Reactive Services. Journal of Systems and Software 82, 2068–2080 (2009) 3. Kathayat, S.B., Bræk, R.: Platform Support for Situated Collaborative Learning. In: International Conference on Mobile, Hybrid, and Online Learning, pp. 53–60. IEEE Computer Society, Los Alamitos (2009) 4. Kraemer, F.A., Kathayat, S.B., Bræk, R.: Unified Modeling of Service Logic with User Interfaces. In: Proceeding of the First International Workshop on Model Driven Service Engineering and Data Quality and Security, pp. 37–44. ACM, New York (2009) 5. Castej´ on, H.N., Bræk, R., Bochmann, G.V.: Realizability of Collaboration-Based Service Specifications. In: Proceedings of the 14th Asia-Pacific Software Engineering Conference, pp. 73–80. IEEE Computer Society, Los Alamitos (2007) 6. Kraemer, F.A.: Engineering Reactive Systems: A Compositional and Model-Driven Method Based on Collaborative Building Blocks. PhD Thesis, Norwegian University of Science and Technology (2008) 7. Kathayat, S.B., Bræk, R., Le, H.N.: Automatic Derivation of Components from Choreographies - A Case Study. In: International Conference on Software Engineering, Phuket, Thailand (2010) 8. Decker, G.: Realizability of Interaction Models. In: 1st Central-European Workshop on Services and their Composition, CEUR-WS.org, pp. 55–60 (2009) 9. OMG, Unified Modeling Language 2.1.1 Specification (Superstructure 07-02-05), http://www.omg.org 10. Whittle, J.: Extending Interaction Overview Diagrams with Activity Diagram Constructs. Software and Systems Modeling 9, 203–224 (2010) 11. R¨ oßler, F., Geppert, B., Gotzhein, R.: CoSDL - An Experimental Language for Collaboration Specification. In: Sherratt, E. (ed.) SAM 2002. LNCS, vol. 2599, pp. 1–20. Springer, Heidelberg (2003) 12. International Telecommunication Union: Recommendation Z.100, Specification and Description Language (SDL) (November 2007), http://www.itu.int/rec/T-REC-Z.100/en 13. Castej´ on, H.N.: Synthesizing State-Machine Behaviour from UML Collaborations and Use Case Maps. In: Prinz, A., Reed, R., Reed, J. (eds.) SDL 2005. LNCS, vol. 3530, pp. 339–359. Springer, Heidelberg (2005)
From Flow-Global Choreography to Component Types
55
14. Buhr, R.J.A.: Use Case Maps as Architectural Entities for Complex Systems. IEEE Transactions on Software Engineering 24, 1131–1155 (1998) 15. Kazhamiakin, R., Pistore, M.: Choreography Conformance Analysis: Asynchronous Communications and Information Alignment. In: Bravetti, M., N´ un ˜ez, M., Tennenholtz, M. (eds.) WS-FM 2006. LNCS, vol. 4184, pp. 227–241. Springer, Heidelberg (2006) 16. Busi, N., Gorrieri, R., Guidi, C., Lucchi, R., Zavattaro, G.: Choreography and Orchestration Conformance for System Design. In: Ciancarini, P., Wiklicky, H. (eds.) COORDINATION 2006. LNCS, vol. 4038, pp. 63–81. Springer, Heidelberg (2006) 17. Qiu, Z., Zhao, X., Cai, C., Yang, H.: Towards the Theoretical Foundation of Choreography. In: Proceedings of the 16th International Conference on World Wide Web, pp. 973–982. ACM, New York (2007) 18. Sala¨ un, G., Bultan, T.: Realizability of Choreographies Using Process Algebra Encodings. In: Leuschel, M., Wehrheim, H. (eds.) IFM 2009. LNCS, vol. 5423, pp. 167–182. Springer, Heidelberg (2009) 19. Mendling, J., Hafner, M.: From Inter-organizational Workflows to Process Execution: Generating BPEL from WS-CDL. In: Meersman, R., Tari, Z., Herrero, P. (eds.) OTM-WS 2005. LNCS, vol. 3762, pp. 506–515. Springer, Heidelberg (2005) 20. Barros, A., Dumas, M., Oaks, P.: A Critical Overview of Web Service Choreography Description Language (WS-CDL). In: BPTrends (March 2005) 21. Wieczorek, S., Roth, A., Stefanescu, A., Kozyura, V., Charfi, A., Kraft, F.M., Schieferdecker, I.: Viewpoints for Modeling Choreographies in Service-Oriented Architectures. In: WICSA/ECSA, pp. 11–20. IEEE Press, Los Alamitos (2009) 22. Bræk, R., Floch, J.: ICT convergence: Modeling issues. In: Amyot, D., Williams, A.W. (eds.) SAM 2004. LNCS, vol. 3319, pp. 237–256. Springer, Heidelberg (2005) 23. Milner, R.: Communication and Concurrency. Prentice-Hall, Inc., Englewood Cliffs (1989) 24. Castej´ on, H.N.: Collaborations in Service Engineering: Modeling, Analysis and Execution. PhD thesis, Norwegian University of Science and Technology (2008)
Integration of FlexRay into the SDL-Model-Driven Development Approach Tobias Braun, Reinhard Gotzhein, and Matthias Wiebel Networked Systems Group, University of Kaiserslautern, Germany {tbraun,gotzhein,m_wiebel}@cs.uni-kl.de
Abstract. In today’s cars, communication systems providing deterministic guarantees regarding latency and jitter are needed. For safety-critical x-by-wire applications, even physical redundancy is required. FlexRay is a recent field-bus technology especially devised for these needs. In this paper, we present the integration of FlexRay into SDL-MDD, the SDL Model-driven Development approach. In particular, we show how certain dynamic configuration aspects of and communication via FlexRay can be specified already on design level with SDL, thereby abstracting from technological details. Furthermore, we extend the SDL Environment Framework by driver components supporting the automatic interfacing of SDL systems with FlexRay hardware. Finally, we present a functionally complex application scenario with real FlexRay hardware demonstrating the benefits and full operativeness of our solution. Keywords: SDL, SDL-MDD, Model-Driven Development, Automotive, FlexRay.
1
Introduction
Today, cars are equipped with a growing number of networked electronic control units (ECUs), providing functionality for chassis and power train control, security, comfort, and entertainment. Communication among ECUs has to meet high demands regarding timeliness, with deterministic guarantees for latency and jitter. With the upcoming trend towards x-by-wire-systems for safety-critical functionalities, e.g. steering or braking, physical redundancy is required, too, in order to cope with partial system failures. A protocol especially devised for these needs of the automotive domain is FlexRay [1], which is being used in vehicles since 2006. To meet hard timing constraints, FlexRay has been conceived as a deterministic, time-triggered protocol, with built-in features to support event-based communication, too. Redundancy is achieved by two independent physical channels. Yet, these real-time capabilities and its high degree of configurability make FlexRay a complex protocol that has turned out to be difficult to handle in practice. Our method to cope with the complexity of FlexRay is its integration into SDL-MDD [2,3], our model-driven development approach with SDL [4] as modeling language. On design level, we provide a comprehensive abstract signal F.A. Kraemer and P. Herrmann (Eds.): SAM 2010, LNCS 6598, pp. 56–71, 2011. c Springer-Verlag Berlin Heidelberg 2011
Integration of FlexRay into the SDL-Model-Driven Development Approach
57
interface that enables high-level, SDL-style interaction with virtual FlexRay environments, thereby hiding technological details. On implementation level, we have extended the tool support of SDL-MDD such that implementations generated from SDL designs are automatically instrumented to interface with real FlexRay hardware, avoiding manual coding entirely. This is in line with the idea of model-driven development, where the model is in the center of the development activity. It furthermore relates closely to work previously done in our group [5], where we integrated other communication technologies, e.g. WLAN and Bluetooth, into the SDL-MDD. Regarding the integration of FlexRay into the model-driven development process with SDL, no other work has been done so far. However, another approach to reduce the complexity of the development for FlexRay-based systems is shown in [6]. Here, the model-driven approach is realized using a system description language called TDL (Time Definition Language). A TDL program explicitly specifies the exact real-time interactions of software components with each other and the physical world. The authors focus on the improvement of systems developed with SIMULINK. They were able to measure a productivity gain by a factor of 20 and more with TDL compared to state-of-the-art FlexRay development methods and tools used in the automotive domain. Videos showing the tool that has been devised to support this approach can be found in the web [7]. In [8], SDL has been used to specifiy the behaviour of a FlexRay communication controller based on the SDL specifications given in the FlexRay Communication System Protocol Specification [1]. But this specification is just used to assist the implementation of a communication controller in Verilog HDL, and not to enable the usage of FlexRay in a model-driven development approach with SDL. The paper is organized as follows: In Sect. 2, we survey SDL-MDD including its tool chain and explain the principles of integrating FlexRay. Sect. 3 gives an overview of FlexRay and explains common hardware-specific details of a typical FlexRay communication controller. With this technological background, we introduce the SDL signal interface for FlexRay and tool support in Sect. 4. Sect. 5 presents a functionally complex application scenario, starting with an SDL design and finally running the generated implementation on real FlexRay hardware. In Sect. 6, we draw conclusions and outline future work.
2
SDL-MDD - Model-Driven Development with SDL
SDL-MDD [3] is a model-driven development approach based on a formal system model using ITU-T’s Specification and Description Language (SDL, [4]) as design language. It is in line with the OMG MDA and starts with a computationindependent model (CIM), where message sequence charts (MSC) and informal texts are used to collect essential requirements and functionalities (see Fig. 1). The specification of the platform-independent model (PIM) is done with SDL as design language and fully covers the system functionalities, still abstracting from platform-specific details. The platform-specific model (PSM) is derived from the PIM by selecting a concrete hardware platform and adding
58
T. Braun, R. Gotzhein, and M. Wiebel
CIM (MSC)
Specification Phase
PIM (SDL)
SVM (C-CODE)
PSM (SDL)
PSSI (SDL)
RIC (C-CODE)
SEnF (C-CODE)
RSC (machine code)
Implementation Phase
Fig. 1. SDL-MDD (grey: Platform specific supplements for the integration of FlexRay)
platform-specific abstract interfaces. One example for such an interface, called PSSI (platform-specific signal interface, see Fig. 1) is our SDL interface for using FlexRay, which is presented in Sect. 4. Executables for the chosen hardware platform are generated automatically from the PSM in two steps. In the first step, a code generator, e.g. Tau Cadvanced [9] or ConTraST [10], is used to generate intermediate code (RIC - Runtimeindependent Code) in a language such as C or C++. Our SDL Environment Framework (SEnF) provides the necessary hardware-specific drivers for the abstract interfaces used in the PSM. Hence, a platform-dependent C or C++compiler can be used to obtain the executable machine code (RSC - RuntimeSpecific Code). The RSC is executed under the control of the SDL Virtual Machine (SVM), which is amongst others responsible for the initialization of the SDL system, selection and execution of transitions, and the signal transfer between SDL processes. SdlRE (SDL Runtime Environment) is our implementation of an SDL Virtual Machine supporting the RIC generated by ConTraST.
3
FlexRay - A Field Bus in the Automotive Domain
FlexRay is a deterministic, time-triggered field bus with two independent physical channels, especially devised for the needs of the automotive industry [11]. The FlexRay 2.1A protocol specification [1] was developed and published in 2005 by the FlexRay Consortium. Partners of the FlexRay Consortium, which finished its work in 2009, were leading companies in the automotive and chip design sector, such as BMW AG, DaimlerChrysler AG, Freescale and General Motors. In this section, we give an overview of the FlexRay protocol (Sect. 3.1) and the FlexRay hardware (see Sect. 3.2).
Integration of FlexRay into the SDL-Model-Driven Development Approach
3.1
59
Outline of the FlexRay Protocol
FlexRay supports redundant transmission of frames. Therefore, two independent physical channels A and B with up to 10 Mbit/s of bandwidth each are available. If this redundancy is not needed, both channels can be used to transmit different frames at the same time to double the transfer rate. FlexRay uses TDMA (Time Division Multiple Access) as medium access control mechanism. This allows deterministic guarantees concerning frame latency and jitter as well as prioritybased transmissions of frames with dynamic bandwidth acquisition. To achieve this, the FlexRay protocol divides time into a sequence of communication cycles of constant duration. Each communication cycle consists of a mandatory static segment, an optional dynamic segment, an optional symbol window and the mandatory network idle time (NIT) as shown in Fig. 2. Every node has an 8-bit cycle counter numbering communication cycles. This counter has the same value in all synchronized cluster nodes and can be used as filter criterion. communication cycle static segment
....
static slot 1
symbol window NIT
dynamic segment
....
static slot k
....
static slot i
.... Frame k
....
slots
....
minislots
....
macroticks
dynamic slot i+1 i+2 i+3
Frame i+1
i+3
Fig. 2. Possible communication cycle with static segment, dynamic segment, symbol window and NIT
The static segment is subdivided into a configurable, but fixed number of static slots. Each static slot is assigned to at most one node exclusively, which can send frames in that slot without contention with other nodes. By default, each node is assigned one static slot called key slot. Beside the transfer of data, these key slots can be used for management purposes. The slots of the static segment are sequentially numbered, starting with one. Frames to be sent in static slots have a unique frame ID, which corresponds to the slot number. Static slots have equal length, which is expressed in terms of macroticks, the smallest common, cluster-wide synchronized time unit of the FlexRay protocol. Special cluster nodes, so-called synchronization nodes, are responsible for sustaining synchronization during the entire cluster lifetime. They transmit special
60
T. Braun, R. Gotzhein, and M. Wiebel
synchronization frames1 in their key slot. Coldstart nodes are another type of cluster node, responsible for the startup process of the cluster and the joining of additional nodes. For this purpose, they transmit startup frames in their key slots. For correct operation of FlexRay, it is important that all synchronized nodes associate the start and end of a frame transmission to the same static slot. Slot boundaries are determined by each node using local clocks, which are resynchronized periodically. Due to imperfect synchronization caused by clock skew and propagation delay, there is a clock offset, for which, however, an upper bound aWorstCasePrecision can be determined [1]. Each node sending a frame in a static slot has to delay the start of transmission - called action point - by this value,2 which ensures that all other nodes will detect the start of transmission in the same time slot (see Fig. 2). For the same reasons, a node has to stop its transmission aWorstCasePrecision before the end of the time slot. The dynamic segment consists of a configurable, but fixed number of minislots of equal length expressed in terms of macroticks. Besides minislots, the dynamic segment is divided into dynamic slots at runtime. These slots are created according to the communication needs of the current communication cycle by the so-called minislot mechanism. A dynamic slot consists of at least one minislot. The exact number of minislots of a dynamic slot is determined at runtime and depends on the priorities of the scheduled frames and the length of their payload. Therefore, the number of dynamic slots in a communication cycle also depends on these values. Dynamic slots are sequentially numbered, starting with the number of the last static slot increased by one (see Fig. 2). A transmission of a frame is only allowed, if the slot number matches the frame ID. The frame IDs a node is allowed to transmit represent the priority of the frames, where a low frame ID corresponds to a high transmission priority. It is up to the designer to ensure that each dynamic slot on a channel is assigned to at most one node for each communication cycle. FlexRay’s minislot mechanism works in the following way. Every node uses a local slot counter, which is increased by one for every minislot3 that is not used for transmission. If the value of the slot counter is equal to the ID of the scheduled frame, the transfer of the frame is started. As long as a frame is transmitted, the slot counters of all nodes remain unchanged. A node only transmits its frame, if the transmission can be completed within the bounds of the dynamic segment. Otherwise, no further deterministic guarantee concerning the latency for transmissions in later communication cycles would be possible. Figure 2 shows an example of the minislot mechanism, used to transmit two frames with different payload lengths. The frame with ID i+1 has higher priority than the frame with ID i + 3 and is therefore transmitted first. Each minislot 1 2 3
A frame with a sync bit set in the frame header. The worst case precision aWorstCasePrecision is not the only quantity to be considered, but the most important, see [1] for further details. During the static segment, the same counter is used and incremented by one for every static slot.
Integration of FlexRay into the SDL-Model-Driven Development Approach
61
has its own dynamic action point for the same reasons as described for static slots. Different from the static segment,a transmission in the dynamic segment always starts and ends at a dynamic action point (where padding is used when required). Typically, the dynamic action point offset is chosen more aggressively than the action point offset of the static segment in order to achieve better usage of the available bandwidth. The symbol window can be used to send and receive special symbols, such as the media access test symbol. Finally, the network idle time (NIT ) is reserved for resynchronization of clocks and related internal computations. 3.2
Outline of the FlexRay Hardware
A FlexRay node consists of host, communication controller and two bus drivers, one for each physical channel. The host comprises the hardware platform to be attached to a FlexRay cluster and executes the application code. The communication controller (CC) implements the FlexRay protocol engine [1]. There are two possible integrations of host and CC, either a single-chip solution or two separate circuits. In our demonstrator, we have realized the latter option, with host (Imote2, [12]) and CC (Fujitsu MB88121C, [13]) communicating via serial peripheral interface (SPI). The bus drivers provide interfaces between CC and physical channels, i.e., the adjustment of the electrical level on the wire for transmission or the sampling for reception of frames. The CC provides a freely configurable message RAM that stores data, status, and configuration information of frames. The message RAM is structured into a set of message buffers of different types:4 • Send buffers are assigned to one specific static or dynamic slot, i.e. one frame ID. If the slot boundary is reached and the assigned send buffer contains data, a corresponding frame with this payload is created and transmitted. Send buffers support two different modes of operation: Single-shot and continuous mode. A buffer configured to work in single-shot mode is cleared after message transmission. In continuous mode, the message remains in the buffer and is resent until it is replaced. • As send buffers, receive buffers are assigned to one specific static or dynamic slot. Receive buffers can also be grouped to form a FIFO buffer. Frames without a corresponding receive buffer are stored in this buffer, if they pass a configurable filter decision. • It is possible to use communication cycle multiplexing for receive, send, and FIFO buffers. This means that a message buffer with configured cycle counter filter is only used if the number of the current communication cycle (i.e., the cycle counter) satisfies the filter constraints. For example, it is possible to configure message buffers for odd or even communication cycles only. This grants the option to preload a send buffer in a cycle where it is not scheduled, or to postpone the reading of a receive buffer without losing data. 4
The following description applies to CCs using the Bosch E-Ray IP-Module [14]. However, the same concepts are supported by most CCs currently available, such as the Fujitsu MB88121C [13], which we have used in our experiments.
62
T. Braun, R. Gotzhein, and M. Wiebel
The option to preload send buffers and to delay the reading of receive and FIFO buffers supports temporal decoupling between the host and the CC. Thus, a synchronization between processes running on the host and the timing of the FlexRay protocol is not stringent for successful operation.
4
The SDL-FlexRay Interface
According to SDL-MDD, the PSM is derived from the PIM by selecting a concrete hardware platform and adding platform-specific interfaces (see Sect. 2). At this point, the developer can select FlexRay as the underlying communication technology of the system. In Sect. 4.1, we provide a comprehensive abstract signal interface that enables high-level, SDL-style interaction with virtual FlexRay environments, thereby hiding technological details. In Sect. 4.2, we outline the extension of the SDL Environment Framework (SEnF) to automatically instrument implementations generated from SDL designs to interface with real FlexRay hardware. 4.1
The SDL-FlexRay Signal Interface for the PSM
With SDL-MDD, the transformation from PIM to PSM is done on design level, using SDL as modeling language. By adding dedicated SDL signals addressing individual functionalities of different hardware platforms, high-level interaction between the PSM and virtual platforms can be specified. Following this idea, the SDL-FlexRay signal interface defines FlexRay-specific SDL signals with appropriate SDL signal parameter types. Hence, the PSM can use and control the FlexRay hardware directly with these signals. In the following, we elaborate on a subset of signals defined by the SDLFlexRay interface. Fig. 3 lists a subset of the outgoing signals and a data type used for the reconfiguration of buffers. Further signals can be found in Sect. 5. Startup Signals. The SDL signal FLEXRAY_startup is used to set up a node for communication, and to integrate it into a FlexRay cluster. If the system runs on a coldstart node and there is no communication under way, the signal invokes the initial startup. Otherwise, the node synchronizes itself with the other nodes and joins the running cluster. FLEXRAY_startup has three parameters of type Boolean. The first parameter indicates whether the node should send a wakeup pattern before it proceeds with its startup sequence. Receiving this pattern grants nodes in energy-saving mode the possibility to wake up and reintegrate into the cluster. If the second parameter is set, the node remains in single-slot mode after successful startup or integration. In this mode, a node uses only its key slot to send frames. The third parameter is relevant for coldstart nodes only. It determines whether the node is permitted to initiate a startup and thus to act as a leading coldstarter. Nodes using their key slot to send startup frames are called coldstarters, whilst nodes only
Integration of FlexRay into the SDL-Model-Driven Development Approach SIGNAL /*Boolean: true−> with WAKEUP, Boolean: singleSlotMode, Boolean: allowColdstart*/ FLEXRAY_startup(Boolean, Boolean, Boolean), /*Integer: buffer number, Octet_string: data*/ FLEXRAY_send(Integer, Octet_string), /*Integer: buffer number, Octet_string: payload with preamble and data*/ FLEXRAY_ppSend(Integer, Octet_string), /*Buffer: struct with configuration data*/ FLEXRAY_cfgBuffer(Buffer),
63
NEWTYPE Buffer STRUCT tx_mode TransmissionMode; generates_interrupts Boolean; msg_type MessageType; bff_type BufferType; connected2 Channels; cyc_code Int7; fid Int11; number Int7; segment SegmentType; payload_length Int7; data_pointer Int11 ENDNEWTYPE;
/*Boolean: true −> switch directly to config state*/ FLEXRAY_freeze(Boolean), /*Invokes transition from halt to config state*/ FLEXRAY_halt2Config, FLEXRAY_getCycleCount, FLEXRAY_getPOCstate, /*Outgoing signals */ SIGNALLIST Sdl2Flexray = FLEXRAY_startup, FLEXRAY_send, FLEXRAY_ppSend, FLEXRAY_cfgBuffer, FLEXRAY_freeze, FLEXRAY_halt2Config, FLEXRAY_getPOCstate, FLEXRAY_getCycleCount;
Fig. 3. Signals sent from the SDL system to the environment (left). Structure used for the reconfiguration of the message buffers (right).
allowed to participate in a startup are called non-coldstarters. When the startup has finished, the SDL system receives the signal FLEXRAY_startupFinished from the virtual FlexRay environment. Send Signals. The SDL signal interface provides two signals to send messages via FlexRay: FLEXRAY_send and FLEXRAY_ppSend. Normal messages are sent using the former signal, while the latter is used to send messages with a payload containing a special preamble like network information or CAN-like message identifiers (see also [1]). The send and receive signals use Octet_strings as parameter for the payload of the FlexRay frame. This allows us to use standardized techniques like ASN.1 in conjunction with SDL [15] to encode, transmit and decode complex datatypes with little effort. Both signals have an Integer parameter to select the associated message buffer of the CC. The second parameter is of type Octet_string and contains the data to be sent. By generating the signal FLEXRAY_sendFinished, the virtual FlexRay environment indicates the completion of the transmission. Its parameters provide information about the error status of the associated buffer and the cycle count number of the transmission. Receive Signals. If a message is received, the virtual FlexRay environment returns a signal FLEXRAY_recv to the SDL system, with five parameters. The first parameter is of type Integer and holds the number of the receive buffer. The
64
T. Braun, R. Gotzhein, and M. Wiebel
second parameter contains the received payload of type Octet_string, followed by a Boolean-flag set in case of an error and the number of the cycle count of this reception. Finally, the fifth parameter gives more details in case of an error occurrence. Buffer Configuration. Since the FlexRay controller needs a set of initial working buffers to be able to integrate a node into a cluster, it is necessary to provide some static configuration parameters. This is done by specifying a so-called Controller Host Interface (CHI ) file, which is included during code generation. Our FlexRay interface also allows the reconfiguration during runtime, as far as supported by the used communication controller. Therefore, the SDL interface provides a signal called FLEXRAY_cfgBuffer. It has one parameter of type Buffer containing a structure that holds the information needed for reconfiguration (see Fig. 3). This structure Buffer encapsulates information about the intended transmission mode (single-shot or continuous), buffer type (send or receive), the frame id to be used for messages sent via this buffer and several other configuration parameters. When the configuration has finished or been aborted due to an error, the driver generates the signal FLEXRAY_cfgFinished. As the aforementioned finished -signals, it contains parameters with information about the success or failure of the invoked driver function. 4.2
The SDL-FlexRay Driver of the SDL Environment Framework
After the transformation of the PSM to the RIC, the conversion to the RSC is performed (see Sect. 2). If the PSM uses signals of the SDL-FlexRay signal interface, the SDL-FlexRay Driver of the SDL Environment Framework (SEnF) is automatically incorporated. It consists of functions handling incoming and outgoing signals, received interrupts, and interaction with the CC. As a result of different execution speeds of the SDL system running on the host and the processes running on the CC, incoming signals and protocol-related information have to be temporarily buffered by the SDL-FlexRay Driver. Figure 4 shows the data structures of the driver. Arrays buffering data for the SDL system, such as bufferSendFinished, are colored white, while information for the CC are held in the arrays colored black (e.g. bufferSendPending). For every buffer used in the CC, we implemented a corresponding buffer in the driver. The buffered information is kept until the environment polls it for the generation of new signals or, respectively, the message buffers of the controller are ready to receive new information. This buffer architecture ensures the temporal decoupling of the FlexRay hardware, which has to satisfy hard real-time constraints, from the execution of the SDL-system on the host.
5
FlexRay Application Scenario
To demonstrate the benefits and full operativeness of the SDL-FlexRay interface, we now present a functionally complex application scenario that we have
Integration of FlexRay into the SDL-Model-Driven Development Approach
65
% ! " # #
" !%#
" # $#
" # ! $#
$!#
Fig. 4. The SEnF part of the SDL-FlexRay interface embedded in the runtime environment (white: buffers to hold information for the SDL-System, black: buffers to hold information for the FlexRay controller)
executed on real FlexRay hardware. For this purpose, we have developed a circuit board called FlexBoard allowing us to connect Imote2 sensor nodes to a FlexRay cluster. The FlexBoard consists of a communication controller (CC), two bus drivers and additional circuits for power supply and power adjustment. By means of different jumpers, it is possible to use this board in a star topology as well as in a bus topology. Via these jumpers, terminating resistors can be connected in parallel to the bus lines for each channel separately, as described in [16]. Figure 5 shows a fully assembled FlexBoard. As host, we use Imote2 nodes, which are plugged into the connectors on the upper side of the FlexBoard. We are using the MB88121C communication controller by Fujitsu Semiconductor, which is based on the Bosch E-Ray IP-Module and supports the FlexRay Protocol Specification V2.1 Rev.A [1,13]. Imote2 and MB88121C are connected via SPI and additional interrupt and Fig. 5. FlexBoard with Imote2 control lines. The circuit diagram follows the recommendations given in [17]. As bus drivers, we use the AS8221D by Austriamicrosystems, which are compliant with the current FlexRay Electrical Layer Specification [18,19].
66
T. Braun, R. Gotzhein, and M. Wiebel
On design level, we have specified an SDL system, consisting of two SDL processes communicating via FlexRay. On SDL level, we use the SDL-FlexRay signal interface (see Sect. 4.1), triggering a substantial subset of the FlexRay functionality. Fig. 6 shows an excerpt of the SDL specification. First, the startup of the cluster is invoked. This is followed by the exchange of 50 ping messages via FlexRay, using dynamic slots. Next, the buffers are dynamically reconfigured, followed by another message exchange using static slots. This scenario is first executed with both channels attached, to simulate the regular FlexRay behavior, and a second time with one of the channels disconnected, to examine the failure safety of the FlexRay protocol. From the SDL design, code is generated, automatically interfaced with the hardware platform (see Sect. 4.2) and deployed. Log messages of the system under execution show the expected operation. We have configured the CCs using Controller Host Interface (CHI) files with different buffer configurations for each node. In these files, the number of static slots is set to 40 each with a length of 44 macroticks. The length of the dynamic segment is configured to 176 minislots, each consisting of 6 macroticks. The total length of the communication cycle is 3000 macroticks,5 which corresponds to 3 ms. If a frame is transferred in the dynamic segment, the minimal message length is two minislots, because of the used padding of the minislot mechanism (see Sect. 3.1). Accordingly, this leads to a maximum number of 88 dynamic slots in one communication cycle. Since a FlexRay cluster needs at least two coldstart nodes, both nodes were configured as coldstarters. The startup of the system is invoked by the signal FLEXRAY_startup. When the startup is completed, the driver generates the signal FLEXRAY_startupFinished. Receiving this signal, the sender immediately starts transmitting 50 Octet_strings of the format ".|..Nnnn " over the bus, where nnn represents the running number of the message. The initial buffer configuration of the sender uses buffer 4 to transmit messages with frame ID 41 in the first dynamic slot on channel A only. After 50 messages have been transmitted, the send buffer is reconfigured. From now on, it is connected to both channels (newConfig!connected2 := AB) and used to send frames with frame ID 10 (newConfig!fid := 10) in the static segment. Furthermore, the payload length is set to 10 two-byte-words in accordance with the configuration of the payload length for the static segment. Followed by the reconfiguration, 50 messages of the format "........|.......Nnnn " are sent over the bus. Finally, a log message displaying the total number of messages sent is created. The receiving node starts an internal timer after it has received the first message. It waits for five seconds and generates an aggregated log message after the timer has expired. This log message is shown in Figure 8 and contains information about the received messages, e.g. the cycle number of the reception (Cnn) and the number of the buffer it has been assigned to (Bnn).6 Buffer 4 (normal) and 5 (FIFO) are configured for reception. In the first run of the scenario, the 5 6
Note that this is also part of the configuration and therefore scenario-specific. Every buffer is assigned a frame ID and thus a slot number. Messages with a matching ID are stored in or sent from the corresponding buffer.
Integration of FlexRay into the SDL-Model-Driven Development Approach
67
(% ') (% $% * +,-) (% .( ') (% ./ .%0 / *) (% .'1 '1 /
) (% "% /) (% 2 )
"
! #$
!
"
'$
% &
% &
$% 3, 4 $% ! $4 7
! /"%
$% +, $% 9-)
"7$
"% 5 & $ +,2# ) "% 5 +,) "% 5&0 +, &) "% 560 +,&) "% 5 $ +,/) "% 50 $ +,) "% 5$ +,-) "% 5&6 +,7) "% 5& +,$0&) "% 5 0 $# +,-) "% 5$ +,8)
"7
"7
:
!$#$ ./ .'1 .%0
!/#$ / '1
.'1
.'1 '1
(
'$
% &
'$
'
'$
;
'$
'
Fig. 6. Excerpt of the SDL system with a cluster startup, message sending and buffer reconfiguration
68
T. Braun, R. Gotzhein, and M. Wiebel
! "
# $ ! "
Fig. 7. Configuration of the message buffers. Buffer 4 starts sending with ID 41 (black arrow). After its reconfiguration (grey) it sends with ID 10 (dashed arrow). Receiving buffers are outlined with dashes.
node receives 50 messages with the frame ID 41. Since there is no receive buffer associated with this ID, these messages are stored in the FIFO buffer, consisting of buffers 5, 6, and 7 (see Fig. 7). After the 50th message, in cycle 39, we reconfigure the send buffer. The next message is received in cycle 43 and stored in buffer 4. This delay of four cycles corresponds to 12 ms and is a result of the reconfiguration process started on the CC and the SDL execution model. The last message in the log output states the total number (100) of received messages. In the following part of the log message, we see the results of the second run with channel A detached. Since frames with ID 41 are sent only over channel A, the first 50 messages are not received. After reconfiguration, the send buffer is connected to both channels and uses them for redundant transfer. This leads to the reception of the second 50 messages over channel B and therefore to a total number of 50 received messages as stated in the log. The possibility of redundant sending is one of the key features of FlexRay and enables the protocol to provide a high grade of failure safety. In scenarios where the host needs to send messages periodically in the same static slot,7 it is necessary that the clocks of the Imote and the FlexRay CC are synchronized. Otherwise, the periods of host and controller could deviate in a way that messages are created too late and their dedicated slot has passed before they are available for sending. The deviation results from the usage of different oscillators driving the clocks of host and CC and the continuous 7
For example, consider data resulting from a periodic sampling.
Integration of FlexRay into the SDL-Model-Driven Development Approach
69
Fig. 8. Log messages of the receiving node
re-synchronisation of the CCs, which is part of FlexRay. To overcome these problems, we realized a function that matches the time on the Imotes with the clocks of the communication controllers. This way, we can keep the clock of the host and the CC synchronized with respect to the FlexRay protocol.
6
Conclusions and Outlook
In this paper, we have presented our solution for the integration of FlexRay into SDL-MDD, our model-driven development approach. At design level, we have defined a comprehensive abstract signal interface enabling high-level interaction with virtual FlexRay environments, which can be applied to specify the platformspecific model (PSM). At implementation level, we have extended our tool chain
70
T. Braun, R. Gotzhein, and M. Wiebel
to support the automatic interfacing of SDL systems with FlexRay hardware. A functionally complex application scenario has demonstrated the benefits and full operativeness of our solution. In practice, it has turned out that the manual coding of hardware interfaces, also called environment functions in the context of the toolset TAU, is a timeconsuming and error-prone task, with code that is difficult to maintain and to extend. The results reported in this paper show that based on the abstract design, interfacing can be achieved automatically even for embedded systems and complex communication technologies such as FlexRay, thereby extending the scope of model-driven development. Thus, we expect a simular productivity gain as measured in [6] using our development approach. In previous work [20], we have shown that the same SDL models from which implementations are generated can be used for performance simulations. Furthermore, the same compiler is used to generate simulation code, which increases confidence in simulation results. To extend this idea to FlexRay, we are currently devising a simulation model that is sufficiently detailed to express real-time capabilities, configurations, communication cycles, and frame schedules. This will support architectural decisions about assignment of functionalities to ECUs such that all timing constraints are met early in the development process.
References 1. FlexRay Consortium. FlexRay Communication System Protocol Specification V2.1 Rev.A. FlexRay Consortium (December 2005) 2. Kuhn, T., Gotzhein, R., Webel, C.: Model-Driven Development with SDL – Process, Tools, and Experiences. In: Nierstrasz, O., Whittle, J., Harel, D., Reggio, G. (eds.) MoDELS 2006. LNCS, vol. 4199, pp. 83–97. Springer, Heidelberg (2006) 3. Gotzhein, R.: Model-driven with SDL – Improving the Quality of Networked Systems Development (Invited Paper). In: Proceedings of the 7th International Conference on New Technologies of Distributed Systems (NOTERE 2007), Marrakesh, Morocco, pp. 31–46 (2007) 4. International Telecommunication Union (ITU): ITU-T Recommendation Z.100: Specification and Description Language, SDL (August 2002) 5. Kuhn, T.: Model Driven Development of MacZ – A QoS Medium Access Control Layer for Ambient Intelligence Systems. PhD thesis, University of Kaiserslautern (2009) 6. Naderlinger, A., Pletzer, J., Pree, W., Templ, J.: Model-Driven Development of FlexRay-Based Systems with the Timing Definition Language (TDL). In: 4th International ICSE Workshop on Software Engineering for Automotive Systems (2007) 7. preeTec GmbH: Product demos for TDL: Visual creator / TDL: VisualDistributor / TDL: VisualAnalyzer (2010), http://www.preetec.com/index.php?id=2 8. Xu, Y., Kang, H., Kim, Y., Cho, K., Chung, J.: Implementation of FlexRay CC and BG Protocols with Application to a Robot System. In: Arabnia, H.R., Deligiannidis, L. (eds.) MSV, pp. 232–237. CSREA Press (2008) 9. IBM: Rational SDL Suite (2011), http://www-01.ibm.com/software/awdtools/ sdlsuite/
Integration of FlexRay into the SDL-Model-Driven Development Approach
71
10. Fliege, I., Grammes, R., Weber, C.: ConTraST - A Configurable SDL Transpiler and Runtime Environment. In: Gotzhein, R., Reed, R. (eds.) SAM 2006. LNCS, vol. 4320, pp. 216–228. Springer, Heidelberg (2006) 11. FlexRay Consortium: FlexRay Requirements Specification V2.1. FlexRay Consortium (December 2005) 12. Crossbow: Imote 2 Datasheet (2009), http://www.xbow.com/Products/Product_ pdf_files/Wireless_pdf/Imote2_Datasheet.pdf 13. Fujitsu Limited: FlexRay ASSP MB88121C, Preliminary Hardware Manual (2007) 14. Robert Bosch GmbH: E-Ray, FlexRay IP-Module, User’s Manual (November 2007) 15. International Telecommunication Union (ITU): ITU-T Recommendation: Programming Languages - SDL Combined with ASN.1 (SDL/ASN.1) (March 1995) 16. FlexRay Consortium: FlexRay Communication System Electrical Physical Layer Application Notes V2.1 Rev. B. FlexRay Consortium (November 2006) 17. Fujitsu Semiconductor: FlexRay ASSAP MB88121/MB88121A/MB88121B/ MB88121C Preliminary Data Sheet, Revision FME-MB88121-1.45E (September 2008) 18. FlexRay Consortium: FlexRay Communication System Electrical Physical Layer Specification V2.1 Rev.B. FlexRay Consortium (November 2006) 19. Austriamicrosystems: AS8221D FlexRay Standard Transceiver. Revision 17732005-10a, http://www.austriamicrosystems.com/eng/content/download/1214/ 7001/file/AS8221D_ObjectiveDataSheet_17732-005-10a.pdf 20. Kuhn, T., Geraldy, A., Gotzhein, R., Rothländer, F.: ns+SDL – The Network Simulator for SDL Systems. In: Prinz, A., Reed, R., Reed, J. (eds.) SDL 2005. LNCS, vol. 3530, pp. 103–116. Springer, Heidelberg (2005)
Design and Development of a CPU Scheduler Simulator for Educational Purposes Using SDL Manuel Rodr´ıguez-Cayetano Department of Signal Theory and Telematics Engineering University of Valladolid, ES-47011 Valladolid, Spain [email protected]
Abstract. This paper presents the design and development of a CPU scheduler simulator using SDL. This simulator enables us to study the behavior of one level and multilevel queue scheduling algorithms (including the real-time ones), and to obtain performance statistics for algorithm evaluation. In addition, a multi-platform graphical user interface, based on the Tcl/Tk language, has been developed to simplify the simulator use. The paper also presents our experiences in using SDL for the specification of CPU scheduling algorithms for educational purposes. Keywords: Operating systems, CPU scheduling, simulation, GUI, Tcl/Tk.
1
Introduction
Scheduling is a fundamental operating system function. Almost all computer resources are scheduled before use, and the processor (CPU) is one of the primary computer resources. CPU scheduling is the basis of multiprogrammed operating systems. By switching the CPU among processes, the operating system can make the computer more productive, [9]. CPU scheduling deals with the problem of deciding which of the processes ready to execute is going to be executed (the CPU is allocated to it). There are several CPU scheduling algorithms. The main difference among them is the criterion used for selecting the process to be executed. Different CPU scheduling algorithms have different properties and may favor one class of processes over another. In choosing which algorithm to use in a particular situation, we must evaluate the behavior of the various algorithms. One of the evaluation methods is simulation. Simulations involve programming a model of the computer system. The design, coding and debugging of a simulator can be a major task. Thus, appropriate specification techniques, like the Specification and Description Language (SDL, [6]), should be used to simplify the development and testing of the simulator. This paper presents the main aspects of the design and development of a CPU scheduler simulator for educational purposes that has been specified using SDL. The rest of the paper is organized as follows. Section 2 gives an overview of the CPU scheduling concepts and algorithms. Section 3 is devoted to the F.A. Kraemer and P. Herrmann (Eds.): SAM 2010, LNCS 6598, pp. 72–90, 2011. c Springer-Verlag Berlin Heidelberg 2011
Design and Development of a CPU Scheduler Simulator
73
development of the CPU scheduler simulator (requirements, internal structure and behavior). In Sect. 4 we discuss some aspects of the graphical user interface developed. Finally, in Sect. 5 we discuss the conclusions of the paper.
2 2.1
CPU Scheduling Overview
CPU scheduling deals with the problem of deciding which of the processes in the ready queue (processes ready to execute) is going to be executed (the CPU is allocated to it). There are several CPU scheduling algorithms. The main difference among them is the criterion used for selecting the process to be executed: process with the smallest arrival time, smallest CPU-burst length, shortest remaining execution time, earliest deadline (for real-time processes, where schedulability should be guaranteed), etc. Algorithms using a single criterion are appropriate for situations in which processes belong to a single group (all processes are equivalent with respect to the CPU scheduling). Another class of scheduling algorithms has been created for situations in which processes are easily classified into different groups (because they have different response time requirements and so might have different scheduling needs, for example). A multilevel queue scheduling algorithm partitions the ready queue into several ready queues, and each process is associated to the same ready queue during its life in the system. Each queue has its own algorithm, and the scheduling among the queues is commonly implemented as a fixed-priority preemptive scheduling. A detailed description of CPU scheduling algorithms for non real-time systems can be found in [9,10,11] and for real-time systems in [2]. Different CPU scheduling algorithms have different properties and may favor one class of processes over another. These properties should be used for choosing the appropriate algorithm for a particular situation. Many performance evaluation parameters have been suggested for comparing CPU scheduling algorithms. These evaluation parameters include CPU utilization, throughput, turnaround time, waiting time and response time (see [9] and [2] for a detailed definition). The criteria to be used in selecting an algorithm are often defined in terms of performance evaluation parameters. Once the selection criteria have been defined, algorithms under study have to be evaluated. One of the evaluation methods is simulation. Simulations involve programming a model of the computer system (the resulting program is called simulator ). In this model, software data structures represent the main components of the system (CPU, arrival queue, ready queue, etc.). The simulator has a variable representing a clock; as this variable is increased, the simulator modifies the system state to reflect the activities of the devices, the processes and the scheduler. As the simulation executes, statistics that indicate algorithm performance are gathered and printed.
74
M. Rodr´ıguez-Cayetano
The design coding and debugging of a simulator can be a major task. Thus, appropriate specification techniques, like SDL, should be used to simplify development and testing of this software. 2.2
Existing Simulators
Several CPU scheduling simulators have been previously developed for CPU scheduling algorithm evaluation. Among them we can find CPU Scheduling Simulator, [3], CPU Scheduler Application, [14], Process Scheduling Simulator, [8] or MOSS Scheduling Simulator, [7]. All of them (except for MOSS Scheduling Simulator ) can obtain the main per process (waiting time, response time, turnaround time, etc.) and global performance evaluation parameters (mean waiting time, maximum response time, mean turnaround time, etc.). Process Scheduling Simulator is also capable of plotting a Gantt chart showing the temporal ordering of the main simulation events. The main shortcoming of these simulators is that real-time and multilevel queue algorithms are not supported. Furthermore, in most of them the characteristics of the processes can not be defined using deterministic values (used for testing special process workloads, for example loads with several arrivals at the same time or arrivals during a context switch). They have to be specified using random values obtained from a statistical distribution. These shortcomings have lead to the development of a CPU scheduler simulator specified in SDL (sdlCPUSched). The main aspects of this simulator will be described in the following sections.
3 3.1
The SDL CPU Scheduler Simulator Simulator Requirements
Considering the shortcomings of the simulators analyzed in the previous section, the main requirements for the SDL CPU scheduler simulator (sdlCPUSched) are the following: – simulator for educational purposes, mainly used for behavior and performance analysis of CPU scheduling algorithms – support for non real-time algorithms: first come first served (FCFS), shortest job first (SJF), shortest remaining time first (SRTF), round robin (RR) and priority based (priorities) – support for real-time algorithms: Rate Monotonic Scheduling (RMS) and early deadline first (EDF) – support for multilevel queue algorithms, where the number of queues, queue algorithm and queue priority are configurable – generation of Gantt chart of process events during simulation – step by step or continuous simulation
Design and Development of a CPU Scheduler Simulator
75
Furthermore, to simplify the development of the simulator, some assumptions have been made: every process has only one CPU burst and zero input/output bursts, and all the processes are independent (process properties like arrival time and CPU burst time do not depend on properties of other processes). Considering these assumptions, a process is defined by the following information: – – – – –
arrival time CPU burst duration process priority (only for priority based algorithms) process period (only for real-time algorithms for periodic processes) identifier of the ready queue where the process is initially placed (0 if a single queue algorithm is used)
The simulator developed is a discrete-event simulator in which the operation of a system is represented as a chronological sequence of events. Each event occurs at an instant in time and marks a change of state in the system, represented by changes in the simulator variables. The clock always moves forward to the start time of the next event as the simulation proceeds. The simulator behavior will be explained in the following sections. 3.2
Simulator Behavior Overview
In this section the interactions between the simulator and its environment are summarized. A signal-based communication has been selected for the interactions between the SDL system and its environment, since these interactions are mainly asynchronous. Synchronous interaction is only required during configuration of a simulation. Interactions during the configuration of a simulation have to be synchronous because the simulator must confirm to its environment if every configuration parameter is correct or not. For example, arrival times of processes must be greater or equal to zero. If a configuration parameter is incorrect, the configuration of the simulation is aborted and the simulator returns to the initial state (no simulation is configured). Furthermore, the format of data exchanged between the SDL system and its environment does not depend on the type of communication used (signal-based or remote procedure-based) because a remote procedure call is modeled by an exchange of implicitly defined signals. The input signals of the SDL system are used for simulation configuration (process parameters, context switch times, algorithm to be simulated and its parameters) and for simulation control (start, stop or abort a simulation, etc.) The signals output to the environment are used for notifying configuration or simulation errors, performance statistics calculated at the end of the simulation and, if verbose mode is selected, for notifying events that occur during the simulation (a new process has arrived, a process is selected for execution, etc.) and the contents of the simulator queues. These signals are exchanged between the SDL system and its environment (the Graphical User Interface, GUI) using two TCP ports: a fixed-number port
76
M. Rodr´ıguez-Cayetano
created by the SDL system for the incoming signals and another one used for the outgoing signals. TCP communications are managed by the TCP/IP communications module of Telelogic SDL Suite 6.3, [4], included in the executable program generated from the SDL system specification. This program runs continuously, listening for requests from the user interfaces of different users. All the system output signals include as parameters the IP address and TCP listening port of the client user interface (this information is needed for the signal routing function of the program). The interactions allowed between the simulator and its environment are as follows. After starting, the simulator is waiting for new simulations to be requested. Interactions relating to configuration of a new simulation can be seen in Fig. 1 for a scenario without errors (all the scenarios are described using the Message Sequence Charts notation, [5]). A new simulation is requested through newScheduler signal, which includes as parameters the IP address and TCP port where the client of sdlCPUSched is listening for responses, and the language selected for messages (currently English or Spanish). After receiving the confirmation for this request (which includes the simulation identifier to be used in the rest of the input signals of this simulation), the client has to select the algorithm to be simulated with the signal simulationConfig c and if the step-by-step and verbose modes have to be selected or not. If the algorithm is multiqueue, the simulator will wait for one or more queueConfig c signals for specifying the parameters of each queue: single queue algorithm and queue priority (used also as queue identifier). endQueueConfig c signal is used to indicate end of queues configuration. If the algorithm is not multiqueue or if the endQueueConfig c signal is received, the simulator responds with a readySignal to confirm the configuration of queue(s). After that, context save and load times are specified (signal contextTimes c) and confirmed by the simulator. After this confirmation has been sent the queues of the system are configured and the simulator is ready to receive parameters relating to the processes of the workload. This scenario is shown in Fig. 2. Each process parameter is specified by a processData c signal (and confirmed with a readySignal one). End of process configuration is indicated with a dataEnd c signal. After the process configuration phase has been finished, the simulator is ready to start the simulation. This scenario (for a continuous simulation) is shown in Fig. 3. During simulation (and if verbose mode has been selected in the configuration phase) the simulator sends to the environment signals of type sendList with the contents of every queue modified by a simulation event, and a printEvent signal with event details (kind of event, process identifier and period of the process involved). Simulation end is notified by the simulationEnd signal, followed by processStatistic signals containing values of per-process statistics, globalStatistic signals with values of global statistics of the process workload and a schedulerEnd signal.
Design and Development of a CPU Scheduler Simulator
MSC CPUSchedulerOverview−configSim environment
CPUScheduler
initial newScheduler (IPAddress, port, language)
schedulerReady (IP, port, simId)
alt
1
simulationConfig_c (MultiQueue, verboseMode, stepByStepMode, simId)
2
loop <1,numberOfQueues> queueConfig_c (algorithm, queuePriority, simId)
3
opt extraAlgorithmConfig
3 2 endQueueConfig_c (simId)
1
simulationConfig_c (NonMultiqueueAlg, verboseMode, stepByStepMode, simId) 2
opt extraAlgorithmConfig
2 1 readySignal (IP, port, clock, code, msg) contextTimes_c (saveTime, loadTime, simId)
readySignal (IP, port, clock, code, msg)
simulationConfigured
Fig. 1. sdlCPUSched simulation configuration scenario
77
78
M. Rodr´ıguez-Cayetano
MSC CPUSchedulerOverview−configProcess environment
CPUScheduler
simulationConfigured 1
loop <1,numberOfProcesses> processData_c (arrivalTime, CPUBurstDuration, priorityOrPeriod, QueueId, simId) readySignal (IP, port, clock, code, msg)
1
dataEnd_c (simId)
readySignal (IP, port, clock, code, msg) simulationReadyToStart
Fig. 2. sdlCPUSched process configuration scenario
3.3
Simulator Structure and Detailed Behavior
The SDL system modeling the CPU scheduler consists of one block of type CPUSchedulerBlockType whose description can be seen in Fig. 4. This block consists of the processes in charge of the simulation tasks: control, masterScheduler and slaveScheduler. This structure has been selected for several reasons: – To keep intra-queue scheduling functions (responsible for selecting a process from a ready queue) apart from inter-queue scheduling functions (responsible for selecting a queue among all the ready-queues for activating it): for this reason, a MasterSchedulerType process type (for inter-queue scheduling) and a SlaveSchedulerType process type (for intra-queue scheduling) have been developed. – To minimize the amount of code not automatically generated from the SDL specification: To satisfy the requirement of multiuser simultaneous access to the simulator, several options can be considered: 1. A simulator only runs a simulation of one user (one simulator program instance for every user): in this case, every simulator program has to use a different TCP port number and that number has to be sent to its connected GUI, using auxiliary files or starting the GUI from the simulator with extra calling parameters (these methods require including c-language code, that could be non-portable, in SDL tasks). 2. A simulator can run several simulations: in this case, the simulator uses a well-known TCP port number for receiving input signals, that are
Design and Development of a CPU Scheduler Simulator
79
MSC CPUSchedulerOverview_running environment
CPUScheduler
simulationReadyToStart
opt
1
loop <1,numberOfEvents>
2 3
loop<0,numberOfListsModified> sendList (IP, port, clock, listyKind, list, listId)
3
printEvent (IP,port, clock, processId, processPeriodNum, enventType, msg) 2 1 simulationEnd (IP, port, clock) sendList (IP, port, clock, listyKind, list,listId) 1
loop <1, numberOfProcesses> loop <1, numberOfProcessStatistics>
processStatistic
(IP, port, processId, processPeriodNum, statisticName, statisticMsg, value)
2 2 1 1
loop <1, globalStatistics> globalStatistic (IP, port, statisticName, statisticMsg, value)
1 schedulerEnd_c (IP, port)
Fig. 3. sdlCPUSched simulation running scenario
routed by a control process to the processes in charge of simulation (masterScheduler processes, one per simultaneous running simulation). This is the selected option because it does not require extra coding. The main functions of the processes included in the CPUSchedulerBlockType block are described in the following sections. The control Process. The control process is responsible for creating the masterScheduler process in charge of a simulation requested by one user through its user interface, and for dispatching the signals coming from different user interfaces to the corresponding masterScheduler processes.
80
M. Rodr´ıguez-Cayetano
block type CPUSchedulerBlockType
1(1)
ControlType
Control_Env_R
control: ControlType ControlType_G
(control_input_sl)
ControlType_G schedulerEnd
schedulerReady, errorSignal, clientIdSignal, schedulerEnd_c
ctrl_scheduler_G schedulerReady, errorSignal, clientIdSignal, schedulerEnd_c, (output_sl)
(control_input_sl)
control_scheduler_R (scheduler_input_sl)
Master_Env_R (output_sl)
Master_Control_G masterScheduler(0,): MasterSchedulerType Master_Env_G master_slave_G
sendList, errorSignal
algorithmEnd, deactivateQueueACK
master_slave_R
slave_env_R
MasterSchedulerType
startAlgorithm, abortAlgorithm, getList, quantumSignal, apropiative, finaltime, activateQueue, procedure updateReadyList
slave_master_G slave_env_G slaveScheduler(0,): SlaveSchedulerType
Synonym CPUSchedulerBlockType.sbt_Id charstring = ’$Id: CPUSchedulerBlockType.sbt,v 1.2 2010/03/11 18:36:02 manrod Exp $’;
Fig. 4. CPUSchedulerBlockType block type
When the control process receives a request to start a new simulation (newScheduler signal) it creates a new masterScheduler process and a new client identifier (clientId ) for the new simulation. The control process also stores the IP address and port of the user interface requesting the simulation, the PId of the new masterScheduler process and the clientId in a new entry in the table of clients data (clientsData table). The request is answered with a signal (schedulerReady) which includes the clientId (used as parameter for the next input signals). Subsequent input signals, used for the configuration and control of the simulation, are forwarded to the corresponding masterScheduler process using the value of the clientId signal parameter and the information of the clientsData table. The masterScheduler Process. A masterScheduler process handles the functionality associated with simulation configuration, inter-queues algorithm and access control of the variables shared by the slaveScheduler processes.
Design and Development of a CPU Scheduler Simulator
81
Initially this process receives signals with simulation configuration and updates simulator variables as a result. It also creates slaveScheduler processes, one for each ready queue (there will be several ready queues if multilevel queue algorithm is selected, only one otherwise). After finishing configuration the process enters the simulationRunning state. In this state it executes the inter-queue algorithm (a preemptive priority based one). This algorithm selects the maximum priority non-empty ready queue and activates the corresponding slaveScheduler process. A slaveScheduler process implements a simple (non-multiqueue) scheduling algorithm on a ready queue. The inter-queue algorithm is activated when a process arrives to a ready queue or when a process terminates and its ready queue is empty. A masterScheduler process is also in charge of controlling the access to variables shared with its offspring slaveScheduler processes (arrival queue, terminated queue, idle CPU time, clock, etc.). Shared variables are defined in the masterScheduler process and accessed by using exported procedures (findArrivals, execProcess, interruptProcess, terminateProcess, etc.) called by slaveScheduler processes. When the simulation has finished (all the slaveScheduler processes have notified their termination to the master) the masterScheduler calculates the simulation statistics (per-process and global), sends the results to the SDL system environment (using signals processStatistic and globalStatistic) and terminates. The slaveScheduler Process. The main functionality of a slaveScheduler process is to simulate a simple (one ready queue) scheduling algorithm. This algorithm is in charge of finding process arrivals (storing every arrived process in a ready queue), selecting a process from a ready queue to be executed, interrupting a process and returning it to a ready queue (for example, if a process of greater priority arrives) and terminating a process when its CPU burst is completed (storing the process in the terminated queue). Some of these tasks are executed in an algorithm-independent way, and are described in the genericAlgorithm procedure; the others are described in algorithm specific procedures (fcfs, sjf, srtf, rr, priorities, rms and edf ). The appropriate algorithm specific procedure is called from the slaveScheduler process depending on the simulation configuration. The genericAlgorithm Procedure. The specification of the genericAlgorithm procedure can be seen in Fig. 5. This procedure starts in the deactivated state in which it only can receive requests to the updateReadyList procedure (invoked from the masterScheduler process to update the ready queue associated to this algorithm with new process arrivals) or the signal activateQueue that activates the queue managed by the algorithm. After this activation, the procedure enters a new state. This state is checkingExec if the ready queue is not empty and there is no process arrival at the current time; otherwise, the state is checkingArrivals. In the checkingArrivals state the findArrivals procedure (exported by the masterScheduler process) is called to update the ready queues with the processes
82
M. Rodr´ıguez-Cayetano procedure genericAlgorithm ;FPAR in/out readyList listType, in readyListId Integer, in/out runningProcess nodeData, in/out processInExec Boolean, in/out nextArrivalT Real, in/out clock Real, contextSaveT, contextLoadT Real, verboseMode Boolean, language languageType, clientData clientDataStruct; RETURNS endCauseType; maxPriArrivalQueueId := call findMaxPriNonEmptyQueue to PARENT
DCL aborting Boolean := False, abortCause endCauseType, auxNode nodeData, algActive Boolean := False, maxPriArrivalQueueId Integer := 0;
1(2) virtual
*(deactivated)
deactivated
procedure updateReadyList
checkingArrivals procedure updateReadyList
activateQueue( clock, nextArrivalT)
aborting = False − call emptyArrivalList to PARENT
False
False
True
algActive := True
True ENDOK
auxNode:= call getArrivalListHead to PARENT
(maxPriArrivalQueueId /= readyListId)
False
False
(not (call emptyList( readyList))) and (not (nextArrivalT = clock)) True
updateIdleCPUT (auxNode!arrivalTime −clock) to PARENT
processInExec checkingArrivals
True
checkingExec
clock := auxNode!arrivalTime *
clock := auxNode!arrivalTime findArrivals(verboseMode, aborting, readyList, readyListId, mkstring(runningProcess), clock, nextArrivalT, algActive, language, clientData) to PARENT
findArrivals(verboseMode, aborting, readyList, readyListId, Empty, clock, nextArrivalT, algActive, language, clientData) to PARENT
abortAlgorithm( abortCause)
aborting=True
abortCause
ERR
checkingActive algActive := False checkingExec
interruptProcess( verboseMode, aborting, readyList, readyListId, runningProcess, processInExec, clock, contextSaveT, nextArrivalT, algActive, False,language, clientData) to PARENT
not(aborting) and not(algActive)
not(aborting) and algActive
processInExec
checkingExec
aborting=True
true false
ERR deactivateQueueACK( clock)
deactivated
DCL genericAlgorithm.spd_Id charstring := ’ $Id: genericAlgorithm.spd,v 1.7 2010/09/07 09:32:45 manrod Exp $’;
procedure genericAlgorithm ;FPAR in/out readyList listType, in readyListId Integer, in/out runningProcess nodeData, in/out processInExec Boolean, in/out nextArrivalT Real, in/out clock Real, contextSaveT, contextLoadT Real, verboseMode Boolean, language languageType, clientData clientDataStruct; RETURNS endCauseType;
2(2) executingProc
interruptingProc
aborting = false
aborting = false
execProcess(verboseMode, aborting, readyList, readyListId, runningProcess, processInExec, clock, contextLoadT, nextArrivalT, algActive, language, clientData) to PARENT
interruptProcess(verboseMode, aborting, readyList, readyListId, runningProcess, processInExec, clock, contextSaveT, nextArrivalT, algActive, True, language, clientData) to PARENT
checkingActive
checkingActive
Fig. 5. genericAlgorithm procedure
Design and Development of a CPU Scheduler Simulator
83
arriving at the current clock time. If a process arrives at a queue of greater priority than the queue associated to the slaveScheduler process executing this genericAlgorithm procedure, this queue is deactivated (new state is deactivated ), and the running process, if any, is interrupted. The algorithm ends when the arrival and ready queues are empty. In every state of the procedure, the input of an abortAlgorithm signal or the change of the variable aborting to the true value triggers the procedure end, returning a false value (indicating that the simulation has been aborted so no statistics should be calculated). Tasks relating to the checkingExec state are algorithm specific, and are described in the algorithm specific procedures. Algorithm Specific Procedures. Algorithm specific procedures are in charge of tasks specific to the simple algorithm selected (tasks included in the transition from the checkingExec state to the checkingArrivals or executingProc states). These procedures inherit the specification of the algorithm-independent tasks from the genericAlgorithm procedure. An example of this kind of procedures is fcfs, whose specification can be seen in Fig. 6. If the procedure is in the checkingExec state and aborting of the simulation has not been selected, the procedure checks if a process is running in the CPU. If not, the process at the head of the ready queue is selected for execution by
procedure fcfs
1(1)
inherits genericAlgorithm;
DCL fcfs.spd_Id charstring := ’ $Id: fcfs.spd,v 1.8 2010/11/10 20:09:17 manrod Exp $’;
checkingExec
aborting=False
False processInExec True
((call precCompare( runningProcess! remainingExecT+clock, nextArrivalT)) /= LESS) AND (NOT(nextArrivalT = NOMOREPROCESSES))
True decrRemainingExecT( runningProcess, nextArrivalT−clock) to PARENT
executingProc
False
terminateProcess( verboseMode, aborting, runningProcess, processInExec, clock, language, clientData) to PARENT
True
checkingArrivals
call emptyList( readyList) False
Fig. 6. fcfs procedure
84
M. Rodr´ıguez-Cayetano
calling the execProcess procedure (exported by the masterScheduler process). After that, the procedure checks which is the next event: process termination or new process arrival. In case of a process termination, terminateProcess procedure is called (moving the terminated process from the ready queue to the terminated queue) and the algorithm tries to execute another process (if the ready queue is not empty) or to find another arrival. In case a new arrival occurs before the termination of the running process, the remaining execution time of this process is updated (because the clock is going to be updated to the time of the next arrival) and the procedure enters the checkingArrivals state. Transitions from the checkingArrivals state are inherited from the genericAlgorithm procedure. 3.4
Simulator Testing and Implementation
For testing the correct behavior of the simulator the facilities for simulating SDL systems of Telelogic SDL suite (simulator kernel and simulator user interface) have been used. Every single queue algorithm has been tested using two workloads: One with events occurring at different times and one with several events occurring at the same time, and with process arrivals during context switches (the more complex scenario). After all these tests have been passed, these two kinds of workloads have also been used with a two-queue and a three-queue configuration (with a real-time algorithm in one queue and non real-time algorithm in the others). For the implementation of the simulator a thread based integration has been used (every process of the SDL system is mapped to a thread of the operating system). The simulator implementation with the graphical user interface explained in the next section has been tested in several practical lessons of operating systems with 20 simultaneous users. The developed application has been mainly used for showing the behavior of scheduling algorithms in different scenarios to students, and for studying the suitability of every algorithm for scheduling different kinds of processes. In this study we have considered scheduling requirements of every kind of processes, described by performance evaluation parameters, and the degree of fulfillment of these requirements by the different algorithms. For example, CPU intensive processes do not have strict temporal requirements, but a low value for the mean waiting time of a workload of this kind of processes is desirable. Different algorithms have been used for scheduling this type of workloads, obtaining the mean waiting time for every algorithm and workload studied, and analyzing its variation with respect to processes and simulation parameters (number of processes, arrival times, CPU-burst lengths, save and load context switch times, etc.). This way, some conclusions can be drawn: A preemptive algorithm (like SRTF) usually obtains lower values for the mean waiting time than a non-preemptive one (like SJF or FCFS), but only if save and load context times are not too high.
Design and Development of a CPU Scheduler Simulator
4
85
The CPU Scheduler Simulator Graphical User Interface
The executable program generated from the SDL specification using Telelogic SDL suite does not include a user interface, but only an interface based on an ASCII text encoding of SDL signals exchanged with the environment, and accessible through a TCP port. A graphical interface (tkCPUSched ) has been developed to simplify the access to the simulator functionalities. This interface has been developed with Tcl/Tk [1], an interpreted language that provides rapid development of crossplatform graphical user interfaces. To simplify the design of the module in charge of communications with the SDL system, an approach based on an automatic generation of a parser (syntactical analyzer) and a lexical analyzer for received signals has been used. The basis of this approach is the definition of a grammar appropriate for the format used for representing SDL signals exchanged through the SDL system environment (Telelogic SDL suite ASCII encoding). This grammar includes the description of lexical tokens (a natural number, a string, etc.) and the rules to combine them (“a signal consists of a signal name and a list of parameters between {}”, for example). Using this grammar a parser and a lexical analyzer generator are used for obtaining signal parsing functions. fickle program, [13], has been used as the lexical analyzer generator and taccle, [12], as the parser generator. Both programs are described in Tcl and generate Tcl code.
Fig. 7. tkCPUSched main window
86
M. Rodr´ıguez-Cayetano
The main tasks of the graphical user interface (GUI) are the translation of user requests for configuration and execution control of a simulation into signals sent to the SDL system, and the translation of signals coming from the SDL system relating to the simulation events into a human readable format. The main window of the GUI can be seen in Fig. 7. This window includes several frames: – simulation parameters: for specifying the algorithm to be simulated, execution mode (step-by-step or continuous) and verbose mode (if activated all simulation events are shown) – statistics: shows the global statistics for the process workload and algorithm selected – simulator control: includes the buttons to control the simulation execution (next step for a step-by-step simulation, continue simulation, break or abort a running simulation) – events: shows simulation events (only in verbose mode), which include the event time, process number, period number and event specific message – data file loaded: shows the name of the file that contains the workload process properties to be simulated. When the simulation starts, a new window with the system queues status is opened. This window can be seen in Fig. 8. Every queue contains zero or more processes. There are three types of queues: an arrival queue (containing processes of the workload that still have not arrived to the system), ready queues (containing processes ready to run and waiting for allocation of the CPU), and a terminated queue (containing processes that have completed their execution). The process running and the clock value are also shown. When a process in a queue is selected with the mouse a new window is opened, showing process specific parameters (arrival time, burst time, total waiting time, etc.) This interface also provides some useful additional functionalities, like storing the simulation events and performance statistics (global and per process) in a file,
Fig. 8. tkCPUSched system queues window
Design and Development of a CPU Scheduler Simulator
87
Fig. 9. tkCPUSched Gantt chart window
and the automatic generation of the Gantt chart of a simulation from its events (that can be saved in a encapsulated postscript file). An example of a Gantt chart plotted during the simulation can be seen in Fig. 9. This figure shows different events: arrival, interruption (Int.) and end of processes, and process context save start (CSS), context save end (CSE), context load start (CLS) and context load end (CLE).
5
Concluding Remarks and Future Work
In this paper we have described the design and development of a CPU scheduling simulator using SDL. The use of this language for the specification of the simulator instead of developing it using a programming language has several advantages. First, an SDL specification of the behavior of a CPU scheduler algorithm is easier to understand than a description using a programming language: a graphical syntax is more expressive than a textual one, and an SDL specification does not have to include low-level details usually required in a programming language. Moreover, flow charts are usually used to describe algorithm or protocol behavior, and these charts can be easily translated into a high-level SDL specification that can be turned into a complete specification. In fact, a simplified version of the SDL specification of the FCFS algorithm, with a simpler structure but the same behavior than the version used in the simulator, has been used to illustrate its main behavior to students, and as a starting point for them to develop more complex algorithms. The aim of this
88
M. Rodr´ıguez-Cayetano
simplified version is to show an overview of the algorithm behavior. Due to this fact, the behavior is described in one diagram, without using object-oriented concepts like inheritance or virtual and redefined types. These concepts are useful to obtain well-structured and reusable specifications, but their use produces specifications based on several diagrams, more difficult to interpret by students. In our experience, the use of SDL for the specification of scheduling algorithms helps students to understand how algorithms work internally, as the specification describes in detail the algorithm behavior in every possible scenario. This specification is formal unlike natural language based specifications (usually used in operating systems text books), and it is simpler than a programming language based equivalent specification. Second, development and testing of a concurrent application (like the sdlCPUScheduler simulator) is simpler using SDL than using a general-purpose programming language: – Process communication mechanisms are included in SDL (signal or remote procedures); otherwise, in general purpose programming languages we have to use ad-hoc methods that require extra coding, methods based on external libraries, or methods based on threads and shared variables (methods that are error-prone and difficult to test). – Interactions allowed among processes are explicitly shown in SDL diagrams (channels connecting processes, signals that can be exchanged using each channel, etc.), but there is no explicit information about these interactions if a programming language is used (only send or receive primitives or access to shared variables, which are indistinguishable from non-shared variable access, are shown). This fact makes it more difficult to understand and debug a programming language source code than the equivalent SDL specification. With regard to the experience of using SDL, one of the problems we have found during the development with SDL is the routing of output signals when a signal destination is not specified and several destinations are possible. In this case, the signal will be received by an arbitrary instance of a process instance set. This instance set is arbitrarily chosen among instance sets which can be reached by the communication paths able to convey the signal instance. This feature is useful to simplify the specification of a system which includes several equivalent processes (any of them can execute the tasks relating to the input of the signal) but may lead to specification errors in many other kinds of systems (where the signal must be sent to an specific process of an instance set). We think that semantic analyzers of SDL tools should issue a warning when output without explicit destination is used and several destinations for the signal are possible. This way, some errors that otherwise have to be detected by simulation or testing, can be avoided. The other main problem was related to the correct use of exported procedures to avoid deadlocks. Exported procedures are an SDL feature useful to simplify the specification of synchronous communication among processes. In our development, they have been mainly used to ensure mutual-exclusion in the access to shared variables: these variables are accessed by processes using procedures
Design and Development of a CPU Scheduler Simulator
89
exported by the process which owns the variables. To avoid deadlocks, an exported procedure should not call procedures exported by other processes (because these in turn can call the first procedure). Furthermore, some rules have to be followed for calls among procedures belonging to the same process: all non-exported procedures that call an exported procedure should be specified at the process (or process type) level. If non-exported procedures are defined at an upper level, the exported procedure definition (specified at process or process type level) will not be visible for them, and a call to the local exported procedure by a non-exported local procedure will be considered a remote call (assuming that the remote definition is specified at an upper level). With regard to the developed application, the simulator is capable of simulating the behavior of simple scheduling algorithms (appropriate for one class of processes) and multilevel queue algorithms (appropriate for workloads with processes of different scheduling requirements). The simulator shows events relating to process scheduling during simulation and calculates per-process and global performance statistics. All the information is presented in a human-readable format using a graphical user interface. Concurrent access to the simulator from several user interfaces, showing results of different simulations, is also supported. The graphical user interface has been developed with Tcl/Tk, an interpreted language that provides rapid development of cross-platform graphical user interfaces. To simplify the functions required for SDL signal parsing, parser and lexical analyzer generators have been used, based on a grammar definition of the signal encoding used. This approach has the advantage that changes in the encoding used for the signals exchanged with the SDL system environment only involve changes in the signal grammar definition, and the automatic generation of the parser and lexical analyzer from the new grammar definition. This way, the graphical user interface can be easily adapted to support simulators generated by different SDL case tools or based on different signal encodings. The current version of the simulator can be improved by adding more complex algorithms, like multilevel feedback queue scheduling, in which a process can move from one ready queue to another depending on the scheduling requirements during its life in the system. Another improvement will be the extension of the simulation model to support multiple-processor/multi-core scheduling. Finally, the simulator could be modified to support processes with several CPU and I/O bursts. The current version only supports one CPU burst per process.
References 1. Tcl Developer Xchange, http://www.tcl.tk 2. Burns, A., Wellings, A.: Real-Time Systems and Programming Languages. Addison-Wesley, Reading (2002) 3. CodePlex: CPU Scheduling Simulator (April 2008), http://cpuss.codeplex.com 4. IBM: Telelogic SDL Suite 6.3 User’s Manual (September 2009) 5. International Telecommunication Union: Recommendation Z.120, Message Sequence Chart (MSC) (April 2004), http://www.itu.int/rec/T-REC-Z.120/en
90
M. Rodr´ıguez-Cayetano
6. International Telecommunication Union: Recommendation Z.100, Specification and Description Language (SDL) (November 2007), http://www.itu.int/rec/T-REC-Z.100/en 7. Ontko, R.: MOSS Scheduling Simulator User Guide (May 2001), http://www.ontko.com/moss/sched/user_guide.html 8. Robbins, S.: Using the Process Scheduling Simulator (January 2007), http://vip.cs.utsa.edu/simulators/guides/ps/ps_doc.html 9. Silberschatz, A., Galvin, P.B., Gagne, G.: Operating System Concepts. John Wiley & Sons, Chichester (2005) 10. Stallings, W.: Operating Systems: Internals and Design Principles. Prentice-Hall, Englewood Cliffs (2005) 11. Tanenbaum, A.S., Woodhull, A.S.: Operating Systems: Design and Implementation. Prentice-Hall International, Englewood Cliffs (2009) 12. Tang, J.: Taccle: Tcl LALR Parser Generator (July 2008), http://wiki.tcl.tk/11425 13. Tang, J.: Fickle: Tcl Lexical Analyzer Generator (July 2010), http://wiki.tcl.tk/3555 14. Weller, J.: CPU Scheduler Application. University of Alaska Anchorage (March 2006), http://jimweller.com/jim-weller/jim/java_proc_sched
UML-Based Specification and Generation of Executable Web Services Wafi Dahman and Jens Grabowski Institute for Computer Science, University of G¨ ottingen Goldschmidt Str. 7, 37077 G¨ ottingen, Germany {wdahman,grabowski}@informatik.uni-goettingen.de
Abstract. This paper presents an approach for the development of executable Web services based on model transformation techniques. The approach is based on a new Web service profile for the Unified Modeling Language (UML), which allows an efficient definition of Web service models. Such Web service models allow the generation of the source code and the corresponding platform-specific configuration files necessary in order to run the modelled Web services. The code generation is realised by means of transformation and code generation rules defined in the Xpand transformation language. The feasibility of the proposed approach for the development of executable Web services is validated by implementing a library system Web service as a case study. Keywords: Web Services, UML, Model Transformation, Code Generation, MDSD, Xpand, M2T, SOA, SoaML.
1
Introduction
Similar to other software applications, Web services have a specific structure and behaviour. The structure is the static part of Web services, which is composed of the objects and entities and their associations. The behaviour is the dynamic part, which represents how the Web service behaves in terms of sending requests, preparing responses to these requests, and how they will be sent back to the clients. Both parts are essential in the development of Web services in this paper. The UML [1,2,3] gains great acceptance among software developers due to its standardisation by the Object Management Group (OMG) [4]. Furthermore, it gets high support from tool vendors, where these tool offer also the possibility to generate parts of the source code from UML models [5,6]. In addition, UML offers an extension mechanism, where UML metamodels can be extended to fit the requirements of specific domains (e.g., Web services). Model Driven Software Development (MDSD) [7] is a software engineering approach that targets the development of executable software systems based on domain specific models. MDSD concentrates on domain models rather than computation. It focuses on defining a metamodel for a specific domain in any F.A. Kraemer and P. Herrmann (Eds.): SAM 2010, LNCS 6598, pp. 91–107, 2011. c Springer-Verlag Berlin Heidelberg 2011
92
W. Dahman and J. Grabowski
Domain Specific Language (DSL), then the model transformation takes place in order to reach the executable source code. MDSD offers possibilities to different types of model transformations such as Model-to-Model (M2M) or Model-toText (M2T). Our main goal is to enable the model-driven development of Web services though automated code generation from UML models. We are achieving this goal via two main contributions, summarized as follows: 1. UML Profile for Web Services (UP4WS): we define two categories of UML extensions. The first category represents the main extensions needed for any Web service application, while the second category is defined to enable the generation of executable Web services. 2. UP4WS implementation: the definition of Xpand transformation rules enables transforming UML models into source code. These transformation rules work at the UP4WS level in order to control the output of the code generation process. We have used our profile on two case studies, a weather Web service and a library system Web service. The value of our approach is that it helps reducing time and effort during the development process by the simple allocation of the UP4WS stereotypes on a UML model of the service. This finding has been observed during the development and implementation of the library service. We believe that our approach can also improve the quality of the final product, since the iterative use of UP4WS helps detecting and avoiding certain types of anomalies. This paper is organised as follows: Section 2 describes the underlying technologies related to our approach. Section 3 presents the definition of UP4WS profile, while Sect. 4 presents the implementation of the UP4WS. Section 5 shows the case study used to validate our approach. Section 6 describes the related work. In Sect. 7, a summary and outlook is provided.
2
Foundations
In this section, the underlying technologies of our approach are introduced. 2.1
Web Services
Web services are one of the methods for the implementations of the Service Oriented Architecture (SOA) [8], which is sketched in Fig. 1. The figure shows the service provider, the service client, and the service broker and their associations. This paper is mainly focusing on implementing the service provider and service client sides. The word Web in the name Web services does not mean that it is a Web application, but that it relies on technologies for the Web like the Hypertext Transfer Protocol (HTTP) [9]. The main goal of Web services is to enhance the interoperability of distributed systems over networks, especially the Internet.
UML-Based Specification and Generation of Executable Web Services
93
Fig. 1. Roles in the Service Oriented Architecture (SOA)
2.2
Unified Modeling Language Profiles
UML is a general purpose graphical modelling language for the development of systems. Despite the fact that UML is mostly used with object oriented systems, it has the capability to model other types of systems through its flexible extension mechanism. UML profiles can be defined to adapt UML for specific domains. Arlow and Neustadt [5] define a UML profile as“a collection of stereotypes, tagged values, and constraints”. The OMG has standardised many UML profiles to fit different types of systems and technologies, such as UML Profile for Common Object Request Broker Architecture (CORBA) [10]. Figure 2 illustrates a sample UML profile called WidthAndLength shown as a package with «profile» stereotype. The WidthAndLength profile includes two stereotypes, i.e., Length extending the Association and Class metaclasses, and Width, extending the Class metaclass. The Length stereotype includes a tagged value length of type float, while the Width stereotype includes a tagged value width of type Integer. The Length stereotype contains a constraint limiting the length to less than or equal five ({length<=5.0}). The WidthAndLength profile is applied by the MyWidthAndLengthApplication model.
Fig. 2. UML WidthAndLength profile
!"
94
W. Dahman and J. Grabowski
Fig. 3. Xpand in example
2.3
Code Generation
Code generation is the other common name for Model-to-Text (M2T) or Modelto-Code (M2C) transformations, where textual code is generated from a given model. The generated code is supposed to be ready for interpretation or compilation. Therefore, it should be complete and executable from the modeller’s point of view [11]. Code Generation with Xpand. Xpand is a template-based M2T transformation language. It was initially developed by OpenArchitectureWare [12]. Since September 2009, Xpand has become part of the M2T transformation languages integrated into the Eclipse platform [13]. Figure 3 shows the Xpand transformation rules for generating a Java file that corresponds to the UML class Book. On the left, a template file that consists of different templates is shown. Each template handles specific elements in the class, such as attribute declarations, operations, setter and getter methods.
3
UP4WS Definition
Unlike other UML profiles that try to represent the semantics of the technology (e.g., UML profile for CORBA), the UP4WS can be considered as an implementation oriented profile, since we developed it to enable the generation of executable Web services. The profile captures knowledge similar to what is found in
UML-Based Specification and Generation of Executable Web Services
95
the Service Oriented Architecture Modelling Language (SoaML) [14] by defining some stereotypes. However, the SoaML is extended in a way that enables the generation of executable Web services. This includes the definition of additional stereotypes that make the generation of executable source code possible. The UP4WS represents the core of the modelling of Web services, and the basis on which the code generation process will rely, since the proposed code generation process and the transformation rules will handle directly the stereotypes of the UP4WS. The UP4WS defines two categories of UML extensions. The first category contains the basic extensions, which must be present in any Web service application model. The second category includes the stereotypes that make Web services executable by enabling the generation of source code from the model elements applying those stereotypes. Both the service provider side and the service client side are considered in the definition of the profile and its implementation. The target output from the code generation process using the UP4WS comprised of: – Source code, – Configuration files for the implementation and deployment platforms, and – Documentation files. 3.1
Web Services Basic Extensions
The basic extensions are mandatory extensions, since they represent the necessary parts for Web services. These extensions are explained in the following: – Each Web service application comprises a service provider side, and a service client side. – The service provider side must have a service object representing the different services provided by the Web service. These services can be represented in terms of operations or methods. – The methods or operations in the service object manipulate data stored in other objects, i.e., data objects. These objects provide different data elements, i.e., data variables or attributes. – The service client side always contains a client object that invokes the services provided by the Web service and represented in the service object. The execution of the Web service is achieved by executing the client object. Therefore, it must contain an execution mechanism (e.g., main method in Java or C). Our assumption is to define two objects at the service client side: the proxy client object, which is accessed by another client object. The proxy client object implements the services from the client’s perspective, while the client object contains the execution mechanism of the Web service. Table 1 shows the main stereotypes in the UP4WS and the UML metaclasses, while Figure 4 represents a simplified weather Web service model that applies the UP4WS.
96
W. Dahman and J. Grabowski Table 1. Main web service stereotypes UP4WS main stereotypes Web Service Element Stereotype UML Metaclass Web service object «WebService» Class Services «ProxyMethod» Operation Data objects «DataContainer» Class Data variables «DataElement» Attribute Proxy client object «ProxyImplementation» Class Client object «Client» Class Client Execution mechanism «ClientMain» Operation
Fig. 4. Weather web service model
3.2
Making Web Services Executable
In order to enable the generation of source code and configuration files that make Web services executable, an additional set of UML extensions is required in the UP4WS. This set enables the generator to access the stereotyped elements of the UML model and generate the output according to their specifications. The extensions in this respect are classified into two categories. The first extensions category enables the generation of Web services behaviour from state machines. Specifying the behaviour of the Web service in detail enables its execution by generating the corresponding source code for that behaviour. State machine diagrams can be used to represent the behaviour of the Web service. Therefore, additional extensions to be applied by state machine diagrams and their elements have to be specified. We distinguish between two types of state machine diagram extensions: – The «ObjectStateMachine» stereotype is defined to enable the generation of the behaviour implementation of the data objects. If one of the data
UML-Based Specification and Generation of Executable Web Services
97
objects has a behaviour, the state machine representing this behaviour should apply the «ObjectStateMachine» stereotype. Other stereotypes that enable its implementation shall also be included. Those stereotypes are «ObjectState», «ObjectTransition» and «ObjectFinalState» stereotypes. – The «OperationStateMachine» stereotype is defined to enable the generation of the implementation of the class operations. Therefore, a state machine applying this stereotype has to be assigned to the operation, for which we need to generate the implementation. As parts of the «OperationStateMachine» stereotype, the «OperationState» and «OperationTransition» stereotypes are defined. The second extensions category enables the generation of specific implementation constructs in the source code (e.g., attribute declarations). For this category, we define two stereotypes as follows: – «Initializable» stereotype to generate the declaration of the attribute that have to be initialized. – «Enumerizable» stereotype to generate the declaration of the attributes of a type corresponding to an enumeration object. The complete UP4WS stereotyped are presented in the following classification. – Basic extensions: «WebService», «DataContainer», «DataContainer», «ProxyImplementation», «ProxyMethod», «Client», and «ClientMain» stereotypes. – Making Web services executable extensions: this category is classified into two sub-categories as follows: • Executable state machines: we distinguish between two types of state machines depending to which they are assigned, i.e., assigned to an object, and assigned to an operation. For the first type we define «ObjectStateMachine», «ObjectState», «ObjectTransition» and «ObjectFinalState» stereotypes. The second type of stereotypes includes «DataBehavior», «OperationStateMachine», «OperationState», and «OperationTransition» stereotypes. • Auxiliary extensions: in this category we define «Initializable», and «Enumerizable» stereotypes.
4
UP4WS Implementation
The profile implementation represents the model transformation and code generation process, which includes defining the transformation rules for transforming the model elements into the source code, and configuration and documentation files. Each element in the source model applying any stereotype defined in the UP4WS will be processed by the generator and thus influences the output. It is important to mention here that the communication between the service client and service provider is not part of the UP4WS implementation since it is done completely in the background by the Web service engine. In other words, we treat both sides independently of the way they communicate.
98
4.1
W. Dahman and J. Grabowski
Model Transformation and Code Generation
The model transformation and code generation process aims at producing the target output from the UML model. Figure 5 provides an overview of the entire model transformation process. It shows the UP4WS, which is applied by a UML model. The model is then exported to the generator, which applies the transformation rules on it in order to generate the relevant output. The Xpand transformation language is used for transforming the UML model into the target output files (i.e., source code and configuration files for the platform). The transformation rules work on the UP4WS level, meaning that they handle only stereotyped elements in the Web service model. The Xpand transformation rules are defined in terms of templates and template files. Each template file corresponds to a specific stereotype. We have organised the transformation rules in different template files, where each one is responsible for generating the Java classes that correspond to the objects in the model. In addition, we have defined a common template file, where general transformation rules exist. These rules are invoked inside other template files.
*+
!
$"
% &'#( )
! "#
Fig. 5. Model transformation and code generation process
The Xpand code inf Fig. 6 represents an example of transformation rules, which are responsible for generating setter and getter methods for any attribute applying the «DataElement» stereotype. At first, it checks that that visibility of the attribute is private. If yes, the transformation rules are executed and the corresponding methods are generated.
5
A Case Study: Library System Web Service
For the validation of the UP4WS and the code generation process, a case study is implemented in order to demonstrate the feasibility of our approach. 5.1
Web Service Description
The library system Web service is chosen because of its well-known characteristics and the familiarity of its functionalities. Each functionality represents one of the services provided by the library system Web service.
UML-Based Specification and Generation of Executable Web Services
99
«DEFINE gettersAndSetters FOR UP4WS::DataElement» «IF visibility.toString() == "private"» public void set«name.toFirstUpper()» («type.name» «name.toFirstLower()») this.«name»= «name.toFirstLower()»; public «type.name» get«name.toFirstUpper()» () return this.«name»; «ENDIF» «ENDDEFINE» Fig. 6. Example for transformation rules
A typical library system Web service could have the following brief description: The library Web service system manages the virtual book list of the library. Each book is distinguished via title, International Serial Book Number (ISBN), and author. The library Web service provides mechanisms for different processes on books. The client shall be able to add books to the book list. The books become available and can be borrowed. If a book is borrowed, it becomes on loan. The borrowed book shall be returned to the book list and become available again. In order to allocate the stereotypes of the UP4WS to the model elements we have to identify the model elements that shall apply the basic stereotypes in the UP4WS. From the library Web service system description, the following objects are identified. – Library System service (Web service object). – Book, and Book List (data objects). – Client (proxy client and client object). In addition, the Web service description indicated that the Web service provides the following services: – Adding books – Lending books – Returning books 5.2
Identifying and Allocating UML Extensions to the Library Web Service
We now identify the UML extensions for the library Web service. This is the initial step for allocating the stereotypes on the elements that represent the UML extensions for Web services. UP4WS defines a set of basic extensions that must be specified in any Web service model applying it. The following is a list of the identified basic extensions for the library Web service:
100
W. Dahman and J. Grabowski
Fig. 7. Class diagram for the service provider side
– – – – –
LibrarySystemService represents the service object. addBook, lendBook, and returnBook represent the provided services. Book and BookList represent the data objects. Book name, ISBN, and author represent data variables. Client represents client object.
The allocation of the UP4WS stereotypes on the UML model elements for the library Web service is shown in Fig. 7. The figure shows the main objects at the service provider side and a specific subset of their elements to show the usage of the basic extensions of the UP4WS in the library system Web service model. In the following, the allocation of the UP4WS stereotypes on those objects is presented. – – – –
5.3
LibrarySystemService extends the «WebService» stereotype. Book and BookList extend the «DataContainer» stereotype. isbn, title, author in Book class extend the «DataElement» stereotype. getBook, and lendBook in LibrarySystemService class extend the «ProxyMethod» stereotype. Representing Library Web Service Behaviour
The description of the library Web service indicates that the Book object has different states, e.g., available and borrowed. For the representation of the Book object behaviour, a state machine diagram is used. The state machine diagram enables the implementation of the behaviour of the corresponding object. Figure 8 represents the state machine diagram modelled to represent the behaviour of the Book object. It contains three states, i.e., NotAvailable, Available, and OnLoan. The state NotAvailable is added to represent the default state of any book instance. The BookStatus state machine diagram in Fig. 8 applies the «ObjectStateMachine» stereotype in order to enable the generation of the behavioural source code.
UML-Based Specification and Generation of Executable Web Services
101
Fig. 8. Book Status
5.4
Generating, Deploying and Executing the Web Service
This process includes the code generation process and the deployment and execution of the library Web service on the selected platform, which is the Apache Axis2/Java [15] as a Web service engine, and the Apache Tomcat [16] as an application server. The code generation process is performed by using the Xpand transformation language on the Eclipse platform [13]. The generator receives the source UML model for the library Web service as an Eclipse Modeling Framework (EMF) [17] Unified Modeling Language v.2.x (UML2) XML Metadata Interchange (XMI) [18] file. This is the file format used in the library Web service and exported using the Magic Draw [19] UML tool. Running the Eclipse/Xpand generator requires the definition of the Modeling Workflow Engine (MWE) file. The MWE file specifies different parameters of the project, such as the source model, UML profile, and location of output files. The MWE file includes different components, which serve for various purposes. The following list describes briefly the main components in the MWE file: – Cleaner component to clean the output folder at each run of the generator. – Generator components, which are responsible for generating the different types of the output files. Each generator component can define an outlet to specify the exact location of output file. The configuration files are platform dependent files needed to implement and deploy the library system Web service on the Apache Axis2/Java Web service engine and the Apache Tomcat application server. The files in this specific context are the build.xml and the services.xml files. The build.xml file enables the compilation of the Java files at the service provider side the generation of the archive file LibrarySystemService.aar, which enables the deployment of the Web service on the Apache Tomcat application server. The README.txt file is a documentation file that provides instructions on how to execute the Web service application.
102
W. Dahman and J. Grabowski
Based on the generated output, the Web service shall be executable on the Apache Axis2/Java Web service engine. Figure 5 has shown the code generation process for the UP4WS and the corresponding model. In the following, a description of the sequence of steps that shall be done to execute the Web service is presented. These steps are also explained in the README.txt file, which is part of the output. – Export the profile and model to the Eclipse/Xpand generator where the transformation rules for generating the output reside. – Run the generator in order to get the target output. – Move the output to the Apache Axis2/Java platform for executing the Web service. – Compile the Java files at the service provider side using the ANT [20] tool. This will generate the archive file of the Web service. This file contains all information about the Web service. and should be copied in the relevant location in the Apache Tomcat [16], in order to deploy the Web service. – Compile the Java files at the service client side in order to execute the Web service. The Web service can be executed by running the client object that contains the main method. The code generation process produces the source code required for executing the Web service. The source code includes all Java classes resulting from the UML classes in the model, which apply the corresponding stereotypes in UP4WS, and the containing the behaviour expressed in state machine diagrams as described in Sect. 3.2. The source code runs successfully in Windows XP and Windows Vista environments [21].
6
Related Work
The examined work covers different perspectives that relate to the goal of this paper. Each perspective corresponds to a sub-goal of this paper. For example, some approaches try to model Web services with UML. However, their view of Web services is constrained to Web Service Description Language (WSDL) documents [22,23,24]. Others take the composition of Web services into consideration [25,26]. Another category of the related work focuses on the generation of source code out of UML models independent of the type of the application and the implementation platform [27]. The following is a brief description for the most relevant and related work. The conversion rules between UML and Web services described by WSDL documents and Xtensible Mark-up Language (XML) Schema is provided by Grønmo et al. in [23]. They recommend the modelling of Web services by UML disregarding the WSDL constructs and present a mapping between WSDLindependent UML models and the service description in WSDL. They find out that: 1) a WSDL-independent UML model of a web service is better than a WSDL-dependent model or pure WSDL in explaining the service, 2) WSDLindependent UML models make the building of Web services simpler, especially
UML-Based Specification and Generation of Executable Web Services
103
if the Web service is complex, and 3) reverse and forward engineering between WSDL specifications and WSDL-independent UML models is possible for all kinds of services. Skogan et al. [25] introduce a UML-based model-driven method for Web service composition. This method shows the possibility of using model transformations to get executable models from composite Web services models. In addition, they present a UML profile and guidelines for modelling composite Web services. Th¨one et al. [26] define a similar method to describe a UML-Web Service Composition (WSC) profile as a replacement for the Business Process Execution Language for Web Services (BPEL4WS), which is a language for the formal specification of business processes and business interaction protocols [28]. Lautenbacher [29] defines transformation rules in Xpand for semantic Web services. He develops a UML profile for semantic Web services based on a predefined metamodel. The work considers a set of World Wide Web Consortium (W3C) specifications, such as Semantic Markup for Web Services (OWL-S), Web Service Modeling Ontology (WSMO), Web Service Description Language with Semantics (WSDL-S) and Semantic Web Services Framework (SWSF). Usman and Nadeem [27] develop a code generation tool known as UJECTOR. The UJECTOR tool generates code from UML class, sequence, and activity diagrams. The structure of the code is generated from the class diagrams, while the sequence diagrams with incorporation of the activity diagrams generate the code for the methods in the classes. Since the work presented in this paper is targeting the generation of executable source code for Web services, the following comparison discusses how close the related work is to ours. Our approach introduces a comprehensive specification for the development of executable Web services, and not only for WSDL documents [23,25,26] or specific W3C standards [29]. Furthermore, it defines a set of transformation rules in order to generate different output files of several types from UML models based on the UP4WS [21]. The work presented in this paper concentrates on the implementation of Web services and how we can generate executable source code from UML models, which applies the proposed UP4WS. The work in [23,25,26] rather concentrates on the representation of Web services by means of WSDL and BPEL4WS without providing a mechanism for implementing the Web service. In [29], Lautenbacher defines transformation rules with Xpand, which is also used in our approach. However, it focuses on different semantic Web services specifications (i.e., OWL-S, WSMO, WSDL-S and SWSF), which do not enable the implementation of executable Web services. A review of the work of Usman and Nadeem [27] shows that their work does not target any specific platform. It defines a mechanism for generating Java source code from UML diagrams, without targeting any domain or platform. Unlike our work, their model transformation approach is not based on a specific metamodel for the target domain. The OMG [4] standardised a modeling language for SOA based application [14]. This language expresses the semantic of such applications by defining different stereotypes for
104
W. Dahman and J. Grabowski
the elements involved in them. However, we had to define additional stereotypes to enable the generation of executable Web services, especially for generating the Web service behaviour.
7
Summary and Outlook
This section provides a summary of the paper together with a brief discussion of its main contributions. It also gives an outlook for the possible extensions of this work. 7.1
Summary
This paper introduced an approach for the code generation of executable Web services. For this purpose, a UML Profile for Web Services (UP4WS) is defined. The UP4WS defines two types of extensions for Web services. The first type is the Web service specific extensions, which are mandatory and must be specified for any Web service application disregarding on which platform the Web service will be implemented and deployed. Those extensions consider the implementation of the service provider and service client sides. The second type are the extensions that enable the generation of executable source code for Web services. The paper defines the UP4WS implementation process, which includes the definition of the transformation rules for the generation of the target output. The transformation rules are defined in the Xpand language. For the validation of this work, a case study where we applied our approach to a library Web service is presented. 7.2
Discussion
Our approach has shown how we can utilise model driven development approaches for defining domain specific models. We shall be able to generate executable source code and configuration files based on those models. In this section, we illustrate some issues that may come in question. The following is a brief discussion of some of these issues. We aim at implementing a Web service, namely service provider and service client sides. The mechanism by which both sides communicate is out of the scope of this paper since it is done completely in the background by the Web service engine. For enabling the implementation of Web services, we defined a small set of stereotypes that can be easily understood, even by non-Web service developers. It is supposed that the UP4WS stereotypes can be applied by any Web service application. Another additional benefit of the UP4WS is its potential reusability. Since Web services are based on the SOA architecture, the proposed UP4WS seems promising for implementing other types of applications that rely on the same architecture. For example, it should be possible to customise the UP4WS for CORBA applications.
UML-Based Specification and Generation of Executable Web Services
105
We used the Xpand transformation language for defining the transformation rules. Xpand is one of the most recent transformation languages, which has gained experience from its ancestors by avoiding their weaknesses such as a complex syntax. It follows a simple and understandable syntax, and has an interactive support from its community and developers as well. The transformation rules process the stereotyped elements in the model. This increases their usability, since they are dedicated only to the UP4WS stereotypes, and thus, do not contain the complexities imposed by some UML elements. The transformation rules are defined to generate the source code in Java. Although this could be seen as a limitation, we believe that they can be reused to enable the generation of source code in other programming languages, such as C and C++, since programming languages follow a similar syntax. The Web service engine used to implement Web services in our approach is the Apache Axis2 together with the Apache Tomcat as an application server. This selection only influences the transformation rules for generating Java classes at the service client side. Therefore, the transformation rules can be reused for implementing Web services using other Web service engines by only applying the corresponding modifications for the new Web service engine. 7.3
Outlook
This paper showed how to use state machine diagrams for the representation of Web services behaviour. Using other behavioural diagrams, such as activity diagrams is promising as well and could be investigated in future work. Furthermore, this paper demonstrated how to generate Java source code for a specific platform and Web service engine. It should be possible to extend this approach to the implementation of Web services in other programming languages and on different platforms and Web service engines. The composition of Web services is one of the most important topics related to Web services. Composite Web services enable the reuse of already existing Web services to provide more comprehensive and larger Web services. In such cases, the Web service plays the role of service provider and service client at the same time. Therefore, it should have the mechanisms for providing and invoking other Web services. The UP4WS defines a specific set of UML extensions for a single Web service. Since the composite Web services have more sophisticated architecture and behaviour, it may be necessary to define additional UML extensions for composite Web services. Our approach provides a promising starting point for investigating the required modifications of the profile definition and its implementation. Additionally, we will investigate the possibility to follow the guidelines for UML profile design [30] standardised by the International Telecommunication Union-Telecommunication (ITU-T). Acknowledgements. The authors are very thankful to Dr. Daniel Amyot and Philip Makedonski for their valuable suggestions and the proof reading.
106
W. Dahman and J. Grabowski
References 1. OMG: Unified Modeling Language: Infrastructure, V2.3. formal/2010-05-03 (2010) 2. OMG: Unified Modeling Language: Superstructure, V2.3. formal/2010-05-05 (2010) 3. UML: Unified Modeling Language, http://www.uml.org/ (last visited August 2010) 4. OMG: Object Management Group (OMG), http://www.omg.org/ (last visited August 2010) 5. Arlow, J., Neustadt, I.: UML 2 and the Unified Process, 2nd edn. Addison-Wesley, Reading (2005) 6. Fowler, M.: UML Distilled. Addison-Wesley, Reading (2004) 7. Stahl, T., Voelter, M.: Model-Driven Software Development. John Wiley & Sons, Ltd., Chichester (2006) 8. Erl, T.: Service-Oriented Architecture. A Field Guide to Integrating XML and Web Services. Prentice-Hall, Englewood Cliffs (2004) 9. Conallen, J.: Building Web Application with UML, 2nd edn. Addison-Wesley, Reading (2003) 10. O.M.G.: UML Profile for CORBA, v 1.0. formal-02-04-01 (April 2002) 11. Kelly, S., Tolvanen, J.P.: Domain Specific Modeling. Wiley-Interscience Publication, Hoboken (2008) 12. OAW: OpenArchitectureWare (oAW), http://www.openarchitectureware.org (last visited August 2010) 13. Eclipse: Eclipse Platform, http://www.eclipse.org/ (last visited August 2010) 14. OMG: Service Oriented Architecture Modelling Language. ptc/2009-12-09 (December 2009) 15. Apache: Apache Axis2/Java, http://ws.apache.org/axis2/ (last visited August 2010) 16. Apache: Apache Tomcat, http://tomcat.apache.org/ (last visited August 2010) 17. Steinberg, D., Bundinsky, F., Paternostro, M., Merks, E.: EMF Eclipse Modeling Framework, 2nd edn. Addison-Wesley, Reading (2008) 18. OMG: MOF 2.0/XMI Mapping, v2.1.1. formal/2007-12-01 (December 2007) 19. MagicDraw: Magicdraw, http://www.nomagic.com (last visited August 2010) 20. Apache: The Apache ANT Project, http://ant.apache.org/ (last visited August 2010) 21. Dahman, W.: A UML Based Methodology for the Development of Web Services, An Approach to Model Transformation and Code Generation. PhD Thesis, Institute for Informatics, Georg August University of G¨ ottingen (July 2010) 22. Marcos, S., Castro, V., Vela, B.: Representing Web Services with UML: A Case Study. In: UNITN - The First International Conference on Service Oriented Computing, UNITN (2003) 23. Grønmo, R., Skogan, D., Solheim, I., Oldevik, J.: Model-Driven Web Services Development. In: Proceedings of the IEEE International Conference on e-Technology, e-Commerce and e-Service (IEEE 2004), pp. 42–45. IEEE Computer Society, Washington, DC (2004) 24. Armstrong, C.: Modeling Web Services with UML. In: OMG Web Services Workshop 2002 (2002) 25. Skogan, D., Grønmo, R., Solheim, I.: Web Service Composition in UML. In: Enterprise Distributed Object Computing Conference (EDOC 2004), pp. 47–57. IEEE Computer Society Press, Washington, DC (2004)
UML-Based Specification and Generation of Executable Web Services
107
26. Th¨ one, S., Depke, R., Engels, G.: Process-Oriented, Flexible Composition of Web ` Yoshikawa, M., Yu, E.S.K. (eds.) ER 2003. LNCS, Services with UML. In: Oliv´e, A., vol. 2784, pp. 390–401. Springer, Heidelberg (2003) 27. Usman, M., Nadeem, A.: Automatic Generation of Java Code from UML Diagrams using UJECTOR. International Journal of Software Engineering and its Applications 3(2) (2009) 28. BPEL4WS: BPEL4WS V1.1 specification (2003), http://download.boulder.ibm. com/ibmdl/pub/software/dw/specs/ws-bpel/ws-bpel.pdf (last visited August 2010) 29. Lautenbacher, F.: A UML Profile and Transformation Rules for Semantic Web Services. Technical Report 2006-2020, Institut for Informatics. Augsburg University, Germany (2006) 30. International Telecommunication Union: Recommendation Z.119, Guidelines for UML Profile Design (February 2007), http://www.itu.int/rec/T-REC-Z. 109-200706-I/en
The SDL-UML Profile Revisited Alexander Kraas Poppenreuther Str. 45, D-90419 Nürnberg, Germany [email protected]
Abstract. The ITU-T has published the most recent version of a UML profile for the combined use of the Specification and Description Language (SDL) and the Unified Modelling Language (UML) in the year 2007. This SDL-UML profile encompases the specification of structural and behavioral aspects of a SDL system in terms of a UML model. In this paper, limitations of the models for data type and value specification of the current SDL-UML profile are analyzed. On this foundation, new models for both aspects are proposed in order to remedy the analysed limitations in an upcoming version of a UML profile for SDL-2010. Keywords: SDL-2010, SDL-UML Profile, Value Specification, Data Type Specification.
1
Introduction
The first version of a UML profile for the combined use of the Specification and Description Language (SDL) and the Unified Modeling Language (UML) was published in 1999 by the ITU-T [1]. This profile version had only supported the specification of structural aspects, whereas the most recent version of the SDL-UML profile [2] also includes the modelling of behavioral aspects. This also comprises a particular action language and an associated surface language, which is a subset of the concrete syntax of SDL-2000 [3]. In consequence, with the current profile version it is possible to specify a SDL system in terms of a UML model. This aspect was analysed in a case study [4], which had the objective to model the same system in native SDL and with the SDL-UML profile. In general, the case study proved that SDL-UML is applicable in the same way as SDL. Nevertheless, some limitation and shortcomings have been discovered on the basis of this case study. The author of this paper has reported the analyzed shortcomings to the ITU-T Study Group 17 in order to remedy them in the current version of the Z.109 Recommedation [2]. However, discovered limitations related to the current data type model and the value specification model were not included in that report. Hence, the different limitations are presented in the following chapters. In addition, a new data type model and a new value specification model are proposed for the upcoming version of a UML profile for SDL-2010. The rest of this paper is structured as follows. Section 2 discusses other related UML profiles for the modeling of communication systems. In Sect. 3, a few F.A. Kraemer and P. Herrmann (Eds.): SAM 2010, LNCS 6598, pp. 108–123, 2011. c Springer-Verlag Berlin Heidelberg 2011
The SDL-UML Profile Revisited
109
notational conventions are introduced. The limitations of the current data type model of SDL-UML and an approach for their solution are discussed in Sect. 4. In the scope of Sect. 5, the current model for value specification is analyzed. Finally, the last section provides a brief summary.
2
Related Work
Apart from the SDL-UML profile as specified in the most recent version of the Z.109 [2], also other approaches had been proposed for the UML-based specification of communicating systems (such as [5,6]). Of these, the UML profile for communicating systems (UML-CS) in [6] is the most complete. The most significant difference between profiles is the manner in which the semantics are specified. The mapping rules of the SDL-UML profile are specified in terms of textual rules. In contrast, for the mapping of the UML-CS profile, an eXtensible Stylesheet Language Transformation (XSLT) approach is utilized. Both profiles specify SDL-specific action semantics, but SDL expressions are represented in a different way. In SDL-UML, expressions are represented in terms of UML expressions, whereas in UML-CS the semantics of expressions are not specified. In addition, for the UML-CS profile no model for value specification is defined. The advantage of representing SDL expressions and values in terms of dedicated UML elements is that parse trees for the textual surface language of SDL-UML can be stored in the model repository of a UML tool. Hence, transformations of shorthand notations and static syntax checks can be directly performed on UML elements. The general applicability of the SDL-UML profile was analyzed in [4], but during the implementation of an appropriate editor, some limitations of the most recent version of the profile have been found. In particular, this concerns the specified models for data type and value specifications. The data type model and model for value specification in the following chapters are proposed to remedy this situation.
3
Notational Conventions
Due to the fact that in the following chapters grammar and semantics related issues of three different standards are discussed, for the sake of clarity the subsequent notational conventions apply. These conventions comply1 with the guidelines for UML profile design as specified in the ITU-T Z.119 Recommendation [7]. The same guidelines were also used for the specification of the SDL-UML profile. – A name written within guillemets («...») refers to an instance of a stereotype of the SDL-UML profile [2]. Otherwise, if a name written within guillemets is followed by the word “stereotype”, the name refers to the corresponding stereotype of the SDL-UML profile. 1
With the following minor refinement in this paper: both Z.119 and Z.109 use <<...>> to bracket stereotype names, whereas this paper uses guillemets («...»).
110
A. Kraas
– An underlined Name starting with a capital letter refers to a metaclass of the UML Superstructure [8]. In addition, a property of such a metaclass is represented by an underlined name starting with a lower-case character. – Nodes of the abstract syntax of SDL [3] are referred by names written in italic style starting with a capital letter. – A name written in bold letters starting with lower-case characters refers to a keyword of the concrete grammar of SDL.
4
Data Type Model
The data type model proposed for the upcoming version of the SDL-UML profile for SDL-2010 in this chapter is designed to remove some limitations of the data type model of the most recent version of SDL-UML. However, only a semi-formal specification is given within this chapter, because it is only intended to give an overview of the capabilities of the proposed model. 4.1
Actual Data Type Model
In order to make it easier to compare data type related features provided by the most recent version of SDL-UML with those proposed in this chapter, a brief overview of the data type model as specified in Z.109 [2] is given below. Irrelevant aspects (such as some metaattributes) of UML metaclasses are omitted in Fig. 1.
Fig. 1. Actual data type model of SDL-UML
In general, a distinction has to be made between «PassiveClass» and «DataType»(including stereotypes that extend sub-classes of DataType). That is because a «PassiveClass» is mapped to an Object-data-type-definition in the
The SDL-UML Profile Revisited
111
abstract syntax of SDL, whereas all DataType related elements are mapped to a Value-data-type-definition. Considering the data type model depicted in Fig. 1., the most important disadvantage of that model is that an object data type can only be specified in terms of a «PassiveClass», whereas in contrast three different stereotypes of SDL-UML can be used for the specification of a value data type. However, this is not the only drawback of the current data type model. In the next section, the most important issues of the actual data type model are discussed in detail. 4.2
Limitations of the Actual SDL-UML Data Type Concept
Before proposing possible data type related enhancements for a new version of the SDL-UML profile in the following sections, the most important limitations of the current model are analyzed below. 1. Deletion of object data types in SDL-2010: The ITU Study Group 17 [9] has decided not to support object data types in SDL-2010, so they will no longer be required in the SDL-UML profile. Consequently, the «PassiveClass» stereotype is dropped in the proposed data type model. 2. Behavior of operations: As depicted in Fig. 1, the metaclass DataType directly inherits from the metaclass Classifier. Therefore, the DataType metaclass does not own an ownedBehavior property. In consequence, the method of an «Operation» owned by a DataType cannot be stored in the same namespace. Hence, an «Activity» forming the method of an «Operation» has to be stored elsewhere, instead of within the enclosing DataType. 3. Missing support for choice data type: The most recent version of the SDL-UML profile does not support the specification of choice data types, whereas this is the case in SDL. Choice types are necessary for specifying some kind of data types in the Abstract Syntax Notation One (ASN.1). This notation can be used as an alternative for data type specification in SDL. Hence, choice data types should also be supported by SDL-UML. 4. Missing support for optional fields in a structured data type: The abstract syntax of SDL makes a distinction between a Static-operationsignature and a Dynamic-operation-signature of a Data-type-definition. In general, this differentiation is also made between operator and method operations in the concrete syntax of SDL. But in SDL-UML, no explicit distinction between the two kinds of operations can be made. 5. Missing support for syntypes: Apart from the specification of data types and interfaces, SDL also supports the definition of syntypes. This language feature provides a mechanism to constrain the set of possible elements of an already existing data type (sort). A syntype is an alternative for specifying a data type which means that a syntype can be referenced in the same manner as a normal data type.
112
A. Kraas
6. Restricted possibility to specify literal signatures: The actual version of SDL-UML supports the specification of literal data types by the «Enumeration» stereotype. In contrast to native SDL, the expressiveness of an UML Enumeration is rather limited. That is because the concrete grammar of SDL supports the specification of literal signatures in terms of literal names, name class literals and named numbers, whereas the actual version of SDL-UML supports only literal names. For instance, a HTTP response includes numerical status codes, which are partitioned in different classes of responses. Since the numbering of the status codes is not in an ascending order, this kind of numbering cannot be expressed by the «Enumeration» stereotype of the actual version of SDL-UML. 4.3
Features of the Proposed New Data Type Model
In this section, new features for the data type model of the SDL-UML profile are proposed in order to address the omissions listed in Sect. 4.2. Nonetheless, the discussed model does not attempt to cover all missing data type features of SDL; only those features we consider to be essential. In particular, the proposal does not include: Renaming mechanisms: In SDL, operations or literals that are inherited from a super-type can be renamed in a specializing sub-type. This feature is not included in the proposal, because it is assumed that renaming is rarely used. Argument virtuality: Parameters of methods can be declared as virtual, making it possible to change the parameter type in a redefining method. However, this feature is only applicable for parameters consisting of object data types. Since object data types shall not be supported in SDL-2010, the feature of argument virtuality is not usable any longer. Name class literals: In general, name class literals are used in order to specify the predefined data types of SDL-2000 in a formal manner, but for the specification of user-defined data types they are not relevant. An overview of the proposed data type model for SDL-UML is shown in Fig. 2. The most important difference between the current data type model (see Fig. 1) and the new one is that the «PassiveClass» stereotype is not any longer present (issue 1 of Sect. 4.2). In addition, the new data type model introduces three optional stereotypes extending the DataType metaclass. The «Choice» stereotype represents a SDL choice data type and addresses the limitations of issue 3 of Sect. 4.2. The «Syntype» stereotype introduces the feature of syntype specification in SDL-UML (issue 5 of Sect. 4.2). However, the ability to specify structured data types is already supported by the most recent version of SDL-UML, but corresponding mapping rules and constraints are specified in the context of the «DataType» stereotype. Since this stereotype is applied automatically to all instances of metaclasses inheriting from DataType, for instance PrimitiveType, this approach is considered to be inappropriate. Hence, the new data type model introduces the «Structure» stereotype, which shall be mapped to a SDL structure data type.
The SDL-UML Profile Revisited
113
Fig. 2. Enhanced data type model for SDL-UML
In addition to the before mentioned stereotypes, the new data type model also introduces the «EnumerationLiteral» stereotype in order to address issue 6 of Sect. 4.2. The optional tagged value namedNumber (which is of type UnlimitedNatural) shall be used in order to specify literals in terms of SDL named numbers. Furthermore, the «DataType» stereotype shall own the tagged value owned Behavior as a composition (issue 2 of Sect. 4.2). That is because all elements of ownedBehavior shall be directly stored in the namespace of a «DataType» element. 4.4
Stereotypes of the Proposed New Data Type Model
This section describes the stereotypes of the proposed new model. «DataType» In general, an element stereotyped with «DataType» shall be mapped to a Valuedata-type-definition in the abstract syntax of SDL. The «DataType» stereotype extends the metaclass DataType with a multiplicity of [1..1]. Since the DataType metaclass is the most general metaclass of the UML-SS for specifying data types, the «DataType» stereotype is applied automatically to all appropriate UML elements.
114
A. Kraas
Owned Behavior of Operations: In order to address issue 2 of Sect. 4.2, the «DataType» stereotype owns the tagged value ownedBehavior, which is of type Activity. The multiplicity of the tagged value is * and its aggregation kind is composite. The ownedBehavior is used in order to store each «Activity», specifying the method of an «Operation» of the enclosing data type. Appropriate mapping rules are specified in the context of the «Operation» stereotype. Specialization: A «DataType» can specialize a more general super-type by adding additional operations or attributes. A generalization is denoted by the general property of the specializing «DataType». Since SDL does not support multiple inheritance, the general property shall refer at most to only one «DataType». In addition, only the same kind of stereotype shall be applied to a super-type and its sub-type. That is because in SDL, for instance, a structure type can only be specialized by another structured type. The general property of a «DataType» shall be mapped to the Datatype-identifier in the abstract syntax of SDL. Redefinition: When an enclosing Classifier CB (e.g. an «ActiveClass») specializes a more general classifier CA, an enclosed «DataType» B of CB can redefine another «DataType» A of CA. In this case, the redefined «DataType» A shall be referenced by the redefinedClassifier property of the redefining «DataType» B. Since multiple inheritance is not supported in SDL, the redefinedClassifier property of a «DataType» shall contain at most one reference to a redefined data type. In addition, when the isLeaf property of a «DataType» is true, it is not permitted to redefine this data type any more. This is equivalent to a SDL virtual type of kind finalized. DataType with no Additional Stereotypes: The concrete semantics and constraints are specified in the context of stereotyped metaclasses inheriting from DataType. In general, it is possible to specify a «DataType» without any further applied stereotype. Such a data type shall only contain Operations, if any. «Structure» The optional «Structure» stereotype extends the DataType metaclass with a multiplicity of [0..1]. This stereotype corresponds to a SDL structure data type of the concrete grammar of SDL. In addition to the «DataType» stereotype, this optional stereotype introduces additional constraints and mapping rules. Owned Attributes of a Structure Data Type: As in the case of the actual version of SDL-UML, also in the proposed data type model, the different fields of a «Structure» data type are represented as ownedAttributes. The type of an ownedAttribute shall refer only to DataType specifications (including derived metaclasses). That is because in SDL-UML the type of a Property can also be an «ActiveClass» or an «Interface». An ownedAttribute of a «Structure» data type with the multiplicity of [0..1] denotes an optional data field. In all other cases, the multiplicity of an
The SDL-UML Profile Revisited
115
ownedAttribute shall be [1], which means that it is mandatory (see the example given in Fig. 3). According to the Z.100 [3], a field of a structure data type introduces the following set of implicit defined methods for accessing and modifying the value of that field: – virtual field-modify-operation-name ( <field sort> ) -> this S; – virtual field-extract-operation-name -> <field sort> ; – field-presence-operation-name -> Boolean; The field-presence-operation-name method should only be present, when the corresponding ownedAttribute has a multiplicity of [0..1]. For the mapping of an ownedAttribute of a «Structure» data type towards the abstract syntax of SDL, the model specified in Sect. 12.1.7.2 of Z.100 [3] shall be applied. «Choice» The optional «Choice» stereotype extends the metaclass DataType with a multiplicity [0..1] (see Fig. 2). The stereotype corresponds to a SDL choice data type of the concrete grammar of SDL. This stereotype introduces additional constraints and appropriate mapping rules in addition to the «DataType» stereotype. The «Choice» can comprise a set of different data types, but only one of those types can be used as the actual type of the choice. Before a «Choice» data type can be mapped to the abstract syntax of SDL, some transformations have to be applied on the concrete syntax level. An example of a «Choice» data type is shown in Fig. 3. Owned Attributes of a Choice Data Type: An ownedAttribute of a data type «Choice» shall be used in order to represent a particular variant of a choice type. The type property of such an ownedAttribute shall refer only to instances of other DataType specifications. Before a «Choice» data type can be mapped to the abstract syntax of SDL, the model specified in Sect. 12.1.7.3 of Z.100 [3] has to be applied. As result of this process, three new data type definitions in the concrete syntax are generated. Afterwards, these data type definitions have to be transformed into the abstract grammar of SDL. But in the case of SDL-UML, it is assumed that a standard compliant tool generates these data types only internally.
Fig. 3. Structure, Enumeration and Choice data type examples
116
A. Kraas
«Enumeration» The «Enumeration» stereotype represents the Literal-signature-set of a Valuedata-type-definition of the abstract grammar of SDL. The stereotype extends the metaclass Enumeration with a multiplicity of [1], which means that this stereotype is applied automatically. The elements referred by the ownedLiteral property of an «Enumeration» shall be mapped to the Literal-signature-set of the corresponding Value-data-type-definition. In general, the same constraints and semantics as specified in the actual version of the Z.109 [2] shall be used for the «Enumeration» stereotype of the proposed data type model. In addition, the rules of the «Enumeration» stereotype are extended by those specified in the context of the «EnumerationLiteral» stereotype. «EnumerationLiteral» The new stereotype «EnumerationLiteral» extends the EnumerationLiteral metaclass with a multiplicity of [1] As mentioned in the section before, this stereotype is introduced in order to increase the expressiveness of SDL literal data type specifications in SDL-UML. An «EnumerationLiteral» shall be mapped to a Literal-signature in the abstract grammar of SDL. Literal Names and Named Numbers: The «EnumerationLiteral» stereotype owns the optional tagged value namedNumber, which is of the type UnlimitedNatural. This tagged value is intended to make an distinction between SDL named numbers and literal names that represent literal signatures of a literal list. All signatures of such a list are arranged in ascending order and are (explicitly or implicitly) associated with a unique number. A named number is associated with an explicitly defined number (e.g. green = 2) that defines the position of a literal signature in a list. In contrast, a literal name (e.g. blue) is implicitly associated with a number, because it is a shorthand notation that has to be transformed to a named number (blue = 3). During the transformation process the lowest number, which is still not used in a literal list, is determined and associated with the newly created named number. When the tagged value namedNumber is present, an «EnumerationLiteral» represents a SDL named number (see Fig. 3) and can be directly mapped to a Literal-signature. If namedNumber is not present, an «EnumerationLiteral» represents a literal name and the above-mentioned transformation has to be applied before it can be mapped to a Literal-signature. The third possibility to specify a literal — the SDL name class — is not intended to be supported, because its syntax is rather complex. Hence, the implementation effort is expected to be very high. «PrimitiveType» The stereotype «PrimitiveType» extends the metaclass PrimitiveType with a multiplicity of [ so that this stereotype is applied automatically. The stereotype shall be mapped to the Value-data-type-definition in the abstract syntax of SDL.
The SDL-UML Profile Revisited
117
However, in the context of SDL-UML, a «PrimitiveType» shall only be used to represent the predefined data types, for instance Integer, of SDL. As in the case of the actual version of SDL-UML, the predefined types shall be contained in the Predefined Package. All predefined data types contained in this package own the same sets of operations and literals as defined by native SDL. Specialization of Predefined Data Types: The predefined SDL-UML data types may be specialized by another «PrimitiveType». Depending on the kind of a predefined data type, a specializing «PrimitiveType» can add new literals and operations. For the purpose of adding new literals, the «PrimitiveType» stereotype owns the tagged value ownedLiteral which is a composition (see Fig. 2). This tagged value shall only be present, when the predefined base data type is specified in terms of a literal data type, for instance Integer. Hence, the predefined parameterized data types of SDL-UML, e.g. String, must not be extended with additional literals. For this kind of data types it is only allowed to add additional Operations. «Operation» The stereotype «Operation» extends the metaclass Operation with a multiplicity of [1..1] so that this stereotype is applied automatically. An «Operation» is not only used in the context of data types, but also in «ActiveClass» elements. The semantics and constraints discussed here only applies for stereotypes associated with data types. Operators and Methods: As discussed in issue 5, the actual SDL-UML profile does not support the explicit distinction between an operator and a method, as it is the case in the concrete syntax of SDL. Apart from implicitly generated operations which depend on the kind of the used data type, e.g. structure data type, operations can also be specified explicitly by the user. In contrast to an operator, which must always return a result, a result is optional for a method. Furthermore, only methods are permitted to be redefined. Depending on the type of an operation (operator or method), it shall be mapped to a Static-operation-signature or a Dynamic-operation-signature in the abstract syntax of SDL. As proposed in [6], the isStatic property of an «Operation» shall be used in order to make a distinction between both types of operation signatures (see SuperType in Fig. 4). If the isStatic property of an «Operation» is true, it shall be mapped to a Static-operation-signature. Otherwise, an «Operation» shall be mapped to a Dynamic-operation-signature. Redefinition of Methods: The concrete syntax of SDL provides a mechanism to redefine a method which means that a method in a super-type can be redefined by a method in a derived sub-type. In the context of SDL, this feature is denoted as method virtuality. In UML an element can be redefined, if its metaclass inherits from RedefinableElement. Since Operation is such a metaclass, also in SDL-UML an «Operation» can be redefined.
118
A. Kraas
Fig. 4. Example of operators and methods
Due to that in SDL only a method is permitted to be redefined, in SDL-UML only an «Operation» with an isStatic property of false shall be allowed to be redefined. The redefinedOperation property of a redefining «Operation» in a sub-type (see SubType in Fig. 4) shall refer to an operation of a supertype. At most, the redefinedOperation property shall contain one reference. In addition, an «Operation» shall not be redefined in further specializations contexts, when the isLeaf property is true. «Property» The stereotype «Property» extends the metaclass Property with a multiplicity of [1..1]. A «Property» is used in the context of SDL-UML elements associated with data types, and also by an «ActiveClass». The statements and rules discussed here only apply for the first mentioned context. Only a «Structure» or «Choice» data type is permitted to own a «Property» as an ownedAttribute. The concrete constraints and mapping rules are specified in the context of the corresponding stereotypes. «Syntype» The new «Syntype» stereotype extends the DataType metaclass with a multiplicity of [0..1]. Therefore, this stereotype is optional for appropriate UML elements. The «Syntype» data type constrains an existing data type in order to restrict the usable literals. Syntype Constraint: The mandatory tagged value constraint of the «Syntype» stereotype shall be used to specify the constraint of a syntype definition. The tagged value shall reference an Expression representing a SDL constraint. Since in native SDL a syntype definition only consists of at most one constraint, the ownedAttribute and ownedOperation properties of a
The SDL-UML Profile Revisited
119
Fig. 5. Syntype example
«Syntype» shall be empty. In the example shown in Fig. 5, the NegativeInt syntype constrains the predefined Integer type in such a way so that only negative integer values can be used. Associations to Data Types: The usage of the generalization mechanism of UML in order to establish an association between a «DataType» and a «Syntype» is considered to be not syntactically correct. That is because in UML a Generalization of