author | uvangapally |
Tue, 01 Aug 2017 10:33:47 +0530 | |
changeset 46050 | f51c14dc540f |
parent 32034 | 05676cfd40b5 |
permissions | -rw-r--r-- |
2 | 1 |
<html> |
2 |
<head> |
|
3 |
<title>javax.management.monitor package</title> |
|
4 |
<!-- |
|
46050
f51c14dc540f
8181895: javax management docs contain links to technotes
uvangapally
parents:
32034
diff
changeset
|
5 |
Copyright (c) 1999, 2017, 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 |
|
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
44 |
{@code java.lang.management} has an attribute |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
45 |
{@code HeapMemoryUsage} of type {@link |
833 | 46 |
java.lang.management.MemoryUsage MemoryUsage}. To monitor the |
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
47 |
amount of <i>used</i> memory, described by the {@code used} |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
48 |
property of {@code MemoryUsage}, you could monitor |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
49 |
"{@code HeapMemoryUsage.used}". That string would be the |
833 | 50 |
argument to {@link |
51 |
javax.management.monitor.MonitorMBean#setObservedAttribute(String) |
|
2 | 52 |
setObservedAttribute}.</p> |
53 |
||
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
54 |
<p>The rules used to interpret an {@code ObservedAttribute} like |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
55 |
{@code "HeapMemoryUsage.used"} are as follows. Suppose the string is |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
56 |
<i>A.e</i> (so <i>A</i> would be {@code "HeapMemoryUsage"} and <i>e</i> |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
57 |
would be {@code "used"} in the example).</p> |
2 | 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> |
|
15300 | 63 |
|
2 | 64 |
<li>If <i>v</i> is a {@link javax.management.openmbean.CompositeData |
65 |
CompositeData} and if <i>v</i>.{@link |
|
66 |
javax.management.openmbean.CompositeData#get(String) get}(<i>e</i>) |
|
67 |
returns a value then <i>x</i> is that value.</li> |
|
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
68 |
<li>If <i>v</i> is an array and <i>e</i> is the string {@code "length"} |
2 | 69 |
then <i>x</i> is the length of the array.</li> |
15300 | 70 |
|
71 |
<li>If the above rules do not produce a value, and if introspection, as |
|
72 |
if by calling {@link java.beans.Introspector#getBeanInfo(Class) |
|
73 |
Introspector.getBeanInfo}, for the class of <i>v</i> |
|
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
74 |
(<i>v</i>.{@code getClass()}) identifies a property with the name |
15300 | 75 |
<i>e</i>, then <i>x</i> is the result of reading the property value. </li> |
76 |
||
2 | 77 |
</ul> |
78 |
||
79 |
<p>The third rule means for example that if the attribute |
|
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
80 |
{@code HeapMemoryUsage} is a {@code MemoryUsage}, monitoring |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
81 |
{@code "HeapMemoryUsage.used"} will obtain the observed value by |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
82 |
calling {@code MemoryUsage.getUsed()}.</p> |
2 | 83 |
|
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
84 |
<p>If the {@code ObservedAttribute} contains more than one period, |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
85 |
for example {@code "ConnectionPool.connectionStats.length"}, then the |
2 | 86 |
above rules are applied iteratively. Here, <i>v</i> would initially be |
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
87 |
the value of the attribute {@code ConnectionPool}, and <i>x</i> would |
2 | 88 |
be derived by applying the above rules with <i>e</i> equal to |
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
89 |
{@code "connectionStats"}. Then <i>v</i> would be set to this <i>x</i> |
2 | 90 |
and a new <i>x</i> derived by applying the rules again with <i>e</i> |
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
91 |
equal to {@code "length"}.</p> |
2 | 92 |
|
93 |
<p>Although it is recommended that attribute names be valid Java |
|
94 |
identifiers, it is possible for an attribute to be called |
|
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
95 |
{@code HeapMemoryUsage.used}. This means that an |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
96 |
{@code ObservedAttribute} that is {@code HeapMemoryUsage.used} |
2 | 97 |
could mean that the value to observe is either an attribute of that |
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
98 |
name, or the property {@code used} within an attribute called |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
99 |
{@code HeapMemoryUsage}. So for compatibility reasons, when the |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
100 |
{@code ObservedAttribute} contains a period ({@code .}), the monitor |
2 | 101 |
will check whether an attribute exists whose name is the full |
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
102 |
{@code ObservedAttribute} string ({@code HeapMemoryUsage.used} in the |
2 | 103 |
example). It does this by calling {@link |
104 |
javax.management.MBeanServer#getMBeanInfo(javax.management.ObjectName) |
|
105 |
getMBeanInfo} for the observed MBean and looking for a contained {@link |
|
106 |
javax.management.MBeanAttributeInfo MBeanAttributeInfo} with the given |
|
107 |
name. If one is found, then that is what is monitored. If more than one |
|
108 |
MBean is being observed, the behavior is unspecified if some of them have |
|
32034
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
109 |
a {@code HeapMemoryUsage.used} attribute and others do not. An |
05676cfd40b5
8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents:
25859
diff
changeset
|
110 |
implementation may therefore call {@code getMBeanInfo} on just one of |
2 | 111 |
the MBeans in this case. The behavior is also unspecified if the result |
112 |
of the check changes while the monitor is active.</p> |
|
113 |
||
114 |
<p>The exact behavior of monitors is detailed in the |
|
115 |
<a href="#spec">JMX Specification</a>. What follows is a |
|
116 |
summary.</p> |
|
117 |
||
118 |
<p>There are three kinds of Monitors:</p> |
|
119 |
||
120 |
<ul> |
|
121 |
<li> |
|
122 |
||
123 |
<p>A {@link javax.management.monitor.CounterMonitor |
|
124 |
CounterMonitor} observes attributes of integer |
|
125 |
type. The attributes are assumed to be non-negative, and |
|
126 |
monotonically increasing except for a possible |
|
127 |
<em>roll-over</em> at a specified <em>modulus</em>. Each |
|
128 |
observed attribute has an associated <em>threshold</em> |
|
129 |
value. A notification is sent when the attribute exceeds |
|
130 |
its threshold.</p> |
|
131 |
||
132 |
<p>An <em>offset</em> value can be specified. When an |
|
133 |
observed value exceeds its threshold, the threshold is |
|
134 |
incremented by the offset, or by a multiple of the offset |
|
135 |
sufficient to make the threshold greater than the new |
|
136 |
observed value.</p> |
|
137 |
||
138 |
<p>A <code>CounterMonitor</code> can operate in |
|
139 |
<em>difference mode</em>. In this mode, the value |
|
140 |
compared against the threshold is the difference between |
|
141 |
two successive observations of an attribute.</p> |
|
142 |
||
143 |
</li> |
|
144 |
<li> |
|
145 |
||
146 |
<p>A {@link javax.management.monitor.GaugeMonitor |
|
147 |
GaugeMonitor} observes attributes of numerical type. Each |
|
148 |
observed attribute has an associated <em>high |
|
149 |
threshold</em> and <em>low threshold</em>.</p> |
|
150 |
||
151 |
<p>When an observed attribute crosses the high threshold, if |
|
152 |
the <em>notify high</em> flag is true, then a notification |
|
153 |
is sent. Subsequent crossings of the high threshold value |
|
154 |
will not trigger further notifications until the gauge value |
|
155 |
becomes less than or equal to the low threshold.</p> |
|
156 |
||
157 |
<p>When an observed attribute crosses the low threshold, if |
|
158 |
the <em>notify low</em> flag is true, then a notification |
|
159 |
is sent. Subsequent crossings of the low threshold value |
|
160 |
will not trigger further notifications until the gauge |
|
161 |
value becomes greater than or equal to the high |
|
162 |
threshold.</p> |
|
163 |
||
164 |
<p>Typically, only one of the notify high and notify low |
|
165 |
flags is set. The other threshold is used to provide a |
|
166 |
<em>hysteresis</em> mechanism to avoid the repeated |
|
167 |
triggering of notifications when an attribute makes small |
|
168 |
oscillations around the threshold value.</p> |
|
169 |
||
170 |
<p>A <code>GaugeMonitor</code> can operate in <em>difference |
|
171 |
mode</em>. In this mode, the value compared against the |
|
172 |
high and low thresholds is the difference between two |
|
173 |
successive observations of an attribute.</p> |
|
174 |
||
175 |
</li> |
|
176 |
<li> |
|
177 |
||
178 |
<p>A {@link javax.management.monitor.StringMonitor |
|
179 |
StringMonitor} observes attributes of type |
|
180 |
<code>String</code>. A notification is sent when an |
|
181 |
observed attribute becomes equal and/or not equal to a |
|
182 |
given string.</p> |
|
183 |
||
184 |
</li> |
|
185 |
</ul> |
|
186 |
<p id="spec"> |
|
46050
f51c14dc540f
8181895: javax management docs contain links to technotes
uvangapally
parents:
32034
diff
changeset
|
187 |
@see <a href="https://jcp.org/aboutJava/communityprocess/mrel/jsr160/index2.html"> |
f51c14dc540f
8181895: javax management docs contain links to technotes
uvangapally
parents:
32034
diff
changeset
|
188 |
JMX Specification, version 1.4</a> |
2 | 189 |
@since 1.5 |
190 |
||
191 |
</BODY> |
|
192 |
</HTML> |