1 /* 2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.management.monitor; 27 28 29 // jmx imports 30 // 31 import 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 */ 73 public 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 @SuppressWarnings("serial") // Not statically typed as Serializable 166 private ObjectName observedObject = null; 167 168 /** 169 * @serial Monitor notification observed attribute. 170 */ 171 private String observedAttribute = null; 172 173 /** 174 * @serial Monitor notification derived gauge. 175 */ 176 @SuppressWarnings("serial") // Not statically typed as Serializable 177 private Object derivedGauge = null; 178 179 /** 180 * @serial Monitor notification release mechanism. 181 * This value is used to keep the threshold/string (depending on the 182 * monitor type) that triggered off this notification. 183 */ 184 @SuppressWarnings("serial") // Not statically typed as Serializable 185 private Object trigger = null; 186 187 188 /* 189 * ------------------------------------------ 190 * CONSTRUCTORS 191 * ------------------------------------------ 192 */ 193 194 /** 195 * Creates a monitor notification object. 196 * 197 * @param type The notification type. 198 * @param source The notification producer. 199 * @param sequenceNumber The notification sequence number within the source object. 200 * @param timeStamp The notification emission date. 201 * @param msg The notification message. 202 * @param obsObj The object observed by the producer of this notification. 203 * @param obsAtt The attribute observed by the producer of this notification. 204 * @param derGauge The derived gauge. 205 * @param trigger The threshold/string (depending on the monitor type) that triggered the notification. 206 */ MonitorNotification(String type, Object source, long sequenceNumber, long timeStamp, String msg, ObjectName obsObj, String obsAtt, Object derGauge, Object trigger)207 MonitorNotification(String type, Object source, long sequenceNumber, long timeStamp, String msg, 208 ObjectName obsObj, String obsAtt, Object derGauge, Object trigger) { 209 210 super(type, source, sequenceNumber, timeStamp, msg); 211 this.observedObject = obsObj; 212 this.observedAttribute = obsAtt; 213 this.derivedGauge = derGauge; 214 this.trigger = trigger; 215 } 216 217 /* 218 * ------------------------------------------ 219 * PUBLIC METHODS 220 * ------------------------------------------ 221 */ 222 223 // GETTERS AND SETTERS 224 //-------------------- 225 226 /** 227 * Gets the observed object of this monitor notification. 228 * 229 * @return The observed object. 230 */ getObservedObject()231 public ObjectName getObservedObject() { 232 return observedObject; 233 } 234 235 /** 236 * Gets the observed attribute of this monitor notification. 237 * 238 * @return The observed attribute. 239 */ getObservedAttribute()240 public String getObservedAttribute() { 241 return observedAttribute; 242 } 243 244 /** 245 * Gets the derived gauge of this monitor notification. 246 * 247 * @return The derived gauge. 248 */ getDerivedGauge()249 public Object getDerivedGauge() { 250 return derivedGauge; 251 } 252 253 /** 254 * Gets the threshold/string (depending on the monitor type) that triggered off this monitor notification. 255 * 256 * @return The trigger. 257 */ getTrigger()258 public Object getTrigger() { 259 return trigger; 260 } 261 262 } 263