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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filter/FilterMain.java (file contents):
Revision 1.18 by tdb, Fri Jan 12 00:45:25 2001 UTC vs.
Revision 1.29 by tdb, Wed Mar 14 23:25:29 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.filter;
2 > package uk.org.iscream.filter;
3  
4   //---IMPORTS---
5 < import uk.ac.ukc.iscream.util.*;
6 < import uk.ac.ukc.iscream.core.*;
7 < import uk.ac.ukc.iscream.filter.*;
5 > import uk.org.iscream.util.*;
6 > import uk.org.iscream.core.*;
7 > import uk.org.iscream.componentmanager.*;
8 > import uk.org.iscream.filter.*;
9  
10   /**
11   * A Filter Startup Class
# Line 13 | Line 14 | import uk.ac.ukc.iscream.filter.*;
14   * @author  $Author$
15   * @version $Id$
16   */
17 < public class FilterMain implements uk.ac.ukc.iscream.util.Component {
17 > public class FilterMain implements Component {
18  
19   //---FINAL ATTRIBUTES---
20  
# Line 41 | Line 42 | public class FilterMain implements uk.ac.ukc.iscream.u
42       * Starts the Filter component
43       */
44      public void start() throws ComponentStartException {
45 <              
45 >        // get references to key objects
46 >        _logger = _refman.getLogger();
47 >        
48          _logger.write(toString(), Logger.SYSINIT, "coming up");
46            
47        // configuration variables we require
48        int UDPListenPort = 0;
49        int TCPListenPort = 0;
50        String parentFilterName = null;
51
52        Configuration config = _refman.getCM().getConfiguration(FilterMain.NAME);
53        if (config == null) {
54            System.err.println("CRITICAL:Unable to obtain configuration" +
55                               "\n         Advise you check the i-scream log for more information.");
56            _logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration");
57            System.exit(1);
58        } else {
59            try {
60                UDPListenPort = Integer.parseInt(config.getProperty("Filter.UDPListenPort"));
61                TCPListenPort = Integer.parseInt(config.getProperty("Filter.TCPListenPort"));
62                parentFilterName = config.getProperty("Filter.parentFilter");
63            } catch (org.omg.CORBA.MARSHAL e) {
64                System.err.println ("CRITICAL:Unable to obtain required configuration property" +
65                                    "\n         Advise you check the i-scream log for more information.");
66                _logger.write(toString(), Logger.FATAL, "ERROR - required configuration property not present");
67                System.exit(1);
68            }
69        }
70        _logger.write(toString(), Logger.SYSINIT, "configured");
49          
50 <        // get parent
73 <        Filter parentFilter = FilterHelper.narrow(_refman.getCORBARef("iscream.Filter." + parentFilterName));
50 >        ConfigurationProxy cp = ConfigurationProxy.getInstance();
51          
52 +        int UDPListenPort, TCPListenPort;
53 +        try {
54 +            UDPListenPort = Integer.parseInt(cp.getProperty(FilterMain.NAME, "Filter.UDPListenPort"));
55 +            TCPListenPort = Integer.parseInt(cp.getProperty(FilterMain.NAME, "Filter.TCPListenPort"));
56 +        } catch (PropertyNotFoundException e) {
57 +            throw new ComponentStartException("Unable to obtain requried configuration property for component: " + e);
58 +        }
59 +        
60          // setup a queue
61          Queue queue = new Queue();
62          
63 +        // startup a monitor on this queue
64 +        try {
65 +            // try to get the interval, if this fails, we won't start up the monitor
66 +            int queueMonitorInterval = Integer.parseInt(cp.getProperty(FilterMain.NAME, "Queue.MonitorInterval"));
67 +            String queueName = NAME + " Filter";
68 +            queue.startMonitor(queueMonitorInterval*1000, queueName);
69 +        } catch (PropertyNotFoundException e) {
70 +            _logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e);
71 +        }
72 +        
73          // Start a filter thread
74          _logger.write(toString(), Logger.SYSINIT, "starting Filter Thread / Queue consumer");
75 <        FilterThread filterThread = new FilterThread(queue, parentFilter);
75 >        FilterThread filterThread = new FilterThread(queue);
76          filterThread.start();
77          
78          // FilterServant start (for inbound child filter data)
79 <        _logger.write(toString(), Logger.DEBUG, "starting Filter Child -> Parent link for upstream parent - " + parentFilterName);
79 >        _logger.write(toString(), Logger.DEBUG, "starting Servant to listen for downstream filters");
80          FilterServant filterServant = new FilterServant(TCPListenPort, UDPListenPort, queue);
81          _refman.bindToOrb(filterServant, "iscream.Filter." + FilterMain.NAME);
82  
# Line 97 | Line 92 | public class FilterMain implements uk.ac.ukc.iscream.u
92          
93          _logger.write(toString(), Logger.SYSINIT, "started");
94      }
95 <
95 >    
96      /**
97 +     * Does a dependency check. Used mainly at startup to
98 +     * see if the required dependencies (components) are up
99 +     * and running.
100 +     *
101 +     * @return a boolean value, true if the depdencies are satisfied
102 +     */
103 +    public boolean depCheck() {
104 +        try {
105 +            org.omg.CORBA.Object obj;
106 +            // first check the ConfigurationManager is alive
107 +            obj = _refman.getCORBARef("iscream.ConfigurationManager");
108 +            // then suss out our parent filter
109 +            ConfigurationProxy cp = ConfigurationProxy.getInstance();
110 +            String parentFilterName = cp.getProperty(NAME, "Filter.parentFilter");
111 +            // finally check the parent filter is alive
112 +            obj = _refman.getCORBARef("iscream.Filter." + parentFilterName);
113 +        } catch(ComponentCORBAException e) {
114 +            System.err.println(toString() + ": Dependency Failure: "+e);
115 +            return false;
116 +        } catch(PropertyNotFoundException e) {
117 +            System.err.println(toString() + ": Unable to obtain configuration: "+e);
118 +            return false;
119 +        }
120 +        // dependency check suceeded
121 +        return true;
122 +    }
123 +    
124 +    /**
125       * Overrides the {@link java.lang.Object#toString() Object.toString()}
126       * method to provide clean logging (every class should have this).
127       *
128 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
128 >     * This uses the uk.org.iscream.util.NameFormat class
129       * to format the toString()
130       *
131       * @return the name of this class and its CVS revision
# Line 124 | Line 147 | public class FilterMain implements uk.ac.ukc.iscream.u
147       * This holds a reference to the
148       * system logger that is being used.
149       */
150 <    private Logger _logger = ReferenceManager.getInstance().getLogger();
150 >    private Logger _logger;
151  
152      /**
153       * A reference to the reference manager in use
# Line 140 | Line 163 | public class FilterMain implements uk.ac.ukc.iscream.u
163       */
164      public static String NAME;
165  
166 < }            
166 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines