--- projects/cms/source/server/uk/org/iscream/cms/server/client/Register.java 2001/03/04 05:23:41 1.3 +++ projects/cms/source/server/uk/org/iscream/cms/server/client/Register.java 2001/03/05 23:14:53 1.4 @@ -3,7 +3,7 @@ package uk.ac.ukc.iscream.client; //---IMPORTS--- import uk.ac.ukc.iscream.util.*; -import uk.ac.ukc.iscream.componentmanager.ConfigurationProxy; +import uk.ac.ukc.iscream.componentmanager.*; /** * The Register class holds theshold values, @@ -16,8 +16,8 @@ import uk.ac.ukc.iscream.componentmanager.Configuratio * It also stores (and keeps uptodate (via the configuration proxy) * the threshold values for the monitor. * - * @author $Author: ajm $ - * @version $Id: Register.java,v 1.3 2001/03/04 05:23:41 ajm Exp $ + * @author $Author: tdb $ + * @version $Id: Register.java,v 1.4 2001/03/05 23:14:53 tdb Exp $ */ public class Register { @@ -26,7 +26,7 @@ public class Register { /** * The current CVS revision of this class */ - public static final String REVISION = "$Revision: 1.3 $"; + public static final String REVISION = "$Revision: 1.4 $"; //---STATIC METHODS--- @@ -146,15 +146,15 @@ public class Register { * @param level the alert level */ public double getThreshold(int level) { + // -1.0 means we don't use an alert level double threshold = -1.0; - String thresholdString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".threshold." + Alert.thresholdLevels[level]); - if(thresholdString != null) { - try { - threshold = Double.parseDouble(thresholdString); - } catch (NumberFormatException e) { - // -1.0 means we don't use an alert level - threshold = -1.0; - } + try { + String thresholdString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".threshold." + Alert.thresholdLevels[level]); + threshold = Double.parseDouble(thresholdString); + } catch (PropertyNotFoundException e) { + threshold = -1.0; + } catch (NumberFormatException e) { + threshold = -1.0; } return threshold; } @@ -171,24 +171,24 @@ public class Register { * progress faster should a higher threshold value be passed * * If there is no alert timeout for a - * given level, this returns -1.0 + * given level, this returns 0 * * @param level the alert level * @param thresholdLevel the threshold leve we are on */ public long getAlertTimeout(int level, int attributeNum) { + // 0 means we don't use this value long timeout = 0; - String timeoutString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".alertTimeout." + Alert.alertLevels[level]); - if(timeoutString != null) { - try { - int threshold = getLastThresholdLevel(attributeNum); - if (threshold > 0) { - timeout = (Long.parseLong(timeoutString) / threshold) * 1000; - } - } catch (NumberFormatException e) { - // -1.0 means we don't use this value - timeout = 0; + try { + String timeoutString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".alertTimeout." + Alert.alertLevels[level]); + int threshold = getLastThresholdLevel(attributeNum); + if (threshold > 0) { + timeout = (Long.parseLong(timeoutString) / threshold) * 1000; } + } catch (PropertyNotFoundException e) { + timeout = 0; + } catch (NumberFormatException e) { + timeout = 0; } return timeout; }