Thursday Oct 18, 2007

Upgrading from GlassFish V1 to GlassFish V2 and an Interesting Deployment ...

I came across this interesting use case while discussing GlassFish V1-> V2 upgrade.

As you might know, we have modified the process launcher a great deal for V2. This contributed to improved startup performance. In the process, following happened:

  1. asadmin start-domain does not invoke the domain-folder/bin/startserv script anymore.

A user was using V1 in an interesting way. The assumption was asadmin start-domain will always invoke the startserv script.

Here is how:

Consider that I have a heterogeneous environment, with various libraries being used by my application. We have a complicated build environment and we finally make sure that all the libraries needed by the application are saved at a particular location say /libraries and is captured in an environment variable AS_LIBRARIES as:

export AS_LIBRARIES=/libraries/foo.jar:/libraries/bar.jar ...

Then we modified the startserv script as: -Dmylibraries=$AS_LIBRARIES ...

and finally we modified domain.xml as:

<java-config classpath-suffix="${mylibraries}" ....

/>

Now, this was clearly a hack and worked only because of peculiar way in which GlassFish V1 treats the system properties. This is clearly an area in GlassFish that needs improvement because of its over-dependence on (evil) System Properties. Here, however, the user had employed this to his advantage! In short, what he has done was:

Invented a way to pass an environment variable on the system whose value at a given point in time would be picked up by the domain dynamically, at the startup. That way, the user would just modify the value of the environment variable and restart the server to pick up the changes in the variable!

The ordeal is expressed here.

I liked the way they used it and I thought of helping him. Of course, there are better ways of doing this, but they had been having this for some time and apparently, this was the thing holding them back from upgrading to GlassFish V2.

I remembered suddenly, the GlassFish had an attribute named env-classpath-ignored which is set to true by default. This means, that whoever (user on Operating System) starts the application server, if s/he has an environment variable named CLASSPATH it is always ignored by the server by default. This works well in almost all cases, since CLASSPATH is being forgotten by the Java community.

I thought of suggesting this to him and instead of setting AS_LIBRARIES, if CLASSPATH is set as the environment variable in this user's environment, the problem would be solved.

The way the launcher deals with this is:

  • Look at the env-classpath-ignored and it it is set to false (non-default case), append its value to the -cp argument to the JVM.
  • Effectively place the jars pointed to by CLASSPATH into the application server JVM's System ClassLoader.

I thought the problem is solved!

But no, because of various class-loaders in application server (each for a specific purpose), this was not working correctly as some classes were loaded too early by the System ClassLoader. The correct solution was to:

  • Look at env-classpath-ignored and if it is false,
  • Get the value of CLASSPATH and set it as -Dcom.sun.aas.ClassPathSuffix along with classpath-suffix in domain.xml.

It worked perfectly and user tested it (on his laptop, in Mumbai).

Lessons learned:
- Don't rely on private interfaces of a product. Hacks are OK, but look at the consequences.
- Consider using ${path.separator} instead of ':' or ';' if you want GlassFish to virtualize the 
operating platform for you. So, while setting path-like entries in domain.xml, always use
${path.separator}. GlassFish is designed to do the right thing.

Thanks to both Byron Nevins and Sivakumar Thyagarajan for their help in this regard.

Sunday Sep 30, 2007

Yahoo! Pipes and Global GlassFish Aquarium ...

This post is based on two facts:

  1. It (Web 2.0?) has definitely started to change how we look at the Web. It is a collaboration of various technologies that is ultimately going to make the Internet a better place for everyone.
  2. Translation is probably still a topic of active research.

I am trying to suggest an approach to translate TheAquarium into various languages so that developers around the globe can experience it and get benefited by GlassFish technologies.

Yahoo! Pipes is an interesting technology but I am not going to delve into it because there are various resources that help you get started with it. When I looked into it, the first thought that came to my mind was to use it for GlassFish and then I saw the translation module. It sort of guided me into defining the pipes as shown in attached graphic.

TheAquarium Feeds in French 

This shows the pipe that takes the English feed from feedburner (which is rather weird) and then translates the titles into French and creates the list.

Here is the English-French TheAquarium Pipe I published.

My French friends are going to be happy with me.

I bet this technique can be exploited to translate the entire posts so that Global Developers are attracted to TheAquarium. We might not need the Language Buttons any more (although they serve a slightly different purpose).

Isn't the Web (ever) burgeoning?

Monday Sep 17, 2007

Five Reasons to Upgrade to GlassFish V2 ...

GlassFish V2 is now released. 

Download it here. GlassFish V2 

There have been quite a few firsts and positives about this release. Deployers, administrators and developers have all got reasons to pick GlassFish V2. Here are my top five reasons (not in any specific order) to pick GlassFish V2 as your platform:

  • Fully Open Sourced Product: GlassFish is 100% Open Source. This is an attractive option for the industry deployments and developers because of the obvious advantages. The user and developer community for GlassFish is thriving and the discussion forums have been invaluable to various users. There has been contributions from several users to the FAQ's based on their experiences. Over 3500 issues have been filed by the community at large in a year and quite a few of them have been fixed for V2. An excellent knowledge base is being developed at the Wiki. Users and developers have been contributing to documentation and its reviews. A search of specific terms on discussion forums is likely to direct you in the right direction if you are looking to solve a particular problem. The open source momentum is driving this effort fabulously.
