Sunday Mar 21, 2010

Day 2 - Ruby Conf India 2010 Trip Report

Ruby Conf India 2010 Day 2 (follow up from Day 1) started with Nick Sieger's presentation on "Rails 3 Through Choices".

He started by talking about the state of Ruby in 2010

Liked the "Auto" mode of camera analogy with Rails 3, basically start changing the settings as you get more advanced.

Here are some of the highlights of Rails 3:

  • --skip-activerecord, --skip-testunit, --skip-prototype are new options in Rails 3
  • script/server | generate | console == script/rails s g c == rails server generate console (within the app directory)
  • Routing is much cleaner
  • XSS safety is default in Rails 3
  • Railties: extension API for Rails - encapsulates configuration information and enables decoupling.
    • Four main components: Initialization, Rake tasks, Generators, Logging Events.
    • All components in Rails are themselves Railties.
  • Rack is now bundled in Rails 3
  • ActiveModel: creates a contract between controller and model (7 methods), can be connected to any backend data store, provides a bunch of default functionality
  • Migration from 2.0 -> 3.0: bit.ly/online-railsconf-slides has a presentation on migration from earlier versions.

Railties certainly reminds me of the recent modularity in JDK 7 and GlassFish v3. Watch Nick's demo of Rails 3 in this 2-part video. It showed how Rails 3 Active Model can be used to store data in Neo4j (a graph database) instead of a traditional relational database.

My "GlassFish can support multiple Ruby frameworks ... really ?" talked about the pluggable architecture of GlassFish v3 and how it supports multiple Ruby frameworks. It described the 3 deployment models of Rails applications in GlassFish (Gem, WAR, Directory-based), showed live samples of Rails and Sinatra applications, talked about the advantages of NetBeans, and a lot about JRuby. All my talks on Rails/GlassFish end up promoting JRuby a lot as that is indeed the entry point for deploying your Rails applications on GlassFish. Anyway, enjoy the complete slides at:

And I received the following messages few minutes after the presentation was posted on slideshare:

Here are some of the tweets during/after the talk:

  • @gautamrege Really cool article by @arungupta Day 1 – Ruby Conf India 2010 « Miles to go … http://ow.ly/1oZ9M #rubyconfindia
  • @ytvinay sitting with @nicksieger and listening 2 @arungupta 's gr8 talk on glassfish n jruby. is this really happening? #rubyconfindia #honoured
  • @yob_au Enjoying Arun Gupta's jruby and glassfish talk at #rubyconfindia - very clear overview and demos for an MRI traditionalist like me
  • @arjunghosh Second day @ #rubyconfindia Some interesting talks until now,like Nic one on Rails 3, @arungupta 's Glassfish,Sahar's Templating
  • @vijay_dev feeling completely at home in the GlassFish talk! Helps to be a Java and Rails guy :-) #rubyconfindia

Totally love the instant feedback :-) You can follow the complete set of comments at #rubyconfindia.

Post lunch I had a brief hacking session with Obie and ran a local version of bizconf.org using JRuby/Rails 2.3.5/GlassFish Gem/PostgreSQL. Other than installing the required gems, every thing was pretty straight forward. It re-confirms the fact that JRuby is just Ruby and can run any Rails application on GlassFish in a seamless manner.

I would've loved to attend Roy's closing keynote but had to step out because of a prior personal commitment.

Overall, Ruby Conf India turned out to be an excellent experience. I certainly enjoyed spending time with Nick, Ola, Obie and a bunch of folks from ThoughtWorks, specifically Roy, Sagar, Tina, Rohit, Christabel, and Judy. The entire team put a wondertastic show and I certainly hope this is a more regular event.

There is a relentless demand for entrepreneurial spirit and trying out the bleeding edge technologies. I hope other similar conferences will start showing up in the near future. I also hope that the local community pick up efforts to take leadership roles and start organizing free Ruby or Rails workshop to expand the Ruby ecosystem. And of course, I certainly wish they all use JRuby, after all it's Ruby. And once you are using JRuby, that's it - GlassFish serves your Rails, Sinatra, Ramaze, and any other Rack-based framework applications.

Here are a few pictures from Day 2:


And the complete album so far:

The speaker gift is certainly a nice gesture and my son will surely it enjoy more than me. Thanks a lot to Thought Works for organizing the conference!

On a little bit of fun front, totally loved the following advertisement of "Bingo! Spicy Masala Remix" on the local TV channels:



2 conferences, 2 cities, 2 hotels, 5 planned + 1 unplanned sessions covered, 1 city + 4 planned sessions remaining!

Next stop is Tech Days, Hyderabad!

Technorati: conf rubyconfindia ruby jruby rubyonrails glassfish bangalore bengaluru india

Saturday Mar 20, 2010

Day 1 - Ruby Conf India 2010

Roy Singham, founder and chairman of ThoughtWorks Inc, kick started Ruby Conf India by stating that this conference is more important than just Ruby in India. He also mentioned that this conference is sponsored by developers in India instead of any big corporations.  He talked about a global shift is happening because of the passion outside silicon valley in open source, Ruby, Python and other similar technologies. In his opinion, India & Brazil are going to reshape the world of software. He'd like Ruby conference to present the best of humanity, innovative and welcome to all. I think inclusive as opposed to exclusive is certainly a key message for the Ruby audience.


Ola's talk on "The Future of Programming Languages" was interesting as always. He talked about different types of languages such as general purpose (Java & Ruby), special purpose (Erlang & JavaScript), Domain specific (SQL), Functional, Logic, Object-oriented (Prototype or class-based), Multi paradigm (some aspects of each such as C# or Scala).

An interesting part of his talk explored the key Ruby features inherited from which other languages. Lets see how many can you guess ?

  1. Multiple assignments like a, b, c = 1, 2, 3
  2. Regular expressions
  3. $/ (input record separator), $= case insensitive
  4. Object Orientation
  5. Message Passing & Introspection
  6. Mixins
  7. Closures

Try to note down your answers and then match with the corrects ones at the end of this blog :-)

Obie's talk on Blood, Sweat, and Rails was well tailored to the Indian audience. The reference to "All izz well" and couple of pictures from the movie 3 Idiots got a good laugh but then he got reprimanded during his talk to stop using the "F" bomb. From my prior experience, I counted approx 14 times of him dropping the bomb ;-)

Matz skyped in and talked about current state of Ruby and the future. Matz is to Ruby as James Gosling is to Java so the attendees were extremely excited to see him live on the skype session.

It took him 6 months to write the first "Hello World" in Ruby and the first run crashed. But that started the long journey bringing Ruby to its current state. The name "Ruby" was chosen on Feb 24, 1993 and is officially considered the birthday of Ruby. During a later Q&A session he mentioned the name "Ruby" was chosen because the language came after "Perl" which was named after a gem and "Diamond" etc were too long a name. Later on he found out that Pearl is a birth stone for the month of June and Ruby is the birth stone for the month of July so it turned out logical that way as well :-)

Matz also mentioned that Ruby 1.9.2 will be released end of August and then start working on Ruby 2.0. Ruby's future will be faster, more powerful, distributed programming, faster IPC, multi-core aware, broader (for embedded devices to HPC environments), smaller implementation, and more modular.

The social gathering in the evening was fun and gave me the opportunity to interact with lots of folks from the local community. I answered the question "What has Oracle got to do with Rails" at least 4 times during the social. Here are several articles on that topic:

And, of course, now Oracle owns GlassFish that allows native deployment of Rails along with Java EE applications.

The highlight for me was finding a happy customer using the "perfect marriage" of JRuby, Rails, and GlassFish. More details coming on that in a separate blog. I'm giving a session on "GlassFish supports multiple Ruby frameworks ... really ?" at 11am on Day 2.

Now here are some pictures so far:

And here is the evolving album so far:


And now the answers from Ola's talk:

  1. Multiple assignments like a, b, c = 1, 2, 3 from CLU (also templates, generators)
  2. Regular expressions from Perl
  3. $/ (input record separator), $= case insensitive from Perl
  4. Object Orientation from Smalltalk
  5. Message Passing & Introspection from Smalltalk
  6. Mixins from Lisp Machine Lisp
  7. Closures from Scheme

How many did you get right ? :)

Now looking forward to Day 2 starting in a few more hours.

Technorati: conf rubyconfindia ruby jruby rubyonrails glassfish bangalore bengaluru india oracle

Monday May 04, 2009

TOTD #81: How to configure "database.yml" to be used with both JRuby and MRI ?


In JRuby-on-Rails tutorial at Rails Conf 2009, Nick Sieger shared a nice little tip on how to configure "database.yml" to be usable with both JRuby and MRI:

<% jdbc = defined?(JRUBY_VERSION) ? 'jdbc' : '' %>
development:
  adapter: <%= jdbc %>mysql
  encoding: utf8
  reconnect: false
  database: myapp_development
  pool: 5
  username: root
  password:
  socket: /tmp/mysql.sock
# ...

"JRUBY_VERSION" is defined only if your using JRuby and so the right database adapter is picked up accordingly.

The complete slides for the tutorial are available here. Learn about other related talks here.

Please leave suggestions on other TOTD (Tip Of The Day) that you'd like to see. An archive of all the tips is available here.

Technorati: conf railsconf lasvegas tutorial jruby ruby rubyonrails

Tuesday Feb 03, 2009

LOTD #16: Hotspot Flags, JRuby Version String, and JRuby/MRI Benchmark


This post shares 3 links that were recently published.

The first one is about the Favorite Hotspot JVM Flags by Charlie. See how you can use them for tweaking performance or investigating runtime metrics.

The second one is about using JRuby Version String. It explains the detailed meaning of the version string printed by "jruby --version". If you read it carefully then you know the date, hardware, platform, SVN revision and even state of Charlie's local git-svn clone.

The third and the last one is about benchmark results between MRI and JRuby with the following summary:

From my tests it appears that MRI is faster in single threaded mode, but JRuby makes up for the loss big time in the multi-threaded tests. It's also interesting to see that the multi-threaded mode gives MRI(green threads) a performance boost, but it's nowhere close to the boost that JRuby(native threads) can squeeze out from using multiple threads.

Read Igor's report for more results.

And while you are reading this entry, did you know that GlassFish Gem 0.9.2 was recently released ? Use it for running your Rails applications seamlessly :)

All previous entries in this series are archived at LOTD.

Technorati: lotd glassfish v3 gem jruby ruby hotspot vm

Saturday Sep 27, 2008

LOTD #9: Advantages of JRuby over MRI


Andreas blogged about why he likes JRuby even though he dislikes Java.

JRuby is "It's just Ruby" with more than 50,000 tests to ensure MRI compliance. The blog highlights that there is no need to know Java, at all, to run JRuby. Here are some advantages that are described in the blog:
  1. JVM runtime optimization
  2. Efficient memory usage
  3. Native threads to spread work on multiple cores
  4. Great garbage collection to make memory usage more efficient
  5. JIT and AOT compilation
  6. Inegration with Java libraries
  7. Running Rails applications on existing Java application servers
  8. Documentation and specs
Read more details here.

Do you know Rails applications can be deployed (without any packaging) on GlassFish v3 ? Check out more details here.

Technorati: lotd jruby ruby rubyonrails glassfish

Wednesday Sep 10, 2008

Kenai - High Throughput and Scalable Rails on GlassFish



Kenai (pronounced 'keen-eye') is a fictional character from Disney's Brother Bear series. It's also a river, mountain range, national park, peninsula and a city in the southern coast of Alaska in the United States. But that's got nothing to do (as much as I know) with either Rails or GlassFish.




But Project Kenai was announced last week. It's a developer hub with SCM, issue tracking, forums and similar stuff you need for hosting your open source projects. And it is a Rails application deployed on GlassFish v2. 

Read all about it in an interview with the lead developer Nick Sieger. Fernando gave a great overview (slides here), with excellent tuning tips for Rails on GlassFish, in Rails Conf Europe last week.

Other Rails on GlassFish success stories are described here.

And if you want, enjoy this beautiful video of Kenai National Wildlife Refuge.



Technorati: rubyonrails jruby ruby glassfish stories kenai

Monday Sep 08, 2008

TOTD #44: JDBC Connection Pooling for Rails on GlassFish v3


TOTD #9 explained how to configure JDBC connection pooling for Rails application deployed on GlassFish v2. There are several benefits of using using the JDBC connection pools:
  • No need to create a new database connection for each Rails instance.
  • No need to specify your password in database.yml or create a hack to hide it.
  • No garbage collection of connection after each use.
And because of the above mentioned (and other reasons) an improved application performance, scalability and efficiency.
The only way to deploy a Rails application on GlassFish v2 is to create a WAR file using Warbler. That's a great option and is already used in production mode. GlassFish v3 takes that to the next level by allowing to deploy a Rails application without any further pacakging. This TOTD (Tip Of The Day explains how to achieve database connection pooling using GlassFish v3.
  1. Lets create a simple scaffold

    ~/samples/jruby >~/tools/jruby-1.1.3/bin/jruby -S rails jndi_rails2 -d mysql
    ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby script/generate scaffold runner miles:float minutes:integer
    ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby -S rake db:create
    ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby -S rake db:migrate
  2. Install MySQL ActiveRecord JDBC adapter

    ~/samples/jruby/jndi_rails2 >~/tools/jruby-1.1.3/bin/jruby -S gem install activerecord-jdbcmysql-adapter
  3. Copy MySQL Connector/J jar to JAVA_HOME/lib/ext

    ~/samples/jruby/jndi_rails2 >sudo cp ~/tools/mysql-connector-java-5.1.6/mysql-connector-java-5.1.6-bin.jar /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib/ext
  4. Start GlassFish v3 server as ...

    ~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish >java -Xmx512m -DJRUBY_HOME=/Users/arungupta/tools/jruby-1.1.3 -jar modules/glassfish-10.0-SNAPSHOT.jar
  5. Setup JDBC connection pool
    1. Create JDBC connection pool

      ~/samples/jruby/jndi_rails2 >~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --restype javax.sql.DataSource --property "User=duke:Password=duke:URL=jdbc\\:mysql\\://localhost/jndi_rails2_production" jdbc/jndi_rails2_pool 
    2. Create JDBC resource

      ~/samples/jruby/jndi_rails2 >~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish/bin/asadmin create-jdbc-resource --connectionpoolid jdbc/jndi_rails2_pool jdbc/jndi_rails2 
    3. Ping JDBC pool

      ~/samples/jruby >~/tools/glassfish/v3/b23/glassfishv3-prelude/glassfish/bin/asadmin ping-connection-pool jdbc/jndi_rails2_pool 
  6. Change the development database in config/database.yml to:

    development:
      adapter: jdbc
      jndi: jdbc/jndi_rails2
      driver: com.mysql.jdbc.Driver 
  7. Run your app as

    ~/samples/jruby >~/tools/glassfish/v3/b22/glassfishv3-prelude/glassfish/bin/asadmin deploy jndi_rails2
And chug along with your scaffold at http://localhost:8080/jndi_rails2/runners.

Technorati: totd rubyonrails jruby ruby glassfish v3 connectionpooling jndi jdbc mysql

Wednesday Aug 27, 2008

Typo on GlassFish v3 - Ruby-on-Rails Blogging Engine



Typo is an open-source Blogging Engine written using Ruby-on-Rails framework. It provides a lean engine that makes blogging easy. It's main attribtues are ease of use, usability, beauty and excellent support of web standards.

I found out about this application from Sang "Passion" Shin's Lab 5543 (part of FREE 20-week course on Ruby-on-Rails started on Jul 15, 2008). But instead of using standard WEBrick/Mongrel deployment, I describe the steps to deploy this application using GlassFish v3 that supports native deployment of Rails applications. 
  1. Typo can be installed as Gem or from Sources. Installing as gem gives the following error:

    JRuby limited openssl loaded. gem install jruby-openssl for full support.
    http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
    Building native extensions.  This could take a while...
    /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (NotImplementedError)
            from /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/1.8/mkmf.rb:1:in `require'
            from extconf.rb:1
    ERROR:  Error installing typo:
            ERROR: Failed to build gem native extension.

    /Users/arungupta/tools/rails20/jruby-1.1.3/bin/jruby extconf.rb install typo


    Gem files will remain installed in /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
    Results logged to /Users/arungupta/tools/rails20/jruby-1.1.3/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

    This is discussed here. In the meanwhile, download and unzip Typo 5.1.2 as:

    ~/samples/jruby >unzip ~/Downloads/typo-5.1.2.zip
    Archive:  /Users/arungupta/Downloads/typo-5.1.2.zip
       creating: typo-5.1.2/
       creating: typo-5.1.2/app/
       creating: typo-5.1.2/app/apis/
       . . .
      inflating: typo-5.1.2/vendor/uuidtools/lib/uuidtools.rb 
      inflating: typo-5.1.2/vendor/uuidtools/rakefile 
      inflating: typo-5.1.2/vendor/uuidtools/README
  2. Create the database:

    ~/samples/jruby >sudo mysqladmin create typo_dev

    Typo 5.1.x works with Rails 2.0.x only and so migrate as shown below:

    ~/samples/jruby/typo-5.1.2 >~/tools/rails20/jruby-1.1.3/bin/jruby -S rake db:migrate
    (in /Users/arungupta/samples/jruby/typo-5.1.2)
    == 1 InitialSchema: migrating =================================================
    -- create_table(:users)
       -> 0.0377s
    -- create_table(:articles)
       -> 0.0189s
    -- add_index(:articles, :permalink)
       -> 0.0094s
    -- create_table(:categories)
       -> 0.0069s

     . . .

    == 69 AddModulesToProfile: migrating ==========================================
    -- add_column(:profiles, :modules, :text)
       -> 0.0072s
    == 69 AddModulesToProfile: migrated (0.0454s) =================================

    == 70 AddUsersToNonAdmins: migrating ==========================================
    == 70 AddUsersToNonAdmins: migrated (0.0488s) =================================

  3. Typo 5.2 (scheduled in 3 days) will work with Rails 2.1.
  4. Download GlassFish (nightly, promoted or build-your-own) and install by unzipping. I tried the nightly of 8/24 as:

    ~/tools/glassfish/v3/8-24 >unzip ~/Downloads/glassfish-snapshot-v3-prelude-08_24_2008.zip
    Archive:  /Users/arungupta/Downloads/glassfish-snapshot-v3-prelude-08_24_2008.zip
       creating: glassfish/
       creating: glassfish/docs/
       creating: glassfish/docs/css/
       creating: glassfish/docs/graphics/
    . . .
      inflating: glassfish/lib/templates/login.conf 
      inflating: glassfish/lib/templates/profile.properties 
      inflating: glassfish/lib/templates/server.policy
  5. Start GlassFish as:

    ~/tools/glassfish/v3/8-24/glassfish >java -DJRUBY_HOME=/Users/arungupta/tools/rails20/jruby-1.1.3 -jar modules/glassfish-10.0-SNAPSHOT.jar
    Aug 26, 2008 5:56:10 PM com.sun.enterprise.glassfish.bootstrap.ASMain main
    INFO: Launching GlassFish on Apache Felix OSGi platform

    Welcome to Felix.
    =================

    Aug 26, 2008 5:56:11 PM HK2Main start
    INFO: contextRootDir = /Users/arungupta/tools/glassfish/v3/8-24/glassfish/modules
    Aug 26, 2008 5:56:11 PM OSGiFactoryImpl initialize

    . . .

    INFO: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Module [66] ]
    Aug 26, 2008 5:56:13 PM CommonClassLoaderManager Skipping creation of CommonClassLoader as there are no libraries available
    INFO: urls = []
    Aug 26, 2008 5:56:13 PM com.sun.enterprise.v3.server.AppServerStartup run
    INFO: Glassfish v3 started in 2176 ms
  6. And deploy Typo as:

    ~/samples/jruby >~/tools/glassfish/v3/8-24/glassfish/bin/asadmin deploy typo-5.1.2

    Command deploy executed successfully.
The application is available at "http://localhost:8080/typo-5.1.2" and some of the screenshots follow:

















Also check out Redmine, Substruct and Mephisto on GlassFish v3. There are some performance issues when running Typo on GlassFish and this is tracked at Issue #5662.

If your Rails application does not work on the gem, file bugs here with "jruby" as "subcomponent" (default version is "v3").

Technorati: rubyonrails glassfish v3 jruby ruby typo blogging

Monday Aug 25, 2008

LOTD #6: Rails Deployment on GlassFish in 4 steps and 15 minutes

Charlie describes, in 4 easy steps, how to deploy any Rails application on GlassFish:



The main steps are:

Step 1: The App Server
Step 2: Package your App
Step 3: Deploy your application
Step 4: Tweaking (Optional)

And it should only take 15 minutes on GlassFish v2!

The conclusion of the blog is:

Hopefully this walkthrough clears up some confusion around JRuby on Rails deployment to an app server. It's really a simple process, despite the not-so-simple history surrounding Enterprise Application Servers, and GlassFish almost makes it fun :)

The next version, GlassFish v3, allows Rails application to be deployed natively, i.e. no packaging is required. You create a Rails application and run it - just the way you are used to! Read all about it here.

All previous entries in this series are archived at LOTD.

Technorati: lotd rubyonrails jruby ruby glassfish

Wednesday Aug 20, 2008

LOTD #4: Rails running on GlassFish @ LinkedIn


Light Engineering team (BumperSticker fame) at LinkedIn has chosen GlassFish for running their Rails application. One of the developers on the team reports:

Using Warbler, we successfully wrapped our Rails applications into WAR files and deployed on Glassfish (we’ll probably write a more detailed tutorial of this at a future date). A WAR file is completely self contained application that can be deployed simply by copying to an autodeploy directory. No more Apache/Nginx reverse proxy, no more Capistrano, no more installing gems on a production container, no more of any of that madness. This was a huge win, and we broke out the champagne bottles.

Read the complete entry at:

JDBC Connection Pooling for Rails on GlassFish

Stay tuned for more details!

NetBeans development and GlassFish deployment already provide an ideal environment for Rails deployment. You can read about successful deployments of Rails and GlassFish here.

All previous entries in this series are archived at LOTD.

Technorati: lotd rubyonrails jruby ruby netbeans glassfish stories
About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today