1. /*
  2. * @(#)MonitorNotification.java 4.22 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.management.monitor;
  8. // jmx imports
  9. //
  10. import javax.management.ObjectName;
  11. /**
  12. * Provides definitions of the notifications sent by monitor MBeans.
  13. * <P>
  14. * The notification source and a set of parameters concerning the monitor MBean's state
  15. * need to be specified when creating a new object of this class.
  16. *
  17. * The list of notifications fired by the monitor MBeans is the following:
  18. *
  19. * <UL>
  20. * <LI>Common to all kind of monitors:
  21. * <UL>
  22. * <LI>The observed object is not registered in the MBean server.
  23. * <LI>The observed attribute is not contained in the observed object.
  24. * <LI>The type of the observed attribute is not correct.
  25. * <LI>Any exception (except the cases described above) occurs when trying to get the value of the observed attribute.
  26. * </UL>
  27. * <LI>Common to the counter and the gauge monitors:
  28. * <UL>
  29. * <LI>The threshold high or threshold low are not of the same type as the gauge (gauge monitors).
  30. * <LI>The threshold or the offset or the modulus are not of the same type as the counter (counter monitors).
  31. * </UL>
  32. * <LI>Counter monitors only:
  33. * <UL>
  34. * <LI>The observed attribute has reached the threshold value.
  35. * </UL>
  36. * <LI>Gauge monitors only:
  37. * <UL>
  38. * <LI>The observed attribute has exceeded the threshold high value.
  39. * <LI>The observed attribute has exceeded the threshold low value.
  40. * </UL>
  41. * <LI>String monitors only:
  42. * <UL>
  43. * <LI>The observed attribute has matched the "string to compare" value.
  44. * <LI>The observed attribute has differed from the "string to compare" value.
  45. * </UL>
  46. * </UL>
  47. *
  48. * @version 4.22 12/19/03
  49. * @author Sun Microsystems, Inc
  50. *
  51. * @since 1.5
  52. */
  53. public class MonitorNotification extends javax.management.Notification {
  54. /*
  55. * ------------------------------------------
  56. * PUBLIC VARIABLES
  57. * ------------------------------------------
  58. */
  59. /**
  60. * Notification type denoting that the observed object is not registered in the MBean server.
  61. * This notification is fired by all kinds of monitors.
  62. * <BR>The value of this notification type is <CODE>jmx.monitor.error.mbean</CODE>.
  63. */
  64. public static final String OBSERVED_OBJECT_ERROR = "jmx.monitor.error.mbean";
  65. /**
  66. * Notification type denoting that the observed attribute is not contained in the observed object.
  67. * This notification is fired by all kinds of monitors.
  68. * <BR>The value of this notification type is <CODE>jmx.monitor.error.attribute</CODE>.
  69. */
  70. public static final String OBSERVED_ATTRIBUTE_ERROR = "jmx.monitor.error.attribute";
  71. /**
  72. * Notification type denoting that the type of the observed attribute is not correct.
  73. * This notification is fired by all kinds of monitors.
  74. * <BR>The value of this notification type is <CODE>jmx.monitor.error.type</CODE>.
  75. */
  76. public static final String OBSERVED_ATTRIBUTE_TYPE_ERROR = "jmx.monitor.error.type";
  77. /**
  78. * Notification type denoting that the type of the thresholds, offset or modulus is not correct.
  79. * This notification is fired by counter and gauge monitors.
  80. * <BR>The value of this notification type is <CODE>jmx.monitor.error.threshold</CODE>.
  81. */
  82. public static final String THRESHOLD_ERROR = "jmx.monitor.error.threshold";
  83. /**
  84. * Notification type denoting that a non-predefined error type has occurred when trying to get the value of the observed attribute.
  85. * This notification is fired by all kinds of monitors.
  86. * <BR>The value of this notification type is <CODE>jmx.monitor.error.runtime</CODE>.
  87. */
  88. public static final String RUNTIME_ERROR = "jmx.monitor.error.runtime";
  89. /**
  90. * Notification type denoting that the observed attribute has reached the threshold value.
  91. * This notification is only fired by counter monitors.
  92. * <BR>The value of this notification type is <CODE>jmx.monitor.counter.threshold</CODE>.
  93. */
  94. public static final String THRESHOLD_VALUE_EXCEEDED = "jmx.monitor.counter.threshold";
  95. /**
  96. * Notification type denoting that the observed attribute has exceeded the threshold high value.
  97. * This notification is only fired by gauge monitors.
  98. * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.high</CODE>.
  99. */
  100. public static final String THRESHOLD_HIGH_VALUE_EXCEEDED = "jmx.monitor.gauge.high";
  101. /**
  102. * Notification type denoting that the observed attribute has exceeded the threshold low value.
  103. * This notification is only fired by gauge monitors.
  104. * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.low</CODE>.
  105. */
  106. public static final String THRESHOLD_LOW_VALUE_EXCEEDED = "jmx.monitor.gauge.low";
  107. /**
  108. * Notification type denoting that the observed attribute has matched the "string to compare" value.
  109. * This notification is only fired by string monitors.
  110. * <BR>The value of this notification type is <CODE>jmx.monitor.string.matches</CODE>.
  111. */
  112. public static final String STRING_TO_COMPARE_VALUE_MATCHED = "jmx.monitor.string.matches";
  113. /**
  114. * Notification type denoting that the observed attribute has differed from the "string to compare" value.
  115. * This notification is only fired by string monitors.
  116. * <BR>The value of this notification type is <CODE>jmx.monitor.string.differs</CODE>.
  117. */
  118. public static final String STRING_TO_COMPARE_VALUE_DIFFERED = "jmx.monitor.string.differs";
  119. /*
  120. * ------------------------------------------
  121. * PRIVATE VARIABLES
  122. * ------------------------------------------
  123. */
  124. /* Serial version */
  125. private static final long serialVersionUID = -4608189663661929204L;
  126. /**
  127. * @serial Monitor notification observed object.
  128. */
  129. private ObjectName observedObject = null;
  130. /**
  131. * @serial Monitor notification observed attribute.
  132. */
  133. private String observedAttribute = null;
  134. /**
  135. * @serial Monitor notification derived gauge.
  136. */
  137. private Object derivedGauge = null;
  138. /**
  139. * @serial Monitor notification release mechanism.
  140. * This value is used to keep the threshold/string (depending on the
  141. * monitor type) that triggered off this notification.
  142. */
  143. private Object trigger = null;
  144. /*
  145. * ------------------------------------------
  146. * CONSTRUCTORS
  147. * ------------------------------------------
  148. */
  149. /**
  150. * Creates a monitor notification object.
  151. *
  152. * @param type The notification type.
  153. * @param source The notification producer.
  154. * @param sequenceNumber The notification sequence number within the source object.
  155. * @param timeStamp The notification emission date.
  156. * @param msg The notification message.
  157. * @param obsObj The object observed by the producer of this notification.
  158. * @param obsAtt The attribute observed by the producer of this notification.
  159. * @param derGauge The derived gauge.
  160. * @param trigger The threshold/string (depending on the monitor type) that triggered the notification.
  161. */
  162. MonitorNotification(String type, Object source, long sequenceNumber, long timeStamp, String msg,
  163. ObjectName obsObj, String obsAtt, Object derGauge, Object trigger) {
  164. super(type, source, sequenceNumber, timeStamp, msg);
  165. this.observedObject = obsObj;
  166. this.observedAttribute = obsAtt;
  167. this.derivedGauge = derGauge;
  168. this.trigger = trigger;
  169. }
  170. /*
  171. * ------------------------------------------
  172. * PUBLIC METHODS
  173. * ------------------------------------------
  174. */
  175. // GETTERS AND SETTERS
  176. //--------------------
  177. /**
  178. * Gets the observed object of this monitor notification.
  179. *
  180. * @return The observed object.
  181. */
  182. public ObjectName getObservedObject() {
  183. return observedObject;
  184. }
  185. /**
  186. * Gets the observed attribute of this monitor notification.
  187. *
  188. * @return The observed attribute.
  189. */
  190. public String getObservedAttribute() {
  191. return observedAttribute;
  192. }
  193. /**
  194. * Gets the derived gauge of this monitor notification.
  195. *
  196. * @return The derived gauge.
  197. */
  198. public Object getDerivedGauge() {
  199. return derivedGauge;
  200. }
  201. /**
  202. * Gets the threshold/string (depending on the monitor type) that triggered off this monitor notification.
  203. *
  204. * @return The trigger.
  205. */
  206. public Object getTrigger() {
  207. return trigger;
  208. }
  209. }