Today's application stack is built out many popular OSS frameworks such as Cassandra, MongoDB, Scala, Play, Memcache, RabitMQ alongside the more traditional JEE stack which includes app servers such as Tomcat and JBoss. In this environment the same practices that we used to have in JEE centric world for managing and deploying our app are not relevant anymore. In this session we'll introduce a new open source framework based on Groovy for packaging your application, automating the scaling, failover, and more.
3. GOOD AS LONG AS…
You assume the other components
are managed (DB, LB, …)
Everything in your app is Java-based
Servers are statically deployed
4. THINGS HAVE CHANGED
• The world is heterogeneous
• Cloud - The new data center
• Tons of OSS projects
• Speed of change ->
continuous delivery
• Reduced Boundaries
between Dev and Ops
5. THE NEW APPLICATION STACK
Distributed
Dependencies
Application
Pod DB
Tomcat, Node.js, Ruby,
NoSQL
Web
LB
Server
8. What about the operational aspect?
Deployment Post Deployment
Installation Fail-over
Dependency Configuration Update /
Maintenance
Monitoring
Startup
10. We need a new way to describe and
deploy these apps...
11. A DSL TO THE RESCUE
11 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
12. RECIPES – THE NEW APPLICATION DEPLOYMENT DSL
Recipes define all the details needed to run an app:
What middleware services to run
Dependencies between services
How to install services
Where application and service binaries are
When to spawn or terminate instances
How to monitor each of the services.
12 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
14. HOW CAN I DO THE SAME THING IN JAVA?
14 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
15. GROOVY – GREAT FOR JAVA BASED DSL
Removes
Syntactical
Noise
15 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
16. GROOVY – GREAT FOR JAVA BASED DSL
Extendable
16 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
17. GROOVY – GREAT FOR JAVA BASED DSL
Readable
17 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
18. CREATING A GROOVY-BASED APPLICATION
RECIPE DSL – THE CLOUDIFY WAY
18 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
19. CLOUDIFY RECIPE DOMAIN MODEL
Application:
Describes the
application tiers and
their dependencies Application
Pod DB
Service:
Describe an individual tier
e.g. Tomcat, Node.js, Ruby, NoSQL
Web
LB
Server
20. APPLICATION RECIPE
application {
name="petclinic"
service {
name = "mongod"
}
service {
name = "mongoConfig"
}
service {
name = "apacheLB"
}
service {
name = "mongos"
dependsOn = ["mongoConfig", "mongod"]
}
}
® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
21. SERVICE RECIPE: MACHINE TEMPLATES
service {
name "mysql"
icon "mysql.png"
type "DATABASE"
...
}
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"
21])
shutdown ([
"Linux.*":"mysql_uninstall.groovy"
])
® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
22. SERVICE RECIPE: SCALING RULES
scalingRules ([
scalingRule {
serviceStatistics {
metric "Total Requests Count"
statistics
Statistics.maximumThroughput
movingTimeRangeInSeconds 20
}
highThreshold {
value 1
instancesIncrease 1
}
lowThreshold {
value 0.2
instancesDecrease 1
}
}
22])
® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
25. INTEGRATING WITH CHEF
service {
extend "../../../services/chef"
name "your service name"
Extending the Chef Recipe
type "DATABASE"
numInstances 1
compute { Custom Service Name
template "SMALL_UBUNTU"
}
lifecycle {
startDetectionTimeoutSecs 240 Add Custom Start Detector
startDetection {
ServiceUtils.isPortOccupied(System.getenv()["CLOUDIFY_AGENT_ENV_PRIVATE
_IP"], 3306)
}
}
}
runParams = [
“param1": “value1”,
“param2": [“key1”:”subvalue1”,…]
Runtime parameters
…
"run_list": ["recipe[cookbook_name::recipe_name]"]
]
Run list
(Recipes or Roles)
27. LET’S START WITH A BASIC GROOVY FILE
27 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
28. USE CONSTRUCTOR WITH NAMED PARAMETERS
28 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
29. ADD IMPORT CUSTOMIZER TO GROOVY SHELL
29 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
30. BETTER, BUT NEEDS A BIT MORE
30 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
31. OVERRIDE SCRIPT BASE CLASS
A Groovy script is compiled into a Java class.
The Groovy commands runs 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.
31 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
32. OVERRIDE SCRIPT BASE CLASS
Tweak a few small things, like redirecting println() to Logger
32 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
33. AND TWEAK SOME MORE
Override invokeMethod() and setProperty()
Map method names to domain objects
If not a domain object, map to field name of current object
33 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
34. LOAD AN OPTIONAL PROPERTIES FILE AND BIND TO SHELL
Bind to Groovy Shell
34 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
35. EASY TO READ, BUT STILL POWERFUL
35 ® Copyright 2012 GigaSpaces Ltd. All Rights Reserved
37. ON ANY CLOUD
Your Own
Data Center
37 ® Copyright 2011 Gigaspaces Ltd. All Rights Reserved
38. Live Demo
38 ® Copyright 2011 Gigaspaces Ltd. All Rights Reserved
39. Get it today
http://www.cloudifysource.org
http://github.com/CloudifySource/cloudify
Notes de l'éditeur
This is a simpler method to show how to set a service than the previous slide
Use wrapper class which is RunnableWe change the default base class from the default script class to our own extended script class – this enables us to add specific attributes and context to each element in the DSL.
See reference below
We needed to extend the invoke method to map between the service method and the service domain model using naming conventionThe dfferent between this method and monkey patching is that in this method can be called from a java code where monkey patching were adding modethods on the fly a feature that his not that intituive to use if your calling groovy from java.One of the differences is that in this mothod as appose to monkey patching the object meta data doesn’t change i.e. I will not be able to see a new method named service added to the class definition instead we have a defaul handler that will catch every undefined method and will invoke it through this handler.
Note that in this DSL theimpage and preStartMessage are defined as properties
Start local cloud Show recipe – install application – simple Show on ec2 Install Metrics LogsComparison charts