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
Revision: 1.22
Committed: Mon Feb 12 02:22:48 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.21: +4 -2 lines
Log Message:
We now monitor the Queue here every 60 seconds.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.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.componentmanager.*;
8 import uk.ac.ukc.iscream.filter.*;
9
10 /**
11 * A Filter Startup Class
12 * A filter is an iscream component.
13 *
14 * @author $Author: tdb1 $
15 * @version $Id: FilterMain.java,v 1.21 2001/02/01 00:18:42 tdb1 Exp $
16 */
17 public class FilterMain implements Component {
18
19 //---FINAL ATTRIBUTES---
20
21 /**
22 * The current CVS revision of this class
23 */
24 public static final String REVISION = "$Revision: 1.21 $";
25
26 //---STATIC METHODS---
27
28 //---CONSTRUCTORS---
29
30 /**
31 * Constructs a Filter with the name given
32 *
33 * @param givenName the name
34 */
35 public FilterMain(String givenName) {
36 NAME = givenName;
37 }
38
39 //---PUBLIC METHODS---
40
41 /**
42 * Starts the Filter component
43 */
44 public void start() throws ComponentStartException {
45
46 _logger.write(toString(), Logger.SYSINIT, "coming up");
47
48 // configuration variables we require
49 int UDPListenPort = 0;
50 int TCPListenPort = 0;
51 String parentFilterName = null;
52
53 Configuration config = _refman.getCM().getConfiguration(FilterMain.NAME);
54 if (config == null) {
55 throw new ComponentStartException("Unable to obtain configuration for component");
56 }
57 else {
58 try {
59 // get the configuration properties we need
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 throw new ComponentStartException("Unable to obtain requried configuration property for component");
65 }
66 }
67
68 _logger.write(toString(), Logger.SYSINIT, "configured");
69
70 // get parent
71 Filter parentFilter = FilterHelper.narrow(_refman.getCORBARef("iscream.Filter." + parentFilterName));
72
73 // setup a queue
74 Queue queue = new Queue();
75 // startup a monitor on this queue, every minute
76 queue.startMonitor(60*1000, NAME);
77
78 // Start a filter thread
79 _logger.write(toString(), Logger.SYSINIT, "starting Filter Thread / Queue consumer");
80 FilterThread filterThread = new FilterThread(queue, parentFilter);
81 filterThread.start();
82
83 // FilterServant start (for inbound child filter data)
84 _logger.write(toString(), Logger.DEBUG, "starting Filter Child -> Parent link for upstream parent - " + parentFilterName);
85 FilterServant filterServant = new FilterServant(TCPListenPort, UDPListenPort, queue);
86 _refman.bindToOrb(filterServant, "iscream.Filter." + FilterMain.NAME);
87
88 // UDL Reader start (for inbound host data)
89 _logger.write(toString(), Logger.SYSINIT, "starting Filter UDP listener");
90 UDPReader udpReader = new UDPReader(UDPListenPort, queue);
91 udpReader.start();
92
93 // TCP Reader start (for heartbeats)
94 _logger.write(toString(), Logger.SYSINIT, "starting Filter TCP listener");
95 TCPReader tcpReader = new TCPReader(TCPListenPort, queue);
96 tcpReader.start();
97
98 _logger.write(toString(), Logger.SYSINIT, "started");
99 }
100
101 /**
102 * Overrides the {@link java.lang.Object#toString() Object.toString()}
103 * method to provide clean logging (every class should have this).
104 *
105 * This uses the uk.ac.ukc.iscream.util.NameFormat class
106 * to format the toString()
107 *
108 * @return the name of this class and its CVS revision
109 */
110 public String toString() {
111 return FormatName.getName(
112 NAME,
113 getClass().getName(),
114 REVISION);
115 }
116
117 //---PRIVATE METHODS---
118
119 //---ACCESSOR/MUTATOR METHODS---
120
121 //---ATTRIBUTES---
122
123 /**
124 * This holds a reference to the
125 * system logger that is being used.
126 */
127 private Logger _logger = ReferenceManager.getInstance().getLogger();
128
129 /**
130 * A reference to the reference manager in use
131 */
132 private ReferenceManager _refman = ReferenceManager.getInstance();
133
134 //---STATIC ATTRIBUTES---
135
136 /**
137 * The friendly name for this component, used by
138 * all related classes.
139 * This is set from the configuration.
140 */
141 public static String NAME;
142
143 }