jdk/src/share/classes/javax/management/monitor/package.html
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 833 bfa2bef7517c
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
<html>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
<head>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
<title>javax.management.monitor package</title>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
<!--
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
-->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
</head>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
<body bgcolor="white">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
      <p>Provides the definition of the monitor classes.  A Monitor is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
      an MBean that periodically observes the value of an attribute in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
      one or more other MBeans.  If the attribute meets a certain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
      condition, the Monitor emits a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
      javax.management.monitor.MonitorNotification
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
      MonitorNotification}. When the monitor MBean periodically calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
      {@link javax.management.MBeanServer#getAttribute getAttribute}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
      to retrieve the value of the attribute being monitored it does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
      so within the access control context of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
      {@link javax.management.monitor.Monitor#start} caller.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
      <p>The value being monitored can be a simple value contained within a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
      complex type. For example, the {@link java.lang.management.MemoryMXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
      MemoryMXBean} defined in <tt>java.lang.management</tt> has an attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
      <tt>HeapMemoryUsage</tt> of type {@link java.lang.management.MemoryUsage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
      MemoryUsage}. To monitor the amount of <i>used</i> memory, described by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
      the <tt>used</tt> property of <tt>MemoryUsage</tt>, you could monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
      "<tt>HeapMemoryUsage.used</tt>". That string would be the argument to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
      {@link javax.management.monitor.MonitorMBean#setObservedAttribute(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
      setObservedAttribute}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
      <p>The rules used to interpret an <tt>ObservedAttribute</tt> like
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
      <tt>"HeapMemoryUsage.used"</tt> are as follows. Suppose the string is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
      <i>A.e</i> (so <i>A</i> would be <tt>"HeapMemoryUsage"</tt> and <i>e</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
      would be <tt>"used"</tt> in the example).</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
      <p>First the value of the attribute <i>A</i> is obtained. Call it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
      <i>v</i>. A value <i>x</i> is extracted from <i>v</i> as follows:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
      <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
      <li>If <i>v</i> is a {@link javax.management.openmbean.CompositeData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
      CompositeData} and if <i>v</i>.{@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
      javax.management.openmbean.CompositeData#get(String) get}(<i>e</i>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
      returns a value then <i>x</i> is that value.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
      <li>If <i>v</i> is an array and <i>e</i> is the string <tt>"length"</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
      then <i>x</i> is the length of the array.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
      <li>If the above rules do not produce a value, and if {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
      java.beans.Introspector#getBeanInfo(Class) Introspector.getBeanInfo}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
      for the class of <i>v</i> (<i>v</i>.<tt>getClass()</tt>) contains a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
      {@link java.beans.PropertyDescriptor PropertyDescriptor} with the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
      <i>e</i>, then <i>x</i> is the result of calling the property's {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
      java.beans.PropertyDescriptor#getReadMethod() read method} on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
      <i>v</i>.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
      </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
      <p>The third rule means for example that if the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
      <tt>HeapMemoryUsage</tt> is a <tt>MemoryUsage</tt>, monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
      <tt>"HeapMemoryUsage.used"</tt> will obtain the observed value by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
      calling <tt>MemoryUsage.getUsed()</tt>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
      <p>If the <tt>ObservedAttribute</tt> contains more than one period,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      for example <tt>"ConnectionPool.connectionStats.length"</tt>, then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
      above rules are applied iteratively. Here, <i>v</i> would initially be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      the value of the attribute <tt>ConnectionPool</tt>, and <i>x</i> would
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      be derived by applying the above rules with <i>e</i> equal to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
      <tt>"connectionStats"</tt>. Then <i>v</i> would be set to this <i>x</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
      and a new <i>x</i> derived by applying the rules again with <i>e</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
      equal to <tt>"length"</tt>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
      <p>Although it is recommended that attribute names be valid Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
      identifiers, it is possible for an attribute to be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      <tt>HeapMemoryUsage.used</tt>. This means that an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      <tt>ObservedAttribute</tt> that is <tt>HeapMemoryUsage.used</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
      could mean that the value to observe is either an attribute of that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      name, or the property <tt>used</tt> within an attribute called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
      <tt>HeapMemoryUsage</tt>. So for compatibility reasons, when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
      <tt>ObservedAttribute</tt> contains a period (<tt>.</tt>), the monitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      will check whether an attribute exists whose name is the full
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
      <tt>ObservedAttribute</tt> string (<tt>HeapMemoryUsage.used</tt> in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
      example). It does this by calling {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      javax.management.MBeanServer#getMBeanInfo(javax.management.ObjectName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
      getMBeanInfo} for the observed MBean and looking for a contained {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
      javax.management.MBeanAttributeInfo MBeanAttributeInfo} with the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
      name. If one is found, then that is what is monitored. If more than one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
      MBean is being observed, the behavior is unspecified if some of them have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
      a <tt>HeapMemoryUsage.used</tt> attribute and others do not. An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      implementation may therefore call <tt>getMBeanInfo</tt> on just one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
      the MBeans in this case. The behavior is also unspecified if the result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      of the check changes while the monitor is active.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      <p>The exact behavior of monitors is detailed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
	<a href="#spec">JMX Specification</a>.  What follows is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
	summary.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      <p>There are three kinds of Monitors:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
      <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
	<li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
	  <p>A {@link javax.management.monitor.CounterMonitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
	    CounterMonitor} observes attributes of integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
	    type.  The attributes are assumed to be non-negative, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
	    monotonically increasing except for a possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
	    <em>roll-over</em> at a specified <em>modulus</em>.  Each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
	    observed attribute has an associated <em>threshold</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
	    value.  A notification is sent when the attribute exceeds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
	    its threshold.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
	  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
	  <p>An <em>offset</em> value can be specified.  When an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
	    observed value exceeds its threshold, the threshold is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
	    incremented by the offset, or by a multiple of the offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
	    sufficient to make the threshold greater than the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
	    observed value.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
	  <p>A <code>CounterMonitor</code> can operate in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
	    <em>difference mode</em>.  In this mode, the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
	    compared against the threshold is the difference between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
	    two successive observations of an attribute.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
	  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
	</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
	<li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
	  <p>A {@link javax.management.monitor.GaugeMonitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
	    GaugeMonitor} observes attributes of numerical type.  Each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
	    observed attribute has an associated <em>high
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
	      threshold</em> and <em>low threshold</em>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
	  <p>When an observed attribute crosses the high threshold, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
	    the <em>notify high</em> flag is true, then a notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
	    is sent.  Subsequent crossings of the high threshold value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
	    will not trigger further notifications until the gauge value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
	    becomes less than or equal to the low threshold.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
	  <p>When an observed attribute crosses the low threshold, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
	    the <em>notify low</em> flag is true, then a notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
	    is sent.  Subsequent crossings of the low threshold value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
	    will not trigger further notifications until the gauge
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
	    value becomes greater than or equal to the high
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
	    threshold.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
	  <p>Typically, only one of the notify high and notify low
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
	    flags is set.  The other threshold is used to provide a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
	    <em>hysteresis</em> mechanism to avoid the repeated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
	    triggering of notifications when an attribute makes small
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
	    oscillations around the threshold value.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
	  <p>A <code>GaugeMonitor</code> can operate in <em>difference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
	      mode</em>.  In this mode, the value compared against the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
	    high and low thresholds is the difference between two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
	    successive observations of an attribute.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
	</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
	<li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
	  <p>A {@link javax.management.monitor.StringMonitor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
	    StringMonitor} observes attributes of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
	    <code>String</code>.  A notification is sent when an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
	    observed attribute becomes equal and/or not equal to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
	    given string.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
	</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
      </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    <p id="spec">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    @see <a href="{@docRoot}/../technotes/guides/jmx/">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
      Java SE 6 Platform documentation on JMX technology</a>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    in particular the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    <a href="{@docRoot}/../technotes/guides/jmx/JMX_1_4_specification.pdf">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
      JMX Specification, version 1.4(pdf).</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
      @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
</BODY>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
</HTML>