所需积分/C币:9 2019-03-29 22:15:41 1.23MB PDF
收藏 收藏

知道吗?java提供了监控和性能管理的方式,也就是程序员可以利用java中提供的类来监控和管理java程序的性能 然后可以对程序性能优化哦 快来看看吧^_^
Contents Preface Audience Documentation Accessibility Related documents Conventions 1 Overview of Java SE Monitoring and management Key monitoring and management features 1-1 Java virtual Machine Instrumentation 1-1 Monitoring and management AP 1-1 Monitoring and Management Tools 1-2 Java management Extensions Technology 1-2 What are mbeans? 1-3 MBean server 1-3 Creating and Registering MBeans 1-3 Instrumenting Applications 1-4 Platform mxbeans 1-4 Platform mbean server 1-5 2 Monitoring and Management Using JMX Technology Setting System Properties 2-1 Enabling the ready to Use management 2-1 Local monitoring and management 2-2 Local Monitoring and Management Using JConsole 2-2 Remote Monitoring and Management Q Using Password Authentication 2-4 Disabling password authentication 2-6 Using SSL 2-6 Enabling RMi Registry Authentication 2-7 Enabling ssL Client Authentication 2-7 Disabling SSL ORACL∈ Disabling securit 2-8 Remote Monitoring with JConsole 2-8 Remote Monitoring with JConsole with SSL Enabled 2-8 Using Password and Access Files 2-9 Password files 2-9 Access files 2-9 Remote Monitoring with J Console with SSL Disabled 2-10 Ready-to-Use Monitoring and Management Properties 2-10 Configuration Errors Connecting to the JMX Agent Programmatically 2-13 Setting Up Monitoring and Management Programmatically 2-13 Mimicking Ready-to-Use Management Using the JMX Remote API 2-14 EXample of Mimicking Ready-to-Use Management 2-15 Monitoring Applications Through a Firewall 2-17 Using an Agent Class to Instrument an Application 2-18 Creating an Agent Class to Instrument an Application 2-18 3 Using JConsole Starting jConsole Command syntax 3-1 Setting Up Local Monitoring 3-1 Setting Up Remote Monitoring 3-2 Setting Up Secure Remote Monitoring 3- Connecting to a JMX Agent Connecting JConsole to a Local Process 3-3 Connecting JConsole to a Remote process 3-5 Connecting Using a JMX Service URL 3-6 Presenting the JConsole Tabs Viewing overview Information 3-7 Saving chart data 3-7 Monitoring Memory Consumption 3-8 Monitoring Class Loading 3-13 Viewing vm Information 3-13 Monitoring and Managing MBeans 3-15 Creating Custom Tabs 3-24 4 Using the Platform MBean Server and Platform MXBeans Using the platform Mbean server 4-1 Accessing platform MXBeans 4 ORACLE Accessing Platform MXBeans Using the Management Factory Class 4-1 Accessing Platform MXBeans Using an MXBean Proxy 4-2 Accessing Platform MXBeans Using the MBean ServerConnection Class 4-2 Using Oracle JDK's platform Extension Accessing MXBean Attributes directly 4-3 Accessing MXBean Attributes Using MBean ServerConnection 4-3 Monitoring thread Contention and CPU Time 4-4 Managing the Operating System 4-4 Logging Management 4-4 Detecting LoW Memory 4-5 Memory thresholds 4-5 Usage threshold 4-5 Collection Usage Threshold 4-6 Memory M×Bean 4-6 Memory Pool M×Bean 4-6 Polling 4-7 Threshold notifications 4-8 5 Java Discovery Protocol (UDP) ORACL∈ Preface Preface The Java Platform, Standard Edition 11 (Java SE 11) provide utilities that allow you to monitor and manage the performance of a Java virtual machine(Java Vm), and the Java applications that are running in it. the Java SE Monitoring and Management Guide describes those monitoring and management utilities Audience This guide is intended for experienced users of the Java language, such as systems administrators and software developers, for whom the performance of the java latform and their applications is of vital importance Documentation Accessibility For information about Oracle's commitment to accessibility, visit the oracle AccessibilityProgramwebsiteat ctx=acc&id=docacc Access to Oracle Support Oracle customers that have purchased support have access to electronic support throughMyOracleSupportForinformationvisithttp:/ lookup?ctx=acc&id=infoorvisit if you are hearing impaired Related documents See JDK 11 Documentation for other jDK 11 guides Conventions The following text conventions are used in this document Convention canine boldface Boldface type indicates graphical user interface elements associated with an action, or terms detined in text or the glossary italic I talic type indicates book titles, emphasis, or placeholder variables for which you supply particular values Monospace type indicates commands within a paragraph, URLS, code in examples, text that appears on the screen, or text that you enter. ORACLE 1 Overview of Java SE Monitoring and Management This topic introduces the features and utilities that provide monitoring and management services to the Java Platform, Standard Edition (Java SE platform Key monitoring and Management Features The Java SE platform includes significant monitoring and management features These features fall into four broad categories Java yirtual machine instrumentation Monitoring and management APl Monitoring and Management Tools Java Management EXtensions Technology Java virtual machine Instrumentation The Java Virtual Machine Java VM)is instrumented for monitoring and management enabling built-in(or ready-to-use)management capabilities that can be accessed both remotely and locally See Monitoring and Management Using JMX Technology The java vm includes a platform MBean server and platform mBeans for use by management applications that conform to the Java Management Extensions (JMX specification. These platforms are implementations of the monitoring and management API. The platform MXBeans and mbean servers are introduced in the platform MXBeans and Platform MBean Server topics Monitoring and Management ap Java se includes the following apis for monitoring and management Enables monitoring and managing the Java virtual machine and the underlying operating system The aPI enables applications to monitor themselves, and enables jMX-compliant tools to monitor and manage a virtual machine locally and remotely. This aPI provides access to the following types of information Number of classes loaded and threads running Java VM uptime, system properties, and VM input arguments Thread state. thread contention statistics and stack trace of live threads Memory consumption ORACLE Chapter 1 Key Monitoring and Management Features Garbage collection statistics Low memory detection On-demand deadlock detection Operating system information Attach: Allows a management agent to be dynamically loaded onto a virtual machine JConsole: Provides a programmatic interface to access JConsole such as adding a JConsole plug-in Monitoring and management tools The Java se platform provides a graphical monitoring tool called JConsole JConsole implements the JMX APL, and enables you to monitor the performance of a Java Vm and any instrumented applications. It provides information to help you optimize the performance Some of the enhancements in jconsole are as follows: JConsole plug-in support, which allows you to build your own plug-ins to run with JConsole. For example, you can add a custom tab for accessing the mbeans of the appl lication Dynamic attach capability allowing you to connect JConsole to any application that supports the Attach APl Enhanced user interface, which makes data more easily accessible New Overview and Vm Summary tabs for a better presentation of general information about your Java VM Hotspot Diagnostic MBean, which provides an aPi to request heap dump at runtime and also change the setting of certain VM options Improved presentation of M beans to make it easier to access the mbeans operations and attributes JConsole is presented in detail in the Using JConsole topic Other command-line tools are also supplied with the Java SE platform Java management extensions technology The Java se platform, release ll includes the Java management Extensions JMX) specification, version 1. 4. The JMX API allows you to instrument applications for monitoring and management. a remote method invocation(RMI) connector allows this instrumentation to be remotely accessible, for example, using JConsole See JMX technology documentation in the java Platform, Standard Edition Java Management EXtensions Guide The following sections provide a brief introduction to the main components of the JMX API ORACLE 1-2 Chapter 1 Key monitoring and management Features What are mbeans? JMX technology MBeans are managed beans, namely Java objects that represent resources to be managed an m bean has a management interface consisting of the following Named and typed attributes that can be read and written Named and typed operations that can be invoked Typed notifications that can be emitted by the MBean For example, an MBean representing an application s configuration can have attributes representing different configuration parameters, such as a Reading the attribute will return the current size of the cache. Writing updates the size of the cache, potentially changing the behavior of the running application. An operation such as stores the current configuration persistently. The MBean can send a notification such as When the configuration changes MBeans can be standard or dynamic Standard MBeans are Java objects that confor to design patterns derived from the JavaBeans component model. Dynamic MBeans define their management interface at runtime. An additional type of MBean, called MXBean, is added to the Java platform a standard MBean exposes the resource to be managed directly through its attributes and operations. Attributes are exposed through methods. Operations are the other methods of the class that are available to managers. All these methods are defined statically in the mBean interface and are visible to a JMX agent through introspection. This method is the most straightforward way of making a new resource manageable a dynamic MBean is an mbean that defines its management interface at runtime For example, a configuration MBean determines the names and types of the attributes that it exposes, by parsing an XML file An MXBean is a type of MBean that provides a simple way to code an MBean that references only a predefined set of types. In this way, you can ensure that the M Bean is usable by any client it includes remote clients without any requirement that the client has access to model-specific classes, which represents the types of your MBeans. The platform MBeans are all MXBeans MBean server To be useful, an MBean must be registered in an MBean server. An MBean server is a repository of MBeans. Each MBean is registered with a unique name within the MBean server. Usually the only access to the mBeans is through the mBean server. In other words, code does not access an MBean directly, but rather accesses the MBean by the name through the MBean server The Java SE platform includes a built-in platform MBean server. See Using the Platform mbean server and platform mxbeans Creating and Registering MBeans There are two ways to create an MBean. One is to construct a Java object that will be the mbean then use the method to register it in the mbean server. the ORACL∈ Chapter 1 Platform mxbeans other method is to create and register the MBean in a single operation using one of the metnods The method is simpler for local use, but cannot be used remotely. The lethod can be used remotely, but sometimes requires attention to the class loading issues An MBean can perform actions when it is registered in or unregistered from an MBean server if it implements the interface Instrumenting applications General instructions on how to instrument your applications for management by the JMX API is beyond the scope of this document Platform mxbeans a platform MXBean is an MBean for monitoring and managing the Java VM, and other components of the Java Runtime Environment JRE). Each MXBean encapsulates a part of vM functionality such as the class loading system, just-in-time (JIT) compilation system, garbage collector, and so on Table 1-1 lists all the platform MXBeans and the aspect of the VM that they manage Each platform MXBean has a unique for registration in the platform MBean server. a Java Vm may have zero, one, or more than one instance of each MXBean, depending on its function, as shown in the table Table 1-1 platform mxbeans Interface Part of VM Managed object Name Instances per vM lass loading syster Compilation system Zero or one Garbage collecto One or more Logging system ory pool One or more (subinterface of One ol emory system rlying operating system Runtime sys O ORACLE

试读 65P java性能监视和管理官方指南
立即下载 低至0.43元/次 身份认证VIP会员低至7折
java性能监视和管理官方指南 9积分/C币 立即下载

试读结束, 可继续读7页

9积分/C币 立即下载 >