1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.client; |
2 |
> |
package uk.org.iscream.cms.server.client; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.ac.ukc.iscream.clientinterface.*; |
6 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
< |
import uk.ac.ukc.iscream.core.*; |
8 |
< |
import uk.ac.ukc.iscream.util.*; |
5 |
> |
import uk.org.iscream.cms.server.clientinterface.*; |
6 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
7 |
> |
import uk.org.iscream.cms.server.core.*; |
8 |
> |
import uk.org.iscream.cms.server.util.*; |
9 |
|
|
10 |
|
/** |
11 |
|
* A startup component for the Local Clients. |
12 |
+ |
* This class starts the CORBA client used for alerting |
13 |
+ |
* purposes. It reads data using the ClientServant from CORBA |
14 |
+ |
* calls by the i-scream client interface. This data is then |
15 |
+ |
* used by the MonitorManager to pass to Monitors. Monitors then |
16 |
+ |
* analyse the data and raise alerts if needed, these are passed to |
17 |
+ |
* the Alerters, which send out alerts. They are looked after by |
18 |
+ |
* the AlerterManager. |
19 |
|
* |
20 |
|
* @author $Author$ |
21 |
|
* @version $Id$ |
42 |
|
//---PUBLIC METHODS--- |
43 |
|
|
44 |
|
/** |
45 |
< |
* This starts the Local Client component |
45 |
> |
* This starts the Local Client component. |
46 |
> |
* This starts the ClientServant, the MonitorManager and |
47 |
> |
* the AlerterManager, aswell as initialising any queues |
48 |
> |
* and obtaining any initial configuration. |
49 |
> |
* |
50 |
> |
* @throws ComponentStartException if the component fails to start |
51 |
|
*/ |
52 |
|
public void start() throws ComponentStartException { |
53 |
|
// get references to key objects |
54 |
|
_logger = _refman.getLogger(); |
55 |
|
|
56 |
|
_logger.write(toString(), Logger.SYSINIT, "coming up"); |
45 |
– |
|
46 |
– |
// configuration variables we require |
47 |
– |
int queueMonitorInterval = 0; |
57 |
|
|
58 |
< |
Configuration config = _refman.getCM().getConfiguration("LocalClient"); |
59 |
< |
if (config == null) { |
60 |
< |
throw new ComponentStartException("Unable to obtain configuration for component"); |
61 |
< |
} |
62 |
< |
else { |
63 |
< |
try { |
64 |
< |
// get the configuration properties we need |
65 |
< |
queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval")); |
66 |
< |
} catch (org.omg.CORBA.MARSHAL e) { |
67 |
< |
throw new ComponentStartException("Unable to obtain requried configuration property for component"); |
58 |
> |
// get a reference to the configuration proxy |
59 |
> |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
60 |
> |
|
61 |
> |
// see if these Queue's need a size limit |
62 |
> |
try { |
63 |
> |
int queueSizeLimit = Integer.parseInt(cp.getProperty(NAME, "Queue.SizeLimit")); |
64 |
> |
String queueRemoveAlgorithm = cp.getProperty(NAME, "Queue.RemoveAlgorithm"); |
65 |
> |
int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms); |
66 |
> |
if(algorithm != -1) { |
67 |
> |
_logger.write(toString(), Logger.DEBUG, "Starting 2 Queues with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm); |
68 |
> |
// we have valid values, so lets start it. |
69 |
> |
_alerterQueue = new Queue(queueSizeLimit, algorithm); |
70 |
> |
_monitorQueue = new Queue(queueSizeLimit, algorithm); |
71 |
|
} |
72 |
+ |
else { |
73 |
+ |
_logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm); |
74 |
+ |
// just don't activate a limit |
75 |
+ |
_alerterQueue = new Queue(); |
76 |
+ |
_monitorQueue = new Queue(); |
77 |
+ |
} |
78 |
+ |
} catch (PropertyNotFoundException e) { |
79 |
+ |
_logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e); |
80 |
+ |
// just don't activate a limit |
81 |
+ |
_alerterQueue = new Queue(); |
82 |
+ |
_monitorQueue = new Queue(); |
83 |
+ |
} catch (NumberFormatException e) { |
84 |
+ |
_logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e); |
85 |
+ |
// just don't activate a limit |
86 |
+ |
_alerterQueue = new Queue(); |
87 |
+ |
_monitorQueue = new Queue(); |
88 |
|
} |
61 |
– |
|
62 |
– |
_logger.write(toString(), Logger.SYSINIT, "configured"); |
89 |
|
|
90 |
< |
// setup the queues, this must be done before both managers are setup |
91 |
< |
String queueName; |
92 |
< |
// setup a Queue for the servant -> monitor manager |
93 |
< |
_monitorQueue = new Queue(); |
90 |
> |
// startup monitors on these queues |
91 |
> |
try { |
92 |
> |
// try to get the interval, if this fails, we won't start up the monitor |
93 |
> |
int queueMonitorInterval = Integer.parseInt(cp.getProperty(NAME, "Queue.MonitorInterval")); |
94 |
> |
_alerterQueue.startMonitor(queueMonitorInterval*1000, _monitorQueue, NAME + " Alerter"); |
95 |
> |
_monitorQueue.startMonitor(queueMonitorInterval*1000, _monitorQueue, NAME + " Monitor"); |
96 |
> |
} catch (PropertyNotFoundException e) { |
97 |
> |
_logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e); |
98 |
> |
} |
99 |
|
|
69 |
– |
// setup a Queue for the monitors -> alert manager |
70 |
– |
_alerterQueue = new Queue(); |
71 |
– |
|
72 |
– |
|
73 |
– |
|
100 |
|
// setup the servant and connect |
101 |
|
_logger.write(toString(), Logger.SYSINIT, "starting servant and connecting"); |
102 |
|
try { |
127 |
|
alertMan.start(); |
128 |
|
|
129 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
104 |
– |
|
130 |
|
} |
131 |
|
|
132 |
|
/** |
161 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
162 |
|
* method to provide clean logging (every class should have this). |
163 |
|
* |
164 |
< |
* This uses the uk.ac.ukc.iscream.util.FormatName class |
164 |
> |
* This uses the uk.org.iscream.cms.server.util.FormatName class |
165 |
|
* to format the toString() |
166 |
|
* |
167 |
|
* @return the name of this class and its CVS revision |