Monitoring GlassFish application server’s HTTP Service using VisualVM.

Monitoring GlassFish HTTP service using VisualVM.

GlassFish application server has some motniroting features which are exposed through its administration chanlles including Administration Console and asadmin utility. I disucssed some of these features here and in this we will see how we can use visualvm and its plugin as a desktop application to monitor GlassFish HTTP service.

VisualVM is JDK tool based on NetBeans platform, NetBeans profiler, and a handful of plug-ins which let us profile any Java application running in JDK 6 or 7. VisualVM does not works with older JDK or any JRE either 6 or 7. Starting from JDK 6 update 7 visualVM is included in the Sun JDK distribution.

Downloading and installing latest version of visualVM is straight forward, just point to Download Page grab the zip file, extract the zip file content and you are ready to go. Follow the installation instruction (4 very easy steps) here

Now, to monitor GlassFish HTTP service we need to install a visualVM plugin that can interact with GlassFish application server through its JMX/ AMX API to gather the statistics and let us view them live in our desktop application. Run visualVM using the provided script in the bin directory, Open Tools>Plugins menu item and from the available plug-ins section select VisualVM-GlassFish and press install button to install the plug-in. Restart VisualVM and now we are ready to connect to a GlassFish instance.

A_figure01.jpeg

Now we have two options, we can either monitor a local Glassfish instance or we can select to monitor a remote Glassfish instance. All local JVM are listed under the local node and in order to create a remote connection we need to register the host under the Remote node by right clicking on the node and adding the remote host, in my case I add 192.168.1.100. Now on the remote host we may have several JXM enabled applications running, each application on its own port. Default JMX port for GlassFish application server is 8686, therefore to add a GlassFish application server running on 192.168.1.100 we can right click on its node under the Remote node and select add JMX connection, a window will open which asks you to provide the connection information including port number and credentials. default administration credentials for GlassFish are admin/ adminadmin as username/ password. A_figure02.jpeg

Now that The remote GlassFish is registered the right side panel should be similar to the fillowing figure

A_figure03.jpeg

In my case I have a remote and a local GlassFish instances, When you double click on an instance a window will open that shows all monitoring information which VisialVM can gather about the running application in different panels, something similar to the following figure

A_figure04.jpeg

This page shows general information about the JVM which we are going to monitor and some of the plug-in specific configuration which we may need to change. Make sure that you turn the HTTP Service monitoring level and WebContainer Monitoring Level to High or LOW which will result in GlassFish gathering monitoring statistics about the HTTP Service.

A_figure05.jpeg

Now let your application server get some hit from the clients and then switch to HTTP Service Tab in order to get a general overview of your Server HTTP Service performance. Failed, Incoming, Average connections, Keep Alive, and File Cache performance can be monitored here. Following Figure shows HTTP Service Tab

A_figure06.jpeg

Now the funny part begins, Assuming that we have a dozen of application hosted in the same GlassFish instance we expect to be able to monitor each application separately to see how HTTP service is performing for that particular application. It is easy and do-able in no more than 3 steps. Under the GlassFish node you can see Model and under the Model you can see different web applications that you have hosted in your server, double clicking on any of those applications result in viewing the HTTP Service statistics for that particular application. For example If I double click on the admingui I will get a result page similar to the next figure.

A_figure07.jpeg

The fun part continues further I tell you that you can monitor different servlets used in your application separately. for example I can expand the admingui node and double click on ThemeServlet to get an statistical view similar to the next figure.

A_figure08.jpeg

All statistical information which are shown includes two major factors, processing time and error/ request count. in addition to average processing time, maximum processing time, and so on.

WSJ says: “IBM in Talks to Buy Sun”. But Why would IBM buy Sun Microsystems?

The Wall Street Journal Published an article which discuss possibility of IBM buying Sun Microsystems, but why on earth should IBM take over Sun Microsystems when every product which Sun offer has a counterpart in IBM arsenal.

In software range Sun offers Operating System, Database, Application server family of products, identity management family of product, Integration series of products either developed by Sun or acquired from other companies, Software development tools including NetBeans and its related add-ons. All of these products has a counterpart in IBM series of products.

In hardware range Sun offers Storages, X86 and Sparc servers, and networking solutions. All of these products have their counterpart in IBM arsenal and having them add no exceptional value to IBM set of available products which make IBM take over Sun Microsystems.

But Why would IBM think about buying Sun Microsystems and what Sun own that IBM does not?

  • First Sun owns Java and all rights over its patents and source codes
  • Sun owns some products which I am not aware of any counterpart in IBM offering, these products includes: VirtualBox and X86 virtualization, and Sun xVM Ops for data centre management
  • It is told that IBM has the largest patents arsenal but Sun owns enough patents which IBM might be interested to own them
  • Although IBM has AIX and there are some undergo efforts to port Solaris to Z architecture but maybe IBM has some more plans with Solaris

A list of Sun software with their counterpart in IBM arsenal:

Sun Product

IBM counterpart

Sun JDK*

IBM JDK, although I think IBM licensed Some part of Sun JDK to avoid developing them again (class path?)

NetBeans and Sun Studio series of products (For Java, C++ and so on)*

Eclipse and Rational line of products(For Java, C++ and so on)

Sun middle-ware product line including but not limited to: GlassFish, Portal, Sun Identity management, JCAPS and OpenESB, and so on.*

IBM Websphere product line including but not limited to: Application server, Portal, Tivoli Identity management, ESB, and so on.

Sun Solaris*

IBM AIX, Z/OS, Z/VM and whatever Z starting word that you can write here

MySQL as a product which Sun owns, Java DB and PostGreSQL support*

DB2, DB2 express edition, DB2 community edition, Informix dynamic server(is it still alive?)

JavaFX

Nothing that I am aware of

X86 virtualization*

Nothing that I am aware of

Data Centre management(Sun xVM Ops center)

Nothing that I am aware of

*All of these products except JCAPS and Sun xVM Ops are open source. And all of them are high quality with a well established community of user and third party companies which are involved in their development.

Now, Why could be possible reason that we hear "IBM in Talks to Buy Sun"? The reason can be:

  • Patents and rights that Sun is holding over Java, Sparc and Solaris
  • The Open Source model which Sun introduced and looks to be successful
  • Open Source products that Sun is developing and have gained enough attraction from the community which result in "IBM in Talks to Buy Sun" once more.
  • Brilliant architects, engineers, and evangelists which are working for Sun Microsytems
  • Some software and functionalities which IBM does not own
  • Customers and community to gain more market share, specially in middle range market
  • Maybe IBM is interested in un-released Sun Cloud Computing… Sun is known to either does not enter an area or if entered provides a very good product or service in that area, technically speaking.

What can happen if IBM take over Sun Microsytems? The answer is: no one knows expect those IBM super managers which are possibly thinking about this take over. But some predictions:

  • Java will evolve much faster as IBM has more man power to assign to it
  • OpenSolaris will get more attention and possibly replace AIX in long term
  • MySQL and Sun middle-ware products will form a big bundle of highly integrated, high quality Open Source products and bring more revenue to IBM
  • IBM will lay off some Sun employees, specially in sales and marketing section because they have many sales and marketing employees
  • NetBeans and Eclipse? I can not comment with more than 20 percent of certainty, but I think either IBM kill all middle-ware or work on NetBeans development for as long as they provide all NetBeans functionalities that support Sun middle-ware development in Eclipse
  • JavaFX will see a boost in development as IBM can afford more man power
  • Swing and SWT story? I think IBM will keep Swing as a part of JRE but hey will push SWT as a part of the JRE to ensure it will get enough chance of growing in the market
  • Responsibilities for providing support for Java, JCP, TCK and… will be given to a foundation organized by IBM, Oracle, RedHat, …

I may have missed some items due to short term forgetfulness or being completely unaware of their presence. If you happen to know them, let me know and I will include it in this blog.

 

Experimenting replication and failover recovery (High Availability) with OpenDS 1.3 Build 1

If you do not know what OpenDS is, then you can simply learn about it by looking at its website located at http://www.opends.org But a brief description is: OpenDS is a high performance, feature rich and pure Java based, directory server which is under active development by Sun Microsystems.

