1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.client; |
2 |
> |
package uk.org.iscream.client; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import java.util.HashMap; |
6 |
< |
import uk.ac.ukc.iscream.client.*; |
7 |
< |
import uk.ac.ukc.iscream.core.*; |
8 |
< |
import uk.ac.ukc.iscream.util.*; |
9 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
6 |
> |
import uk.org.iscream.client.*; |
7 |
> |
import uk.org.iscream.core.*; |
8 |
> |
import uk.org.iscream.util.*; |
9 |
> |
import uk.org.iscream.componentmanager.*; |
10 |
|
|
11 |
|
/** |
12 |
|
* Skeleton class for Monitors |
14 |
|
* @author $Author$ |
15 |
|
* @version $Id$ |
16 |
|
*/ |
17 |
< |
public abstract class MonitorSkeleton implements PluginMonitor { |
17 |
> |
public abstract class MonitorSkeleton extends Thread implements PluginMonitor { |
18 |
|
|
19 |
|
//---FINAL ATTRIBUTES--- |
20 |
|
|
22 |
|
|
23 |
|
//---CONSTRUCTORS--- |
24 |
|
|
25 |
+ |
public MonitorSkeleton() { |
26 |
+ |
_logger.write(toString(), Logger.SYSINIT, "started."); |
27 |
+ |
this.start(); |
28 |
+ |
} |
29 |
+ |
|
30 |
|
//---PUBLIC METHODS--- |
31 |
|
|
32 |
< |
public abstract void analysePacket(XMLPacket packet); |
32 |
> |
public void run() { |
33 |
> |
while(_running) { |
34 |
> |
try { |
35 |
> |
analysePacket((XMLPacket) getQueue().get(getQueueId())); |
36 |
> |
} catch (InvalidQueueException e) { |
37 |
> |
_logger.write(this.toString(), Logger.ERROR, "Unable to get queue."); |
38 |
> |
} |
39 |
> |
} |
40 |
> |
} |
41 |
> |
|
42 |
> |
protected abstract void analysePacket(XMLPacket packet); |
43 |
|
|
44 |
< |
public void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue) { |
44 |
> |
protected void processAlert(int newThreshold, String attributeName, Register reg, String source, String currentValue) { |
45 |
|
// decide what threshold level we're on, if we've changed, record that |
46 |
|
if (newThreshold != reg.getLastThresholdLevel()) { |
47 |
|
reg.setLastThresholdLevel(newThreshold); |
101 |
|
int thresholdLevel = reg.getLastThresholdLevel(); |
102 |
|
String thresholdValue = String.valueOf(reg.getThreshold(thresholdLevel)); |
103 |
|
String timeout = String.valueOf(reg.getAlertTimeout(reg.getLastAlertLevel()) / 1000); |
104 |
< |
if (thresholdLevel == Alert.thresholdNORMAL) { |
104 |
> |
// ensures we display a nice thing if its -1.0 |
105 |
> |
if (thresholdValue.equals("-1.0")) { |
106 |
|
thresholdValue = "-"; |
107 |
|
} |
108 |
|
if (alertLevel == Alert.alertOK) { |
115 |
|
|
116 |
|
//---ACCESSOR/MUTATOR METHODS--- |
117 |
|
|
118 |
+ |
protected abstract Queue getQueue(); |
119 |
+ |
|
120 |
+ |
protected int getQueueId() { |
121 |
+ |
if (_qID == -1) { |
122 |
+ |
_qID = getQueue().getQueue(); |
123 |
+ |
_logger.write(toString(), Logger.DEBUG, "Assigned Queue - " + _qID); |
124 |
+ |
} |
125 |
+ |
return _qID; |
126 |
+ |
} |
127 |
+ |
|
128 |
|
//---ATTRIBUTES--- |
129 |
|
|
130 |
|
protected Logger _logger = ReferenceManager.getInstance().getLogger(); |
131 |
|
|
132 |
|
protected Queue _alerterQueue = ClientMain._alerterQueue; |
133 |
+ |
|
134 |
+ |
protected int _qID = -1; |
135 |
+ |
|
136 |
+ |
protected boolean _running = true; |
137 |
|
|
138 |
|
//---STATIC ATTRIBUTES--- |
139 |
|
|