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