Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Monitoring and Managing Tomcat Clusters Using JMX : Page 3

It's easy to monitor and load-balance your Tomcat clusters using JMX MBeans. JMX provides a flexible, modular, and reusable framework for managing your J2EE server components.


advertisement
The Sample JMX Application
The sample Web application, called jmxapp, is based on the JMXProxyServlet application provided with the Tomcat 5 installation. It uses an MBean descriptor file located at jmxapp/WEB-INF/classes directory/mbeans-descriptor.xml. A Model MBean is instantiated within the JMX MBean Server for each manageable component listed in Table 2.

Custom MBeans
I wrote custom Java classes to make the cluster elements JMX components. The cluster itself is not shown as part of the accessible JMX components accessible when you launch the Tomcat server. These custom classes provide useful statistics for a cluster monitoring and management framework. For example, session statistics such as default session timeout and number of currently active sessions are exposed as MBean attributes using the custom session manager class. You instantiate and register these MBeans when Tomcat server is started (Make sure you copy these class files to the %TOMCAT_HOME%/server/classes directory because Tomcat requires these classes at startup time).

MBean Naming Syntax:
To provide unique names, JMX specifies a two part naming convention for MBeans. The parts are:
  • JMX Domain: The domain name is a case-sensitive string that defines a top level within the JMX namespace. For example, the domain in Tomcat server is called "Catalina". Therefore, all the manageability components have MBeans names with a "Catalina" prefix.
  • Key-Value Pairs: The second part of an MBean name is a set of one or more name-value pairs. These key properties create unique object names within a specific JMX domain and they provide information about the MBean. This set doesn't have to be ordered; in other words, the order of the key-value pairs is not significant, but the name must begin with the domain. Using key-value pairs, you can supply information such as names, host name, port, locations, application paths, and so forth as shown below

domain:Name=name,Type=type[,key=value]

In the preceding line of code, Name is the string that you provide when you created the managed resource that the MBean represents and Type is the interface class of which the MBean is an instance.

Here's a more expansive example. The following three lines represent the MBeans names for the Service, Host, and Replication Valve components in Tomcat server.

Catalina:serviceName=Catalina,type=Service Catalina:host=localhost,type=Host" Catalina:type=Valve,name=ReplicationValve, host=localhost"

Table 2 shows the list of MBeans monitored using the JMX Web application and their object names.

Table 2. Cluster MBean Names
Managed Component MBean Name
Load Balancer Catalina:host=localhost,name=SimpleLoadBalancer,type=LoadBalancer
Cluster Catalina:host=localhost,name=SimpleTcpCluster,type=Cluster
Session Manager Catalina:host=localhost,path=/jmxapp,type=Manager
Replication Valve Catalina:type=Valve,name=CustomReplicationValve,host=localhost

Table 3 shows the list of attributes for the MBeans monitored by the sample Web application.

Table 3. Cluster MBeans and their attributes.
Cluster Element Attributes
Cluster ManagerClassName Cluster Members MembershipService Container Cluster Sender ClusterReceiver
Load Balancer Load Balancing Rule Name (Round Robin or Random) Server Instance Total number of instances TCP Listen Address TCP Listen Port
Session Manager Number of sessions Manager Class Name Number of ActiveSessions Invalidated Sessions Rejected Sessions Maximum Inactive Interval Session Id, Creation Time, Last Accessed Time for each session
Replication Valve Controller Container Request Filter details



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap