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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/MonitorManager.java (file contents):
Revision 1.15 by tdb, Sat May 18 18:16:00 2002 UTC vs.
Revision 1.22 by tdb, Sun Sep 25 09:57:40 2005 UTC

# Line 1 | Line 1
1   /*
2   * i-scream central monitoring system
3 + * http://www.i-scream.org
4   * Copyright (C) 2000-2002 i-scream
5   *
6   * This program is free software; you can redistribute it and/or
# Line 23 | Line 24 | package uk.org.iscream.cms.server.client;
24   //---IMPORTS---
25   import uk.org.iscream.cms.server.componentmanager.*;
26   import uk.org.iscream.cms.server.core.*;
27 < import uk.org.iscream.cms.server.util.*;
28 < import java.util.*;
27 > import uk.org.iscream.cms.util.*;
28 > import java.util.LinkedList;
29 > import java.util.StringTokenizer;
30  
31   /**
32   * A manager for the Monitors.
# Line 34 | Line 36 | import java.util.*;
36   *
37   * This class then takes the feed of data coming in over CORBA from
38   * the ClientServant queue.  This data is then looked at to determine
39 < * type.  It then places it into either a data queue, a heartbeat queue or
40 < * an other queue, and all data in the the all queue.
39 > * type.  It then places it into either a data queue, or an other
40 > * queue, and all data in the the all queue.
41   *
42   * Monitors then read the data off the queue that they are interested in
43   * and process the data accordingly.
# Line 92 | Line 94 | public class MonitorManager extends Thread {
94              String queueRemoveAlgorithm = cp.getProperty(_name, "Queue.RemoveAlgorithm");
95              int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms);
96              if(algorithm != -1) {
97 <                _logger.write(toString(), Logger.DEBUG, "Starting 4 Queues with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm);
97 >                _logger.write(toString(), Logger.DEBUG, "Starting 3 Queues with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm);
98                  // we have valid values, so lets start it.
99                  _dataQueue = new Queue(queueSizeLimit, algorithm);
98                _heartbeatQueue = new Queue(queueSizeLimit, algorithm);
100                  _otherQueue = new Queue(queueSizeLimit, algorithm);
101                  _allQueue = new Queue(queueSizeLimit, algorithm);
102              }
# Line 103 | Line 104 | public class MonitorManager extends Thread {
104                  _logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm);
105                  // just don't activate a limit
106                  _dataQueue = new Queue();
106                _heartbeatQueue = new Queue();
107                  _otherQueue = new Queue();
108                  _allQueue = new Queue();
109              }
# Line 111 | Line 111 | public class MonitorManager extends Thread {
111              _logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e);
112              // just don't activate a limit
113              _dataQueue = new Queue();
114            _heartbeatQueue = new Queue();
114              _otherQueue = new Queue();
115              _allQueue = new Queue();
116          } catch (NumberFormatException e) {
117              _logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e);
118              // just don't activate a limit
119              _dataQueue = new Queue();
121            _heartbeatQueue = new Queue();
120              _otherQueue = new Queue();
121              _allQueue = new Queue();
122          }
# Line 128 | Line 126 | public class MonitorManager extends Thread {
126              // try to get the interval, if this fails, we won't start up the monitor
127              int queueMonitorInterval = Integer.parseInt(cp.getProperty(_name, "Queue.MonitorInterval"));
128              _dataQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " DataQueue");
131            _heartbeatQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " HeartbeatQueue");
129              _otherQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " OtherQueue");
130              _allQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " AllQueue");
131          } catch (PropertyNotFoundException e) {
# Line 181 | Line 178 | public class MonitorManager extends Thread {
178       * threads.
179       */
180      public void run() {
184        // construct now, and use multiple times
185        XMLPacketMaker xmlPacketMaker = new XMLPacketMaker();
186        
181          boolean run=true;
182          
183          // keep these out here, saves recreating the object
# Line 200 | Line 194 | public class MonitorManager extends Thread {
194              XMLPacket packet = null;
195              
196              try {
197 <                packet = xmlPacketMaker.createXMLPacket(xml);
197 >                packet = _xmlCache.getXMLPacket(xml);
198              } catch(InvalidXMLException e) {
199                  _logger.write(toString(), Logger.ERROR, "Invalid XML: "+e);
200                  // skip the rest of this loop iteration
201                  continue;
202              }
203 +
204 +            if(packet == null) {
205 +                _logger.write(toString(), Logger.WARNING, "Got a null packet when parsing: "+xml);
206 +                // skip to next packet
207 +                continue;
208 +            }
209              
210              // examine the packet and place it in the relevant outgoing queue
211 <            if(packet.getParam("packet.attributes.type").equals("data")) {
211 >            if(packet.getParam("packet.attributes.type") != null &&
212 >               packet.getParam("packet.attributes.type").equals("data")) {
213                  _dataQueue.add(packet);
214              }
214            else if(packet.getParam("packet.attributes.type").equals("heartbeat")) {
215                _heartbeatQueue.add(packet);
216            }
215              else {
216                  _otherQueue.add(packet);
217              }
# Line 226 | Line 224 | public class MonitorManager extends Thread {
224       * Overrides the {@link java.lang.Object#toString() Object.toString()}
225       * method to provide clean logging (every class should have this).
226       *
227 <     * This uses the uk.org.iscream.cms.server.util.FormatName class
227 >     * This uses the uk.org.iscream.cms.util.FormatName class
228       * to format the toString()
229       *
230       * @return the name of this class and its CVS revision
# Line 252 | Line 250 | public class MonitorManager extends Thread {
250      
251      /**
252       * Allows Monitors to obtain
255     * the queue of heatbeat packets
256     */
257    public Queue getHeartbeatQueue() {
258        return _heartbeatQueue;
259    }
260    
261    /**
262     * Allows Monitors to obtain
253       * the queue of all other packets
254       */
255      public Queue getOtherQueue() {
# Line 325 | Line 315 | public class MonitorManager extends Thread {
315      private Queue _dataQueue;
316      
317      /**
328     * Outgoing heartbeat Queue
329     */
330    private Queue _heartbeatQueue;
331    
332    /**
318       * Outgoing other Queue
319       */
320      private Queue _otherQueue;
# Line 338 | Line 323 | public class MonitorManager extends Thread {
323       * Outgoing ALL Queue
324       */
325      private Queue _allQueue;
326 +    
327 +    /**
328 +     * A reference to the XMLCache in use
329 +     */
330 +    private XMLCache _xmlCache = XMLCache.getInstance();
331      
332   //---STATIC ATTRIBUTES---
333  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines