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/Register.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/Register.java (file contents):
Revision 1.15 by ajm, Thu Mar 22 00:31:24 2001 UTC vs.
Revision 1.21 by tdb, Thu Jan 15 13:41:47 2004 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22 < package uk.org.iscream.client;
22 > package uk.org.iscream.cms.server.client;
23  
24   //---IMPORTS---
25 < import uk.org.iscream.util.*;
26 < import uk.org.iscream.componentmanager.*;
25 > import uk.org.iscream.cms.util.*;
26 > import uk.org.iscream.cms.server.componentmanager.*;
27  
28   /**
29   * The Register class holds theshold values,
# Line 71 | Line 91 | public class Register {
91  
92   //---PUBLIC METHODS---
93  
94 +    /**
95 +     * Advances the alert level to the next one up.
96 +     *
97 +     * This keeps track of the number of the number
98 +     * of times the highest NON-FINAL alert level
99 +     * has been reached.  Note this isn't a specific
100 +     * level, just the highest, so you could configure
101 +     * more levels and not affect this.
102 +     *
103 +     * If the count exceeds the number of times
104 +     * set in the configuration, it escalates to
105 +     * a FINAL alert if we're using FINAL's.
106 +     *
107 +     * It determines if to use FINAL's from the config
108 +     * entry reachFINALcount, when the count exceeds
109 +     * this value, it escalates to a FINAL.  If that attribute
110 +     * is mis-read or is not configured.  It will NEVER reach
111 +     * a FINAL.
112 +     */
113 +    public void escalateAlert() {
114 +        // don't escalate if we're already on the last alert
115 +        if(getLastAlertLevel() != Alert.alertLevels.length -1) {
116 +            setLastAlertLevel(getNextAlertLevel());
117 +        }
118 +        try {
119 +            // note if we fail to get this value, we won't process the res of this
120 +            int reachFINALcount = Integer.parseInt(_cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".reachFINALcount"));
121 +            if (getLastAlertLevel() == Alert.alertLevels.length - 2) {
122 +                _maxLevelCount++;
123 +                if(_maxLevelCount > reachFINALcount) {
124 +                    setLastAlertLevel(Alert.alertFINAL);
125 +                }
126 +            }
127 +        } catch (PropertyNotFoundException e) {
128 +            // we NEVER reach FINAL in this case
129 +        } catch (NumberFormatException e) {
130 +            // we NEVER reach FINAL in this case
131 +        }
132 +    }
133 +
134   //---PRIVATE METHODS---
135  
136      /**
# Line 206 | Line 266 | public class Register {
266       * and is converted from the value in the config,
267       * which should be seconds.
268       *
269 +     * Note that if the alert timeout for the current monitor
270 +     * is not configured, it will try to obtain the default
271 +     * timeout for all Monitor's.  If there is no alert timeout
272 +     * for either the monitor or a default setting this returns 0.
273 +     *
274       * Note that this is dependant on the threshold value
275       * given, the timeout is obatined from the config, then
276       * divided by the threshold value, this allows alerts to
277       * progress faster should a higher threshold value be passed
278       *
214     * If there is no alert timeout for a
215     * given level, this returns 0
216     *
279       * @param level the alert level
280       * @param thresholdLevel the threshold leve we are on
281       */
# Line 221 | Line 283 | public class Register {
283          // 0 means we don't use this value
284          long timeout = 0;
285          try {
286 <            String timeoutString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".alertTimeout." + Alert.alertLevels[level]);
286 >            String timeoutString;
287 >            try {
288 >                timeoutString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".alertTimeout." + Alert.alertLevels[level]);
289 >            } catch (PropertyNotFoundException e) {
290 >                // if there is no timeout for the monitor
291 >                // check for a default
292 >                timeoutString = _cp.getProperty("Host." + _hostname, "Monitor.alertTimeout." + Alert.alertLevels[level]);
293 >            }    
294              int threshold = getLastThresholdLevel();
295              if (threshold > 0) {
296                  timeout = (Long.parseLong(timeoutString) / threshold) * 1000;
# Line 278 | Line 347 | public class Register {
347       */
348      public long getInitialAlertTime() {
349          return _initialAlertTime;
281    }
282
283    /**
284     * Advances the alert level to the next one up.
285     *
286     * This keeps track of the number of the number
287     * of times the highest NON-FINAL alert level
288     * has been reached.  Note this isn't a specific
289     * level, just the highest, so you could configure
290     * more levels and not affect this.
291     *
292     * If the count exceeds the number of times
293     * set in the configuration, it escalates to
294     * a FINAL alert if we're using FINAL's.
295     *
296     * It determines if to use FINAL's from the config
297     * entry reachFINALcount, when the count exceeds
298     * this value, it escalates to a FINAL.  If that attribute
299     * is mis-read or is not configured.  It will NEVER reach
300     * a FINAL.
301     *
302     */
303    public void escalateAlert() {
304        // don't escalate if we're already on the last alert
305        if(getLastAlertLevel() != Alert.alertLevels.length -1) {
306            setLastAlertLevel(getNextAlertLevel());
307        }
308        try {
309            // note if we fail to get this value, we won't process the res of this
310            int reachFINALcount = Integer.parseInt(_cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".reachFINALcount"));
311            if (getLastAlertLevel() == Alert.alertLevels.length - 2) {
312                _maxLevelCount++;
313                if(_maxLevelCount > reachFINALcount) {
314                    setLastAlertLevel(Alert.alertFINAL);
315                }
316            }
317        } catch (PropertyNotFoundException e) {
318            // we NEVER reach FINAL in this case
319        } catch (NumberFormatException e) {
320            // we NEVER reach FINAL in this case
321        }
350      }
351  
352   //---ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines