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.7 by tdb, Thu Mar 15 18:59:50 2001 UTC vs.
Revision 1.10 by tdb, Thu Mar 22 17:54:43 2001 UTC

# Line 46 | Line 46 | class MonitorManager extends Thread {
46          _logger.write(toString(), Logger.SYSINIT, "Initialising");
47          _logger.write(toString(), Logger.SYSMSG, "Creating monitor pipeline for plugin monitors ...");
48          
49 +        // get the config proxy
50 +        ConfigurationProxy cp = ConfigurationProxy.getInstance();
51 +        
52 +        // get the configuration for our outgoing queue's
53 +        
54 +        // see if these Queue's need a size limit
55 +        try {
56 +            int queueSizeLimit = Integer.parseInt(cp.getProperty(_name, "Queue.SizeLimit"));
57 +            String queueRemoveAlgorithm = cp.getProperty(_name, "Queue.RemoveAlgorithm");
58 +            int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms);
59 +            if(algorithm != -1) {
60 +                _logger.write(toString(), Logger.DEBUG, "Starting 4 Queues with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm);
61 +                // we have valid values, so lets start it.
62 +                _dataQueue = new Queue(queueSizeLimit, algorithm);
63 +                _heartbeatQueue = new Queue(queueSizeLimit, algorithm);
64 +                _otherQueue = new Queue(queueSizeLimit, algorithm);
65 +                _allQueue = new Queue(queueSizeLimit, algorithm);
66 +            }
67 +            else {
68 +                _logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm);
69 +                // just don't activate a limit
70 +                _dataQueue = new Queue();
71 +                _heartbeatQueue = new Queue();
72 +                _otherQueue = new Queue();
73 +                _allQueue = new Queue();
74 +            }
75 +        } catch (PropertyNotFoundException e) {
76 +            _logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e);
77 +            // just don't activate a limit
78 +            _dataQueue = new Queue();
79 +            _heartbeatQueue = new Queue();
80 +            _otherQueue = new Queue();
81 +            _allQueue = new Queue();
82 +        } catch (NumberFormatException e) {
83 +            _logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e);
84 +            // just don't activate a limit
85 +            _dataQueue = new Queue();
86 +            _heartbeatQueue = new Queue();
87 +            _otherQueue = new Queue();
88 +            _allQueue = new Queue();
89 +        }
90 +        
91 +        // startup monitors on these queues
92 +        try {
93 +            // try to get the interval, if this fails, we won't start up the monitor
94 +            int queueMonitorInterval = Integer.parseInt(cp.getProperty(_name, "Queue.MonitorInterval"));
95 +            _dataQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " DataQueue");
96 +            _heartbeatQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " HeartbeatQueue");
97 +            _otherQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " OtherQueue");
98 +            _allQueue.startMonitor(queueMonitorInterval*1000, ClientMain._monitorQueue, _name + " AllQueue");
99 +        } catch (PropertyNotFoundException e) {
100 +            _logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e);
101 +        }
102 +        
103          // get the configuration for this plug-in setup
104 <        Configuration config = _refman.getCM().getConfiguration(_name);
105 <        String pluginsPackage = config.getProperty("Monitor.PluginsPackage");
106 <        String pluginsList = config.getProperty("Monitor.Plugins");
104 >        String pluginsPackage, pluginsList;
105 >        try {
106 >            pluginsPackage = cp.getProperty(_name, "Monitor.PluginsPackage");
107 >            pluginsList = cp.getProperty(_name, "Monitor.Plugins");
108 >        } catch(PropertyNotFoundException e) {
109 >            _logger.write(toString(), Logger.WARNING, "Unable to get required configuration, Monitor's will not be activated: "+e);
110 >            // setting these will ensure we don't build a pipeline
111 >            pluginsPackage = "";
112 >            pluginsList = "";
113 >        }
114          
115          StringTokenizer st = new StringTokenizer(pluginsList, ";");
116          
# Line 104 | Line 165 | class MonitorManager extends Thread {
165                  // skip the rest of this loop iteration
166                  continue;
167              }
168 <                        
169 <            // for each monitor in the pipeline...
170 <            Iterator pluginMonitors = _monitorPipeline.iterator();
171 <            while (pluginMonitors.hasNext()){
111 <                PluginMonitor monitor = (PluginMonitor)pluginMonitors.next();
112 <                monitor.analysePacket(packet);
168 >            
169 >            // examine the packet and place it in the relevant outgoing queue
170 >            if(packet.getParam("packet.attributes.type").equals("data")) {
171 >                _dataQueue.add(packet);
172              }
173 +            else if(packet.getParam("packet.attributes.type").equals("heartbeat")) {
174 +                _heartbeatQueue.add(packet);
175 +            }
176 +            else {
177 +                _otherQueue.add(packet);
178 +            }
179 +            // always add to all queue
180 +            _allQueue.add(packet);
181          }
182      }
183  
# Line 133 | Line 200 | class MonitorManager extends Thread {
200   //---PRIVATE METHODS---
201  
202   //---ACCESSOR/MUTATOR METHODS---
203 <
203 >    
204 >    public Queue getDataQueue() {
205 >        return _dataQueue;
206 >    }
207 >    
208 >    public Queue getHeartbeatQueue() {
209 >        return _heartbeatQueue;
210 >    }
211 >    
212 >    public Queue getOtherQueue() {
213 >        return _otherQueue;
214 >    }
215 >    
216 >    public Queue getAllQueue() {
217 >        return _allQueue;
218 >    }
219 >    
220   //---ATTRIBUTES---
221  
222      /**
# Line 159 | Line 242 | class MonitorManager extends Thread {
242      private ReferenceManager _refman = ReferenceManager.getInstance();
243      
244      /**
245 <     * A reference to our Queue
245 >     * A reference to our incoming Queue
246       */
247      private Queue _queue;
248      
249      /**
250 <     * Our queue ID
250 >     * Our incoming queue ID
251       */
252      private int _qID;
253      
# Line 177 | Line 260 | class MonitorManager extends Thread {
260       * LinkedList for holding the PluginMonitor objects (the pipeline).
261       */
262      private LinkedList _monitorPipeline = new LinkedList();
263 <
263 >    
264 >    /**
265 >     * Outgoing data Queue
266 >     */
267 >    private Queue _dataQueue;
268 >    
269 >    /**
270 >     * Outgoing heartbeat Queue
271 >     */
272 >    private Queue _heartbeatQueue;
273 >    
274 >    /**
275 >     * Outgoing other Queue
276 >     */
277 >    private Queue _otherQueue;
278 >    
279 >    /**
280 >     * Outgoing ALL Queue
281 >     */
282 >    private Queue _allQueue;
283 >    
284   //---STATIC ATTRIBUTES---
285  
286      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines