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.16 by ajm, Wed Dec 13 13:36:46 2000 UTC vs.
Revision 1.24 by ajm, Fri Feb 23 17:11:09 2001 UTC

# Line 4 | Line 4 | package uk.ac.ukc.iscream.filter;
4   //---IMPORTS---
5   import uk.ac.ukc.iscream.util.*;
6   import uk.ac.ukc.iscream.core.*;
7 + import uk.ac.ukc.iscream.componentmanager.*;
8   import uk.ac.ukc.iscream.filter.*;
9  
10   /**
# 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 >        _refman = ReferenceManager.getInstance();
47 >        _logger = ReferenceManager.getInstance().getLogger();
48 >        
49          _logger.write(toString(), Logger.SYSINIT, "coming up");
50              
51          // configuration variables we require
52          int UDPListenPort = 0;
53          int TCPListenPort = 0;
54          String parentFilterName = null;
55 <
55 >        int queueMonitorInterval = 0;
56 >        
57          Configuration config = _refman.getCM().getConfiguration(FilterMain.NAME);
58          if (config == null) {
59 <            System.err.println("CRITICAL:Unable to obtain configuration" +
60 <                               "\n         Advise you check the i-scream log for more information.");
61 <            _logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration");
57 <            System.exit(1);
58 <        } else {
59 >            throw new ComponentStartException("Unable to obtain configuration for component");
60 >        }
61 >        else {
62              try {
63 +                // get the configuration properties we need
64                  UDPListenPort = Integer.parseInt(config.getProperty("Filter.UDPListenPort"));
65                  TCPListenPort = Integer.parseInt(config.getProperty("Filter.TCPListenPort"));
66                  parentFilterName = config.getProperty("Filter.parentFilter");
67 +                queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval"));
68              } catch (org.omg.CORBA.MARSHAL e) {
69 <                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);
69 >                throw new ComponentStartException("Unable to obtain requried configuration property for component");
70              }
71          }
72 +        
73          _logger.write(toString(), Logger.SYSINIT, "configured");
74          
75          // get parent
76          Filter parentFilter = FilterHelper.narrow(_refman.getCORBARef("iscream.Filter." + parentFilterName));
77          
78 +        // setup a queue
79 +        Queue queue = new Queue();
80 +        // startup a monitor on this queue, every minute
81 +        String queueName = NAME + " Filter";
82 +        queue.startMonitor(queueMonitorInterval*1000, queueName);
83 +        
84 +        // Start a filter thread
85 +        _logger.write(toString(), Logger.SYSINIT, "starting Filter Thread / Queue consumer");
86 +        FilterThread filterThread = new FilterThread(queue, parentFilter);
87 +        filterThread.start();
88 +        
89          // FilterServant start (for inbound child filter data)
90          _logger.write(toString(), Logger.DEBUG, "starting Filter Child -> Parent link for upstream parent - " + parentFilterName);
91 <        FilterServant filterServant = new FilterServant(parentFilter, TCPListenPort, UDPListenPort);
91 >        FilterServant filterServant = new FilterServant(TCPListenPort, UDPListenPort, queue);
92          _refman.bindToOrb(filterServant, "iscream.Filter." + FilterMain.NAME);
93  
94          // UDL Reader start (for inbound host data)
95          _logger.write(toString(), Logger.SYSINIT, "starting Filter UDP listener");
96 <        UDPReader udpReader = new UDPReader(UDPListenPort, parentFilter);
96 >        UDPReader udpReader = new UDPReader(UDPListenPort, queue);
97          udpReader.start();
98  
99          // TCP Reader start (for heartbeats)
100          _logger.write(toString(), Logger.SYSINIT, "starting Filter TCP listener");
101 <        TCPReader tcpReader = new TCPReader(TCPListenPort, parentFilter);
101 >        TCPReader tcpReader = new TCPReader(TCPListenPort, queue);
102          tcpReader.start();
103          
104          _logger.write(toString(), Logger.SYSINIT, "started");
# Line 101 | Line 115 | public class FilterMain implements uk.ac.ukc.iscream.u
115       */
116      public String toString() {
117          return FormatName.getName(
118 <            _name,
118 >            NAME,
119              getClass().getName(),
120              REVISION);
121      }
# Line 113 | Line 127 | public class FilterMain implements uk.ac.ukc.iscream.u
127   //---ATTRIBUTES---
128  
129      /**
116     * This is the friendly identifier of the
117     * component this class is running in.
118     * eg, a Filter may be called "filter1",
119     * If this class does not have an owning
120     * component,  a name from the configuration
121     * can be placed here.  This name could also
122     * be changed to null for utility classes.
123     */
124    private String _name = FilterMain.NAME;
125
126    /**
130       * This holds a reference to the
131       * system logger that is being used.
132       */
133 <    private Logger _logger = ReferenceManager.getInstance().getLogger();
133 >    private Logger _logger;
134  
135      /**
136       * A reference to the reference manager in use
137       */
138 <    private ReferenceManager _refman = ReferenceManager.getInstance();
138 >    private ReferenceManager _refman;
139  
140   //---STATIC ATTRIBUTES---
141  
# Line 143 | Line 146 | public class FilterMain implements uk.ac.ukc.iscream.u
146       */
147      public static String NAME;
148  
149 < }            
149 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines