640 likes | 737 Views
Reflecting Running Systems as Standard Models. A series of small applications of model-driven techniques. Hui Song songhui06@sei.pku.edu.cn. From the very beginning. Future Software Dependent on the Internet Always running Long life-cycle and unstable We have to manage them at runtime.
E N D
Reflecting Running Systems as Standard Models A series of small applications of model-driven techniques Hui Song songhui06@sei.pku.edu.cn
From the very beginning • Future Software • Dependent on the Internet • Always running • Long life-cycle and unstable • We have to manage them at runtime Abstract! automated mgmt agent Topological diagram of the Internet http://orbitalteapot.blogspot.com/2007/10/how-universe-looks-like-brain.html human administrator
A JavaEE system (and its runtime states) What’s running on server? Any situation to handle?
Model-based runtime management • Abstract the system as models • A long history • Architecture-based runtime management (abstract) • models@run.time workshop (model-based approaches) • Runtime model as a part of MDE (integration) • Benefits • Abstract and separation of concerns • Richer semantics basis • Integrated with whole development process • Many reusable approaches and tools
Some stories about the last benefit • Xiangping’s work: analyzing system states • Some situation means something • Identify situations, express meaning, do something • ATL! • Franck’s work: Goal-driven adaptation • Calculate a configuration -> deploy it • Compare, execute the changes • Model comparison • My own work: runtime architecture view • Monitor changes on arch, control system through arch • Synchronization between them dynamically • QVT bidirectional transformation
A big barrier to model-based runtime mgmt Model-driven apps and techs • Model guys at model level • Everything is model • Everything could be resolved in a model based way • If states are models • System guys at system level • Care more about mechanisms • Model-driven is not omnipotentright now • Management APIfor flexibility Mgmt API How to invoke JMX interface? Management mgt=… ObjectName ds=… Object obj=mgt.getAttribute( ds, “jdbcMaxConnPool” ) State
Asking system vendors to change their minds? Hey, why not provide a model-like interface for your system. Seemed everyone’s talking about model-based management. I don’t wanna waste my time on such a toy…
An alternative solution Model-driven apps and techs Standard model processing interface Adapter Ad hoc mgmt API State
Roadmap Model-based runtime mgmt gap between model and API - Specify state type - Wrap APIs 1. JADE 2. MoDisco Fractal ADL Fractal reflection intf Self-healing MOF meta-model MOF reflection intf Anything
The first work: Jade • Jade: a framework for autonomic management • part of the ObjectWeb Jasmine project • an administration tool facilitate the job of administrators • related to Fractal • Representative work • S. Sicard, F. Boyer, and N. D. Palma. • Using components for architecture-based management: the self-repair case. • In ICSE, pages 101-110, 2008.
Sicard-ICSE-08: Motivation • A basic pattern for self-repair: Substitute the failed components by new ones • A mature algorithm for • identifying failures, • removing failed components, safely, • starting new ones • Seemed applicable to many systems • But, … (in the next slide)
But, … Self-repair Anything in common? JMX cfg file who knows JEE Apache …
Anything in common? Yes, of course. • Management state (state from mgmt API)is constituted of managed elements • EJBs, data sources, middleware services; • apache servers, tomcat servers • ... • Features sufficient for managed elements • Local state • Life cycle state • Functional dependency • Connection • Composition • Just mapped to the Fractal component model ()
Fractal component model • Component : runtime entity • Interface : access point to component • Binding : interaction, communication • Special interfaces for management (controller): • life-cycle controller • Attribute controller • … • Fractal ADL • Specify structures • Fractal API • Standard way to invoke
Idea: Wrap all the APIs as Fractal • This ICSE paper talks about the wrapping Apache-JEE-Mysql systems under Fractal, manually!
Effect Fractal ADL: Apache conn_pool Tomcat MySQL
The pusher behind MoDisco • INRIA -> Nante University • Some publications aboutmodel driven engineering • The chief of ATL group! • ATL: the de facto model transformation standard • ATL group: an important participant of Eclipse Modeling Project (EMP) • EMP: currently a relatively successful MDE implementation
MoDisco: motivation • The work of ATL group • Model transformation: ATL • Based on OMG’s Meta Object Facilities (MOF) • Mega-model: Use ATL, OCL … to manage many models together • Design model, • Code, • Deploy model • Developer role model • It seems that something is missing • Runtime system state • How to achieve handling system states as MOF compliant models
One of the use cases: JarToUML • A Jar package • Many java classes • Complex class structures • Visualization may be useful • How to get these structure • apache.bcel • API! • How to visualize the structure • Eclipse UML2 class diagram • Gap, again! InputStream input=jarFile.getInputStream(entry); ClassParser parser=new ClassParser(input, entry.getName()); JavaClass clazz=parser.parse(); Field[] fd=clazz.getFields(); Method[] md=clazz.getMethods();
JarToUML UML2 class diagram generator Discoverer Write: Class Attribute Operation Generalization … In UML2 Read: JavaClass Fields Methods … By bcel
Roadmap of MoDisco • 1. Creation and initialization of the project • 2. Elaboration of several use cases • 3. Common toolbox and initial framework for building model discoverers. • 4. Improvement of the framework as additional use cases are built and contributed. • Currently blocked at step 2: • Manually coding a discoverer for each of the cases
Look back Jade and MoDisco • Difference • Fractal vs. MOF • “If all you have is a hammer, everything looks like a nail.” • Similarity • Specify state structure (Fractal ADL vs. MOF meta-model) • Manually wrap the different APIs (wrapper vs. discoverer) • Enjoy model-based management (reusing self-healing algorithms vs. reusing ATL)
The idea of “specify-wrap” • Really useful • Shown by the cases • Widely accepted • ICSE, INRIA, ObjectWeb • Eclipse, IBM • Still an initial attempt • Manually develop the adapters by ordinary languages • Using raw code to specify the mapping between state structures and the ad hoc APIs
Roadmap Model-based mgmt - Implicit structure - Ad hoc invocation - Specify structures - Wrap APIs 1. JADE 2. MoDisco 3. Data processing 4. Code composition DSL to specify data structure Generate data processing tools DSL, with pieces of code Code generation to compose the code Wrapping mgmt APIs Raw code to specify relations high-level specification & auto generation
Packet Types • Abstract Specification of Network Protocol Messages • Peter J. McCann and Satish Chandra • Bell Laboratories • SIGCOMM 2000 • Motivation • Protocol analyzing is a very common work • Corresponding programs are not easy to write • So, • A new language for high level specification of protocol types • A generator for pre-processing the protocols
Compiler • Proper C structs for the specified types • Utility programs for parsing a packet, and instantiate proper variables of the structs • A unified interface to manipulate these variables
PADS: Processing Ad hoc Data Sources • Kathleen Fisher • AT&T Labs • Chief of Sig-PLAN • PADS project • http://www.padsproj.org • PLDI 2005, POPL 2006, POPL 2008… • A DSL to specify the format of ad hoc data • Automatically generate data parser • With the generated parser, people can manipulate the ad hoc data, as if the data is in XML
Ad hoc data: web logs 207.136.97.49 - - [15/Oct/2006:18:46:51 -0700] "GET /turkey/amnty1.gif HTTP/1.0" 200 3013 207.136.97.49 - - [15/Oct/2006:18:46:51 -0700] "GET /turkey/clear.gif HTTP/1.0" 200 76 207.136.97.49 - - [15/Oct/2006:18:46:52 -0700] "GET /turkey/back.gif HTTP/1.0" 200 224 207.136.97.49 - - [15/Oct/2006:18:46:52 -0700] "GET /turkey/women.html HTTP/1.0" 200 17534 208.196.124.26 - Dbuser [15/Oct/2006:18:46:55 -0700] "GET /candatop.html HTTP/1.0" 200 - 208.196.124.26 - - [15/Oct/2006:18:46:57 -0700] "GET /images/done.gif HTTP/1.0" 200 4785 www.att.com - - [15/Oct/2006:18:47:01 -0700] "GET /images/reddash2.gif HTTP/1.0" 200 237 208.196.124.26 - - [15/Oct/2006:18:47:02 -0700] "POST /images/refrun1.gif HTTP/1.0" 200 836 208.196.124.26 - - [15/Oct/2006:18:47:05 -0700] "GET /images/hasene2.gif HTTP/1.0" 200 8833 www.cnn.com - - [15/Oct/2006:18:47:08 -0700] "GET /images/candalog.gif HTTP/1.0" 200 - 208.196.124.26 - - [15/Oct/2006:18:47:09 -0700] "GET /images/nigpost1.gif HTTP/1.0" 200 4429 208.196.124.26 - - [15/Oct/2006:18:47:09 -0700] "GET /images/rally4.jpg HTTP/1.0" 200 7352 128.200.68.71 - - [15/Oct/2006:18:47:11 -0700] "GET /amnesty/usalinks.html HTTP/1.0" 143 10329 208.196.124.26 - - [15/Oct/2006:18:47:11 -0700] "GET /images/reyes.gif HTTP/1.0" 200 10859
Data description language • Ad hoc data is difficult to manage • Data arrives “as is” in a wide-variety of encodings and formats. • Documentation is out of data or non-existent. • Data sources often have high volume. • Existing solutions are insufficient • Hand-coded C/Perl programs are time-consuming to produce, brittle with respect to changes, and fail to handle errors well. • Data description languages (DDLs) address these issues • Data expert writes declarative description rather than a parser. • Description serves as living documentation. • From declarative specification, compiler can generate auxiliary tools. Data description languages facilitate managing ad hoc data.
Parray Phostname{ Pstring_SE(:"/[. ]/":) [] : Psep('.') && Pterm(Pnosep); }; Punion host { Pip ip; /- 135.207.23.32 Phostname host; /- www.research.att.com }; Punion auth_id { Pchar unauthorized : unauthorized == '-'; Pstring(:' ':) id; }; Penum method { GET, PUT, POST, HEAD, DELETE, LINK, UNLINK }; Pstruct version { "HTTP/"; Puint8 major; '.'; Puint8 minor; }; int chkVersion(version v, method m) { if ((v.major == 1) && (v.minor == 0)) return 1; if ((m == LINK) || (m == UNLINK)) return 0; return 1; }; Pstruct request { '\"'; method meth; ' '; Pstring(:' ':) req_uri; ' '; version version : chkVersion(version, meth); '\"'; }; Ptypedef Puint16_FW(:3:) response : response x => { 100 <= x && x < 600}; Punion length { Pchar unavailable : unavailable == '-'; Puint32 len; }; PrecordPstruct entry { host client; ' '; auth_id remoteID; ' '; auth_id auth; " ["; Pdate(:']':) date; "] "; request request; ' '; response response; ' '; length length; }; PsourceParray clf { entry []; } Common Log Format in PADS A complete PADS/C description of the web server log data shown in the box: 207.136.97.50 - - [15/Oct/1997:18:46:51 -0700] "GET /turkey/amnty1.gif HTTP/1.0" 200 3013 PADS allows concise, precise, and intuitive data specifications.
PADS compiler • Converts description to C header and implementation files. • Code organization • For each built-in/user-defined type: • C structs • Functions (read, write, auxiliary functions) • Runtime organization • Variables of C structs • In-memory representation
Generated representation Pstruct http_request { '\"'; http_method meth; /- Request method ' '; Pstring(:' ':) req_uri; /- Requested uri. ' '; http_version version : check(version, meth); '\"'; }; typedefstruct { http_method meth; /* Request method */ Pstring req_uri; /* Requested uri */ http_version version; /* check(version, meth) */ } http_request;
Leverage! • With the generated parser, people can manipulate the ad hoc data, as if the data is in XML • Generated code implements a “PADS” interface • Strict map between data format description and the invocation of PADS interface • A set of tools upon PADS interface • Graphical representation • XQuery interpreter • XPath interpreter
About auto-generation of data process tools Data description language -High-level language to define “types” -Code: structs corresponding to types -Runtime: variables of structs as an in-memory representation Systems are not data -Structure: graph vs. tree -Operation: standard ASCII vs. ad hoc mgmt APIs 3. PacketType & PADS 4. AHEAD & FSML For data processing DSL to specify data format Generate dataprocessing tools For framework completion DSL, how to invoke framework APIs Generate code to invoke APIs Specify pieces of code (invoking mgmt API) and compose them together
AHEAD • Scaling Step-Wise Refinement • TSE 2004 • Basic Idea • Traditional refinement: m++ • Scaling refinement: m+n • Basic solution • A program is constituted of features • A feature corresponds to a piece of code • High-level: an algebra of features (for developers) • Low-level: composition of code according to the algebra (automated)
Feature Algebra • Constants • Functions • Applications
Implementation (hidden from developers) k1 k1 ● k2 mixin k1 ● k2 jampack k2
FSML: Framework-Specific Modeling Language • Michal Antkiewicz, Krzysztof Czarnecki • Representative work • MoDELS06 (best paper) • ASE07 (ACM distinguish paper)
Overview • Object-oriented application framework • Java Applet, eclipse workbench, Struts • A widely used software reuse technology • Coding upon framework: framework completion • Instantiate several framework specific concepts • Following the specific ways to invoke the API • Can be challenging • A declarative approach to framework completion • Framework experts define the concepts and the invocation method • Common developers specify what concepts to instantiate, and how many • A tool automatically generate the code to realize framework-based applications
Example: Java Applet • Overview: small Java app, embedded in web pages • Framework specific concepts • Applet (name, listen to mouse, show status message) • Reused logic inside the framework: JApplet class • Interaction between Applet and browser, etc • Framework completion (programming under Applet) • class MyApplet extends JApplet { shows=“…”; listens=new XXX(); …}
Roadmap Developing mgmt tools - Implicit structure - Ad hoc invocation - Specify structures - Wrap APIs 1. JADE 2. MoDisco Wrapping mgmt APIs Raw code to specify relations high-level specification & auto generation 1 2 3. PADS 4. FSML - Specify state structure Specify API invocation Auto generate wrappers for the specific API Our work: 1. language to specify structure and API, 2. generate wrappers