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/CorbaControlHandlerServant.java
Revision: 1.1
Committed: Mon May 5 22:05:14 2003 UTC (21 years ago) by tdb
Branch: MAIN
Log Message:
Tidy up of the client interface code - more commonly known as the
"right hand side of the server". Right since the start the filter
side of the server has been nice and tree like - every Filter sent
data to another Filter. At the top of the tree there was a "special"
Filter known as the RootFilter, which to the other Filters just
looked like a normal Filter. This was nice, and simple, and expandable.

The Client Interface on the other hand was messy. The root filter
had some hacky wrapper threads which pulled from a queue and pushed
to the relevant client interfaces (one for real time stuff, and the
other for databases). There was no simple room for expandability -
it was all hardwired to do just what was needed at the time.

This commit changes that. A Client Interface now connects to another
Client Interface, with a special one being found in the RootFilter
(yes, maybe that needs a name change now :-). So we can chain client
interfaces, and move other bits and bobs around in the server - for
example, alerting no longer needs to be connected to the Client
Interface, it can connect straight to the RootFilter (or, wherever
the config tells it ;).

Hopefully this sanitizes the underlying layout of the server a bit.

As a final note, I dropped the DBInterface. This used to insert
data in to a MySQL database. We've long since stopped using that,
and it's fallen behind and is way out of date. For now, it's gone
in to the attic.

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * http://www.i-scream.org.uk
4 * Copyright (C) 2000-2002 i-scream
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 //---PACKAGE DECLARATION---
22 package uk.org.iscream.cms.server.rootfilter;
23
24 //---IMPORTS---
25 import uk.org.iscream.cms.util.*;
26 import uk.org.iscream.cms.server.componentmanager.*;
27 import uk.org.iscream.cms.server.core.*;
28 import uk.org.iscream.cms.server.clientinterface.*;
29
30
31 /**
32 * Acts as a Control Handler to a CORBA based client.
33 *
34 * @author $Author: tdb $
35 * @version $Id: CorbaControlHandlerServant.java,v 1.17 2003/02/05 16:43:46 tdb Exp $
36 */
37 class CorbaControlHandlerServant extends CorbaControlHandlerPOA {
38
39 //---FINAL ATTRIBUTES---
40
41 /**
42 * The current CVS revision of this class
43 */
44 public final String REVISION = "$Revision: 1.1 $";
45
46 //---STATIC METHODS---
47
48 //---CONSTRUCTORS---
49
50 /**
51 * Construct a new CorbaControlHandlerServant.
52 *
53 * @param queue A reference to the Queue we're using
54 * @param client A reference to the "servant" part of the connecting client.
55 * @param clientname A name to identify the client.
56 */
57 public CorbaControlHandlerServant(Queue queue, Client client, String clientname) {
58 _queue = queue;
59 _client = client;
60 _clientname = clientname;
61 _dataHandler = null;
62 _logger.write(toString(), Logger.SYSINIT, "created");
63 }
64
65 //---PUBLIC METHODS---
66
67 /**
68 * Start sending data to the client.
69 *
70 * @return a boolean stating whether the attempt to start succeeded
71 */
72 public boolean startData() {
73 if(_dataHandler == null) {
74 // create a new DataHandler
75 CorbaDataHandler dh = new CorbaDataHandler(_client, this, _queue);
76 // start the DataHandler running
77 dh.start();
78 // keep a reference
79 _dataHandler = dh;
80 return true;
81 }
82 else {
83 return false;
84 }
85 }
86
87 /**
88 * Stop sending data to the client.
89 *
90 * @return a boolean stating whether the attempt to stop succeeded
91 */
92 public boolean stopData() {
93 if(_dataHandler != null) {
94 // stop the DataHandler
95 _dataHandler.shutdown();
96 // destroy the reference
97 _dataHandler = null;
98 return true;
99 }
100 else {
101 return false;
102 }
103 }
104
105 /**
106 * Sets the host list for the Client to the requested semi-colon separated
107 * list of hostnames. This will only succeed if we are not sending data.
108 *
109 * @param hostList A semi-colon separated list of hostnames to use.
110 * @return Whether the request succeeded.
111 */
112 public boolean setHostList(String hostList) {
113 return false;
114 }
115
116 /**
117 * Disconnect, this will shutdown the data and unhook from
118 * the CORBA ORB.
119 */
120 public void disconnect() {
121 // close the data handler
122 stopData();
123 // disconnect from the ORB
124 try {
125 byte[] oid = _refman.getRootPOA().servant_to_id(this);
126 _refman.getRootPOA().deactivate_object(oid);
127 } catch(Exception e) {
128 _logger.write(this.toString(), Logger.ERROR, "disconnect failed: "+e);
129 }
130 }
131
132 /**
133 * Overrides the {@link java.lang.Object#toString() Object.toString()}
134 * method to provide clean logging (every class should have this).
135 *
136 * This uses the uk.org.iscream.cms.util.NameFormat class
137 * to format the toString()
138 *
139 * @return the name of this class and its CVS revision
140 */
141 public String toString() {
142 return FormatName.getName(
143 _name,
144 getClass().getName(),
145 REVISION);
146 }
147
148 //---PRIVATE METHODS---
149
150 /**
151 * Overridden for debugging purposes
152 * to see when an instance of this class
153 * is destroyed
154 */
155 protected void finalize() throws Throwable {
156 _logger.write(this.toString(), Logger.DEBUG, "finalized by GC");
157 }
158
159 //---ACCESSOR/MUTATOR METHODS---
160
161 //---ATTRIBUTES---
162
163 /**
164 * This is the friendly identifier of the
165 * component this class is running in.
166 * eg, a Filter may be called "filter1",
167 * If this class does not have an owning
168 * component, a name from the configuration
169 * can be placed here. This name could also
170 * be changed to null for utility classes.
171 */
172 private String _name = RootFilter.NAME;
173
174 /**
175 * This holds a reference to the
176 * system logger that is being used.
177 */
178 private Logger _logger = ReferenceManager.getInstance().getLogger();
179
180 /**
181 * A reference to the reference manager in use
182 */
183 private ReferenceManager _refman = ReferenceManager.getInstance();
184
185 /**
186 * A reference to our Queue.
187 */
188 private Queue _queue;
189
190 /**
191 * The "servant" part of the client we're connected to.
192 */
193 private Client _client;
194
195 /**
196 * A reference to our DataHandler, if we have one
197 */
198 private CorbaDataHandler _dataHandler;
199
200 /**
201 * A name to identify the client
202 */
203 private String _clientname;
204
205 //---STATIC ATTRIBUTES---
206
207 }