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
Revision: 1.21
Committed: Fri Jan 19 01:20:15 2001 UTC (23 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.20: +4 -4 lines
Log Message:
Best catch some exceptions... correctly.

File Contents

# User Rev Content
1 tdb 1.1 //---PACKAGE DECLARATION---
2 tdb 1.3 package uk.ac.ukc.iscream.rootfilter;
3 tdb 1.1
4     //---IMPORTS---
5 ajm 1.5 import uk.ac.ukc.iscream.util.*;
6 tdb 1.1 import uk.ac.ukc.iscream.core.*;
7 tdb 1.16 import uk.ac.ukc.iscream.componentmanager.*;
8 ajm 1.8 import uk.ac.ukc.iscream.clientinterface.*;
9 tdb 1.1
10     /**
11 ajm 1.10 * The root filter is what all filters talk to
12     * Hosts cannot talk to this implementation of a filter.
13     * It provides hooks to all data interfaces for the system
14     * namely the client interface and the db interface.
15     * This is an i-scream component that starts the
16     * RootFilter services.
17 tdb 1.1 *
18 tdb 1.16 * @author $Author: tdb1 $
19 tdb 1.21 * @version $Id: RootFilter.java,v 1.20 2001/01/19 01:19:31 tdb1 Exp $
20 tdb 1.1 */
21 tdb 1.17 public class RootFilter implements Component {
22 tdb 1.1
23     //---FINAL ATTRIBUTES---
24    
25     /**
26     * The current CVS revision of this class
27     */
28 tdb 1.21 public static final String REVISION = "$Revision: 1.20 $";
29 ajm 1.10
30 tdb 1.1 //---STATIC METHODS---
31    
32 ajm 1.10 //---CONSTRUCTORS---
33    
34     //---PUBLIC METHODS---
35 ajm 1.5
36 ajm 1.10 /**
37     * This starts the Root Filter for the system
38     */
39     public void start() throws ComponentStartException {
40 ajm 1.5
41 ajm 1.10 _logger.write(toString(), Logger.SYSINIT, "coming up");
42 ajm 1.5
43     // configuration variables we require
44     String ourName = null;
45 ajm 1.8 String realInterface = null;
46     String dbInterface = null;
47 ajm 1.5
48 ajm 1.10 Configuration config = _refman.getCM().getConfiguration("RootFilter");
49 ajm 1.5 if (config == null) {
50 ajm 1.10 System.err.println("CRITICAL:Unable to obtain configuration" +
51     "\n Advise you check the i-scream log for more information.");
52     _logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration");
53     System.exit(1);
54 ajm 1.5 } else {
55     try {
56 ajm 1.8 ourName = config.getProperty("RootFilter.name");
57     realInterface = config.getProperty("RootFilter.realtimeInterfaceName");
58     dbInterface = config.getProperty("RootFilter.dbInterfaceName");
59 ajm 1.5 } catch (org.omg.CORBA.MARSHAL e) {
60 ajm 1.10 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 ajm 1.5 }
65 tdb 1.1 }
66 ajm 1.5 // now we have the name of the Root Filter we set it
67 ajm 1.10 NAME = ourName;
68    
69     _logger.write(toString(), Logger.SYSINIT, "configured");
70 ajm 1.13
71     ClientInterface ciReal = null, ciDB = null;
72 ajm 1.8 // get reference to the client interfaces - the real time one
73 ajm 1.11 if (realInterface != null) {
74 ajm 1.13 ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface));
75 ajm 1.11 }
76 ajm 1.10 // get reference to the client interfaces - and the db one
77 ajm 1.11 if (dbInterface != null) {
78 ajm 1.13 ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface));
79 ajm 1.11 }
80 tdb 1.15
81     Queue queue = new Queue();
82    
83 ajm 1.11 if (realInterface == null) {
84     _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface);
85 tdb 1.15 CIWrapper c = new CIWrapper(ciDB, queue);
86     c.start();
87 ajm 1.11 } else if (dbInterface == null) {
88     _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface);
89 tdb 1.15 CIWrapper c = new CIWrapper(ciReal, queue);
90     c.start();
91 ajm 1.11 } else {
92     _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface);
93 tdb 1.15 CIWrapper c = new CIWrapper(ciReal, queue);
94     c.start();
95     c = new CIWrapper(ciDB, queue);
96     c.start();
97 ajm 1.11 }
98 tdb 1.15
99 ajm 1.8 // RootFilterServant start (for inbound child filter data)
100 ajm 1.10 _logger.write(toString(), Logger.DEBUG, "starting Root Filter");
101 tdb 1.15 RootFilterServant filterServant = new RootFilterServant(queue);
102 ajm 1.8 // bind to the naming service as a filter
103 ajm 1.14 _refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME);
104 tdb 1.1
105 ajm 1.10 _logger.write(toString(), Logger.SYSINIT, "started");
106 tdb 1.18
107     // !!!! TEMPORARY CODE !!!!
108     // Monitor the queue's status (queue 0 and 1 - big assumption!)
109     while(true) {
110     // wait 30 seconds
111     try { Thread.sleep(30000); } catch(Exception e) {}
112 tdb 1.20 try {
113     int q0 = queue.queueSize(0);
114     int q1 = queue.queueSize(1);
115     int tot = queue.elementCount();
116 tdb 1.21 String message = "Queue status - queue0: "+q0+" queue1: "+q1+" total: "+tot;
117     _logger.write(toString(), Logger.DEBUG, message);
118 tdb 1.20 }
119     catch(Exception e) {
120     _logger.write(toString(), Logger.ERROR, e.getMessage());
121     }
122 tdb 1.18 }
123 tdb 1.1 }
124 ajm 1.10
125     /**
126     * Overrides the {@link java.lang.Object#toString() Object.toString()}
127     * method to provide clean logging (every class should have this).
128     *
129     * This uses the uk.ac.ukc.iscream.util.NameFormat class
130     * to format the toString()
131     *
132     * @return the name of this class and its CVS revision
133     */
134     public String toString() {
135     return FormatName.getName(
136 ajm 1.14 NAME,
137 ajm 1.10 getClass().getName(),
138     REVISION);
139 tdb 1.1 }
140    
141     //---PRIVATE METHODS---
142    
143     //---ACCESSOR/MUTATOR METHODS---
144    
145     //---ATTRIBUTES---
146 ajm 1.10
147     /**
148     * This holds a reference to the
149     * system logger that is being used.
150     */
151     private Logger _logger = ReferenceManager.getInstance().getLogger();
152    
153     /**
154     * A reference to the reference manager in use
155     */
156     private ReferenceManager _refman = ReferenceManager.getInstance();
157    
158 tdb 1.1 //---STATIC ATTRIBUTES---
159 ajm 1.10
160     /**
161     * The friendly name for this component, used by
162     * all related classes.
163     * This is set from the configuration.
164     */
165     public static String NAME;
166 tdb 1.1
167 ajm 1.5 }