Another interesting fallout of this is that GlassFish V2 has been successful in integrating various technologies so that deployers can pick and choose. These include SOA integration in terms of Open ESB and Web Services Interoperability Technologies.
  • Ease of Use for Developers and Deployers: GlassFish V1 was the reference implementation for Java EE 5 more than a year ago and that won the mindshare of several developers. The success of EJB 3.0 and JPA is evident. Developers like the ease with which they can develop the enterprise applications. The industry-leading IDE for Java EE 5 in NetBeans makes the development even easier. All of these advantages have been retained in GlassFish V2 as it is fully compliant with Java EE 5. With its introduction of usage profiles, it has been possible to get rid of the Product Editions, which were too course-grained and difficult to upgrade. GlassFish V2 adds the ability to manage the software for enterprise with ease. The attractive features for administrators and deployers include:
    • A Web-based Administrative Console with uniform look and feel.
    • An exhaustive, easy to use and uniform command line interface (asadmin).
    • An ability to add clustering support to an existing server, retaining your behavior (in other words, an easy upgrade to clustering).
    • Ability to monitor the servers in the cluster and the admin server itself using any tool of choice. The tools for monitoring include the asadmin, admin-console, JConsole and any JMX-enabled console (like HP OpenView) etc. The asadmin program has added a new command called "monitor" that gives you a more intuitive output, similar to several Unixy commands like iostat, vmstat etc.
    • Ability to run heterogeneous domains through use of profiles. Three profiles of interest are bundled with any distribution and they can be made to work if required components are just plugged in. This was not possible in the past with Sun's application server offering. The introduction of profiles makes it possible to have single download that gives you an ability to create administrative domains (protected by distinct security credentials) with specific behavior.
These administrative advances in GlassFish V2 make other offerings without any cluster management support look old-fashioned.
  • World-record Web-tier Performance: GlassFish V2 posted the best ever Specjappserver2004 performance numbers. The Grizzly front-end adds performance and features that are poised to make your deployment blazingly fast. Grizzly brings in the Comet Support and Port Unification. The additional Web Container enhancements are described by Jan Luehe.
  • Clustering and Availability: This is one of the distinguishing features of GlassFish V2. Clustering of the application server instances as far as the conversational state of Stateful Session Beans and HTTP Session is concerned would not have been easier to manage. Based on robust architecture of JXTA, this solution is close to zero-configuration and delivers reasonable availability. In case your business demands warrant a more available solution, you can always use the Highly Available Database (this is available as a binary download from www.sun.com). The good thing about this is, it is pretty easy to interchange the in-memory session state replication and HADB solution, for well-written user applications.
  • Pluggability into Sun's Software Stack and Support Benefits: You can reap the benefits of alignment of Sun's server product offerings. Along with the GlassFish V2 release, Sun has also released Sun Java System Application Server and Application Server/Platform Suites. These integrate the Identity Management, BPEL Engine and so on. Sun also delivers the same set of GlassFish V2 bits into Java Enterprise System -- an integrated stack involving industry-leading directory server, identity manager, portal server and registry. The integration has been smoother than ever before.
Sun's support is more than equipped to guide you with right advice on deployment on Solaris, Linux and Windows platforms. GlassFish V2 also supports Mac OS X. If you have an adoption story, please let us know at stories portal.

Tuesday Apr 17, 2007

A recipe to create clusters with GlassFish V2 ...

I have been seeing several questions about clustering on GlassFish Users alias. Here is a simple recipe, very crude, but the one that works.

Questions? Shoot.

  • Domain Spans machines, usually. One of the machines is designated as DAS.
  • The DAS is the admin server and it manages the servers in the same domain. The servers can be clustered if administrator wants them so. The administrator has benefits of management when instances are clustered. Now, on the other machine, all you need is "bits".
  • Consider the scenario: You have "m1" and "m2" as two machines.
  • Let's say you want to create a cluster "c1" with instances "s1" and "s2" with node-agents "na1" on "m1" and "na2" on "m2".
  • Your DAS is on "m1".
  • Let's call the domain where all this "logically" resides as "domain1". You do the following:
    • 1- Download the glassfish.jar on both "m1" and "m2".
    • 2- On "m1", run "ant -f setup-cluster.xml". This creates the domain, domain1 that is capable of handling clusters.
    • 3- On "m1", you start domain, domain1.
    • 4- On "m1", /asadmin create-node-agent na1
    • 5- On "m2", run ant -f setup-cluster.xml on glassfish.jar you downloaded (after of course, java -jar ...) This creates a domain on that machine as well, but you don't need it. I will file an RFE in this regard.
    • 6- On "m2" you create a node-agent \*pointing to domain1 on "m1"\* as: /asadmin create-node-agent --host m1 --user admin-user na2
    • 7- On "m1", /asadmin start-node-agent na1 On "m2", /asadmin start-node-agent na2 Now, your topology is created and ready to go. You have a domain domain1, this spans "m1" and "m2". Node-agent "na1" is on "m1". It will control instances on "m1". Node-agent "na2" is on "m2". It will control instances on "m2". From this point on, forget you had machine "m2". The entire configuration can be done just from machine "m1". This is the beauty of the process, IMO.
    • 8- On "m1", just try: /asadmin create-cluster c1
    • 9- On "m1", /asadmin create-instance --cluster c1 --nodeagent na1 s1 This puts "s1" in cluster "c1". Note that this instance is controlled by Node Agent "na1". This instance uses "physical resources" from "m1".
    • 10- On "m1", (not "m2"!) /asadmin create-instance --cluster c1 --nodeagent na2 s2 11- On "m1", /asadmin start-cluster "c1". This is where it culminates. All you do is "start cluster". It starts instance "s1" on "m1" and "s2" on "m2". The instances have homogeneous configuration.
About

Welcome to my blog where mostly my work related thoughts are expressed.

Search

Categories
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