1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.util; |
2 |
> |
package uk.org.iscream.cms.server.util; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.ac.ukc.iscream.util.*; |
5 |
> |
import uk.org.iscream.cms.server.util.*; |
6 |
|
|
7 |
|
/** |
8 |
|
* This class monitors a given Queue at regular intervals, |
34 |
|
* @param name A name to identify the source Queue with |
35 |
|
*/ |
36 |
|
public QueueMonitor (Queue sourceQueue, Queue destQueue, long interval, String name) { |
37 |
+ |
// set the Thread name |
38 |
+ |
setName("util.QueueMonitor"); |
39 |
+ |
|
40 |
|
_sourceQueue = sourceQueue; |
41 |
|
_destQueue = destQueue; |
42 |
|
_interval = interval; |
58 |
|
try { Thread.sleep(_interval); } catch(Exception e) {} |
59 |
|
// check the Queue |
60 |
|
String status = _sourceQueue.xmlStatus(); |
61 |
+ |
// get a hash of our Queue (for identification) |
62 |
+ |
String hashCode = String.valueOf(_sourceQueue.hashCode()); |
63 |
|
// create some XML |
64 |
|
String date = new Long(System.currentTimeMillis()/((long) 1000)).toString(); |
65 |
< |
String xml = "<packet type=\"queueStat\" date=\""+date+"\" name=\""+_srcName+"\">" + status + "</packet>"; |
65 |
> |
String xml = "<packet type=\"queueStat\" date=\""+date+"\" name=\""+_srcName+"\" hashCode=\""+hashCode+"\">" + status + "</packet>"; |
66 |
|
// write XML to destination Queue |
67 |
|
_destQueue.add(xml); |
68 |
|
} |
74 |
|
public void shutdown() { |
75 |
|
// this will stop the main loop |
76 |
|
_run = false; |
77 |
+ |
// get a hash of our Queue (for identification) |
78 |
+ |
String hashCode = String.valueOf(_sourceQueue.hashCode()); |
79 |
+ |
// create some XML |
80 |
+ |
String date = new Long(System.currentTimeMillis()/((long) 1000)).toString(); |
81 |
+ |
String xml = "<packet type=\"queueStat\" date=\""+date+"\" name=\""+_srcName+"\" hashCode=\""+hashCode+"\" shutdown=\"true\"></packet>"; |
82 |
+ |
// write XML to destination Queue |
83 |
+ |
_destQueue.add(xml); |
84 |
|
} |
85 |
|
|
86 |
|
/** |
87 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
88 |
|
* method to provide clean logging (every class should have this). |
89 |
|
* |
90 |
< |
* This uses the uk.ac.ukc.iscream.util.FormatName class |
90 |
> |
* This uses the uk.org.iscream.cms.server.util.FormatName class |
91 |
|
* to format the toString() |
92 |
|
* |
93 |
|
* @return the name of this class and its CVS revision |