GigaSpaces Cloudify Any App, On Any Cloud, Your Way February 2012 Using Groovy in Cloudify The why, the where and the how Barak Merimovich Cloudify Team.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 4 Writing Java Applications, Java Development Tools.
Advertisements

08 Nov 2007Copyright 2007 Patrick Wegerson - All Rights Reserved1 Configuration Management for Embedded Systems Software and the Hard Stuff Patrick Wegerson.
EIONET Training Beginners Zope Course Miruna Bădescu Finsiel Romania Copenhagen, 27 October 2003.
Other Web Application Development Technologies. PHP.
Bringing Procedural Knowledge to XLIFF Prof. Dr. Klemens Waldhör TAUS Labs & FOM University of Applied Science FEISGILTT 16 October 2012 Seattle, USA.
8 C H A P T E R © 2001 The McGraw-Hill Companies, Inc. All Rights Reserved1 Usenet Newsgroups and Web-based Forums In this chapter, you will learn how.
9 C H A P T E R © 2001 The McGraw-Hill Companies, Inc. All Rights Reserved1 Communicating in Real Time Now it is also possible to converse in real time.
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013.
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna.
® IBM Software Group © 2010 IBM Corporation What’s New in Profiling & Code Coverage RAD V8 April 21, 2011 Kathy Chan
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
Building Enterprise Applications Using Visual Studio ®.NET Enterprise Architect.
ManageEngine TM Applications Manager 8 Monitoring Custom Applications.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
1 Ant – Another Neat Tool Representation and Management of Data on the Internet.
DT228/3 Web Development JSP: Directives and Scripting elements.
Java Server Team 8. Overview What is a Java Server? History Architecture Advantages Disadvantages Current Technologies Conclusion.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Apache Jakarta Tomcat Suh, Junho. Road Map Tomcat Overview Tomcat Overview History History What is Tomcat? What is Tomcat? Servlet Container.
Eclipse is an open source IDE (Integrated Development Environment) for developing applications in Java, C/C++, HTML, Cobol, Perl, etc. The official Eclipse.
Using Ant to build J2EE Applications Kumar
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
ITM352 PHP and Dynamic Web Pages: Server Side Processing.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
JSP Standard Tag Library
Cloudify Intro July 2013 Dotan Horovits, Director, Customer Services.
Groovy WHAT IS IT? HOW DOES IT WORK? IS IT USEFUL?
Copyright© Jeffrey Jongko, Ateneo de Manila University Android.
Groovy in 15 minutes… Johannes Carlén Callista Enterprise AB
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Java Users Group Charleston, SC June 25, 2008 Introduction to Grails by Jason McDonald.
.NET Framework Danish Sami UG Lead.NetFoundry
How Java becomes agile riding Rhino Xavier Casellato VP of engineering, Liligo.com.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
POS 406 Java Technology And Beginning Java Code
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Esri UC2013. Technical Workshop. Technical Workshop 2013 Esri International User Conference July 8–12, 2013 | San Diego, California Developing.NET Applications.
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Ibm.com /redbooks © Copyright IBM Corp All rights reserved. WP07 ITSO iSeries Technical Forum WebSphere Portal Express– Installation, Configuration.
1 PUPPET AND DSC. INTRODUCTION AND USAGE IN CONTINUOUS DELIVERY PROCESS. VIKTAR VEDMICH PAVEL PESETSKIY AUGUST 1, 2015.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
Test Specifications A Specification System for Multi-Platform Test Suite Configuration, Build, and Execution Greg Cooksey.
SOAP-based Web Services Telerik Software Academy Software Quality Assurance.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
ModTransf A Simple Model to Model Transformation Engine Cédric Dumoulin.
introductory lecture on java programming
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Creating FunctionstMyn1 Creating Functions Function can be divided into two groups: –Internal (built in) functions –User-defined functions.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Chapter 13 A & B Programming Languages and the.
By: Chad Gallati, Melissa Plakyda, Jenny Wilkes References: /a-z_programming_languages_groovy/
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
SINGLE PLATFORM. COMPLETE SCALABILITY. PaaS on CTO & Founder GigaSpaces.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introducing the Microsoft® .NET Framework
Air Plugins Extending and customizing uDeploy (IBM UrbanCode Deploy)
CMPE419 Mobile Application Development
Groovy.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
CMPE419 Mobile Application Development
IS 135 Business Programming
Presentation transcript:

GigaSpaces Cloudify Any App, On Any Cloud, Your Way February 2012 Using Groovy in Cloudify The why, the where and the how Barak Merimovich Cloudify Team Leader GigaSpaces

Cloudify – A quick overview What is a DSL? Why use a DSL for Cloudify Recipes? Why Groovy? The Cloudify Groovy DSL ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved 2 AGENDA

® Copyright 2012 GigaSpaces Ltd. All Rights Reserved3 Using Recipes Cloudify On-Boards Any App Onto Any Cloud Unchanged CLOUDIFYING ENTERPRISE APPLICATIONS IS EASY

CLOUDIFY CREATES VIRTUAL MACHINES AND INSTALLS AGENTS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved4

CLOUDIFY AGENTS INSTALL AND MANAGE YOUR APPLICATION ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved5

APPLICATION DESCRIPTION THROUGH RECIPES ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved6 Recipe DSL Lifecycle scripts Availability & Monitoring Probes Custom plug-ins(optional) application { name="petclinic" service { name = "mongod" } service { name = "mongoConfig" } service { name = "apacheLB" } service { name = "mongos" dependsOn = ["mongoConfig", "mongod"] } service { name = "tomcat" dependsOn = ["mongos","apacheLB"] }

APPLICATION DESCRIPTION THROUGH RECIPES ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved7 Recipe DSL Lifecycle scripts Availability & Monitoring Probes Custom plug-ins(optional) service { name "mysql" icon "mysql.png" type "DATABASE"... }

APPLICATION DESCRIPTION THROUGH RECIPES ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved8 Recipe DSL Lifecycle scripts Availability & Monitoring Probes Custom plug-ins(optional) Lifecycle { install "mysql_install.groovy" start "mysql_start.groovy" startDetectionTimeoutSecs 900 startDetection "mysql_startDetection.groovy" stopDetection { !ServiceUtils.isPortOccupied(jdbcPort) } preStop ([ "Win.*":"killAllMysql.bat", "Linux.*":"mysql_stop.groovy ]) shutdown ([ "Linux.*":"mysql_uninstall.groovy" ]) }

APPLICATION DESCRIPTION THROUGH RECIPES ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved9 Recipe DSL Lifecycle scripts Availability & Monitoring Probes Custom plug-ins(optional) monitors { def ctxPath = ("default" == context.applicationName)?"":"${context.applicationName} def metricNamesToMBeansNames = [ "Current Http Threads Busy": ["Catalina:type=ThreadPool,name=\"http-bio-${currHttpPort}\"", "currentThreadsBusy"], "Current Http Thread Count": ["Catalina:type=ThreadPool,name=\"http-bio-${currHttpPort}\"", "currentThreadCount"], return getJmxMetrics(" ",currJmxPort,metricNamesToMBeansNames) }

APPLICATION DESCRIPTION THROUGH RECIPES ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved10 Recipe DSL Lifecycle scripts Availability & Monitoring Probes Custom plug-ins(optional) scalingRules ([ scalingRule { serviceStatistics { metric "Total Requests Count" statistics Statistics.maximumThroughput movingTimeRangeInSeconds 20 } highThreshold { value 1 instancesIncrease 1 } lowThreshold { value 0.2 instancesDecrease 1 } ])

APPLICATION DESCRIPTION THROUGH RECIPES ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved11 Recipe DSL Lifecycle scripts Availability & Monitoring Probes Custom plug-ins(optional)

WHAT IS A DSL? ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved12 A domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique. Some examples: SQL UML XSLT

WHY USE A DSL – PRODUCT REQUIREMENTS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved13 The Cloudify Domain model is complex – Need to model the complete lifecycle of a service: machine startup, bootstrapping, installation, etc… Target audience is devops, though not necessarily dev… Keep It Simple. Recipe needs to be easy to read, modify and validate. But allow for complex use cases for power users.

WHY USE A DSL – TECHNICAL REQUIREMENTS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved14 Strongly typed domain model Easy to use objects in code Easy to validate Easy to modify domain model without changing parser code Ideally, adding new fields to existing objects should require no additional code. Allow code snippets inside configuration file (mySpecialField_ + someVariable) But dont want to write a full fledged language Developer tools – IDE, Code completion

WHY GROOVY ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved15

SOME GROOVY CONCEPTS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved16 Groovy is an object-oriented programming language for the Java platform. It is dynamically compiled to Java Virtual Machine (JVM) bytecode and interoperates with other Java code and libraries. A Groovy script is fully parsed, compiled, and generated before execution (similar to Perl and Ruby). This occurs under the hood, and the compiled version is not saved. Each attribute/method invocation in Groovy goes through the metaclass registry. Enables changing a class at runtime.

GROOVY IS VERY DSL FRIENDLY ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved17 Groovy's syntax allows to omit parentheses and dots in some situations. This: take(coffee).with(sugar, milk).and(liquor) Is equivalent to: take coffee with sugar, milk and liquor Closures - similar to a "method pointer", enabling code to be written and run in a later point in time. For example: def operations = { declare 5 sum 4 divide 3 print }

GROOVY FEATURES WE REALLY LIKED ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved18 Allows overriding getProperty(), propertyMissing() among others, Enables intercepting calls to an object and specifying an action for them Native syntax for lists and maps. def someList = [My value', Your Value'] def someMap = [ Some Key' : 31, Some Other Key' : 28] Expressions embedded inside strings println Hello ${world} Native support for various languages XML – useful for manipulating configuration files. ANT – just plain useful.

LOADING A GROOVY DSL FILE FROM JAVA ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved19 The most important class you should know is groovy.lang.GroovyShell Easiest example of usage: Object result = new GroovyShell().evaluate(new File(path)) This runs the groovy runtime with the given file, just like running the groovy command line. Now lets tweak the shell to process our DSL Format.

LETS START WITH A BASIC GROOVY FILE ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved20

USE CONSTRUCTOR WITH NAMED PARAMETERS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved21

ADD IMPORT CUSTOMIZER TO GROOVY SHELL ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved22

BETTER, BUT NEEDS A BIT MORE ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved23

OVERRIDE SCRIPT BASE CLASS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved24 A Groovy script is compiled into a Java class. The Groovy commands run in the run() method. The created Groovy class extends the groovy.lang.Script class. Default implementations of: get/setProperty invokeMethod println Use GroovyShell to replace default base script class with our own implementation.

OVERRIDE SCRIPT BASE CLASS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved25 Tweak a few small things, like redirecting println() to Logger

AND TWEAK SOME MORE ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved26 Override invokeMethod() and setProperty() Map method names to domain objects If not a domain object, map to field name of current object

LOAD AN OPTIONAL PROPERTIES FILE AND BIND TO SHELL ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved27 Bind to Groovy Shell

EASY TO READ, BUT STILL POWERFUL ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved28

GRAB THE CODE ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved29 The Cloudify web site: And on github: See the actual code: n/java/org/cloudifysource/dsl/internal/DSLReader.java n/java/org/cloudifysource/dsl/internal/DSLReader.java n/java/org/cloudifysource/dsl/internal/BaseDslScript.java n/java/org/cloudifysource/dsl/internal/BaseDslScript.java

QUESTIONS ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved30 The Cloudify dev team is available on the Cloudify forum: and bug tracker: