Intel General Session:
I got in late for the session, a reluctant entry to the session given that I was not really impressed by AMD's session the previous evening and had the same impression that it would be bland about perf improvements and a very high level on how they are using it. But the few minutes I was there, which was to the end of the session, it was pretty interesting. With presenters who were adept to stage presence and ex-tempo rather than reading from the presentation visible below the stage on the LCD screens, Intel finished off pretty strongly. The message from the last few minutes was about Intel's Xeon being the fastest processor for Java, strongly moving towards Mobile devices and tablets, an their open source community for development - Moblin.org
Started off by going to the session on TS 5793 on Groovy and Grails. My knowledge on the session was minimal since I had only played around with Groovy. The presentation was a quick overview and at a high level but had good number of snippets of code especially how to use metaClass feature and its related functionality. To this were the tips added on how to replace DAO and ServiceLocator patterns on how the boiler plate code can be avoided. The gaps for me were on the interal workings since I have a deep desire to understand how the internals work - how the code was generated by Groovy behind the scenes, especially the loss of encapsulation that the methods can be defined outside of the class. Pretty evident that I need to do more investigation on this front.
The next session was on JRuby On my way to the session I happen to run into Michael Czapski and Brendan Marry - professional services folks who had become new authors and had published their first every book on Java CAPS suite. After a brief discussion I barged into the JRuby session and could capture some of the notes only. Again this was another session where I was a beginner and could grasp what I could get and look forward to specialize depending on priorities. More notes on the session are below.
My next session was TS 6256 (Scalable non-blocking data structures) which was pretty detailed on how to build DS especially in cases where multiple reads, copying of DS are involved. More notes on the session are below.
My next session was TS 6587 (Patterns and solutions for Offline Batch Processing). This was a problem we had partly attempted to solve as part of the B2B solution. We had done the Batching part only and not the un-batching part. I was curious to hear on difference in how others have solved the problem. But to a large extent the presentation addressed the problem similar to how we had. It rather expanded on it in different ways from tightly coupled to loosely coupled.
--- TS 5793 Groovy & Grails- Changing Java ------------------------------------
By Graeme LaForge - Proj lead of Groovy and JSR 241
Groovy:
- dynamic language for JVM.
- groovy.codhaus.org
Grails:
- web platform that implements full stack from build system down to ORM layer. To put all technologies together.
- Leverages existing tech Spring, Hibernate, Quartz
- grails.org
Groovy dynamic:
Dynamic langs - Python, VB, Ruby, Groovy
Meta Object Protocol - Grovy, Ruby, LISP
Groovy MOP:
- Every class has a MetaClass which can be obtained as below
def obj = "Hello"
df metaClass = obj.metaClass
obj.metaClass.methods.each {
}
using respondsTo and hasProperty
- Need to find out whether an object implements a method? Use respondsTo:
- Need to find out if an object has a property? Use hasProperty:
if (foo.metaClass.hasProperty("bytes")
println foo.bytes.encodeA;
}
MataObject Model and other details available on groovy website
//can add new methods at runtime. Eg: On String class padLeft and other utils dynamically.
class Dog()
Dog.metaClass.bark = { -> "Woof!" }
Dog.metaClass.getBreed = { -> "BullDog"}
def d = new Dog()
println d.bark()
println d.breed() //interestingly this works??? although method is getBreed
Integer.metaClass.plus = { Integer i -> 1 }
3 + 4 (this will always return 1.
Integer.metaClas.getDollars = { -> "$delegate dollars"}
4.dollars
Static methods and constructrs
- static ethods can be added
Dog.metaClass
.static.bark = {new Dog() }
println Dog.create().bark()
- Note that every time you do a new Dog() the same instance is returned. (verify this???)
Constructor can be added using a special property
Meta-Program hooks
- invokeMethod, methodMissing, get/setProperty, propertyMissing:
Dog.metaClass
.methodMissing = { String name, args ->
println "Dogs..."
Meta-Prog Patterns
Interesting pattern developed in Grails
- Intercept, Cache, Invoke
- Basic Usage:
- inercept method
Dynamc create new method
cache new method
invoke new method
Dog.metaClass
.methodMising = { String name, args ->
def cached = {Object[] a ->
println "Dogs.."
}
Dog.metaClass
DAO pattern:
Implications of DAO
- Class explosion
- promotes aemic domain model
- configuration, config, config - a lot of repetition
- violates DRY???
GORM n Grails
- Dynamc queries can us used where methods need not be static. An interceptor can be built, where method name starting with certain string can be identified and corresponding logic executed.
MOP == goodbyte to DAO
- repetitive, boilerplace DAP logic gone (DRY)
- logc exists wher eit belongs - in domain (DDD)
- no direct ref to third party dependencies
Svc Locator
Eg: Spring & Grails
class Book {
Purchasing Service pusvc
Transaction buyBook(User u) {
purchasingService.buyBook(this, u)
}
}
Book.metaClass.constructor = (->
def obj = BeanUtils.instanctiateClass9book)
applicationContext
.getAutowreCapableBeanFactory()
.autowireBeanProperties(obj, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME,
false)
return obj
}
Adv of Meta way
- promotes DomainDriven Design (DDD)
- No config
Summary:
- Meta programming represents a new way to think abt problems
- Common patterns like DAO & Svc locator r present bcos of limitations in Java Platform
- Groovy & Grails open doors to declartive prgms, DSLs and DDD
grails.org
Code available in Grails docs
-------------------------------------------------------------------
--- TS 6490 JRuby --------------------------------------------------------------------
JRub/LDap
penSSL => JRuby/OpenSSL
Warbler: util to package app into web
- Application Layout (Rails) is kind of opposite of WAR file. Warbler takes care of this
- Installed as a gem(jruby -S gem install warbler)
- installing warbler as a plugin - jruby -S warble pluginze
- Configuring Warbler
jruby -S warble config
- Can also specify DataSource name in Wobbler config
Demo:
jruby -S rake db:create //std Rails rake cmd to create DB. The config file with variables is updated.
Tuning your deployment:
Runtime Pool size:
- config/warble.rb:
Warbler::Config.new do |config|
#....
#contorl the pool of Rails runtimes
config.webxml.jruby.min.runtimes = 2
config.webxml.jruby.max.runtimes = 4
end
Session handling:
Rail session != Servlet sessions
Caching and File Stat'ing
- Ensure view cacing is enabled (deault in Rails 202)
configaction_view.cache_template_loading = true
Aviod asset ID timestamp checks with RAILS_ASSET_ID
ENV['RAILS_ASSET_ID'] = 'r#{.....
Ensure ull page cache dir points to root of WAR
config.action_controller.page_cache_directory
Rails.public_path coming in 2.1
Performance: evolving and no stats are available.
concurrent request 10-90 while response time increases linearly.
Pre-compiling Rails
- compile Ruby code to bytecode before execution
- System property: -Djruby.compile.mode=FORCE
- still eveolving and may not return desired results.
JRuby-Rack
wiki.jruby.org/wiki/JRuby_Rack - converts java req to what Rails can understand
rack.rubyforge.org
------------------------------------------------------------------------------
---- TS 6256 -------------------------------------------------------------------
Towards scalable Nonblocking Data Structure - Azul systems
BitVector
Use the bits to capture the state of the DS - from initial(0000) to set data(0XXXX) then to move the content to another DS, you set an intermediate state (1XXXX) and once the DS is copied over reset the status to (10000).
Resize - copy mechanics
- Use Finite state machine to control writes
- Use large array for data
e2e.azulsystems.com - contains papers and other material for engineers.
azulsystems.com/blogs/cliff
--------------------------------------------------------------------------------
---- TS 6587 Patterns and solutions for Offline Batch Processing ----------------------------------------
Higher level framework:
SpringBatch - an implementation from Spring. Do not know much.
Spring Integration
- Batch infrastructure adds optimization adn low level abstractions.
EDA
- Contineous and concurrent
- Sometimes perceived as opp of Batch procesing - but not really
The presentation was pretty much in line with BatchSvc implementation as part of B2B effort. But the presentation started from the ground up how the message is read and written as
- read and write tightly coupled
- read separated out from writer but not in a scalable model
- further were how the batching could be scaled using BP's, JMS etc..
--------------------------------------------------------------------------------
No comments:
Post a Comment