1 |
+ |
|
2 |
|
//---PACKAGE DECLARATION--- |
3 |
|
package uk.ac.ukc.iscream.rootfilter; |
4 |
|
|
38 |
|
* This starts the Root Filter for the system |
39 |
|
*/ |
40 |
|
public void start() throws ComponentStartException { |
41 |
< |
|
41 |
> |
// get references to key objects |
42 |
> |
_refman = ReferenceManager.getInstance(); |
43 |
> |
_logger = ReferenceManager.getInstance().getLogger(); |
44 |
> |
|
45 |
|
_logger.write(toString(), Logger.SYSINIT, "coming up"); |
46 |
|
|
47 |
|
// configuration variables we require |
48 |
|
String ourName = null; |
49 |
|
String realInterface = null; |
50 |
|
String dbInterface = null; |
51 |
+ |
int queueMonitorInterval = 0; |
52 |
|
|
53 |
|
Configuration config = _refman.getCM().getConfiguration("RootFilter"); |
54 |
|
if (config == null) { |
55 |
< |
System.err.println("CRITICAL:Unable to obtain configuration" + |
56 |
< |
"\n Advise you check the i-scream log for more information."); |
57 |
< |
_logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration"); |
53 |
< |
System.exit(1); |
54 |
< |
} else { |
55 |
> |
throw new ComponentStartException("Unable to obtain configuration for component"); |
56 |
> |
} |
57 |
> |
else { |
58 |
|
try { |
59 |
+ |
// get the configuration properties we need |
60 |
|
ourName = config.getProperty("RootFilter.name"); |
61 |
+ |
|
62 |
+ |
queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval")); |
63 |
+ |
} catch (org.omg.CORBA.MARSHAL e) { |
64 |
+ |
throw new ComponentStartException("Unable to obtain requried configuration property for component"); |
65 |
+ |
} |
66 |
+ |
try { |
67 |
+ |
// get the optional configuration properties |
68 |
|
realInterface = config.getProperty("RootFilter.realtimeInterfaceName"); |
69 |
|
dbInterface = config.getProperty("RootFilter.dbInterfaceName"); |
70 |
|
} catch (org.omg.CORBA.MARSHAL e) { |
71 |
< |
System.err.println ("CRITICAL:Unable to obtain required configuration property" + |
61 |
< |
"\n Advise you check the i-scream log for more information."); |
62 |
< |
_logger.write(toString(), Logger.FATAL, "ERROR - required configuration property not present"); |
63 |
< |
System.exit(1); |
71 |
> |
// we can ignore that fact |
72 |
|
} |
73 |
|
} |
74 |
+ |
|
75 |
|
// now we have the name of the Root Filter we set it |
76 |
|
NAME = ourName; |
77 |
|
|
88 |
|
} |
89 |
|
|
90 |
|
Queue queue = new Queue(); |
91 |
+ |
// startup a monitor on this queue, every minute |
92 |
+ |
String queueName = NAME + " RootFilter"; |
93 |
+ |
queue.startMonitor(queueMonitorInterval*1000, queueName); |
94 |
|
|
95 |
|
if (realInterface == null) { |
96 |
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface); |
116 |
|
|
117 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
118 |
|
|
107 |
– |
// !!!! TEMPORARY CODE !!!! |
108 |
– |
// Monitor the queue's status (queue 0 and 1 - big assumption!) |
109 |
– |
while(true) { |
110 |
– |
// wait 30 seconds |
111 |
– |
try { Thread.sleep(30000); } catch(Exception e) {} |
112 |
– |
int q0 = queue.queueSize(0); |
113 |
– |
int q1 = queue.queueSize(1); |
114 |
– |
int tot = queue.elementCount(); |
115 |
– |
String message = "Queue status - queue0: "+q0+" queue1: "+q1+" total: "+tot; |
116 |
– |
_logger.write(toString(), Logger.DEBUG, message); |
117 |
– |
} |
119 |
|
} |
120 |
|
|
121 |
|
/** |
144 |
|
* This holds a reference to the |
145 |
|
* system logger that is being used. |
146 |
|
*/ |
147 |
< |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
147 |
> |
private Logger _logger; |
148 |
|
|
149 |
|
/** |
150 |
|
* A reference to the reference manager in use |
151 |
|
*/ |
152 |
< |
private ReferenceManager _refman = ReferenceManager.getInstance(); |
152 |
> |
private ReferenceManager _refman; |
153 |
|
|
154 |
|
//---STATIC ATTRIBUTES--- |
155 |
|
|