001 /*
002 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.management.monitor;
027
028 // jmx imports
029 //
030 import javax.management.ObjectName;
031
032 /**
033 * Provides definitions of the notifications sent by monitor MBeans.
034 * <P>
035 * The notification source and a set of parameters concerning the monitor MBean's state
036 * need to be specified when creating a new object of this class.
037 *
038 * The list of notifications fired by the monitor MBeans is the following:
039 *
040 * <UL>
041 * <LI>Common to all kind of monitors:
042 * <UL>
043 * <LI>The observed object is not registered in the MBean server.
044 * <LI>The observed attribute is not contained in the observed object.
045 * <LI>The type of the observed attribute is not correct.
046 * <LI>Any exception (except the cases described above) occurs when trying to get the value of the observed attribute.
047 * </UL>
048 * <LI>Common to the counter and the gauge monitors:
049 * <UL>
050 * <LI>The threshold high or threshold low are not of the same type as the gauge (gauge monitors).
051 * <LI>The threshold or the offset or the modulus are not of the same type as the counter (counter monitors).
052 * </UL>
053 * <LI>Counter monitors only:
054 * <UL>
055 * <LI>The observed attribute has reached the threshold value.
056 * </UL>
057 * <LI>Gauge monitors only:
058 * <UL>
059 * <LI>The observed attribute has exceeded the threshold high value.
060 * <LI>The observed attribute has exceeded the threshold low value.
061 * </UL>
062 * <LI>String monitors only:
063 * <UL>
064 * <LI>The observed attribute has matched the "string to compare" value.
065 * <LI>The observed attribute has differed from the "string to compare" value.
066 * </UL>
067 * </UL>
068 *
069 *
070 * @since 1.5
071 */
072 public class MonitorNotification extends javax.management.Notification {
073
074 /*
075 * ------------------------------------------
076 * PUBLIC VARIABLES
077 * ------------------------------------------
078 */
079
080 /**
081 * Notification type denoting that the observed object is not registered in the MBean server.
082 * This notification is fired by all kinds of monitors.
083 * <BR>The value of this notification type is <CODE>jmx.monitor.error.mbean</CODE>.
084 */
085 public static final String OBSERVED_OBJECT_ERROR = "jmx.monitor.error.mbean";
086
087 /**
088 * Notification type denoting that the observed attribute is not contained in the observed object.
089 * This notification is fired by all kinds of monitors.
090 * <BR>The value of this notification type is <CODE>jmx.monitor.error.attribute</CODE>.
091 */
092 public static final String OBSERVED_ATTRIBUTE_ERROR = "jmx.monitor.error.attribute";
093
094 /**
095 * Notification type denoting that the type of the observed attribute is not correct.
096 * This notification is fired by all kinds of monitors.
097 * <BR>The value of this notification type is <CODE>jmx.monitor.error.type</CODE>.
098 */
099 public static final String OBSERVED_ATTRIBUTE_TYPE_ERROR = "jmx.monitor.error.type";
100
101 /**
102 * Notification type denoting that the type of the thresholds, offset or modulus is not correct.
103 * This notification is fired by counter and gauge monitors.
104 * <BR>The value of this notification type is <CODE>jmx.monitor.error.threshold</CODE>.
105 */
106 public static final String THRESHOLD_ERROR = "jmx.monitor.error.threshold";
107
108 /**
109 * Notification type denoting that a non-predefined error type has occurred when trying to get the value of the observed attribute.
110 * This notification is fired by all kinds of monitors.
111 * <BR>The value of this notification type is <CODE>jmx.monitor.error.runtime</CODE>.
112 */
113 public static final String RUNTIME_ERROR = "jmx.monitor.error.runtime";
114
115 /**
116 * Notification type denoting that the observed attribute has reached the threshold value.
117 * This notification is only fired by counter monitors.
118 * <BR>The value of this notification type is <CODE>jmx.monitor.counter.threshold</CODE>.
119 */
120 public static final String THRESHOLD_VALUE_EXCEEDED = "jmx.monitor.counter.threshold";
121
122 /**
123 * Notification type denoting that the observed attribute has exceeded the threshold high value.
124 * This notification is only fired by gauge monitors.
125 * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.high</CODE>.
126 */
127 public static final String THRESHOLD_HIGH_VALUE_EXCEEDED = "jmx.monitor.gauge.high";
128
129 /**
130 * Notification type denoting that the observed attribute has exceeded the threshold low value.
131 * This notification is only fired by gauge monitors.
132 * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.low</CODE>.
133 */
134 public static final String THRESHOLD_LOW_VALUE_EXCEEDED = "jmx.monitor.gauge.low";
135
136 /**
137 * Notification type denoting that the observed attribute has matched the "string to compare" value.
138 * This notification is only fired by string monitors.
139 * <BR>The value of this notification type is <CODE>jmx.monitor.string.matches</CODE>.
140 */
141 public static final String STRING_TO_COMPARE_VALUE_MATCHED = "jmx.monitor.string.matches";
142
143 /**
144 * Notification type denoting that the observed attribute has differed from the "string to compare" value.
145 * This notification is only fired by string monitors.
146 * <BR>The value of this notification type is <CODE>jmx.monitor.string.differs</CODE>.
147 */
148 public static final String STRING_TO_COMPARE_VALUE_DIFFERED = "jmx.monitor.string.differs";
149
150 /*
151 * ------------------------------------------
152 * PRIVATE VARIABLES
153 * ------------------------------------------
154 */
155
156 /* Serial version */
157 private static final long serialVersionUID = -4608189663661929204L;
158
159 /**
160 * @serial Monitor notification observed object.
161 */
162 private ObjectName observedObject = null;
163
164 /**
165 * @serial Monitor notification observed attribute.
166 */
167 private String observedAttribute = null;
168
169 /**
170 * @serial Monitor notification derived gauge.
171 */
172 private Object derivedGauge = null;
173
174 /**
175 * @serial Monitor notification release mechanism.
176 * This value is used to keep the threshold/string (depending on the
177 * monitor type) that triggered off this notification.
178 */
179 private Object trigger = null;
180
181 /*
182 * ------------------------------------------
183 * CONSTRUCTORS
184 * ------------------------------------------
185 */
186
187 /**
188 * Creates a monitor notification object.
189 *
190 * @param type The notification type.
191 * @param source The notification producer.
192 * @param sequenceNumber The notification sequence number within the source object.
193 * @param timeStamp The notification emission date.
194 * @param msg The notification message.
195 * @param obsObj The object observed by the producer of this notification.
196 * @param obsAtt The attribute observed by the producer of this notification.
197 * @param derGauge The derived gauge.
198 * @param trigger The threshold/string (depending on the monitor type) that triggered the notification.
199 */
200 MonitorNotification(String type, Object source,
201 long sequenceNumber, long timeStamp, String msg,
202 ObjectName obsObj, String obsAtt, Object derGauge,
203 Object trigger) {
204
205 super (type, source, sequenceNumber, timeStamp, msg);
206 this .observedObject = obsObj;
207 this .observedAttribute = obsAtt;
208 this .derivedGauge = derGauge;
209 this .trigger = trigger;
210 }
211
212 /*
213 * ------------------------------------------
214 * PUBLIC METHODS
215 * ------------------------------------------
216 */
217
218 // GETTERS AND SETTERS
219 //--------------------
220 /**
221 * Gets the observed object of this monitor notification.
222 *
223 * @return The observed object.
224 */
225 public ObjectName getObservedObject() {
226 return observedObject;
227 }
228
229 /**
230 * Gets the observed attribute of this monitor notification.
231 *
232 * @return The observed attribute.
233 */
234 public String getObservedAttribute() {
235 return observedAttribute;
236 }
237
238 /**
239 * Gets the derived gauge of this monitor notification.
240 *
241 * @return The derived gauge.
242 */
243 public Object getDerivedGauge() {
244 return derivedGauge;
245 }
246
247 /**
248 * Gets the threshold/string (depending on the monitor type) that triggered off this monitor notification.
249 *
250 * @return The trigger.
251 */
252 public Object getTrigger() {
253 return trigger;
254 }
255
256 }
|