blob: 744d7434f1f531e1b569ec3091b1880eb0074188 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package javax.management.monitor;
27
28
29// jmx imports
30//
31import javax.management.ObjectName;
32
33/**
34 * Provides definitions of the notifications sent by monitor MBeans.
35 * <P>
36 * The notification source and a set of parameters concerning the monitor MBean's state
37 * need to be specified when creating a new object of this class.
38 *
39 * The list of notifications fired by the monitor MBeans is the following:
40 *
41 * <UL>
42 * <LI>Common to all kind of monitors:
43 * <UL>
44 * <LI>The observed object is not registered in the MBean server.
45 * <LI>The observed attribute is not contained in the observed object.
46 * <LI>The type of the observed attribute is not correct.
47 * <LI>Any exception (except the cases described above) occurs when trying to get the value of the observed attribute.
48 * </UL>
49 * <LI>Common to the counter and the gauge monitors:
50 * <UL>
51 * <LI>The threshold high or threshold low are not of the same type as the gauge (gauge monitors).
52 * <LI>The threshold or the offset or the modulus are not of the same type as the counter (counter monitors).
53 * </UL>
54 * <LI>Counter monitors only:
55 * <UL>
56 * <LI>The observed attribute has reached the threshold value.
57 * </UL>
58 * <LI>Gauge monitors only:
59 * <UL>
60 * <LI>The observed attribute has exceeded the threshold high value.
61 * <LI>The observed attribute has exceeded the threshold low value.
62 * </UL>
63 * <LI>String monitors only:
64 * <UL>
65 * <LI>The observed attribute has matched the "string to compare" value.
66 * <LI>The observed attribute has differed from the "string to compare" value.
67 * </UL>
68 * </UL>
69 *
70 *
71 * @since 1.5
72 */
73public class MonitorNotification extends javax.management.Notification {
74
75
76 /*
77 * ------------------------------------------
78 * PUBLIC VARIABLES
79 * ------------------------------------------
80 */
81
82 /**
83 * Notification type denoting that the observed object is not registered in the MBean server.
84 * This notification is fired by all kinds of monitors.
85 * <BR>The value of this notification type is <CODE>jmx.monitor.error.mbean</CODE>.
86 */
87 public static final String OBSERVED_OBJECT_ERROR = "jmx.monitor.error.mbean";
88
89 /**
90 * Notification type denoting that the observed attribute is not contained in the observed object.
91 * This notification is fired by all kinds of monitors.
92 * <BR>The value of this notification type is <CODE>jmx.monitor.error.attribute</CODE>.
93 */
94 public static final String OBSERVED_ATTRIBUTE_ERROR = "jmx.monitor.error.attribute";
95
96 /**
97 * Notification type denoting that the type of the observed attribute is not correct.
98 * This notification is fired by all kinds of monitors.
99 * <BR>The value of this notification type is <CODE>jmx.monitor.error.type</CODE>.
100 */
101 public static final String OBSERVED_ATTRIBUTE_TYPE_ERROR = "jmx.monitor.error.type";
102
103 /**
104 * Notification type denoting that the type of the thresholds, offset or modulus is not correct.
105 * This notification is fired by counter and gauge monitors.
106 * <BR>The value of this notification type is <CODE>jmx.monitor.error.threshold</CODE>.
107 */
108 public static final String THRESHOLD_ERROR = "jmx.monitor.error.threshold";
109
110 /**
111 * Notification type denoting that a non-predefined error type has occurred when trying to get the value of the observed attribute.
112 * This notification is fired by all kinds of monitors.
113 * <BR>The value of this notification type is <CODE>jmx.monitor.error.runtime</CODE>.
114 */
115 public static final String RUNTIME_ERROR = "jmx.monitor.error.runtime";
116
117 /**
118 * Notification type denoting that the observed attribute has reached the threshold value.
119 * This notification is only fired by counter monitors.
120 * <BR>The value of this notification type is <CODE>jmx.monitor.counter.threshold</CODE>.
121 */
122 public static final String THRESHOLD_VALUE_EXCEEDED = "jmx.monitor.counter.threshold";
123
124 /**
125 * Notification type denoting that the observed attribute has exceeded the threshold high value.
126 * This notification is only fired by gauge monitors.
127 * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.high</CODE>.
128 */
129 public static final String THRESHOLD_HIGH_VALUE_EXCEEDED = "jmx.monitor.gauge.high";
130
131 /**
132 * Notification type denoting that the observed attribute has exceeded the threshold low value.
133 * This notification is only fired by gauge monitors.
134 * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.low</CODE>.
135 */
136 public static final String THRESHOLD_LOW_VALUE_EXCEEDED = "jmx.monitor.gauge.low";
137
138 /**
139 * Notification type denoting that the observed attribute has matched the "string to compare" value.
140 * This notification is only fired by string monitors.
141 * <BR>The value of this notification type is <CODE>jmx.monitor.string.matches</CODE>.
142 */
143 public static final String STRING_TO_COMPARE_VALUE_MATCHED = "jmx.monitor.string.matches";
144
145 /**
146 * Notification type denoting that the observed attribute has differed from the "string to compare" value.
147 * This notification is only fired by string monitors.
148 * <BR>The value of this notification type is <CODE>jmx.monitor.string.differs</CODE>.
149 */
150 public static final String STRING_TO_COMPARE_VALUE_DIFFERED = "jmx.monitor.string.differs";
151
152
153 /*
154 * ------------------------------------------
155 * PRIVATE VARIABLES
156 * ------------------------------------------
157 */
158
159 /* Serial version */
160 private static final long serialVersionUID = -4608189663661929204L;
161
162 /**
163 * @serial Monitor notification observed object.
164 */
165 private ObjectName observedObject = null;
166
167 /**
168 * @serial Monitor notification observed attribute.
169 */
170 private String observedAttribute = null;
171
172 /**
173 * @serial Monitor notification derived gauge.
174 */
175 private Object derivedGauge = null;
176
177 /**
178 * @serial Monitor notification release mechanism.
179 * This value is used to keep the threshold/string (depending on the
180 * monitor type) that triggered off this notification.
181 */
182 private Object trigger = null;
183
184
185 /*
186 * ------------------------------------------
187 * CONSTRUCTORS
188 * ------------------------------------------
189 */
190
191 /**
192 * Creates a monitor notification object.
193 *
194 * @param type The notification type.
195 * @param source The notification producer.
196 * @param sequenceNumber The notification sequence number within the source object.
197 * @param timeStamp The notification emission date.
198 * @param msg The notification message.
199 * @param obsObj The object observed by the producer of this notification.
200 * @param obsAtt The attribute observed by the producer of this notification.
201 * @param derGauge The derived gauge.
202 * @param trigger The threshold/string (depending on the monitor type) that triggered the notification.
203 */
204 MonitorNotification(String type, Object source, long sequenceNumber, long timeStamp, String msg,
205 ObjectName obsObj, String obsAtt, Object derGauge, Object trigger) {
206
207 super(type, source, sequenceNumber, timeStamp, msg);
208 this.observedObject = obsObj;
209 this.observedAttribute = obsAtt;
210 this.derivedGauge = derGauge;
211 this.trigger = trigger;
212 }
213
214 /*
215 * ------------------------------------------
216 * PUBLIC METHODS
217 * ------------------------------------------
218 */
219
220 // GETTERS AND SETTERS
221 //--------------------
222
223 /**
224 * Gets the observed object of this monitor notification.
225 *
226 * @return The observed object.
227 */
228 public ObjectName getObservedObject() {
229 return observedObject;
230 }
231
232 /**
233 * Gets the observed attribute of this monitor notification.
234 *
235 * @return The observed attribute.
236 */
237 public String getObservedAttribute() {
238 return observedAttribute;
239 }
240
241 /**
242 * Gets the derived gauge of this monitor notification.
243 *
244 * @return The derived gauge.
245 */
246 public Object getDerivedGauge() {
247 return derivedGauge;
248 }
249
250 /**
251 * Gets the threshold/string (depending on the monitor type) that triggered off this monitor notification.
252 *
253 * @return The trigger.
254 */
255 public Object getTrigger() {
256 return trigger;
257 }
258
259}