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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/PacketSorter.java (file contents):
Revision 1.12 by tdb, Thu Mar 1 23:57:09 2001 UTC vs.
Revision 1.22 by tdb, Wed Feb 5 16:43:46 2003 UTC

# Line 1 | Line 1
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.ac.ukc.iscream.clientinterface;
22 > package uk.org.iscream.cms.server.clientinterface;
23  
24   //---IMPORTS---
25 < import uk.ac.ukc.iscream.util.*;
26 < import uk.ac.ukc.iscream.componentmanager.*;
27 < import uk.ac.ukc.iscream.core.*;
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 java.util.*;
29  
30   /**
# Line 33 | Line 53 | class PacketSorter extends Thread {
53  
54      /**
55       * Creates a new PacketSorter.
36     *
37     * @param queueMonitorInterval The interval at which to monitor the Queue
56       */
57 <    public PacketSorter(int queueMonitorInterval) {
58 <        _queue = new Queue();
59 <        // startup a monitor on this queue, every minute
60 <        String queueName = _name + " PacketSorterQueue";
61 <        _queue.startMonitor(queueMonitorInterval*1000, queueName);
57 >    public PacketSorter() {
58 >        // set the Thread name
59 >        setName("clientinterface.PacketSorter");
60 >        
61 >        ConfigurationProxy cp = ConfigurationProxy.getInstance();
62 >        String configName = "ClientInterface";
63 >        
64 >        // see if this Queue needs a size limit
65 >        try {
66 >            int queueSizeLimit = Integer.parseInt(cp.getProperty(configName, "Queue.SizeLimit"));
67 >            String queueRemoveAlgorithm = cp.getProperty(configName, "Queue.RemoveAlgorithm");
68 >            int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms);
69 >            if(algorithm != -1) {
70 >                _logger.write(toString(), Logger.DEBUG, "Starting Queue with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm);
71 >                // we have valid values, so lets start it.
72 >                _queue = new Queue(queueSizeLimit, algorithm);
73 >            }
74 >            else {
75 >                _logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm);
76 >                // just don't activate a limit
77 >                _queue = new Queue();
78 >            }
79 >            
80 >        } catch (PropertyNotFoundException e) {
81 >            _logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e);
82 >            // just don't activate a limit
83 >            _queue = new Queue();
84 >        } catch (NumberFormatException e) {
85 >            _logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e);
86 >            // just don't activate a limit
87 >            _queue = new Queue();
88 >        }
89 >        
90 >        // startup a monitor on this queue
91 >        try {
92 >            // try to get the interval, if this fails, we won't start up the monitor
93 >            int queueMonitorInterval = Integer.parseInt(cp.getProperty(configName, "Queue.MonitorInterval"));
94 >            String queueName = _name + " PacketSorterQueue";
95 >            _queue.startMonitor(queueMonitorInterval*1000, queueName);
96 >        } catch (PropertyNotFoundException e) {
97 >            _logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e);
98 >        }
99 >        
100          _hostMap = new HashMap();
101          _allHostDataList = new LinkedList();
102          _allHostsList = new LinkedList();
# Line 68 | Line 124 | class PacketSorter extends Thread {
124              XMLPacket packet = null;
125              
126              try {
127 <                XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
72 <                packet = xmlPacketMaker.createXMLPacket();
127 >                packet = _xmlCache.getXMLPacket(xml);
128              } catch(InvalidXMLException e) {
129                  _logger.write(toString(), Logger.ERROR, "Invalid XML: "+e);
130                  // skip the rest of this loop iteration
# Line 212 | Line 267 | class PacketSorter extends Thread {
267       * Overrides the {@link java.lang.Object#toString() Object.toString()}
268       * method to provide clean logging (every class should have this).
269       *
270 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
270 >     * This uses the uk.org.iscream.cms.util.NameFormat class
271       * to format the toString()
272       *
273       * @return the name of this class and its CVS revision
# Line 279 | Line 334 | class PacketSorter extends Thread {
334       * A list of all hosts.
335       */
336      private LinkedList _allHostsList;
337 +    
338 +    /**
339 +     * A reference to the XMLCache in use
340 +     */
341 +    private XMLCache _xmlCache = XMLCache.getInstance();
342      
343   //---STATIC ATTRIBUTES---
344  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines