BEAJRockit SDK. Using the Monitoring and Management APIs

Similar documents
BEAWebLogic. Platform. 8.1 Supported Configurations: Microsoft Windows 2000 Professional on x86

BEAWebLogic. Platform. 8.1 Supported Configurations: Red Hat Enterprise Linux 4.0 AS, ES on Itanium

BEAWebLogic. Platform. 8.1 Supported Configurations: Microsoft Windows x64

BEAWebLogic. Platform. 8.1 Supported Configurations: Novell SUSE LINUX Enterprise Server 8 on PowerPC

BEAWebLogic. Platform. 8.1 Supported Configurations: Red Hat Enterprise Linux WS on AMD64 and EM64T

BEAWebLogic. Portal. Getting Started with Autonomy Search

BEAWebLogic. Server. Monitoring and Managing with the J2EE Management APIs

Adapter for Manugistics

Portal. BEAWebLogic. White Paper: Integrating Content Into the BEA Virtual Content Repository

BEA WebLogic. JRockit 7.0 SDK. User Guide

BEAWebLogic. Portal. Simplifying Portal URLs

Copyright. Restricted Rights Legend. Trademarks or Service Marks. Copyright 2003 BEA Systems, Inc. All Rights Reserved.

BEA Adapter for. ClarifyCRM. Release Notes

BEA WebLogic. Adapter for Siebel. Release Notes

BEAWebLogic. Platform. 8.1 Supported Configurations: HP-UX 11i on Itanium

BEA WebLogic. Adapter for HL7. Release Notes

BEA WebLogic. Integration. Samples

BEAJRockit Mission Control. JRockit Memory Leak Detector User Guide

BEA Tuxedo. System Messages CMDFML Catalog

Server and WebLogic Express

Mainframe Adapter for TCP

BEA WebLogic. Integration. Tutorial: Building Your First Data Transformation

BEAWebLogic RFID. Edge Server. Supported Configurations

BEA Tuxedo. System Messages TMADMIN Catalog

BEAWebLogic. Adapter for HIPAA. Installation and Configuration Guide

Copyright. Restricted Rights Legend. Trademarks or Service Marks. Copyright 2003 BEA Systems, Inc. All Rights Reserved.

BEAWebLogic. Enterprise Security. WebLogic Server v8.1 Installation

BEAWebLogic. Platform. 8.1 Supported Configurations: Red Hat Enterprise Linux 4.0 AS, ES on IBM pseries

BEA WebLogic. Integration. Best Practices in Designing BPM Workflows

Adapter for Mainframe

BEA WebLogic. Server. MedRec Clustering Tutorial

BEA WebLogic. Adapter for Siebel. Release Notes

BEAWebLogic. Portal. MobileAware Interaction Server Installation Guide

BEA WebLogic. Adapter for . Installation and Configuration Guide for WebLogic Integration 7.0

Mainframe Adapter for SNA

BEA WebLogic. Adapter for HL7. Installation and Configuration Guide for WebLogic Integration 7.0

BEA Liquid Data for. WebLogic. Deploying Liquid Data

WebLogic Adapter for Siebel

BEAWebLogic. Adapter for RDBMS. Installation and Configuration Guide

Copyright. Restricted Rights Legend. Trademarks or Service Marks. Copyright 2003 BEA Systems, Inc. All Rights Reserved.

BEAWebLogic. Adapter for RDBMS. Installation and Configuration Guide

CollabraSuite, BEA Edition

BEA AquaLogic Commerce Services. Release Notes

BEA WebLogic. Platform. Configuration Wizard Template Reference

Adapter for Mainframe

BEA WebLogic Mobility Server Installation Guide

Portlets for Groupware Integration

BEAProducts. ISV Partners Guide

BEAWebLogic. Platform. Introducing WebLogic Platform. Version 8.1 Document Date: July 2003 Part Number:

BEA Tuxedo. System Messages CMDGW Catalog

BEA WebLogic Integration Installing BEA WebLogic Integration

BEAWebLogic. Server. Monitoring and Managing with the J2EE Management APIs

BEAWebLogic RFID. Edge Server. Using the Reader Simulator

BEAWebLogic RFID. Edge Server. Release Notes

BEA WebLogic. Server. Programming WebLogic JNDI

BEAWebLogic RFID. Enterprise Server. Using the Telemetry Console Extension

BEA TUXEDO System Messages. TxRPC Catalog

BEAWebLogic. Integration. TIBCO Rendezvous Control and Event Generator User Guide

Mainframe Adapter for OSI TP

BEAWebLogic. Platform. 8.1 Supported Configurations: HP OpenVMS on Itanium

BEAWebLogic. Server. Programming WebLogic Management Services with JMX

Adapter for ClarifyCRM

BEA Tuxedo. System Messages LIBWSC Catalog

BEAWebLogic RFID. Enterprise Server. Using the Serial Number Assignment Service

BEAAquaLogic. Service Bus. Upgrade Guide

BEA Tuxedo. System Messages Q Catalog

BEA WebLogic Server. Using WebLogic File Services

BEAWebLogic. Server. Deploying WebLogic Server Applications

Title Page. Working with Task Workflows

BEA WebLogic. Adapter for RDBMS. User Guide

BEAWebLogic. Server. Configuring and Managing WebLogic JDBC

BEA WebLogic. Server. Creating and Configuring WebLogic Server Domains

BEAWebLogic. Platform. ISV Partners Guide

BEAWebLogic. Server. WebLogic SNMP Management Guide

AquaLogic Data Services Platform Tutorial: Part I

Interaction JSR-168 Container

BEAWebLogic. Portal. MobileAware Interaction Server - BEA Sample Workshop Mobility Project Guide

Copyright. Restricted Rights Legend. Trademarks or Service Marks. Copyright 2003 BEA Systems, Inc. All Rights Reserved.

Interaction Development Kit (IDK) Version 5.4

BEAWebLogic. Platform. 8.1 Supported Configurations: HP NonStop Server on MIPS

BEAWebLogic RFID. Edge Server. Installing WebLogic RFID Edge Server

BEA Tuxedo. Using CORBA Request-Level Interceptors

BEAWebLogic. Integration. Tips and Tricks

Portlets for Groupware Integration

BEAWebLogic. Server. Developing Manageable Applications with JMX

BEAWebLogic. Platform. Release Notes

BEATuxedo Mainframe Adapter for SNA. Release Notes

Adapter for Mainframe

BEA JRockit. Introduction to BEA JRockit SDK

BEA TUXEDO System Messages. CMDTUX Catalog

BEAWebLogic. Portal. Cache Reference

BEA. SNMP Agent MIB Reference. For BEA Tuxedo and BEA WebLogic Enterprise

BEA WebLogic Server. and BEA WebLogic Express. Installation Guide for BEA WebLogic Server 6.1

BEAWebLogic. Server. Deploying Applications to WebLogic Server

Contents. BEA WebLogic Mobility Server Mobilize Your Portal Guide

ThingWorx Core 7.2 System Requirements. Version 1.1

BEAWebLogic. Portal. Customizing the Portal Administration Console

ORACLE ENTERPRISE MANAGER 10g ORACLE DIAGNOSTICS PACK FOR NON-ORACLE MIDDLEWARE

BEATuxedo. Using the Tuxedo.NET Workstation Client

BEA WebLogic Integration. Designing BEA WebLogic Integration Solutions

Transcription:

BEAJRockit SDK Using the Monitoring and Management APIs Version 1.4.2 April 2004

