Monday, March 28, 2011

Richfaces showcase on Cloudbees

To continue with my experiments with different PAAS providers, I took Run@Cloud provided by Cloudbees for a ride this time. Overall its web interface is very straightforward and intuitive and similar to what I mentioned about AWS Elastic Beanstalk . I was able to deploy Richfaces 4 Showcase application in couple of minutes and you can see in action at http://showcase.eejot.cloudbees.net.  Once your app is running, besides application logs, you can monitor different operational parameters such as system load, number of request, session etc as evident in following screen shot:


Keep in mind that I did not try its SDK  which allows you to deploy your webapp from command line on your local box.

I found it a bit odd that when you add a new application, the wizard asks you for app name only and not the actual deployable. The advantage of this approach is that you get a running URL immediately to which you can upload your .war. I would have merged these two steps into one.

I also would have liked to have a shell access to actual server as well as ability to specify different JVM parameters. May be it's a work in progress? ;-)


Sunday, March 20, 2011

Richfaces showcase on Amazon's Elastic Beanstalk

Richfaces 4 is around the corner and it runs pretty much same in both Tomcat and JBoss. The major difference is that with Tomcat, you have to bundle in your .war a JSF implementation which could be Mojarra or MyFaces. I don't have a preference on JSF implementation at this stage.  Given that Richfaces runs without problem on Tomcat, I thought I should take AWS Elastic Beanstalk for a ride. As it turns out deploying is as simple as deploying it to your local tomcat instance which is a good thing but it also differs a bit.

In following screen shot, you can see that  I have chosen Richfaces showcase application (showcase.war) which I want to deploy on a 32-bit Linux OS running Tomcat 6. Once app is deployed, it should be deployed on http://prabhat.elasticbeanstalk.com (I have shut down my instance so link wont work).



When I deployed my app, I expected my app to be available at http://prabhat.elasticbeanstalk.com/showcase in line with what I get when I deploy the app locally which is http://localhost:8080/showcase . But Beanstalk renames the .war and deploys it as /usr/share/tomcat6/webapps/ROOT which is why it's available under root context . This is important to know because in the next step of configuration, you would  need to supply the URL which can be used for health check. I initially provided /showcase and I ran into problem. Following is what should be:



Other noteworthy differences or rather limitations are that currently Beanstalk configuration does not give you options to edit JVM parameters initially. Once you have instance up and running, it does give you an option to edit JVM configurations as well pass five application specific parameters but the name of parameters has to be PARAM1, PARAM2 ... May be this will be fixed in future versions or it's already available and I don't know. The latter is likely given that I did not spend a whole lot of time on it.  Anyway, here is screen shot of app running on Beanstalk.







Tuesday, March 8, 2011

Quick tip on hibernate batch operation

You can find the details of what batch operation with respect to DB is and related Hibernate guide at http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html . Any time you need to do bulk inserts/updates, it's better to do in batch to get a better performance. Recently I was developing a small app and followed Hibernate guide to make sure that my configurations were correct. Even after trying several things, I kept seeing following in log generated by Hibernate:

Hibernate: insert into Member (name, id) values (?, ?)
Hibernate: insert into Member (name, id) values (?, ?)
Hibernate: insert into Member (name, id) values (?, ?)
Hibernate: insert into Member (name, id) values (?, ?)
Hibernate: insert into Member (name, id) values (?, ?) 


But batch operation is supposed to generate statements like


insert into Member (name, id) values ('name0', 1),('name1', 2),('name2', 3),('name3', 4),('name4', 5),('name5', 6),('name6', 7),('name7', 8),('name8', 9),('name9', 10),('name10', 11),('name11', 12),('name12', 13),('name13', 14),('name14',
15),('name15', 16),('name16', 17),('name17', 18),('name18', 19),('name19', 20)


It turns out that even when batch operation is in progress, hibernate log shows individual operation. If you don't know this, you might be up for a ride figuring out what the heck is going on. The best way to make sure is to turn on the query logs in DB itself. For MySQL5 installed on Fedora, you do it by adding log parameter at /etc/my.conf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
log=/var/log/mysqld.log


You should see statements like following at /var/log/mysqld.log :

2 Query insert into Member (name, id) values ('name0', 1),('name1', 2),('name2', 3),('name3', 4),('name4', 5),('name5', 6),('name6', 7),('name7', 8),('name8', 9),('name9', 10),('name10', 11),('name11', 12),('name12', 13),('name13', 14),('name14',
15),('name15', 16),('name16', 17),('name17', 18),('name18', 19),('name19', 20)
2 Query    commit


The complete test project is at http://anonsvn.jboss.org/repos/qa/prabhat/batch-insert . The relevant hibernate configuration is at http://anonsvn.jboss.org/repos/qa/prabhat/batch-insert/src/main/resources/hibernate.cfg.xml . If you are letting hibernate generate the primary key then don't use GenerationType.Identity in your  model otherwise batch insert will not take place.

Wednesday, March 2, 2011

New guide, tips and tricks for GateIn

Recently my team members published several how-to docs and guides on customizing GateIn Portal which applies to Enterprise Portal Platform (EPP) in most cases as well. Here is a compilation of those docs in one place:



The first two articles use extension mechanism which means that there is no or very very minimal change to OOB GateIn. I believe these docs should help you do an efficient customization of GateIn for your use.