Today I grabbed OpenDS 1.3 build 1 to see what is new and check its replication and fail-over recovery. You can grab a copy at https://www.opends.org/promoted-builds/latest/. First thing that I noticed is the new control panel which replaces the old likely status panel. You can see an screen-shot of the control panel right here.

 

Although the control panel has good set of features and functionalities and it is very good to have a built-in LDAP browser and management utility coming with the OpenDS but this control panel is not user friendly enough. I think we will see some changes for this control panel in new future. for example some better menu design, tab based content pane instead of opening new window,… To run the control-panel application you can run control-panel script either from bat or bin directory

figure01.jpeg

Down to business, I though I can test the replication and fail over recovery of OpenDS replication by some simple Java code and the new control panel application. To install OpenDS in an specific directory, extract the zip file in that directory and run setup script. I installed first instance of OpenDS server in /home/masoud/opends1.3/OpenDS-1.3.0-inst01. The installation process is quite simple, you just need to execute the setup script, it opens a GUI setup application which guide you through the installation. Following screenshots shows the installation process for first instance.

Welcome page:
figure02.jpeg
Server Setting page: I used admin as password
figure03.jpeg
Topology Options
figure04.jpeg
Directory Data
figure05.jpeg
Installation review page
figure06.jpeg
Installation finished
figure07.jpeg

Installation application will open the control-panel application, the control panel needs administration credentials to connect to the directory server. administration credentials are cn=Directory Manager as the bind DN and admin as password. (If you used anything else then you should use your own credentials)

Now we should install the second directory server instance, this instance will form a replication group with instance 02, I extracted the zip file into /home/masoud/opends1.3/OpenDS-1.3.0-inst02 and then execute the setup script to commence with the installation. Following screen shots shows the installation process:

Welcome page:
figure08.jpeg
Server Setting page: I used admin as password, as you can see port numbers are different because default ports are in use and setup application try to use new port numbers instead.
figure09.jpeg

Topology Options: Here we are adding this server instance to a replication topology which already has one member. We connect this instance to another instance in the topology by providing the setup application with host name, administration port and administration credentials of that server. In my case both instances are installed on the same machine.

figure10.jpeg

Global Administration: A administration credentials which can be used to manage the whole replication topology. I used admin/admin for username/password

figure11.jpeg

Data Replication: As we want to have a replica of our remote server we should select "Create local instance of existing base DNs and….", And we should select the Base DNs which we want to replication

figure12.jpeg

 

Review: review the installation and if you found anything wrong you can go back and fix it

figure13.jpeg

As both installation tasks are finished we have our replication topology installed, and configured.

So far, we should have two control-panel open. Each one of them can manage one of our installation and if it comes to data management, if we change data in one control-panel we can see the change in other control panel.

To test the replication configuration, in one of the control-panel applications, under the Directory Data tab, select manage entries and then delete some entries, now go to the other control-panel and you will those entries are gone. To make the test more understandable about fail-over recover, stop one server, delete some entries in other server, start the server which you have stopped and you should see that all deleted record are deleted in the new server as soon as it has been started.

Directory Data tab:
figure14.jpeg
Deleting some entries:
figure15.jpeg

We have a replication topology configured and working, what we can do with this topology from a Java application? The answer is simple: as we can not afford to see our client applications stopped working because a directory server machine is down or a router which route the clients to one of the server is not working and so on… we need to have our Java application uses any available server instead of depending on one server and then stop working when the server is down.

following sample code shows how we can use these two instances to prevent our client application stop working when one instance is down.


import java.util.Date;
import java.util.Hashtable;

import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.InitialDirContext;

public class Main {

    public static void main(String[] args) throws NamingException {

        final Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL, "ldap://192.168.1.100:2389 ldap://192.168.1.100:1389");
        env.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
        env.put(Context.SECURITY_CREDENTIALS, "admin");
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        Timer t = new Timer();
        TimerTask ts = new TimerTask() {

            @Override
            public void run() {
                try {
                    InitialDirContext ctx = new InitialDirContext(env);
                    Attributes attrs = ctx.getAttributes("");
                    final NamingEnumeration enm = attrs.getAll();
                    System.out.println(enm.next());
                    ctx.close();
                } catch (NamingException ex) {
                    ex.printStackTrace();
                }
            }
        };