Copyright Copyright 2003 BEA Systems, Inc. All Rights Reserved. Restricted Rights Legend This software and documentation is subject to and made available only pursuant to the terms of the BEA Systems License Agreement and may be used or copied only in accordance with the terms of that agreement. It is against the law to copy the software except as specifically allowed in the agreement. This document may not, in whole or in part, be copied, photocopied, reproduced, translated, or reduced to any electronic medium or machine readable form without prior consent, in writing, from BEA Systems, Inc. Use, duplication or disclosure by the U.S. Government is subject to restrictions set forth in the BEA Systems License Agreement and in subparagraph (c)(1) of the Commercial Computer Software-Restricted Rights Clause at FAR 52.227-19; subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013, subparagraph (d) of the Commercial Computer Software--Licensing clause at NASA FAR supplement 16-52.227-86; or their equivalent. Information in this document is subject to change without notice and does not represent a commitment on the part of BEA Systems. THE SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. FURTHER, BEA Systems DOES NOT WARRANT, GUARANTEE, OR MAKE ANY REPRESENTATIONS REGARDING THE USE, OR THE RESULTS OF THE USE, OF THE SOFTWARE OR WRITTEN MATERIAL IN TERMS OF CORRECTNESS, ACCURACY, RELIABILITY, OR OTHERWISE. Trademarks or Service Marks BEA, Jolt, Tuxedo, and WebLogic are registered trademarks of BEA Systems, Inc. BEA Builder, BEA Campaign Manager for WebLogic, BEA elink, BEA Liquid Data for WebLogic, BEA Manager, BEA WebLogic Commerce Server, BEA WebLogic Enterprise, BEA WebLogic Enterprise Platform, BEA WebLogic Express, BEA WebLogic Integration, BEA WebLogic Personalization Server, BEA WebLogic Platform, BEA WebLogic Portal, BEA WebLogic Server, BEA WebLogic Workshop and How Business Becomes E-Business are trademarks of BEA Systems, Inc. All other trademarks are the property of their respective companies.

Contents Using JMAPI Using the Javadoc.........................................................2 Getting Started............................................................2 Using JMAPI to Subscribe to Events...........................................3 Using JMAPI to Access the BEA JRockit Profiler................................4 Using JMAPI to Access Exception Counting....................................5 Accessing JMAPI from Code Running in BEA JRockit Having a Security Manager.....6 Using the Monitoring and Management APIs 1

2 Using the Monitoring and Management APIs

Using JMAPI This product is provided as-is, without any expressed or implied warranties or support by BEA Systems, Inc. This product, which may or may not become an officially supported product from BEA Systems, may contain errors and/or inaccuracies. Use of this product is left solely upon the discretion of the user without any endorsement from BEA Systems. The JMAPI functionality may or may not be available in future JRockit versions. Questions and problems may be reported via online BEA JRockit newsgroups at http://newsgroups.bea.com. This document provides a short introduction to the BEA JRockit Monitoring and Management APIs (JMAPI) an API that provides a way to monitor and manage the BEA JRockit JVM. This section includes information on the following subjects: Using the Javadoc Getting Started Using JMAPI to Subscribe to Events Using JMAPI to Access the BEA JRockit Profiler Using JMAPI to Access Exception Counting Accessing JMAPI from Code Running in BEA JRockit Having a Security Manager Using the Monitoring and Management APIs 1

Using JMAPI Using the Javadoc This document is simply an overview of JMAPI.While it provides basic instructions on how to implement this interface and describes some of its capabilities, the best source of documentation is the javadoc, available at: http://edocs.bea.com/wljrockit/docs142/jmapi/javadoc/management API/index.html Getting Started To implement JMAPI, you first need to fetch a reference to an actual instance of JVM by using the JVMFactory. JVMFactory provides a static method to fetch an instance of JVM. This is the starting point for working with the API. JVM provides basic information about the JVM and is also the interface used to access the different information subsystems available. These subsystems are: ClassLibrary, which provides a way to monitor and manage the set of currently loaded Classes and ClassLoaders. CompilationSystem, which provides a way to monitor and manage the way methods and constructors are compiled. Machine, which provides information about the hardware the JVM is running on, like CPUs, network adapters and memory. MemorySystem, which provides heap and garbage collection data. OperatingSystem, which passes information about the OS the JVM is running on. ProfilingSystem, which provides a way to perform lightweight profiling of the JVM, for instance invocation counting. ThreadSystem, which provides thread stack dumps, thread snapshots, thread counts and means to access the threads running in BEA JRockit. To fetch the instance of JVM, you need to add code such as the following: com.bea.jvm.jvm myjvm = com.bea.jvm.jvmfactory.getjvm(); From the JVM instance you can access the different subsystems, such as the memory system. From the memory system you can, among other things, ask for heap size information or access the GarbageCollector. Reading the currently used heap size (in bytes) looks like this: 2 Using the Monitoring and Management APIs

Using JMAPI to Subscribe to Events Listing 1 Reading the Current Heap Size com.bea.jvm.jvm myjvm = com.bea.jvm.jvmfactory.getjvm(); long heapsize = myjvm.getmemorysystem().getusedheapsize(); To check if we are using a parallel garbage collector with a nursery, you might include something similar to the example in Listing 2: Listing 2 Checking the Garbage Collector Type com.bea.jvm.garbagecollector mygc = myjvm.getmemorysystem().getgarbagecollector(); boolean isparallelwithnursery = mygc.isparallel() && mygc.isgenerational(); Using JMAPI to Subscribe to Events You can use JMAPI to subscribe to a number of different events: ClassLoadEvent, which reports loaded and unloaded classes. CompilationListener, which reports compiled methods and constructors. GarbageCollectionEvent, which is fired after a garbage collection. Listing 3 shows how to add an anonymous ClassLoadListener that prints out the name of the class that was loaded/unloaded: Listing 3 Adding and Anonymous ClassLoadListener JVM myjvm = JVMFactory.getJVM(); myjvm.getclasslibrary().addclassloadlistener(new ClassLoadListener() public void onclassload(classloadevent event) Using the Monitoring and Management APIs 3

Using JMAPI ); String prefix = (event.geteventtype() == ClassLoadEvent.CLASS_LOADED)? "Loaded" : "Unloaded"; System.out.println(prefix + " : " + event.getclassobject().getname()); Listing 4 shows how to add an anonymous CompilationListener that prints out the method/constructor that was compiled and the optimization level used. Listing 4 Adding an Anonymous CompilationListener JVM myjvm = JVMFactory.getJVM(); myjvm.getcompilationsystem().addcompilationlistener( new CompilationListener() public void onmethodcompilation( CompilationEvent event) String prefix = "Compiled " + (event.hasconstructor()? " constructor " + event.getconstructor().getclass().getname() : "method " + event.getmethod().getclass().getname()); System.out.println(prefix + " : Optimization lvl " + event.getoptimizationlevel().getdescription()); ); Using JMAPI to Access the BEA JRockit Profiler The BEA JRockit JVM includes a very efficient, low overhead profiler to get method invocation counts and method timing information. Listing 6 shows how to call a method in an example class (shown in Listing 5), then print out how many times it has been invoked and the total time spent in that method. 4 Using the Monitoring and Management APIs

Using JMAPI to Access Exception Counting Listing 5 Example Class A public class A public boolean check(object obj) return this.getclass().isinstance(obj); Listing 6 Calling a Method in an Example Class ProfilingSystem profiler = JVMFactory.getJVM().getProfilingSystem(); A a = new A(); Method [] methods = A.class.getDeclaredMethods(); profiler.setinvocationcountenabled(methods[0], true); profiler.settimingenabled(methods[0], true); for (int i = 0; i < 100000; i++) a.check(a); System.out.println("Profiling system: check method invoked " + m_jrockit.getprofilingsystem().getinvocationcount(methods[0]) + " times"); System.out.println("Time spent in method " + m_jrockit.getprofilingsystem().gettiming(methods[0]) + " ms"); Using JMAPI to Access Exception Counting JMAPI also provides access to an exception counter that allows you to count how many exceptions of a certain class and, optionally, all of its subclasses have been thrown. Listing 7 shows an example of counting IOExceptions. Using the Monitoring and Management APIs 5

Using JMAPI Listing 7 Counting IOExceptions with JMAPI profiler.setexceptioncountenabled(ioexception.class, true, false); for (int i = 0; i < 10000; i++) try throw new IOException(); catch (Exception e) // Deliberately left blank. System.out.println("Profiling system: exception counts = " + m_jrockit.getprofilingsystem(). getexceptioncount(ioexception.class)); Accessing JMAPI from Code Running in BEA JRockit Having a Security Manager To access JMAPI from code running in BEA JRockit that has a security manager, the permission com.bea.jvm.managementpermission createinstance must first be granted to that code. For more information on how to grant code permissions, see Permissions in the Java 2 SDK. If the code has not been granted the permission, any attempt to access JMAPI will result in a SecurityException being thrown. Listing 8 shows a simple policy statement, granting all code the permission to access the JMAPI: Listing 8 Accessing JMAPI from Code Having a Security Manager grant // Needed to access the JRockit Management API. permission com.bea.jvm.managementpermission "createinstance"; ; 6 Using the Monitoring and Management APIs

Accessing JMAPI from Code Running in BEA JRockit Having a Security Manager Using the Monitoring and Management APIs 7

Using JMAPI 8 Using the Monitoring and Management APIs