1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.gwe.app.client.web.view;
18
19 import org.gwe.api.Session4ClientAPIEnhancer;
20 import org.gwe.app.client.SessionsRepository;
21 import org.gwe.app.client.config.ClientConfig;
22 import org.gwe.app.client.web.request.Param;
23 import org.gwe.persistence.model.HeadResourceInfo;
24 import org.gwe.utils.web.HtmlLink;
25 import org.gwe.utils.web.HtmlTable;
26 import org.gwe.utils.web.HtmlTableCell;
27 import org.gwe.utils.web.WebIcon;
28
29
30
31
32
33 public class HtmlClustersTable extends HtmlTable {
34
35 public static String getStatusIcon(Session4ClientAPIEnhancer session) {
36 return (session == null) ? "icon_error_sml.gif" : "icon_success_sml.gif";
37 }
38
39 public HtmlClustersTable(ClientConfig config) {
40 super("Status", "Name", "Host", "Queue Size", "Wait Connection Timeout", "Hijack Timeout", "Idle Timeout", "Variables");
41 SessionsRepository sessionsRepo = config.getSessionsRepository();
42 for (HeadResourceInfo obj : config.getGrid().getHeadResources()) {
43 Session4ClientAPIEnhancer session = null;
44 try {
45 session = sessionsRepo.getSession(obj, false);
46 } catch (Exception e) {}
47 WebIcon statusImage = WebIcon.getImageFor(session);
48 String tootip = (statusImage == WebIcon.STATUS_OK) ? "GWE enabled cluster" : "Cluster not enabled with GWE";
49 HtmlTableCell status = new HtmlTableCell("", tootip, null, statusImage);
50 HtmlTableCell name = new HtmlTableCell(obj.getName(), "", new HtmlClusterLink(obj.getName()));
51 addRow(status, name, obj.getHost(), obj.getQueueSize(), getMinutes(obj.getMaxWaitMins()), getMinutes(obj.getMaxHijackMins()), getMinutes(obj.getMaxIdleMins()), obj.getVarsAsMap());
52 }
53 }
54
55 private String getMinutes(float minutes) {
56 return minutes + " minutes";
57 }
58 }
59
60 class HtmlClusterLink extends HtmlLink {
61
62 public HtmlClusterLink(String clusterId) {
63 super(false, "cluster");
64 addParam(Param.CLUSTER_ID, clusterId);
65 }
66 }