1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.clientinterface; |
2 |
> |
package uk.org.iscream.clientinterface; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.ac.ukc.iscream.util.*; |
6 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
< |
import uk.ac.ukc.iscream.core.*; |
5 |
> |
import uk.org.iscream.util.*; |
6 |
> |
import uk.org.iscream.componentmanager.*; |
7 |
> |
import uk.org.iscream.core.*; |
8 |
|
import java.util.*; |
9 |
|
|
10 |
|
/** |
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); |
41 |
> |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
42 |
> |
String configName = "ClientInterface"; |
43 |
> |
|
44 |
> |
// see if this Queue needs a size limit |
45 |
> |
try { |
46 |
> |
int queueSizeLimit = Integer.parseInt(cp.getProperty(configName, "Queue.SizeLimit")); |
47 |
> |
String queueRemoveAlgorithm = cp.getProperty(configName, "Queue.RemoveAlgorithm"); |
48 |
> |
int algorithm = StringUtils.getStringPos(queueRemoveAlgorithm, Queue.algorithms); |
49 |
> |
if(algorithm != -1) { |
50 |
> |
_logger.write(toString(), Logger.DEBUG, "Starting Queue with size limit of "+queueSizeLimit+", using remove algorithm "+queueRemoveAlgorithm); |
51 |
> |
// we have valid values, so lets start it. |
52 |
> |
_queue = new Queue(queueSizeLimit, algorithm); |
53 |
> |
} |
54 |
> |
else { |
55 |
> |
_logger.write(toString(), Logger.WARNING, "Bad Queue Algorithm configuration, not known: "+queueRemoveAlgorithm); |
56 |
> |
// just don't activate a limit |
57 |
> |
_queue = new Queue(); |
58 |
> |
} |
59 |
> |
|
60 |
> |
} catch (PropertyNotFoundException e) { |
61 |
> |
_logger.write(toString(), Logger.DEBUG, "Optional config not set: "+e); |
62 |
> |
// just don't activate a limit |
63 |
> |
_queue = new Queue(); |
64 |
> |
} catch (NumberFormatException e) { |
65 |
> |
_logger.write(toString(), Logger.WARNING, "Bad Queue SizeLimit configuration: "+e); |
66 |
> |
// just don't activate a limit |
67 |
> |
_queue = new Queue(); |
68 |
> |
} |
69 |
> |
|
70 |
> |
// startup a monitor on this queue |
71 |
> |
try { |
72 |
> |
// try to get the interval, if this fails, we won't start up the monitor |
73 |
> |
int queueMonitorInterval = Integer.parseInt(cp.getProperty(configName, "Queue.MonitorInterval")); |
74 |
> |
String queueName = _name + " PacketSorterQueue"; |
75 |
> |
_queue.startMonitor(queueMonitorInterval*1000, queueName); |
76 |
> |
} catch (PropertyNotFoundException e) { |
77 |
> |
_logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e); |
78 |
> |
} |
79 |
> |
|
80 |
|
_hostMap = new HashMap(); |
81 |
|
_allHostDataList = new LinkedList(); |
82 |
|
_allHostsList = new LinkedList(); |
248 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
249 |
|
* method to provide clean logging (every class should have this). |
250 |
|
* |
251 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
251 |
> |
* This uses the uk.org.iscream.util.NameFormat class |
252 |
|
* to format the toString() |
253 |
|
* |
254 |
|
* @return the name of this class and its CVS revision |