1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* Copyright (C) 2000-2002 i-scream |
4 |
+ |
* |
5 |
+ |
* This program is free software; you can redistribute it and/or |
6 |
+ |
* modify it under the terms of the GNU General Public License |
7 |
+ |
* as published by the Free Software Foundation; either version 2 |
8 |
+ |
* of the License, or (at your option) any later version. |
9 |
+ |
* |
10 |
+ |
* This program is distributed in the hope that it will be useful, |
11 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
+ |
* GNU General Public License for more details. |
14 |
+ |
* |
15 |
+ |
* You should have received a copy of the GNU General Public License |
16 |
+ |
* along with this program; if not, write to the Free Software |
17 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
+ |
*/ |
19 |
+ |
|
20 |
|
//---PACKAGE DECLARATION--- |
21 |
< |
package uk.ac.ukc.iscream.conient; |
21 |
> |
package uk.org.iscream.cms.conient; |
22 |
|
|
23 |
|
//---IMPORTS--- |
24 |
< |
import uk.ac.ukc.iscream.util.*; |
25 |
< |
import uk.ac.ukc.iscream.conient.datacomponents.*; |
24 |
> |
import uk.org.iscream.cms.server.util.*; |
25 |
> |
import uk.org.iscream.cms.conient.datacomponents.*; |
26 |
|
import javax.swing.*; |
27 |
|
import javax.swing.border.*; |
28 |
|
import java.util.*; |
30 |
|
import java.awt.event.*; |
31 |
|
|
32 |
|
/** |
33 |
+ |
* This class allows a window to be shown which displays |
34 |
+ |
* internel server queue information as sent by the i-scream |
35 |
+ |
* server. |
36 |
|
* |
37 |
+ |
* This allows a check to be made on the current performance of |
38 |
+ |
* the internal queues. |
39 |
+ |
* |
40 |
|
* @author $Author$ |
41 |
|
* @version $Id$ |
42 |
|
*/ |
54 |
|
//---CONSTRUCTORS--- |
55 |
|
|
56 |
|
/** |
57 |
< |
* |
57 |
> |
* Constructs a new frame |
58 |
|
*/ |
59 |
|
public QueueFrame() { |
60 |
|
super("Server Queue Status"); |
61 |
< |
//addVisibleDataComponent(_conent, new StringDataComponent("Host Name", "packet.attributes.machine_name")); |
62 |
< |
|
38 |
< |
getContentPane().add(_content, "Center"); |
61 |
> |
JScrollPane scrollPane = new JScrollPane(_content,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED , JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
62 |
> |
getContentPane().add(scrollPane, "Center"); |
63 |
|
JButton close = new JButton("Close Window"); |
64 |
|
close.addActionListener(new ActionListener() { |
65 |
|
public void actionPerformed(ActionEvent e) { |
105 |
|
|
106 |
|
//---PRIVATE METHODS--- |
107 |
|
|
108 |
+ |
/** |
109 |
+ |
* Constructs and adds a new Queue panel to the |
110 |
+ |
* current window. This happens when a new queue packet |
111 |
+ |
* is detected |
112 |
+ |
* |
113 |
+ |
* @param packet the packet to obtain the queue data from |
114 |
+ |
*/ |
115 |
|
private void addQueue(XMLPacket packet) { |
116 |
|
HashMap newQueue = new HashMap(); |
117 |
|
String queueName = packet.getParam("packet.attributes.name"); |
118 |
|
String queueHashCode = packet.getParam("packet.attributes.hashCode"); |
119 |
|
VisibleDataComponent date = new DateDataComponent("Last timestamp", "packet.attributes.date"); |
120 |
|
VisibleDataComponent total = new StringDataComponent("Total queued to date", "packet.queue.attributes.total"); |
121 |
+ |
VisibleDataComponent max = new StringDataComponent("Maximum queue size", "packet.queue.attributes.maxSize"); |
122 |
|
newQueue.put("packet.attributes.name", new StringDataComponent("Name", "packet.attributes.name")); |
123 |
|
newQueue.put("packet.queue.attributes.total", total); |
124 |
+ |
newQueue.put("packet.queue.attributes.maxSize", max); |
125 |
|
newQueue.put("packet.attributes.date", date); |
126 |
+ |
|
127 |
|
JPanel newQueueDisplay = new JPanel(); |
128 |
|
newQueueDisplay.setLayout(new BoxLayout(newQueueDisplay, BoxLayout.Y_AXIS)); |
129 |
|
newQueueDisplay.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), queueName)); |
130 |
|
newQueueDisplay.add(date); |
131 |
|
newQueueDisplay.add(total); |
132 |
+ |
newQueueDisplay.add(max); |
133 |
|
_queuesDisplays.put(queueHashCode, newQueueDisplay); |
134 |
|
try { |
135 |
|
SwingSafeAdd task = new SwingSafeAdd(_content, newQueueDisplay); |
140 |
|
pack(); |
141 |
|
_queues.put(queueHashCode, newQueue); |
142 |
|
} |
143 |
< |
|
143 |
> |
|
144 |
> |
/** |
145 |
> |
* Updates a queue panel with new data |
146 |
> |
* |
147 |
> |
* @param packet the packet to obtain the new data from |
148 |
> |
* @throws DataFormatException if the packet contains invalid data |
149 |
> |
*/ |
150 |
|
private void updateQueueInformation(XMLPacket packet) throws DataFormatException { |
151 |
|
String queueHashCode = packet.getParam("packet.attributes.hashCode"); |
152 |
|
|
185 |
|
// note we ignore all other attributes |
186 |
|
} |
187 |
|
if(components.containsKey(dataKey)) { |
188 |
< |
((DataComponent) components.get(dataKey)).setValue(packet.getParam(dataKey)); |
188 |
> |
((DataComponent) components.get(dataKey)).setValue(packet); |
189 |
|
} |
190 |
|
} |
191 |
|
} |
201 |
|
* are stored here. |
202 |
|
*/ |
203 |
|
private HashMap _queues = new HashMap(); |
204 |
+ |
|
205 |
+ |
/** |
206 |
+ |
* The Panels on the display hooked to the queue hashid |
207 |
+ |
*/ |
208 |
|
private HashMap _queuesDisplays = new HashMap(); |
209 |
|
|
210 |
+ |
/** |
211 |
+ |
* The box to lay queue panels into. |
212 |
+ |
*/ |
213 |
|
private Box _content = Box.createVerticalBox(); |
214 |
|
|
215 |
|
//---STATIC ATTRIBUTES--- |