serli's Blog
Virtual clustering in GlassFish 4 : focus on the VMware plugin
GlassFish 4 will be the JAVA EE 7 reference implementation. This new version is to be released on Q3, 2012 but promoted builds can already be downloaded : http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/. The main idea of this future release is to provide GlassFish as a PAAS solution.
GlassFish 4 will be shipped with a new component called PAAS console. This component is a GUI that allows to deploy and monitor an application in a cloud environment. GlassFish 4 will be able to dynamically provision the services (load-balancer, Java EE, database ... ) needed by the application. The number and type of services to be deployed can be specified explicitly by adding an XML configuration file in the application archive, or determined implicitly by GlassFish. The user will also have the possibility to set up quality of service requirements for his application, GlassFish relying on some auto-scaling features to meet these requirements. If you want to try GlassFish 4, Arun Gupta has already written a really nice article : http://glassfish.java.net/javaone2011/.
In GlassFish 4, the underlying physical infrastructure will be managed using virtual clustering. A virtual cluster is made up of a list of server pools. A server pool can be either a group of physical machines or a reference to a public cloud. Each server pool is associated with one virtualization plugin which is responsible of the communication with its machines or its cloud API.
A virtualization plugin has the responsibility to :
- create virtual machines in the server pool
- handle the lifecycle of the created virtual machines (pause, resume, delete ... )
- retrieve resource usage
- possibly add/remove machines in the server pool
A VM (virtual machine) provides one service instance for an application. To create a VM, a virtualization plugin needs a VM template. Each template is associated with one service type, meaning that all the VMs created from a template will provide an instance of the same service. To deploy a cloud application, you will probably need at least a load-balancer template and a JavaEE template.
One virtualization plugin can usually handle only one kind of machine or one cloud API. For example, an OVM plugin is expected to be developed to manage OVM servers only. But in GlassFish 4, everything has been designed to make the integration of new virtualization plugins easy. A plugin provides an HK2 service that implements a ServerPool interface. Thanks to HK2 dynamic service discovery, the plugin can automatically be used by GlassFish at runtime. Consequently, since GlassFish is open source, it is possible for anybody to develop and offer his own plugin.
At SERLI, we are currently developing a VMware plugin to allow GlassFish to deploy services on VMware ESX and ESXi machines (versions 3.5 to 5).
A template for the VMware plugin is made up of a VMDK virtual disk and optionally a VMX file. The VMDK is a virtual disk on which an OS and some applications have been installed (for example : JeOS + GlassFish for a JavaEE template). The VMX file allows to specify the physical parameters of the VMs that will be created from this template. The interaction with the hypervisors is provided by VI Java (http://vijava.sourceforge.net/).
Example of a VMX file
for the VMware plugin
A demonstration of virtual clustering in GlassFish 4 can be found at : http://www.youtube.com/watch?v=FMHIjNfRDaw.
Thank you very much to the GlassFish team, especially Alexis Moussine-Pouchkine and Jérôme Dochez for their time and effort.
Fabien Leroy
SERLI Team
- Login or register to post comments
- Printer-friendly version
- serli's blog
- 2646 reads
How to use GlassFish application versioning
Few weeks ago, a new “awesome” feature made appearence in the GlassFish Milestone 1. This feature, the “Application versioning”, aims to help you deal with the multiple versions of your Java EE applications in a simple and easy way with the usual GlassFish administration commands.
This feature allows users to deploy multiple versions of the same application in a GlassFish server at runtime with only one version enabled at a time. The application versioning provides a full set of commands to interact with the versions of an application naturally integrated in existing CLI commands.
The “versions” of an application can be pretty much anything because a version is really just a qualifier so you can use you maven version identifiers for instance (SNAPSHOT, BETA, etc ... ) or anything you want as version. Also there is no notion of “version sequence” so you can easily switch to any version from any other (actually GlassFish deals with a version like it’s an individual application).
And now, a little user story. To present how to use application versioning, let me introduce Robert

Robert is a Java EE developer and a GlassFish enthousiast since long time. Robert uses GlassFish on his laptop, on a “Continuous Build” server and on the production server. Right now, Robert is writting a very cool Java EE application, called “Foo”, and hopes to become rich with it.
After writing some GUI code, Robert decides to deploy the “foo” application on his laptop like this :
$ asadmin deploy foo.war
The deployed applications are :
$ asadmin list-applications [prettify]foo <web> </pre> <p>at this point, the application is pretty basic and looks like this</p> <p><img alt="" src="http://www.java.net/sites/default/files/untagged-half.png" /></p> <p>during the development Robert uses the force option the redeploy “Foo”. For instance after replacing the JPS with a servlet :</p> <pre> $ asadmin deploy --force=true foo.war </pre> <p>The deployed applications are :</p> <pre> $ asadmin list-applications
foo <web> </pre>
<p><img alt="" src="http://www.java.net/sites/default/files/untagged-force-half.png" /></p>
<p>Now let's use some cool Java EE stuff. After spending hours on the code, Robert thinks it’s time for a beta version. So he deploys the <span class="caps">BETA</span>-1.0 version on GlassFish</p>
<pre> $ asadmin deploy --name=foo:BETA-1.0 foo.war </pre>
<p>The deployed applications are :</p>
<pre> $ asadmin list-applications foo <web> foo:BETA-1.0 <web> </pre>
<p>You can notice here the versioning syntax used in the command to create a <span class="caps">BETA</span>-1.0 version of the “Foo” application. Basically the syntax is used in the <code> --name option and is composed with the name of the app. and the identifier of the version separated by a column charater.
--name=application_name:version_identifier[/prettify]
It’s now time for a second BETA version. Robert wants to deploy it, but in a disable state because he has to check some things in the previous version. To do that he uses the following command
$ asadmin deploy --name=foo:BETA-1.1 --enable=false foo.warThe deployed applications are :
$ asadmin list-applications
[prettify]foo <web>
foo:BETA-1.0 <web>
foo:BETA-1.1 <ejb, web> </pre> <p>as you can see, the version is deployed, but the previous version is still active.</p> <p><img alt="" src="http://www.java.net/sites/default/files/beta-1-half.png" /></p> <p>Now to enable the BETA-1.1 version, Robert uses the command :</p> <pre> $ asadmin enable foo:BETA-1.1 </pre> <p><img alt="" src="http://www.java.net/sites/default/files/beta-1.1-half.png" /></p> <p>After some more lines of code, Robert thinks “It’s time for a new version !” and decides to publish a Release Candidate of the “Foo” application. To deploy it, Robert uses the command :</p> <meta charset="utf-8"> <meta charset="utf-8"> <meta charset="utf-8"> <pre> $ asadmin deploy --name=foo:RC-1.0 foo.war </pre> <p>The deployed applications are :</p> <pre> $ asadmin list-applications
foo <web>
foo:BETA-1.0 <web>
foo:BETA-1.1 <ejb, web>
foo:RC-1.0 <ejb, web> </pre> <p>This new Release Candidate version looks like this</p> <p><img alt="" src="http://www.java.net/sites/default/files/rc-1-half.png" /></p> <p>Now with this new RC-1.0 version, <span class="caps">BETA</span> versions are useless to Robert. To undeploy all these versions, Robert uses what we call a “version expression” to handle multiple versions in a single undeploy command.</p> <meta charset="utf-8"> <pre> $ asadmin undeploy foo:BETA-* </pre> <p>The deployed applications are :</p> <pre> $ asadmin list-applications
foo <web>
foo:RC-1.0 <ejb, web> </pre> <p> </p> <p>Unfortunally for Robert, the “Foo corporation” company just release a first version of a similar application called “Magic Foo”. Naturally Robert wants to give it a try, download the app. and deploys it on GlassFish to find out that “Magic Foo” is way better than “Foo”</p> <pre> $ asadmin undeploy foo:*
$ asadmin deploy magicFOO.war [/prettify]
You can find the code of the “foo” application here.
The entire documentation of GlassFish versioning is available on the GlassFish wiki at http://wiki.glassfish.java.net/Wiki.jsp?page=ApplicationVersionings
You can see a screencast of the “Application versioning” feature on Alexis blog at
http://blogs.sun.com/alexismp/entry/glassfish_3_1_milestone_1
You can also try the feature by yourself with the latest GlassFish promoted build
Mathieu ANCELIN
SERLI Team
- Login or register to post comments
- Printer-friendly version
- serli's blog
- 3787 reads






Comments
Thanks SERLI :)
by laps - 2010-09-13 13:28
Very cool article, thanks a lot :)
Nevertheless, I'm wondering what's the best solution if we need to keep active more than one version of the same application. I'd like some people to work on a specific version, and other people to work on another one. We could need maybe a dozen of simultaneous working versions. The only solution I've found today is to install as many glassfish servers as many simultaneous versions I need ; I'm not sure the performances and memory are optimized with this kind of configuration.Do somebody have a suggestion with it ?
Why hasn't anyone though of this before?
by regwhitton - 2010-09-03 05:58
What a great idea. This seems ideal for staging a code fix release onto a production system (... assuming all the dependences match - like the DB schemas).I am assuming that the disabled versions of the app have started up and run concurrently with the enabled one, and we could just switch over at the drop of a hat.
All it needs now is some way to test the new version, before it is enabled.