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.10 by tdb, Thu Mar 1 16:53:16 2001 UTC vs.
Revision 1.11 by tdb, Thu Mar 1 17:29:46 2001 UTC

# Line 41 | Line 41 | class PacketSorter extends Thread {
41          // startup a monitor on this queue, every minute
42          String queueName = _name + " PacketSorterQueue";
43          _queue.startMonitor(queueMonitorInterval*1000, queueName);
44 <        _hostMap = Collections.synchronizedMap(new HashMap());
45 <        _allHostDataList = Collections.synchronizedList(new LinkedList());
46 <        _allHostsList = Collections.synchronizedList(new LinkedList());
44 >        _hostMap = new HashMap();
45 >        _allHostDataList = new LinkedList();
46 >        _allHostsList = new LinkedList();
47          _logger.write(toString(), Logger.SYSINIT, "created");
48      }
49      
# Line 82 | Line 82 | class PacketSorter extends Thread {
82                  String host = packet.getParam("packet.attributes.machine_name");
83                  
84                  // look in the hostMap to see if anyone wants this data
85 <                if(_hostMap.containsKey(host)) {
86 <                    List list = (List) _hostMap.get(host);
87 <                    Iterator i = list.iterator();
88 <                    // push the data to the listening Handler's queue
89 <                    while(i.hasNext()) {
90 <                        ((Queue) i.next()).add(xml);
85 >                synchronized(this) {
86 >                    if(_hostMap.containsKey(host)) {
87 >                        LinkedList list = (LinkedList) _hostMap.get(host);
88 >                        Iterator i = list.iterator();
89 >                        // push the data to the listening Handler's queue
90 >                        while(i.hasNext()) {
91 >                            ((Queue) i.next()).add(xml);
92 >                        }
93                      }
94                  }
95                  
96                  // any handler in this list wants all packets, so send
97                  // it on to them regardless
98 <                Iterator i = _allHostDataList.iterator();
99 <                while(i.hasNext()) {
100 <                    ((Queue) i.next()).add(xml);
101 <                }
98 >                synchronized(this) {
99 >                    Iterator i = _allHostDataList.iterator();
100 >                    while(i.hasNext()) {
101 >                        ((Queue) i.next()).add(xml);
102 >                    }
103 >                }
104              }
105              else {
106                  // always send this packet to all hosts, because it's
107                  // "extra" data, not host data
108 <                Iterator i = _allHostsList.iterator();
109 <                while(i.hasNext()) {
110 <                    ((Queue) i.next()).add(xml);
111 <                }
108 >                synchronized(this) {
109 >                    Iterator i = _allHostsList.iterator();
110 >                    while(i.hasNext()) {
111 >                        ((Queue) i.next()).add(xml);
112 >                    }
113 >                }
114              }
115          }
116      }
# Line 141 | Line 147 | class PacketSorter extends Thread {
147                  }
148                  else {
149                      // we don't, so create a list and put it in the map
150 <                    List list = Collections.synchronizedList(new LinkedList());
150 >                    LinkedList list = new LinkedList();
151                      list.add(dhQueue);
152                      _hostMap.put(host, list);
153                  }
# Line 176 | Line 182 | class PacketSorter extends Thread {
182                  // this should in reality always be true, but best check
183                  if(_hostMap.containsKey(host)) {
184                      // get the list and remove the host in question
185 <                    List list = (List) _hostMap.get(host);
185 >                    LinkedList list = (LinkedList) _hostMap.get(host);
186                      list.remove(dhQueue);
187                      // if the list is now empty, we might as well remove it
188                      if(list.size()==0) {
# Line 249 | Line 255 | class PacketSorter extends Thread {
255       * A HashMap to store lists of Queue's (in the DataHandlers)
256       * in a way that can be easily accessed when data comes in.
257       */
258 <    private Map _hostMap;
258 >    private HashMap _hostMap;
259      
260      /**
261       * A list specifically for a Queue's associated with DataHandlers
262       * that want all host information.
263       */
264 <    private List _allHostDataList;
264 >    private LinkedList _allHostDataList;
265      
266      /**
267       * A list of all hosts.
268       */
269 <    private List _allHostsList;
269 >    private LinkedList _allHostsList;
270      
271   //---STATIC ATTRIBUTES---
272  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines