3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import uk.ac.ukc.iscream.util.*; |
6 |
< |
import uk.ac.ukc.iscream.componentmanager.ConfigurationProxy; |
6 |
> |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
|
|
8 |
|
/** |
9 |
|
* The Register class holds theshold values, |
146 |
|
* @param level the alert level |
147 |
|
*/ |
148 |
|
public double getThreshold(int level) { |
149 |
+ |
// -1.0 means we don't use an alert level |
150 |
|
double threshold = -1.0; |
151 |
< |
String thresholdString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".threshold." + Alert.thresholdLevels[level]); |
152 |
< |
if(thresholdString != null) { |
153 |
< |
try { |
154 |
< |
threshold = Double.parseDouble(thresholdString); |
155 |
< |
} catch (NumberFormatException e) { |
156 |
< |
// -1.0 means we don't use an alert level |
157 |
< |
threshold = -1.0; |
157 |
< |
} |
151 |
> |
try { |
152 |
> |
String thresholdString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".threshold." + Alert.thresholdLevels[level]); |
153 |
> |
threshold = Double.parseDouble(thresholdString); |
154 |
> |
} catch (PropertyNotFoundException e) { |
155 |
> |
threshold = -1.0; |
156 |
> |
} catch (NumberFormatException e) { |
157 |
> |
threshold = -1.0; |
158 |
|
} |
159 |
|
return threshold; |
160 |
|
} |
171 |
|
* progress faster should a higher threshold value be passed |
172 |
|
* |
173 |
|
* If there is no alert timeout for a |
174 |
< |
* given level, this returns -1.0 |
174 |
> |
* given level, this returns 0 |
175 |
|
* |
176 |
|
* @param level the alert level |
177 |
|
* @param thresholdLevel the threshold leve we are on |
178 |
|
*/ |
179 |
|
public long getAlertTimeout(int level, int attributeNum) { |
180 |
+ |
// 0 means we don't use this value |
181 |
|
long timeout = 0; |
182 |
< |
String timeoutString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".alertTimeout." + Alert.alertLevels[level]); |
183 |
< |
if(timeoutString != null) { |
184 |
< |
try { |
185 |
< |
int threshold = getLastThresholdLevel(attributeNum); |
186 |
< |
if (threshold > 0) { |
186 |
< |
timeout = (Long.parseLong(timeoutString) / threshold) * 1000; |
187 |
< |
} |
188 |
< |
} catch (NumberFormatException e) { |
189 |
< |
// -1.0 means we don't use this value |
190 |
< |
timeout = 0; |
182 |
> |
try { |
183 |
> |
String timeoutString = _cp.getProperty("Host." + _hostname, "Monitor." + _monitorName + ".alertTimeout." + Alert.alertLevels[level]); |
184 |
> |
int threshold = getLastThresholdLevel(attributeNum); |
185 |
> |
if (threshold > 0) { |
186 |
> |
timeout = (Long.parseLong(timeoutString) / threshold) * 1000; |
187 |
|
} |
188 |
+ |
} catch (PropertyNotFoundException e) { |
189 |
+ |
timeout = 0; |
190 |
+ |
} catch (NumberFormatException e) { |
191 |
+ |
timeout = 0; |
192 |
|
} |
193 |
|
return timeout; |
194 |
|
} |