ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/RootFilter.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/RootFilter.java (file contents):
Revision 1.18 by tdb, Fri Jan 19 01:12:42 2001 UTC vs.
Revision 1.29 by tdb, Wed Mar 14 01:34:34 2001 UTC

# Line 1 | Line 1
1 +
2   //---PACKAGE DECLARATION---
3   package uk.ac.ukc.iscream.rootfilter;
4  
# Line 37 | Line 38 | public class RootFilter implements Component {
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");
42            
43        // configuration variables we require
44        String ourName = null;
45        String realInterface = null;
46        String dbInterface = null;
46          
47 <        Configuration config = _refman.getCM().getConfiguration("RootFilter");
48 <        if (config == null) {
49 <            System.err.println("CRITICAL:Unable to obtain configuration" +
50 <                               "\n         Advise you check the i-scream log for more information.");
51 <            _logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration");
52 <            System.exit(1);
53 <        } else {
54 <            try {
55 <                ourName = config.getProperty("RootFilter.name");
57 <                realInterface = config.getProperty("RootFilter.realtimeInterfaceName");
58 <                dbInterface = config.getProperty("RootFilter.dbInterfaceName");
59 <            } catch (org.omg.CORBA.MARSHAL e) {
60 <                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);
64 <            }
47 >        ConfigurationProxy cp = ConfigurationProxy.getInstance();
48 >        String configName = "RootFilter";
49 >        
50 >        // set the name of the root filter
51 >        try {
52 >            NAME = cp.getProperty(configName, "RootFilter.name");
53 >        } catch (PropertyNotFoundException e) {
54 >            NAME = null;
55 >            _logger.write(toString(), Logger.WARNING, "RootFilter name not set: "+e);
56          }
66        // now we have the name of the Root Filter we set it
67        NAME = ourName;
57          
58 <        _logger.write(toString(), Logger.SYSINIT, "configured");
58 >        // try and get the names of the ciReal and ciDB
59 >        String realInterface, dbInterface;
60 >        try {
61 >            realInterface = cp.getProperty(configName, "RootFilter.realtimeInterfaceName");
62 >            dbInterface = cp.getProperty(configName, "RootFilter.dbInterfaceName");
63 >        } catch (PropertyNotFoundException e) {
64 >            _logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e);
65 >            realInterface = null;
66 >            dbInterface = null;
67 >        }
68          
69          ClientInterface ciReal = null, ciDB = null;
70          // get reference to the client interfaces - the real time one
# Line 77 | Line 75 | public class RootFilter implements Component {
75          if (dbInterface != null) {
76              ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface));
77          }
78 <        
78 >
79 >        // setup a queue
80          Queue queue = new Queue();
81          
82 +        // startup a monitor on this queue
83 +        try {
84 +            // try to get the interval, if this fails, we won't start up the monitor
85 +            int queueMonitorInterval = Integer.parseInt(cp.getProperty(configName, "Queue.MonitorInterval"));
86 +            String queueName = NAME + " RootFilter";
87 +            queue.startMonitor(queueMonitorInterval*1000, queueName);
88 +        } catch (PropertyNotFoundException e) {
89 +            _logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e);
90 +        }
91 +        
92          if (realInterface == null) {        
93              _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface);
94              CIWrapper c = new CIWrapper(ciDB, queue);
# Line 104 | Line 113 | public class RootFilter implements Component {
113          
114          _logger.write(toString(), Logger.SYSINIT, "started");
115          
116 <        // !!!! TEMPORARY CODE !!!!
117 <        // Monitor the queue's status (queue 0 and 1 - big assumption!)
118 <        while(true) {
119 <            // wait 30 seconds
120 <            try { Thread.sleep(30000); } catch(Exception e) {}
121 <            int q0 = _queue.queueSize(0);
122 <            int q1 = _queue.queueSize(1);
123 <            int tot = _queue.elementCount();
124 <            String message = "Queue status - queue1: "+q1+" queue2: "+q2+" total: "+tot;
125 <            _logger.write(toString(), Logger.DEBUG, message);
116 >    }
117 >    
118 >    /**
119 >     * Does a dependency check. Used mainly at startup to
120 >     * see if the required dependencies (components) are up
121 >     * and running.
122 >     *
123 >     * @return a boolean value, true if the depdencies are satisfied
124 >     */
125 >    public boolean depCheck() {
126 >        try {
127 >            org.omg.CORBA.Object obj;
128 >            // first check the ConfigurationManager is alive
129 >            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);
137 >        } catch(ComponentCORBAException e) {
138 >            _logger.write(toString(), Logger.WARNING, "Dependency Failure: "+e);
139 >            return false;
140 >        } catch(PropertyNotFoundException e) {
141 >            _logger.write(toString(), Logger.WARNING, "Unable to obtain configuration: "+e);
142 >            return false;
143          }
144 +        // dependency check suceeded
145 +        return true;
146      }
147      
148      /**
# Line 143 | Line 171 | public class RootFilter implements Component {
171       * This holds a reference to the
172       * system logger that is being used.
173       */
174 <    private Logger _logger = ReferenceManager.getInstance().getLogger();
174 >    private Logger _logger;
175  
176      /**
177       * A reference to the reference manager in use
178       */
179 <    private ReferenceManager _refman = ReferenceManager.getInstance();
179 >    private ReferenceManager _refman;
180  
181   //---STATIC ATTRIBUTES---
182  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines