1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* http://www.i-scream.org.uk |
4 |
+ |
* Copyright (C) 2000-2002 i-scream |
5 |
+ |
* |
6 |
+ |
* This program is free software; you can redistribute it and/or |
7 |
+ |
* modify it under the terms of the GNU General Public License |
8 |
+ |
* as published by the Free Software Foundation; either version 2 |
9 |
+ |
* of the License, or (at your option) any later version. |
10 |
+ |
* |
11 |
+ |
* This program is distributed in the hope that it will be useful, |
12 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
+ |
* GNU General Public License for more details. |
15 |
+ |
* |
16 |
+ |
* You should have received a copy of the GNU General Public License |
17 |
+ |
* along with this program; if not, write to the Free Software |
18 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
+ |
*/ |
20 |
|
|
21 |
+ |
|
22 |
|
//---PACKAGE DECLARATION--- |
23 |
< |
package uk.ac.ukc.iscream.rootfilter; |
23 |
> |
package uk.org.iscream.cms.server.rootfilter; |
24 |
|
|
25 |
|
//---IMPORTS--- |
26 |
< |
import uk.ac.ukc.iscream.util.*; |
27 |
< |
import uk.ac.ukc.iscream.core.*; |
28 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
29 |
< |
import uk.ac.ukc.iscream.clientinterface.*; |
26 |
> |
import uk.org.iscream.cms.util.*; |
27 |
> |
import uk.org.iscream.cms.server.core.*; |
28 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
29 |
> |
import uk.org.iscream.cms.server.clientinterface.*; |
30 |
|
|
31 |
|
/** |
32 |
|
* The root filter is what all filters talk to |
59 |
|
*/ |
60 |
|
public void start() throws ComponentStartException { |
61 |
|
// get references to key objects |
62 |
< |
_refman = ReferenceManager.getInstance(); |
43 |
< |
_logger = ReferenceManager.getInstance().getLogger(); |
62 |
> |
_logger = _refman.getLogger(); |
63 |
|
|
64 |
|
_logger.write(toString(), Logger.SYSINIT, "coming up"); |
65 |
|
|
74 |
|
_logger.write(toString(), Logger.WARNING, "RootFilter name not set: "+e); |
75 |
|
} |
76 |
|
|
77 |
< |
// try and get the names of the ciReal and ciDB |
78 |
< |
String realInterface, dbInterface; |
77 |
> |
// setup a queue |
78 |
> |
Queue queue; |
79 |
> |
// see if this Queue needs a size limit |
80 |
|
try { |
81 |
< |
realInterface = cp.getProperty(configName, "RootFilter.realtimeInterfaceName"); |
82 |
< |
dbInterface = cp.getProperty(configName, "RootFilter.dbInterfaceName"); |
81 |
> |
int queueSizeLimit = Integer.parseInt(cp.getProperty(configName, "Queue.SizeLimit")); |
82 |
> |
String queueRemoveAlgorithm = cp.getProperty(configName, "Queue.RemoveAlgorithm"); |
83 |
> |
int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms); |
84 |
> |
if(algorithm != -1) { |
85 |
> |
_logger.write(toString(), Logger.DEBUG, "Starting Queue with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm); |
86 |
> |
// we have valid values, so lets start it. |
87 |
> |
queue = new Queue(queueSizeLimit, algorithm); |
88 |
> |
} |
89 |
> |
else { |
90 |
> |
_logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm); |
91 |
> |
// just don't activate a limit |
92 |
> |
queue = new Queue(); |
93 |
> |
} |
94 |
> |
|
95 |
|
} catch (PropertyNotFoundException e) { |
96 |
|
_logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e); |
97 |
< |
realInterface = null; |
98 |
< |
dbInterface = null; |
97 |
> |
// just don't activate a limit |
98 |
> |
queue = new Queue(); |
99 |
> |
} catch (NumberFormatException e) { |
100 |
> |
_logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e); |
101 |
> |
// just don't activate a limit |
102 |
> |
queue = new Queue(); |
103 |
|
} |
104 |
|
|
69 |
– |
ClientInterface ciReal = null, ciDB = null; |
70 |
– |
// get reference to the client interfaces - the real time one |
71 |
– |
if (realInterface != null) { |
72 |
– |
ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface)); |
73 |
– |
} |
74 |
– |
// get reference to the client interfaces - and the db one |
75 |
– |
if (dbInterface != null) { |
76 |
– |
ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface)); |
77 |
– |
} |
78 |
– |
|
79 |
– |
// setup a queue |
80 |
– |
Queue queue = new Queue(); |
81 |
– |
|
105 |
|
// startup a monitor on this queue |
106 |
|
try { |
107 |
|
// try to get the interval, if this fails, we won't start up the monitor |
112 |
|
_logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e); |
113 |
|
} |
114 |
|
|
92 |
– |
if (realInterface == null) { |
93 |
– |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface); |
94 |
– |
CIWrapper c = new CIWrapper(ciDB, queue); |
95 |
– |
c.start(); |
96 |
– |
} else if (dbInterface == null) { |
97 |
– |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface); |
98 |
– |
CIWrapper c = new CIWrapper(ciReal, queue); |
99 |
– |
c.start(); |
100 |
– |
} else { |
101 |
– |
_logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface); |
102 |
– |
CIWrapper c = new CIWrapper(ciReal, queue); |
103 |
– |
c.start(); |
104 |
– |
c = new CIWrapper(ciDB, queue); |
105 |
– |
c.start(); |
106 |
– |
} |
107 |
– |
|
115 |
|
// RootFilterServant start (for inbound child filter data) |
116 |
|
_logger.write(toString(), Logger.DEBUG, "starting Root Filter"); |
117 |
|
RootFilterServant filterServant = new RootFilterServant(queue); |
118 |
|
// bind to the naming service as a filter |
119 |
< |
_refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME); |
119 |
> |
_refman.bindToOrb(filterServant, "iscream.Filter\\." + RootFilter.NAME); |
120 |
|
|
121 |
+ |
// Startup the CORBA Listener |
122 |
+ |
_logger.write(toString(), Logger.DEBUG, "starting servant for inbound clients"); |
123 |
+ |
CorbaClientListenerServant corbaServant = new CorbaClientListenerServant(queue); |
124 |
+ |
_refman.bindToOrb(corbaServant, "iscream.ClientInterface\\." + RootFilter.NAME); |
125 |
+ |
|
126 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
127 |
|
|
128 |
|
} |
135 |
|
* @return a boolean value, true if the depdencies are satisfied |
136 |
|
*/ |
137 |
|
public boolean depCheck() { |
138 |
+ |
org.omg.CORBA.Object obj; |
139 |
+ |
|
140 |
+ |
// first we need to check the Configuration system is available |
141 |
|
try { |
127 |
– |
org.omg.CORBA.Object obj; |
142 |
|
// first check the ConfigurationManager is alive |
143 |
|
obj = _refman.getCORBARef("iscream.ConfigurationManager"); |
130 |
– |
// then get some info on the CLI and DBI |
131 |
– |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
132 |
– |
String cli = cp.getProperty("RootFilter", "RootFilter.realtimeInterfaceName"); |
133 |
– |
String dbi = cp.getProperty("RootFilter", "RootFilter.dbInterfaceName"); |
134 |
– |
// finally check the CLI and DBI are alive |
135 |
– |
obj = _refman.getCORBARef("iscream.ClientInterface." + cli); |
136 |
– |
obj = _refman.getCORBARef("iscream.ClientInterface." + dbi); |
144 |
|
} catch(ComponentCORBAException e) { |
145 |
< |
_logger.write(toString(), Logger.WARNING, "Dependency Failure: "+e); |
145 |
> |
System.err.println(toString() + ": Dependency Failure: "+e); |
146 |
|
return false; |
140 |
– |
} catch(PropertyNotFoundException e) { |
141 |
– |
_logger.write(toString(), Logger.WARNING, "Unable to obtain configuration: "+e); |
142 |
– |
return false; |
147 |
|
} |
148 |
+ |
|
149 |
|
// dependency check suceeded |
150 |
|
return true; |
151 |
|
} |
154 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
155 |
|
* method to provide clean logging (every class should have this). |
156 |
|
* |
157 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
157 |
> |
* This uses the uk.org.iscream.cms.util.NameFormat class |
158 |
|
* to format the toString() |
159 |
|
* |
160 |
|
* @return the name of this class and its CVS revision |
181 |
|
/** |
182 |
|
* A reference to the reference manager in use |
183 |
|
*/ |
184 |
< |
private ReferenceManager _refman; |
184 |
> |
private ReferenceManager _refman = ReferenceManager.getInstance(); |
185 |
|
|
186 |
|
//---STATIC ATTRIBUTES--- |
187 |
|
|
192 |
|
*/ |
193 |
|
public static String NAME; |
194 |
|
|
195 |
< |
} |
195 |
> |
} |