33 |
|
|
34 |
|
/** |
35 |
|
* Creates a new PacketSorter. |
36 |
– |
* |
37 |
– |
* @param queueMonitorInterval The interval at which to monitor the Queue |
36 |
|
*/ |
37 |
< |
public PacketSorter(int queueMonitorInterval) { |
37 |
> |
public PacketSorter() { |
38 |
> |
// set the Thread name |
39 |
> |
setName("clientinterface.PacketSorter"); |
40 |
> |
|
41 |
|
_queue = new Queue(); |
42 |
< |
// startup a monitor on this queue, every minute |
43 |
< |
String queueName = _name + " PacketSorterQueue"; |
44 |
< |
_queue.startMonitor(queueMonitorInterval*1000, queueName); |
42 |
> |
// startup a monitor on this queue |
43 |
> |
try { |
44 |
> |
// try to get the interval, if this fails, we won't start up the monitor |
45 |
> |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
46 |
> |
int queueMonitorInterval = Integer.parseInt(cp.getProperty("ClientInterface", "Queue.MonitorInterval")); |
47 |
> |
String queueName = _name + " PacketSorterQueue"; |
48 |
> |
_queue.startMonitor(queueMonitorInterval*1000, queueName); |
49 |
> |
} catch (PropertyNotFoundException e) { |
50 |
> |
_logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e); |
51 |
> |
} |
52 |
> |
|
53 |
|
_hostMap = new HashMap(); |
54 |
|
_allHostDataList = new LinkedList(); |
55 |
|
_allHostsList = new LinkedList(); |
63 |
|
* loop forever processing and sending data. |
64 |
|
*/ |
65 |
|
public void run() { |
66 |
+ |
XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(); |
67 |
|
int qID = _queue.getQueue(); |
68 |
|
while(true) { |
69 |
|
// attempt to get some data from the Queue |
78 |
|
XMLPacket packet = null; |
79 |
|
|
80 |
|
try { |
81 |
< |
XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml); |
72 |
< |
packet = xmlPacketMaker.createXMLPacket(); |
81 |
> |
packet = xmlPacketMaker.createXMLPacket(xml); |
82 |
|
} catch(InvalidXMLException e) { |
83 |
|
_logger.write(toString(), Logger.ERROR, "Invalid XML: "+e); |
84 |
|
// skip the rest of this loop iteration |