Pan Tutorial: A Whirlwind Tour of the Pan Language C. Loomis (CNRS/LAL) 11 th Quattor Workshop (CERN) 16-18 March 2011.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Spring Semester 2013 Lecture 5
Programming Languages and Paradigms
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Feature requests for Case Manager By Spar Nord Bank A/S IBM Insight 2014 Spar Nord Bank A/S1.
C Lecture Notes 1 Program Control (Cont...). C Lecture Notes 2 4.8The do / while Repetition Structure The do / while repetition structure –Similar to.
DT211/3 Internet Application Development
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Guide To UNIX Using Linux Third Edition
ASP.NET Programming with C# and SQL Server First Edition
Guide To UNIX Using Linux Third Edition
Chapter 13 XML Concept of XML Simple Example of XML XML vs. HTML in Syntax XML Structure DTD and CDATA Sections Concept of SAX Processing Download and.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Using Ant to build J2EE Applications Kumar
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
Functions and Objects. First Midterm exam Date: 10/10/2006 (Tuesday) Content: Multiple choices Determine results of the code Write codes Covert everything.
Functions and Objects. First Midterm exam Date: October 8, 2008 Content: Two parts: On-paper:Multiple choices On-computer: Write codes Cover everything.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
PHP PHP: Hypertext Preprocesor Personal Home Page Tools.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
INFSO-RI Enabling Grids for E-sciencE SCDB C. Loomis / Michel Jouvin (LAL-Orsay) Quattor Tutorial LCG T2 Workshop June 16, 2006.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
JavaScript, Fourth Edition
CS105 Computer Programming PYTHON (based on CS 11 Python track: lecture 1, CALTECH)
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
CPSC 871 John D. McGregor Change management Module 2 Session 3.
QWG Errata Management Framework Ian Collier 10 th Quattor Workshop Rutherford Appleton Laboratory October 2010.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
1 JavaScript in Context. Server-Side Programming.
INFSO-RI Enabling Grids for E-sciencE Pan Compiler C. Loomis (LAL-Orsay) Quattor Workshop (Madrid) October 2007.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Creating FunctionstMyn1 Creating Functions Function can be divided into two groups: –Internal (built in) functions –User-defined functions.
GDT Tips and Tricks. GDT Tips and Tricks Doug Evans GDT 2004 International User Conference – Evolving the Legacy July  Tucson, Arizona GDT Tips.
Linux Configuration using April 12 th 2010 L. Brarda / CERN (some slides & pictures taken from the Quattor website) ‏
Lecture 4 – Function (Part 1) FTMK, UTeM – Sem /2014.
CSIS 113A Lecture 5 Functions. Introduction to Functions  Building Blocks of Programs  Other terminology in other languages:  Procedures, subprograms,
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Perl Subroutines User Input Perl on linux Forks and Pipes.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Linux Administration Working with the BASH Shell.
ActionScript Programming Help
PHP using MySQL Database for Web Development (part II)
>> Introduction to JavaScript
Visit for more Learning Resources
PHP.
Quattor Advanced Tutorial, LAL
Lecture 5: Functions and Parameters
Quattor Advanced Tutorial, LAL
Tutorial 10: Programming with javascript
Introduction to Bash Programming, part 3
Corresponds with Chapter 5
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
SPL – PS1 Introduction to C++.
Presentation transcript:

Pan Tutorial: A Whirlwind Tour of the Pan Language C. Loomis (CNRS/LAL) 11 th Quattor Workshop (CERN) March 2011

Contents Basics – Download, install. – Declarative syntax Performance Idioms Advanced techniques March 2011 Pan Compiler (C. Loomis)2

Raison d’être Purpose – Define (machine) configuration parameters – Subject to (user-defined) validation criteria Goals – Simple, human-friendly syntax – Same language for parameters, validation, etc. – Easy reuse & sharing of configuration information March 2011 Pan Compiler (C. Loomis)3

Place in the Ecosystem Workflow is nearly identical to that for standard software development. Between VCS and “actuators”: – Version control system: SCDB, CDB, … – Quattor NCM subsystem: configuration components, … In principle, could be used with any VCS and used for any type of configuration. Pan Compiler (C. Loomis) March

Download & Installation To follow exercises: – Download latest panc tarball from SF – Requires version of Java JDK or JRE 1.6 – Setup environment (PATH=…) for panc SourceForge links – Use v8.4.7 – c/ c/ March 2011 Pan Compiler (C. Loomis)5

Hello World March 2011 Pan Compiler (C. Loomis)6 # # hello_world.pan # object template hello_world; ‘/message’ = ‘Hello World!’; $ panc hello_world.pan $ ls hello_world.* $ cat hello_world.xml Hello World!

Declarative Language Primary statement is an assignment! Define tree of configuration parameters: – Syntax similar to unix file system – Looks very much like proc file system on linux Other statements: – Template declaration – (Global) variable, type, or function definitions – Binding statement: types applied to path March 2011 Pan Compiler (C. Loomis)7 '/my/path' = 47;

Declarative Language (2) Feel yourself missing procedural flow control in templates? – Very likely an opportunity to capture and reuse some configuration into separate templates. – Or something that is better done in the perl code of a configuration module March 2011 Pan Compiler (C. Loomis)8

Statements March 2011 Pan Compiler (C. Loomis)9 StatementPurpose ‘/path’ = ‘OK’;unconditionally assign the value to the given absolute or relative path ‘/path’ ?= ‘OK’;conditionally assign the value to the given absolute or relative path include { ‘other_template’ };include and execute the statements in the other template; if name if undef or null, nothing is done variable X = ‘OK’;create global variable X with the value ‘OK’ variable X ?= ‘OK’;conditionally set the variable X to the value ‘OK’ type x = string;define type x to be a string function x = 42;define function x that always returns 42 bind ‘/path’ = x;bind type definition x to the path ‘/path’ prefix ‘/path’;sets the path prefix to ‘/path’ for any subsequent relative assignment statements

Types of Templates March 2011 Pan Compiler (C. Loomis)10 ModifierNamePurpose objectobject templatesignals that a profile (*.xml file) should be generated ordinary templatecontains any type of statement for inclusion by other templates uniqueunique templatelike an ordinary template but will be executed only once for each profile declarationdeclaration templatemay only contain variable, type, and function definitions; only executed once for each profile structurestructure templatecontains only relative assignment statements; included via the create() function

Batch System Use example of a simple batch system to show major features of pan language. Batch system (or cluster) has a “head node” that accepts job requests and farms them out to a number of worker nodes for execution. Server: has nodes (each node participates in queues, has capabilities), has queues (each queue has CPU limit) Worker: references server, enabled/disabled Pan Compiler (C. Loomis) March

Batch1 Simple example showing how to declare the configuration for server and 1 worker. Not very extensible organization: – All of the templates at root level. – Copy/paste duplication with workers March 2011Pan Compiler (C. Loomis)12

Batch2 Split service configuration from node declarations. Use namespaces for service and node declarations. Can make more workers with less duplication. Doesn't provide protection against bad values in the configuration March 2011Pan Compiler (C. Loomis)13

Batch3 Add type declarations: – Boolean, longs, etc. Often default values make sense and would like to define values only if different than the default March 2011Pan Compiler (C. Loomis)14

Type Hierarchy March 2011Pan Compiler (C. Loomis)15

Batch4 Provide default values: – Can provide resources as well as properties! – Defaults only provided if the parent exists. Would like to provide consistency checks between values and between node declarations March 2011Pan Compiler (C. Loomis)16

Batch5 Cross-value/cross-machine validation: – Ensure that listed queues actually exist. – Ensure that server and workers all know about each other. Templates often modify multiple parameters in the same part of the configuration tree March 2011Pan Compiler (C. Loomis)17

Batch6 Use of the 'prefix' statement: – Pseudo-statement: only affects containing template – Best practice: one prefix at beginning of template March 2011Pan Compiler (C. Loomis)18

Common Problems Last statement executed provides the value of a DML block. – All DML statements provide a value, even flow control statements like if/else, foreach, while, etc. – Use care when assigning to resources in DML block. Pan Compiler (C. Loomis) March '/path' = if (false) 'MY VALUE'; # returns undef '/path' = { m['child'] = 3; }; # Value is 3, not nlist!

Performance Be explicit with paths, push as much information to left of assignments as possible. Invoking compiler: – Avoid panc script if possible. You pay the startup costs of the JVM every time it is invoked. – Ant/maven are more effective and provide dependency management as well. Pan Compiler (C. Loomis) March '/path' = nlist('a', 1, 'b', 2); # More legible and faster. '/path/a' = 1; '/path/b' = 2;

Performance Use escaped literal syntax: Always use a built-in function instead of a function defined in pan! – Especially important for append(), prepend() – Look at to_uppercase(), to_lowercase(), etc. Pan Compiler (C. Loomis) March '/path' = nlist(escape('a/b'), 1); # More legible and faster. '/path/{a/b}' = 1;

Performance Avoid SELF if possible! – Avoid incremental builds of lists, rearranging the configuration, if possible. – Always (!!) use SELF directly in any DML block. Do NOT copy to a local variable! Pan Compiler (C. Loomis) March '/path/a' = 1; '/path/b' = 2; '/path' = { copy = SELF; # Deep copy of SELF! copy['c'] = 3; SELF; # Added value is LOST. };

Idioms Default variables for modifying configuration March 2011 Pan Compiler (C. Loomis)23 variable MY_SERVICE_CONFIG ?= null; # or undef include { if_exists(MY_SERVICE_CONFIG) }; variable ADD_NFS_MOUNT ?= null; '/mounts' = { if (ADD_NFS_MOUNT) { '/var/log …'; } else { null; };

Idioms null is useful for tri-state variables or sentinel values: Use file_contents() and format() for simple configuration files March 2011 Pan Compiler (C. Loomis)24 variable X = true; # or false or null '/path' = X; # completely unset if null variable X = file_contents('my_cfg_file'); '/path' = format(X, 10, 20, 'USER');

Advanced Techniques Annotations Logging/debugging: – Can generate dependency information – Use verbose for performance stats – Use memory, call, … logging for detailed analysis – Use debug() function for detailed information – Use traceback() to find problem location March 2011 Pan Compiler (C. Loomis)25

Documentation Please read the documentation! – Compiler and language manuals (pan-book). – README often has useful information! March 2011 Pan Compiler (C. Loomis)26