1 |
ajm |
1.27 |
|
2 |
tdb |
1.1 |
//---PACKAGE DECLARATION--- |
3 |
tdb |
1.3 |
package uk.ac.ukc.iscream.rootfilter; |
4 |
tdb |
1.1 |
|
5 |
|
|
//---IMPORTS--- |
6 |
ajm |
1.5 |
import uk.ac.ukc.iscream.util.*; |
7 |
tdb |
1.1 |
import uk.ac.ukc.iscream.core.*; |
8 |
tdb |
1.16 |
import uk.ac.ukc.iscream.componentmanager.*; |
9 |
ajm |
1.8 |
import uk.ac.ukc.iscream.clientinterface.*; |
10 |
tdb |
1.1 |
|
11 |
|
|
/** |
12 |
ajm |
1.10 |
* The root filter is what all filters talk to |
13 |
|
|
* Hosts cannot talk to this implementation of a filter. |
14 |
|
|
* It provides hooks to all data interfaces for the system |
15 |
|
|
* namely the client interface and the db interface. |
16 |
|
|
* This is an i-scream component that starts the |
17 |
|
|
* RootFilter services. |
18 |
tdb |
1.1 |
* |
19 |
tdb |
1.29 |
* @author $Author: tdb1 $ |
20 |
tdb |
1.31 |
* @version $Id: RootFilter.java,v 1.30 2001/03/14 01:43:58 tdb1 Exp $ |
21 |
tdb |
1.1 |
*/ |
22 |
tdb |
1.17 |
public class RootFilter implements Component { |
23 |
tdb |
1.1 |
|
24 |
|
|
//---FINAL ATTRIBUTES--- |
25 |
|
|
|
26 |
|
|
/** |
27 |
|
|
* The current CVS revision of this class |
28 |
|
|
*/ |
29 |
tdb |
1.31 |
public static final String REVISION = "$Revision: 1.30 $"; |
30 |
ajm |
1.10 |
|
31 |
tdb |
1.1 |
//---STATIC METHODS--- |
32 |
|
|
|
33 |
ajm |
1.10 |
//---CONSTRUCTORS--- |
34 |
|
|
|
35 |
|
|
//---PUBLIC METHODS--- |
36 |
ajm |
1.5 |
|
37 |
ajm |
1.10 |
/** |
38 |
|
|
* This starts the Root Filter for the system |
39 |
|
|
*/ |
40 |
|
|
public void start() throws ComponentStartException { |
41 |
ajm |
1.26 |
// get references to key objects |
42 |
tdb |
1.30 |
_logger = _refman.getLogger(); |
43 |
ajm |
1.26 |
|
44 |
ajm |
1.10 |
_logger.write(toString(), Logger.SYSINIT, "coming up"); |
45 |
tdb |
1.28 |
|
46 |
|
|
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
47 |
|
|
String configName = "RootFilter"; |
48 |
|
|
|
49 |
|
|
// set the name of the root filter |
50 |
|
|
try { |
51 |
|
|
NAME = cp.getProperty(configName, "RootFilter.name"); |
52 |
|
|
} catch (PropertyNotFoundException e) { |
53 |
|
|
NAME = null; |
54 |
|
|
_logger.write(toString(), Logger.WARNING, "RootFilter name not set: "+e); |
55 |
tdb |
1.23 |
} |
56 |
tdb |
1.28 |
|
57 |
|
|
// try and get the names of the ciReal and ciDB |
58 |
|
|
String realInterface, dbInterface; |
59 |
|
|
try { |
60 |
|
|
realInterface = cp.getProperty(configName, "RootFilter.realtimeInterfaceName"); |
61 |
|
|
dbInterface = cp.getProperty(configName, "RootFilter.dbInterfaceName"); |
62 |
|
|
} catch (PropertyNotFoundException e) { |
63 |
|
|
_logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e); |
64 |
|
|
realInterface = null; |
65 |
|
|
dbInterface = null; |
66 |
tdb |
1.1 |
} |
67 |
tdb |
1.23 |
|
68 |
ajm |
1.13 |
ClientInterface ciReal = null, ciDB = null; |
69 |
ajm |
1.8 |
// get reference to the client interfaces - the real time one |
70 |
ajm |
1.11 |
if (realInterface != null) { |
71 |
ajm |
1.13 |
ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface)); |
72 |
ajm |
1.11 |
} |
73 |
ajm |
1.10 |
// get reference to the client interfaces - and the db one |
74 |
ajm |
1.11 |
if (dbInterface != null) { |
75 |
ajm |
1.13 |
ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
76 |
ajm |
1.11 |
} |
77 |
tdb |
1.28 |
|
78 |
|
|
// setup a queue |
79 |
|
|
Queue queue = new Queue(); |
80 |
tdb |
1.15 |
|
81 |
tdb |
1.28 |
// startup a monitor on this queue |
82 |
|
|
try { |
83 |
|
|
// try to get the interval, if this fails, we won't start up the monitor |
84 |
|
|
int queueMonitorInterval = Integer.parseInt(cp.getProperty(configName, "Queue.MonitorInterval")); |
85 |
|
|
String queueName = NAME + " RootFilter"; |
86 |
|
|
queue.startMonitor(queueMonitorInterval*1000, queueName); |
87 |
|
|
} catch (PropertyNotFoundException e) { |
88 |
|
|
_logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e); |
89 |
|
|
} |
90 |
tdb |
1.15 |
|
91 |
ajm |
1.11 |
if (realInterface == null) { |
92 |
|
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface); |
93 |
tdb |
1.15 |
CIWrapper c = new CIWrapper(ciDB, queue); |
94 |
|
|
c.start(); |
95 |
ajm |
1.11 |
} else if (dbInterface == null) { |
96 |
|
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface); |
97 |
tdb |
1.15 |
CIWrapper c = new CIWrapper(ciReal, queue); |
98 |
|
|
c.start(); |
99 |
ajm |
1.11 |
} else { |
100 |
|
|
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface); |
101 |
tdb |
1.15 |
CIWrapper c = new CIWrapper(ciReal, queue); |
102 |
|
|
c.start(); |
103 |
|
|
c = new CIWrapper(ciDB, queue); |
104 |
|
|
c.start(); |
105 |
ajm |
1.11 |
} |
106 |
tdb |
1.15 |
|
107 |
ajm |
1.8 |
// RootFilterServant start (for inbound child filter data) |
108 |
ajm |
1.10 |
_logger.write(toString(), Logger.DEBUG, "starting Root Filter"); |
109 |
tdb |
1.15 |
RootFilterServant filterServant = new RootFilterServant(queue); |
110 |
ajm |
1.8 |
// bind to the naming service as a filter |
111 |
ajm |
1.14 |
_refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME); |
112 |
tdb |
1.1 |
|
113 |
ajm |
1.10 |
_logger.write(toString(), Logger.SYSINIT, "started"); |
114 |
tdb |
1.18 |
|
115 |
tdb |
1.29 |
} |
116 |
|
|
|
117 |
|
|
/** |
118 |
|
|
* Does a dependency check. Used mainly at startup to |
119 |
|
|
* see if the required dependencies (components) are up |
120 |
|
|
* and running. |
121 |
|
|
* |
122 |
|
|
* @return a boolean value, true if the depdencies are satisfied |
123 |
|
|
*/ |
124 |
|
|
public boolean depCheck() { |
125 |
|
|
try { |
126 |
|
|
org.omg.CORBA.Object obj; |
127 |
|
|
// first check the ConfigurationManager is alive |
128 |
|
|
obj = _refman.getCORBARef("iscream.ConfigurationManager"); |
129 |
|
|
// then get some info on the CLI and DBI |
130 |
|
|
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
131 |
|
|
String cli = cp.getProperty("RootFilter", "RootFilter.realtimeInterfaceName"); |
132 |
|
|
String dbi = cp.getProperty("RootFilter", "RootFilter.dbInterfaceName"); |
133 |
|
|
// finally check the CLI and DBI are alive |
134 |
|
|
obj = _refman.getCORBARef("iscream.ClientInterface." + cli); |
135 |
|
|
obj = _refman.getCORBARef("iscream.ClientInterface." + dbi); |
136 |
|
|
} catch(ComponentCORBAException e) { |
137 |
tdb |
1.31 |
System.err.println(toString() + ": Dependency Failure: "+e); |
138 |
tdb |
1.29 |
return false; |
139 |
|
|
} catch(PropertyNotFoundException e) { |
140 |
tdb |
1.31 |
System.err.println(toString() + ": Unable to obtain configuration: "+e); |
141 |
tdb |
1.29 |
return false; |
142 |
|
|
} |
143 |
|
|
// dependency check suceeded |
144 |
|
|
return true; |
145 |
tdb |
1.1 |
} |
146 |
ajm |
1.10 |
|
147 |
|
|
/** |
148 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
149 |
|
|
* method to provide clean logging (every class should have this). |
150 |
|
|
* |
151 |
|
|
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
152 |
|
|
* to format the toString() |
153 |
|
|
* |
154 |
|
|
* @return the name of this class and its CVS revision |
155 |
|
|
*/ |
156 |
|
|
public String toString() { |
157 |
|
|
return FormatName.getName( |
158 |
ajm |
1.14 |
NAME, |
159 |
ajm |
1.10 |
getClass().getName(), |
160 |
|
|
REVISION); |
161 |
tdb |
1.1 |
} |
162 |
|
|
|
163 |
|
|
//---PRIVATE METHODS--- |
164 |
|
|
|
165 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
166 |
|
|
|
167 |
|
|
//---ATTRIBUTES--- |
168 |
ajm |
1.10 |
|
169 |
|
|
/** |
170 |
|
|
* This holds a reference to the |
171 |
|
|
* system logger that is being used. |
172 |
|
|
*/ |
173 |
ajm |
1.26 |
private Logger _logger; |
174 |
ajm |
1.10 |
|
175 |
|
|
/** |
176 |
|
|
* A reference to the reference manager in use |
177 |
|
|
*/ |
178 |
tdb |
1.30 |
private ReferenceManager _refman = ReferenceManager.getInstance(); |
179 |
ajm |
1.10 |
|
180 |
tdb |
1.1 |
//---STATIC ATTRIBUTES--- |
181 |
ajm |
1.10 |
|
182 |
|
|
/** |
183 |
|
|
* The friendly name for this component, used by |
184 |
|
|
* all related classes. |
185 |
|
|
* This is set from the configuration. |
186 |
|
|
*/ |
187 |
|
|
public static String NAME; |
188 |
tdb |
1.1 |
|
189 |
ajm |
1.5 |
} |