8 |
|
import java.util.*; |
9 |
|
|
10 |
|
/** |
11 |
< |
* A manager for the Monitors. |
11 |
> |
* A manager for the Alerters. |
12 |
|
* |
13 |
|
* @author $Author$ |
14 |
|
* @version $Id$ |
15 |
|
*/ |
16 |
< |
class AlerterManager extends Thread { |
16 |
> |
public class AlerterManager extends Thread { |
17 |
|
|
18 |
|
//---FINAL ATTRIBUTES--- |
19 |
|
|
46 |
|
_logger.write(toString(), Logger.SYSINIT, "Initialising"); |
47 |
|
_logger.write(toString(), Logger.SYSMSG, "Creating alerter pipeline for plugin alerters ..."); |
48 |
|
|
49 |
+ |
// get the config proxy |
50 |
+ |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
51 |
+ |
|
52 |
|
// get the configuration for this plug-in setup |
53 |
< |
Configuration config = _refman.getCM().getConfiguration(_name); |
54 |
< |
String pluginsPackage = config.getProperty("Alerter.PluginsPackage"); |
55 |
< |
String pluginsList = config.getProperty("Alerter.Plugins"); |
53 |
> |
String pluginsPackage, pluginsList; |
54 |
> |
try { |
55 |
> |
pluginsPackage = cp.getProperty(_name, "Alerter.PluginsPackage"); |
56 |
> |
pluginsList = cp.getProperty(_name, "Alerter.Plugins"); |
57 |
> |
} catch(PropertyNotFoundException e) { |
58 |
> |
_logger.write(toString(), Logger.WARNING, "Unable to get required configuration, Alerter's will not be activated: "+e); |
59 |
> |
// setting these will ensure we don't build a pipeline |
60 |
> |
pluginsPackage = ""; |
61 |
> |
pluginsList = ""; |
62 |
> |
} |
63 |
|
|
64 |
|
StringTokenizer st = new StringTokenizer(pluginsList, ";"); |
65 |
|
|
87 |
|
} |
88 |
|
|
89 |
|
//---PUBLIC METHODS--- |
80 |
– |
|
81 |
– |
public void run() { |
82 |
– |
|
83 |
– |
boolean run=true; |
84 |
– |
while(run) { |
85 |
– |
// attempt to get some data from the Queue |
86 |
– |
Alert alert = null; |
87 |
– |
try { |
88 |
– |
alert = (Alert) _queue.get(_qID); |
89 |
– |
} |
90 |
– |
catch(InvalidQueueException e) { |
91 |
– |
_logger.write(toString(), Logger.ERROR, "Queue failure: "+e); |
92 |
– |
} |
93 |
– |
|
94 |
– |
// for each alerter in the pipeline... |
95 |
– |
Iterator pluginAlerters = _alerterPipeline.iterator(); |
96 |
– |
while (pluginAlerters.hasNext()){ |
97 |
– |
PluginAlerter alerter = (PluginAlerter)pluginAlerters.next(); |
98 |
– |
alerter.sendAlert(alert); |
99 |
– |
} |
100 |
– |
} |
101 |
– |
} |
90 |
|
|
91 |
|
/** |
92 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
107 |
|
//---PRIVATE METHODS--- |
108 |
|
|
109 |
|
//---ACCESSOR/MUTATOR METHODS--- |
110 |
+ |
|
111 |
+ |
/** |
112 |
+ |
* Allows alerters to obtain a reference |
113 |
+ |
* to the alerting queue so that they can |
114 |
+ |
* process any alerts |
115 |
+ |
* |
116 |
+ |
* @return a reference to the alert queue |
117 |
+ |
*/ |
118 |
+ |
public Queue getQueue() { |
119 |
+ |
return _queue; |
120 |
+ |
} |
121 |
|
|
122 |
|
//---ATTRIBUTES--- |
123 |
|
|