ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/Alert.java
Revision: 1.15
Committed: Fri Mar 23 02:30:44 2001 UTC (23 years, 1 month ago) by ajm
Branch: MAIN
CVS Tags: PROJECT_COMPLETION
Changes since 1.14: +147 -10 lines
Log Message:
Javadoc'd the whole bally lot.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.org.iscream.client;
3
4 //---IMPORTS---
5 import uk.org.iscream.util.*;
6
7 /**
8 * An object to hold the state of an Alert.
9 *
10 * When an alert is generated, it has lots of information about
11 * the cirscumstances and source of the alert. This object holds
12 * the information. It is created by Monitors (specifically in the
13 * fireAlert method of MonitorSkeleton). It then places the alert
14 * in the alert queue for Alerters to read and process.
15 *
16 * @author $Author: tdb1 $
17 * @version $Id: Alert.java,v 1.14 2001/03/14 23:25:29 tdb1 Exp $
18 */
19 public class Alert {
20
21 //---FINAL ATTRIBUTES---
22
23 /**
24 * The current CVS revision of this class
25 */
26 public static final String REVISION = "$Revision: 1.14 $";
27
28 /**
29 * An internal representation of a NORMAL threshold
30 */
31 public static final int thresholdNORMAL = 0;
32
33 /**
34 * An internal representation of a LOWER threshold
35 */
36 public static final int thresholdLOWER = 1;
37
38 /**
39 * An internal representation of an UPPER threshold
40 */
41 public static final int thresholdUPPER = 2;
42
43 /**
44 * The textual names of the threshold levels. The position
45 * of the names in this array correspond to the internal
46 * integer representation constants.
47 */
48 public static final String[] thresholdLevels = {"NORMAL", "LOWER", "UPPER"};
49
50 // note OK and FINAL MUST be present...at the beginning and the end
51
52 /**
53 * An internal representation of the OK alert
54 * This must ALWAYS be 0.
55 */
56 public static final int alertOK = 0;
57
58 /**
59 * An internal representation of the NOTICE alert
60 */
61 public static final int alertNOTICE = 1;
62
63 /**
64 * An internal representation of the WARNING alert
65 */
66 public static final int alertWARNING = 2;
67
68 /**
69 * An internal representation of the CAUTION alert
70 */
71 public static final int alertCAUTION = 3;
72
73 /**
74 * An internal representation of the CRITICAL alert
75 */
76 public static final int alertCRITICAL = 4;
77
78 /**
79 * An internal representation of the FINAL alert
80 * This must ALWAYS be the highest.
81 */
82 public static final int alertFINAL = 5;
83
84 /**
85 * The textual names of the alert levels. The position
86 * of the names in this array correspond to the internal
87 * integer representation constants.
88 */
89 public static final String[] alertLevels = {"OK", "NOTICE", "WARNING", "CAUTION", "CRITICAL", "FINAL"};
90
91 //---STATIC METHODS---
92
93 //---CONSTRUCTORS---
94
95 /**
96 * Construct an Alert object with the appropriate data
97 *
98 * @param alertLevel the alert level for this Alert object
99 * @param lastAlert the last alert level before this one
100 * @param thresholdLevel the threshold level that was broken to raise the alert
101 * @param source the source of the alert eg, hostname
102 * @param thresholdValue the configured value of the treshold level that was broken
103 * @param value the value of the attribute that raised the alert
104 * @param attributeName the textual representation of the attribute that has raised the alert
105 * @param timeTillNextAlert the time until the next alert will be sent concerning this attribute (in seconds)
106 * @param initialAlertTime the time the problem with this attribute first occured
107 */
108 public Alert(int alertLevel, int lastAlert, int thresholdLevel, String source, String thresholdValue, String value, String attributeName, String timeTillNextAlert, long initialAlertTime) {
109 _alertLevel = alertLevel;
110 _lastAlert = lastAlert;
111 _thresholdLevel = thresholdLevel;
112 _source = source;
113 _thresholdValue = thresholdValue;
114 _value = value;
115 _attributeName = attributeName;
116 _timeTillNextAlert = timeTillNextAlert;
117 _initialAlertTime = initialAlertTime;
118 }
119
120 //---PUBLIC METHODS---
121
122 /**
123 * Prints a String representation of the Alert object. It
124 * is designed to resemble a HashMap.toString(), such that
125 * it is similar to the XMLPacket.printAll() method.
126 *
127 * This method is used by the WebFeeder specifically.
128 *
129 * @return a String representation of this Alert object.
130 */
131 public String printAll() {
132 String result = "{";
133 result += "alertLevel="+_alertLevel+", ";
134 result += "lastAlert="+_lastAlert+", ";
135 result += "thresholdLevel="+_thresholdLevel+", ";
136 result += "source="+_source+", ";
137 result += "thresholdValue="+_thresholdValue+", ";
138 result += "value="+_value+", ";
139 result += "attributeName="+_attributeName+", ";
140 result += "timeTillNextAlert="+_timeTillNextAlert+", ";
141 result += "initialAlertTime="+_initialAlertTime;
142 result += "}";
143 return result;
144 }
145
146 /**
147 * Overrides the {@link java.lang.Object#toString() Object.toString()}
148 * method to provide clean logging (every class should have this).
149 *
150 * This uses the uk.org.iscream.util.FormatName class
151 * to format the toString()
152 *
153 * @return the name of this class and its CVS revision
154 */
155 public String toString() {
156 return FormatName.getName(
157 _name,
158 getClass().getName(),
159 REVISION);
160 }
161
162 //---PRIVATE METHODS---
163
164 //---ACCESSOR/MUTATOR METHODS---
165
166 /**
167 * Returns the alert level of this Alert object
168 *
169 * @return the level
170 */
171 public int getLevel() {
172 return _alertLevel;
173 }
174
175 /**
176 * Returns the previous alert level for the attribute
177 *
178 * @return the previous level
179 */
180 public int getLastLevel() {
181 return _lastAlert;
182 }
183
184 /**
185 * Returns the threshold level that was broken
186 *
187 * @return the threshold level
188 */
189 public int getThreshold() {
190 return _thresholdLevel;
191 }
192
193 /**
194 * Returns the source of the alert
195 *
196 * @return the alerts source eg, hostname
197 */
198 public String getSource() {
199 return _source;
200 }
201
202 /**
203 * Returns the value that the alert level was caused by
204 *
205 * @return the value
206 */
207 public String getValue() {
208 return _value;
209 }
210
211 /**
212 * Returns the value of the threshold level this alert broke
213 *
214 * @return the value
215 */
216 public String getThresholdValue() {
217 return _thresholdValue;
218 }
219
220 /**
221 * Returns the textual representation of the name of
222 * the attribute that caused the alert.
223 *
224 * @return the attribute name
225 */
226 public String getAttributeName() {
227 return _attributeName;
228 }
229
230 /**
231 * Returns the time in seconds till the next
232 * alert will be sent
233 *
234 * @return the time till the next alert
235 */
236 public String getTimeTillNextAlert() {
237 return _timeTillNextAlert;
238 }
239
240 /**
241 * Returns the time in milliseconds when
242 * the initial alert for this problem with the attribute
243 * occured.
244 *
245 * @return the initial alert time
246 */
247 public long getInitialAlertTime() {
248 return _initialAlertTime;
249 }
250
251 //---ATTRIBUTES---
252
253 /**
254 * This is the friendly identifier of the
255 * component this class is running in.
256 * eg, a Filter may be called "filter1",
257 * If this class does not have an owning
258 * component, a name from the configuration
259 * can be placed here. This name could also
260 * be changed to null for utility classes.
261 */
262 private String _name = ClientMain.NAME;
263
264 /**
265 * The alert level of this Alert object
266 */
267 private int _alertLevel;
268
269 /**
270 * The last alert level for this attribute
271 */
272 private int _lastAlert;
273
274 /**
275 * The threshold level that was broken
276 */
277 private int _thresholdLevel;
278
279 /**
280 * The source of the alert, eg hostname
281 */
282 private String _source;
283
284 /**
285 * The attribute value that caused the alert
286 */
287 private String _value;
288
289 /**
290 * The threshold value that was broken
291 */
292 private String _thresholdValue;
293
294 /**
295 * The textual representation of the attribute
296 * that caused the alert.
297 */
298 private String _attributeName;
299
300 /**
301 * The time in seconds till the next alert
302 * for this attribute will occur.
303 */
304 private String _timeTillNextAlert;
305
306 /**
307 * The time in milliseconds that this
308 * alert first occured.
309 */
310 private long _initialAlertTime;
311
312 //---STATIC ATTRIBUTES---
313
314 }