|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Feature Exploring WebLogic JMX: JMX and J2EE Part 1
Exploring WebLogic JMX: JMX and J2EE Part 1
By: Dan MacKinnon
Apr. 26, 2002 12:00 AM
J2EE is rapidly becoming an established platform for deploying long-running business-critical applications. As the number of J2EE applications grows and their importance increases, a standard way to manage J2EE servers and applications is becoming a key requirement. Java Management Extensions (JMX) provide a pure Java management infrastructure that can be used for all Java-based software. BEA WebLogic's support for JMX comes in not only providing a JMX implementation, but in basing all of its key administration and management features on this standard. The administration and management features of WebLogic are now extensible open to both developers and third-party tool integrations. There are obvious benefits in improved and extensible administration, but J2EE application developers still face several questions: What exactly does JMX provide and how is it likely to be used? What management features should developers build into J2EE applications? Which management facilities should the application server provide automatically? This first article in a two-part series on WebLogic JMX provides a brief overview of JMX and discusses some of its implications for enterprise Java developers. JMX and Application Management Manageable resources include devices such as printers, network routers, and telephone switches. More generally, any software component that resides on a server or in a distributed environment that is available to service requests is a good candidate for instrumentation. J2EE components fit well into this larger category. Management interfaces for such components include functions for tracking resource use, measuring client volumes, generating error logs, stopping and starting services, and load-balancing. Developers (when tuning and debugging systems), system administrators (when monitoring applications and intervening when necessary), and other users employ management applications to access instrumented manageable resources. Management applications range from graphical resource-use monitors that run locally to Web-based administrative consoles that can be accessed remotely. Many of these tools use standard protocols to discover and display managed resources and their interfaces dynamically. JMX is intended to be simple enough to allow developers to rapidly provide a management layer for either new or existing Java applications, and comprehensive enough to be adapted to other standard (non-Java) management protocols. The JMX specification, currently in its 1.0 release, is being developed through the Java Community Process. The JMX reference implementation is available from Sun Microsystems, which also provides a commercial JMX-based product, the Java Dynamic Management Kit (JDMK). A number of J2EE vendors now include JMX implementations in their application servers; WebLogic is one of the more comprehensive of these. A specification for J2EE-specific management requirements based on JMX is currently under development, as are other specifications that describe how JMX should be adapted to other management protocols. JMX Architecture Managed Beans, or MBeans, make up the instrumentation level. These objects represent the manageable resources of the system, and are the primary components of the JMX architecture. An MBean Server is the most essential part of the agent level. It provides a means for creating, registering, and finding MBeans within the system. The agent level includes several services that are also represented by MBeans. The distribution level may provide remote access to the agent level through CORBA, RMI, or other means, and may also provide adapters for other protocols. It may provide security as well. The management level consists of the external applications that can access the MBeans via the APIs exposed through the agent layer, using protocols provided by the distribution layer. WebLogic goes beyond the JMX 1.0 specification to provide a distribution layer that maps logically onto the underlying agent level. Both local and remote users of JMX can access MBeans through the corresponding MBeanHome, a WebLogic-specific component that provides a client with access to MBeans. WebLogic's MBeanHome components offer some distribution facilities, as well as other features that make them easy to use. Using JMX A Standard MBean, the most basic MBean, is not required to implement a special JMX interface or extend a particular abstract class. To be considered a Standard MBean, a class must simply implement an interface whose name matches that of the class with the additional MBean suffix. The MBean interface defines the management interface for the corresponding MBean class. A simple MyService MBean is shown in Listing 1 (code for this article may be found at www.sys-con.com/weblogic/sourcec.cfm). Making the MyService MBean available within a JMX agent is straightforward. The examples in Listings 2 and 3 are based on the standard JMX interfaces and can be used with Sun's reference implementation. Registration of an MBean with the agent layer is carried out using the MBeanServerFactory, MBeanServer, and ObjectName classes, all part of the standard JMX API, found in the javax.management package. The MBeanServer interface provides a rich API for registering and manipulating MBeans; essentially, all management of MBeans is carried out using this interface. The MBeanServerFactory is a class that provides a broker for the various MBeanServer instances within a system. It is an implementation-neutral way of obtaining references to an MBeanServer. The API provided by the MBeanServerFactory allows for multiple servers to be active within the system. An MBean is registered under a particular name that is used to uniquely and meaningfully identify it. For most MBeanServer operations, this name is represented by an ObjectName instance. It is a structured piece of data that complies with the JMX naming conventions. MBean names are given by a domain name, followed by a colon, and then by a sequence of one or more property-value pairs. Certain MBeanServer APIs support pattern-matching for MBean names, allowing users to query for a range of MBeans whose names conform to a given object name expression. As shown in Listing 2, the basic registration process is quite simple. However, additional JMX facilities provide hooks for developers during the registration process, if required. For example, the MBean can implement an additional MBean Registration interface that will give the MBean- event callbacks during registration. These callbacks (preRegsiter, postRegister, deregister, and postDeregister) allow the MBean to obtain a reference to the MBeanServer, allowing the MBean to perform management actions on other MBeans. MBeans are used by invoking their methods through the MBeanServer interface (see Listing 3). Intermediate and Advanced JMX Use Dynamic MBeans Dynamic MBeans generally require more coding than Standard MBeans, but allow the management interface to change at runtime, and allow the MBean developer to expose more information (such as textual descriptions of the MBean and its operations) through the agent level. The surprising aspect of DynamicMBeans is that they present essentially the same client view to their users as Standard MBeans. A Dynamic MBean's attributes are displayed and its actions are invoked through MBeanServer methods in the same way as the much simpler Standard MBeans. Model MBeans
The JMX Notification framework allows MBeans to notify management applications of changes of state or other events that have occurred in the manageable resources of the system. Various subclasses of javax.management.Notification (which extends java.util.EventObject) can be used by MBeans that implement javax.management.NotificationBroadcaster to signal events to objects that have implemented the javax.management.NotificationListener interface. MBean Monitors
One of the key things that JMX provides is a way for managed resources to describe themselves to management applications. This allows management applications to be written independently of the systems they administer, without knowledge of the operations and attributes of the manageable components they will manipulate. The description of manageable resources is carried out through the JMX metadata data classes MBeanInfo, MBeanOperationInfo, MBeanConstructorInfo, MBeanAttributeInfo, and so forth. Without a metadata infrastructure, management applications would have to rely on the Java reflection API for this discovery process. By providing this framework, JMX avoids the difficulties associated with reflection and provides a standard means of self-description that allows developers to provide more information than is available through reflection. Roles in JMX Java developers will likely find themselves in the roles of application developer, while building manageable applications, and management solutions developer, while creating ways to better manage existing applications. The application developer develops Java applications that provide a runtime management interface. J2EE applications built with technologies such as JSPs, servlets, EJB, JMS, and so on are likely to be the most common manageable applications. This role will use the instrumentation level of JMX. Management solutions developers will create customized administration and monitoring systems that will function as components in the management layer of JMX. They will be accessing instrumented application components from the agent level through the distribution level. These developers may have to develop additional protocol adapters in the distribution level if they are integrating legacy management systems. Management tool vendors may build management tools in Java, or may enhance existing tools to use JMX. This may include adapting existing management protocols to JMX. For both the management solutions developer and the management tool vendor, the end-user of their work is the system administrator. This role uses these tools and solutions to manage the running applications monitoring their behavior, running diagnostic checks, shutting down and starting up services, and doing manual load-balancing as required. A standalone Java application may provide a complete JMX implementation, but the more common scenario is that the vendors of J2EE servers will also become JMX Providers. The JMX Provider provides an implementation of JMX either as a framework to be incorporated into standalone Java applications, or as part of an application server. JMX Use in J2EE
Ideally, integrating JMX into J2EE application servers will make the configuration and administration facilities of such servers extensible, allowing developers to create simplified administration consoles, integrate reporting facilities and statistics-gathering into the server, and tie server and application events to logging facilities or messaging channels. The more instrumentation provided by the application server, the less need there will be to build JMX interfaces for individual J2EE application components. Instrumentation provided by the application server will be safer than anything built into individual components, and will provide a consistent management view across all deployed applications. Standard J2EE management facilities may include:
JMX Pitfalls 1. Mixing JMX directly with EJB: Care must be taken to ensure that JMX code does not violate the security and transactional integrity of the EJBs. An EJB cannot also be an MBean for several reasons: EJB components should not also be MBeans, nor should they expose their underlying bean instance directly to MBeans. It is possible, however, for MBeans to access EJBs through the standard EJB protocols. Unfortunately, MBeans would not be able to access EJBs through the new local interfaces provided by EJB 2.0 since these are restricted to use by other enterprise beans. Consequently, MBeans would have to access EJBs as remote clients, and the operations available to the MBeans would be the same as those exposed through the regular client interfaces. 2. Distributed JMX use: Lack of details for distribution in the specification puts developers who are trying to create application serverneutral management solutions at a disadvantage. MBeanHomes make up for this by providing a straightforward distribution mechanism. 3. Relying on Standard J2EE management features: There is no official statement on what management facilities should be present in an application server. The existing management and administration facilities in WebLogic are a good example of the direction in which these specifications are likely to proceed. Conclusions In part two of this series, we will look at WebLogic's JMX implementation, and discuss some concrete ways that it can be used to instrument J2EE applications. References http://jcp.org/jsr/detail/3.jsp. http://jcp.org/jsr/detail/077.jsp. http://jcp.org/jsr/detail/070.jsp. http://jcp.org/jsr/detail/48.jsp http://jcp.org/jsr/detail/3.jsp. http://jcp.org/jsr/detail/070.jsp. http://jcp.org/jsr/detail/3.jsp. http://java.sun.com/products/ejb/ http://java.sun.com/products/JavaManagement/doc.html http://e-docs.bea.com/wls/docs61/jmx/index.html. YOUR FEEDBACK
BEA WEBLOGIC LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||