Thursday April 30, 2009
TOTD #81: How to use nginx to load balance a cluster of GlassFish Gem ?
![]() |
nginx (pronounced as "engine-ex") is an open-source and high-performance HTTP server. It provides the common features such as reverse proxying with caching, load balancing, modular architecture using filters (gzipping, chunked responses, etc), virtual servers, flexible configuration and much more. |
| ~/tools
> curl -L -O http://sysoev.ru/nginx/nginx-0.6.36.tar.gz ~/tools > tar -xzf nginx-0.6.36.tar.gz ~/tools > curl -L -O http://downloads.sourceforge.net/pcre/pcre-7.7.tar.gz ~/tools > tar -xzf pcre-7.7.tar.gz ~/tools/nginx-0.6.36 > ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin --with-debug --with-http_ssl_module --with-pcre=../pcre-7.7 ~/tools/nginx-0.6.36 > make ~/tools/nginx-0.6.36 > sudo make install ~/tools/nginx-0.6.36 > which nginx /usr/sbin/nginx |

| ~/samples/jruby >~/tools/jruby/bin/jruby -S rails
runner ~/samples/jruby/runner >~/tools/jruby/bin/jruby script/generate scaffold runlog miles:float minutes:integer ~/samples/jruby/runner >sed s/'adapter: sqlite3'/'adapter: jdbcsqlite3'/ <config/database.yml >config/database.yml.new ~/samples/jruby/runner >mv config/database.yml.new config/database.yml ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S rake db:migrate |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish -p 3001 Starting GlassFish server at: 192.168.1.145:3001 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| ~/samples/jruby/runner >~/tools/jruby/bin/jruby -S
glassfish -p 3002 Starting GlassFish server at: 192.168.1.145:3002 in development environment... Writing log messages to: /Users/arungupta/samples/jruby/runner/log/development.log. Press Ctrl+C to stop. |
| upstream
glassfish { server 127.0.0.1:3000; server 127.0.0.1:3001; server 127.0.0.1:3002; } |

| proxy_pass http://glassfish; |

| sudo
kill -15 `cat /usr/local/nginx/logs/nginx.pid` sudo nginx |

| log_format
main '$remote_addr - [$upstream_addr]
$remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; |
| 127.0.0.1 - [127.0.0.1:3000]
- [29/Apr/2009:15:27:57 -0700] GET
/runlogs/ HTTP/1.1 "200" 3689 "-" "Mozilla/5.0 (Macintosh;
U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like
Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3001] - [29/Apr/2009:15:27:57 -0700] GET /favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3002] - [29/Apr/2009:15:27:57 -0700] GET /stylesheets/scaffold.css?1240977992 HTTP/1.1 "200" 889 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" |
| 127.0.0.1 - [127.0.0.1:3000]
- [29/Apr/2009:15:28:53 -0700] GET /runlogs/ HTTP/1.1 "200" 3689 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us)
AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1"
"-" 127.0.0.1 - [127.0.0.1:3002, 127.0.0.1:3000] - [29/Apr/2009:15:28:53 -0700] GET /favicon.ico HTTP/1.1 "200" 0 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" 127.0.0.1 - [127.0.0.1:3001] - [29/Apr/2009:15:28:53 -0700] GET /stylesheets/scaffold.css?1240977992 HTTP/1.1 "200" 889 "http://localhost/runlogs/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1" "-" |
Posted by Arun Gupta in web2.0 | Comments[8]
|
|
|
|
|
Wednesday April 29, 2009
TOTD #80: Sinatra CRUD application using Haml templates with JRuby and GlassFish Gem
TOTD
#79 showed how to run a trivial Sinatra
application using GlassFish
Gem. Sinatra
provides support for Haml,
Erb,
Builder,
Sass,
and Inline templates as described here.
This TOTD will show how to get started with creating a Sinatra CRUD
application using Haml templates.
![]() |
Haml is based on one primary principle - Markup should be beautiful
because beauty makes
you faster. Get started by installing the Haml gem as:
And follow the tutorial, documentation, and reference page for more details. |
| ~/tools/jruby/samples/sinatra-sample >mysql --user root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 664 Server version: 5.1.30 MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database hello_development; Query OK, 1 row affected (0.00 sec) mysql> use hello_development; Database changed mysql> CREATE TABLE `runners` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `distance` float, `minutes` int(11), `created_at` datetime, `updated_at` datetime); Query OK, 0 rows affected (0.06 sec) |
| require 'rubygems' require 'sinatra' require 'activerecord' ## Setup ActiveRecord::Base.establish_connection( :adapter => "jdbcmysql", :host => "localhost", :username => "root", :password => "", :database => "hello_development" ) ## Models class Runner < ActiveRecord::Base end ## Controller Actions get '/hi' do "Hello World!" end get '/' do @runner = Runner.find(:all) haml :index end get '/new' do haml :new end get '/:id' do @runner = Runner.find(params[:id]) if (@runner) haml :show else redirect '/' end end post '/' do @runner = Runner.new(:distance => params[:distance], :minutes => params[:minutes]) if @runner.save redirect "/#{@runner.id}" else redirect '/' end end |
| %h1 Listing all runners ... %table %tr %th Distance %th Minutes - @runner.each do |r| %tr %td= r.distance %td= r.minutes %br %a{:href=>"/new"} New Runner |
| %h1 Adding a new runner log ... %form{:method=>"post", :action=>"/"} Distance: %input{:type=>"text", :name=>"distance"} %br Minutes: %input{:type=>"text", :name=>"minutes"} %br %input{:type=>"submit", :value=>"Submit"} %br |
| %h1 Showing a runner log ... Distance: = @runner.distance %br Minutes: = @runner.minutes %br %br %a{:href=>"/"}= "Show All!" |
| . ./hello.rb ./views ./views/index.haml ./views/new.haml ./views/show.haml |
| ~/tools/jruby/samples/sinatra-sample >../../bin/jruby -S glassfish Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log. Press Ctrl+C to stop. |





Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Tuesday April 28, 2009
TOTD #79: Getting Started with Sinatra applications on JRuby and GlassFish Gem
![]() |
Sinatra
is a DSL for quickly creating web-applications in Ruby with minimal
effort. Like Rails and Merb, Sinatra is not an MVC framework and
basically follows a flat-file structure instead. The framework define
conventions such as location of static files and
views, bootstrap, dev/production/test environment variables, filters,
helpers, TDD, and much more. Read Getting Started
for complete details. Even though Sinatra is not a MVC framework but sinatra-gen
may be used to generate new Sinatra projects. GlassFish Gem can easily run Rails, Merb, Sinatra, and any other Ruby framework applications based upon Rack. TOTD #70 shows how to run Rails applications and TOTD #53 shows to run Merb applications. This TOTD will explain how to run a trivial Sinatra application. A later blog will describe how to plug a generic Rack-based framework. |
| ~/tools/jruby >./bin/jruby -S gem install
sinatra JRuby limited openssl loaded. gem install jruby-openssl for full support. http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL Successfully installed sinatra-0.9.1.1 1 gem installed Installing ri documentation for sinatra-0.9.1.1... Installing RDoc documentation for sinatra-0.9.1.1... |
| require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end |
| ~/tools/jruby/samples/sinatra-sample
>../../bin/jruby
-S glassfish Log file /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log does not exist. Creating a new one... Starting GlassFish server at: 192.168.1.145:3000 in development environment... Writing log messages to: /Users/arungupta/tools/jruby-1.2.0/samples/sinatra-sample/log/development.log. Press Ctrl+C to stop. |

Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
|
Monday April 27, 2009
GlassFish, NetBeans, and Project Kenai at Rails Conf 2009
Did you know that ...
![]() |
|
![]() |
Develop
with pleasure, Deploy with Fun: GlassFish and NetBeans for a better
Rails experience Tuesday, May 5th, 2009, 1:50pm Pavilion 1 |
| And you'll get to meet Project Kenai team, they form the foundation for Sun's connected developer experience. Read about their participation here and meet them to learn about NetBeans and Kenai integration. | ![]() |
Posted by Arun Gupta in General | Comments[5]
|
|
|
|
|
blogs.sun.com - the blogging server for Sun
employees has been chugging along for 5 years today!
Congratulations to Linda
and her team for running a stupendous show and providing all Sun
employees with a great opportunity to engage with the community.
| blogs.sun.com | Miles to go ... | |
| Age | 5 years | 3 yrs, 8 months (73.3%) |
| First Entry | Apr 27, 2004 | Aug 2, 2005 |
| Total Entries | 132413 | 836 (0.6 %) |
| Total Comments | 145899 | 3174 (2.2 %) |
| Total Bloggers | 4385 | 1 |





Posted by Arun Gupta in General | Comments[1]
|
|
|
|
|
Thursday April 23, 2009
GlassFish asadmin CLI-driven Cluster Setup
Here is simple script that:
| echo A | java -Xmx256m -jar
~/Downloads/glassfish-installer-v2.1-b60e-darwin.jar -console cd $GLASSFISH_HOME chmod +x ./lib/ant/bin/ant ./lib/ant/bin/ant -f setup.xml cd $GLASSFISH_HOME echo 'AS_ADMIN_ADMINPASSWORD=adminadmin' > password echo 'AS_ADMIN_PASSWORD=adminadmin' >> password echo 'AS_ADMIN_MASTERPASSWORD=changeit' >> password ./bin/asadmin create-domain --user admin --passwordfile ./password --savelogin=true --portbase 5000 --interactive=false --profile cluster cloud ./bin/asadmin start-domain cloud ./bin/asadmin create-node-agent --user admin --port 5048 --interactive=false --passwordfile ./password cloud-nodeagent ./bin/asadmin start-node-agent --interactive=false --passwordfile ./password cloud-nodeagent ./bin/asadmin create-cluster --port 5048 wines ./bin/asadmin create-instance --port 5048 --nodeagent cloud-nodeagent --systemproperties HTTP_LISTENER_PORT=58080 --cluster wines cabernet ./bin/asadmin create-instance --port 5048 --nodeagent cloud-nodeagent --systemproperties HTTP_LISTENER_PORT=58081 --cluster wines merlot ./bin/asadmin deploy --target wines --port 5048 --availabilityenabled=true samples/quickstart/clusterjsp/clusterjsp.ear ./bin/asadmin start-cluster --port 5048 --interactive=false --passwordfile ./password wines |
Posted by Arun Gupta in General | Comments[5]
|
|
|
|
|
Wednesday April 22, 2009
Offshore monitoring of windfarms using GlassFish - MySQL Users Conference 2009 Day 3
John Powell from eMapSite
stopped by at the Whisper
Suite in MySQL
Users Conference earlier today to talk about his GlassFish
issue. The possible workaround was suggested and then the discussion
became interesting on how GlassFish is used for offshore monitoring of
windfarms and process weather forecasting data. Hear all about it and
watch a flashy demo of their product in this video:
NetBeans,
GlassFish, and MySQL
is their development stack with a "very positive experience"!
Stay tuned for the stories
entry.
And the complete picture album is available at:
Technorati: conf
mysqlconf
mysql
santaclara
glassfish
netbeans
Posted by Arun Gupta in General | Comments[1]
|
|
|
|
| LOTD #21: Production Deployment Tips for running Rails on GlassFish v2 using Windows
SeaChange
Affinity uses Rails and GlassFish
as their deployment platform. One of their core developers posted
tips based upon their experience so far and they are
available at:
Rails
on GlassFish v2 using Windows
Here are some of the quotes:
Glassfish can really
handle a heavy load
and
handling 400
simultaneous users under a supremely heavy load, the
memory was holding great
All previous links in this series are archived at LOTD.
Technorati: lotd
glassfish
jruby
rubyonrails
windows
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
| MySQL Users Conference 2009 Day 3 - Cloud Shootout
I arrived at the MySQL
Users Conference just in time for the The
Great Open Cloud Shootout.
| Thorsten | Fully automatbale computing infrastructure, changes the way production scale deployments operate, saves time/cost, increases reliability |
| Chander | Elasiticity is an important aspect, Can "shoot for the moon without shooting foot", accessing a pool of resources which is infinite from an individual/organization perspective |
| Monty | Much like electricity/network bandwidth, applying that same model to computing resources |
| Jeremy | Virtualization is an important piece |
| Lew | Not new technology, rather a new way of delivery. As a developer, provision the application through the code. |
| Monty | It's for you |
| Thorsten | Amazon launched, mostly for geeks. 2007 -> Amazon skeptical and RightScale gets VC funding, 2008 -> some common usage, 2009 -> Top-down from CIOs. Basically everybody, cross-organiation, vertical |
| Mike | Horizontal technology opportunity, starting to see mainstream applications including ISVs/primary line of business, interest/adoption is growing |
| Chander | Definitely growing for ISVs, makes backup sexy, "Even though running a backup company, expected to be entertaining" |
| Jeremy | Power outlets are shaped differently, technology has not matured enough. Next few years standardization will happen. |
| Monty | People will never notice it exists, but able to access the information |
| Prashant | Putting/Sharing the data on cloud |
| Monty | All of a sudden facebook traffic, leverage a collective of people who are already investing in an effort |
| Lew | Cloud computing based on virtualization |
| Mike | More & more enterprises moving in the cloud, gain durability & resilience which was not an option because of a single data center |
| Jeremy | Legacy apps are easiest to move into cloud, they are better understood and can scale easily |
| Prashant | Cloud is the right approach/dream, not there yet. Traditional apps can be moved into cloud. |
| Thorsten | Flexibility in development and tests, DBA clone another slave server with exactly the same setup to test out schema changes |
| Monty | Spin up EC2 instances, run the tests and shut them down ... everything in approx $1. Give it back to the cloud and make it more efficient for the world in general. |
| Lew | We are making it so affordable, cost can be 10% of what it was before. |
| Chander | Performance, a customer requested a refund where they were trying to shove a 1TB in an hour. US is 6Mbps, needs to significantly increase before it can be utilized. |
| Thorsten | Compute needs to move where the data is. |
| Chander | Most businesses will find bandwidth/redundancy limited. Customer always need to customer where not to use cloud and set expectations accordingly |
| Lew | Financially sensitive applications, owning your own data center |
| Chander | Trust and privacy, it's more about education though. Encryption is going tobe a key. |
| Jeremy | Competitiion, unless other companies battle it out and making it easy to to migrate from one service to other, it'll be difficult. Avoid vendor lockin. |
| Mike | Based on open industry standards, no deep rooted concern in the user community |
| Thorsten | Way to operate across different clouds, API is not the most important level. What is a server ? Can I hibernate it, mount it, how much storage volume is allowed, cross-data center boundary are a better abstraction. |
| Lew | Very early to lock the standards, everybody is currently in a stage of experiementation |
| Monty | Potential downside to premature standardization, too early to jump to standards |
| Chander | Open standards are a definite key to success. S3 fostered innovation. |
| Thorsten | S3 is a good standard but not an open API. It will be doubly nice if it's "free" or "open" or whatever the word is. |
| Mike | Standards dont really matter if the performance cannot be met. When innovating at a rapid rate, it' difficult to make everybody agree upon standards. |
| Lew | At least publish the API where everybody can use them. |
| Chander | Showing backup to Sun cloud, Sun has S3 compatible APIs, also compatible to WebDAV. |
| Monty | You can |
| Mike | Very unique and compelling business opportunity. Amazon Dev Pay: Buy infrastructure on demand, setup your software on AMI, set your own price and then customers can use it, "Software as a Innuity" |
| Chander | Traditional backup vendors will be worried. |
| Prashant | Database on the cloud |
| Lew | Seeing an explosion in the amount of data/compute required, accordingly analytics. Tremendous amount of opportunity when Cassandra & Drizzle are cloud-enabled. |
| Mike | More ISVs in the cloud. |
| Jeremy | How to do performance tuning and optimizations in cloud, do that for major cloud infrastructure. |
| Monty | Freedom to work from anywhere, don't need to be physically at the datacenter, enables multinational consulting |
| Chander | When more clouds become available, it'll be explosion which will happen later this year. |
| Jeremy | CPU time in terms of use, storage centric clouds pay for integrity |
| Lew | Creating Data centers with loading docks. |
| Monty | Paying for CPU cycle, like mainframe model. |
| Thorsten | Cloud is like mainframe but very elastic. |
| Chander | Billing is not a challenge, storage clouds are better because of pricing, compute is challenging |
| Thorsten | Flexibility of moving to the next volume, master, slave makes is very refreshing |
| Monty | Start out thinking M x N problems, never think about one database instance in cloud, there will be X > 1 |
Posted by Arun Gupta in General | Comments[6]
|
|
|
|
|
Tuesday April 21, 2009
MySQL Users Conference 2009 Day 2
I presented on Creating
Quick and Powerful Web Applications with MySQL, GlassFish, and NetBeans.
The key messages conveyed during the preso are:
Posted by Arun Gupta in General | Comments[4]
|
|
|
|
|
Monday April 20, 2009
MySQL Users Conference 2009 Day 1 in Photos
MySQL Users Conference started earlier this morning with tutorials. I
attended MySQL
Cluster Tutorial and part of Scale-Up,
Scale-Out, and High Availability: Solutions and Combinations.
Both of them were very involving with practical real-life advice.
Here are tweets from the morning of MySQL Cluster Tutorial:





And now the tweets from "Scale-Up,
Scale-Out, and High Availability: Solutions and Combinations" session:

Here are some pictures captured during the day:
GlassFish in Twitterverse - Oracle buying Sun
Oracle has entered a
definitive agreement to acquire Sun
for $9.50 per
share in cash. Read more details in Sun's
PR and Oracle's
PR.
Here are some tweets captured from the Twitterverse
on GlassFish:













And there is certainly buzz at MySQL Users
Conference about the announcement. Only time will tell the
future and fate of this blog!
It seems there is only one other entry tagged
Oracle on this blog ;-)
Technorati: glassfish
twitter
oracle
sun
Posted by Arun Gupta in General | Comments[4]
|
|
|
|
|
Friday April 17, 2009
GlassFish and NetBeans at MySQL Users Conference 2009

What is open source, production-quality, supported by a large vibrant
community, and comes with full enterprise support ? - GlassFish and MySQL.
Did you know that GlassFish ...
| When: | April 21, 2009 (Tuesday), 3:05 pm |
| Where: | Ballroom A |
Posted by Arun Gupta in General | Comments[6]
|
|
|
|
|
Friday April 10, 2009
Small Steps Foundation Walk 2009 - Help Under Privileged Children by Walking
Did you know walking can help underprivileged children ? Read on ...
Small Steps
Foundation is a 501c3 non-profit organization that helps
under privileged children by raising funds in the US. They
are organizing a 5K/10K walk on May 17th, 10am at Coyote
Hills Regional Park.

I'm walking 10K along with my family and so are bunch of my
family members and friends. There are multiple ways you can participate
in this cause:
Posted by Arun Gupta in Running | Comments[2]
|
|
|
|
|
Thursday April 09, 2009
LOTD #20: How to create a JPA application using GlassFish Tools Bundle for Eclipse ?
Here is a great screencast (from the community) that shows how to
create a JPA application
using EclipseLink and deploy on GlassFish v2.1 - all using GlassFish
Tools Bundle for Eclipse.
Click on the image below for the video:

Thanks!
I'll work on a MySQL version of it :)
All previous links in this series are archived at LOTD.
Technorati: lotd
glassfish
eclipse
jpa javadb screencast
Posted by Arun Gupta in General | Comments[4]
|
|
|
|
|
Today's Page Hits: 611
Total # blog entries: 1002