Project

General

Profile

Download (7.78 KB) Statistics
| Branch: | Tag: | Revision:
1
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
3
<%@page import="eu.etaxonomy.cdm.server.Bootloader"%>
4
<%@page import="java.util.Set" %>
5
<%@page import="java.net.URL" %>
6
<%@page import="eu.etaxonomy.cdm.server.CdmInstanceProperties"%>
7
<%@page import="eu.etaxonomy.cdm.server.JvmManager" %>
8
<%@page import="java.io.IOException"%>
9
<%!
10

    
11
public void printMemoryUsage(java.lang.management.MemoryUsage memoryUsage, Long recommended, String label, String barWidth, String cssColorUsed, String cssColorMax, JspWriter writer) throws IOException{
12

    
13
  float mb = 1024 * 1024;
14
  float gb = mb * 1024;
15
  float max = memoryUsage.getMax() / mb;
16
  float used = memoryUsage.getUsed() / mb;
17
  float percent = used * 100 / max;
18
  float recommendedMB = recommended / mb;
19

    
20
  writer.append("<span class=\"memory-usage\">").append(label + "(" + used + " of "  + max+ " MB, recommended: "  + recommendedMB + " MB)&nbsp;")
21
  .append("<div style=\"height: 100%; width:")
22
  .append(barWidth).append(";background-color:").append(cssColorMax).append("\">")
23
  .append("<div style=\"background-color:" + cssColorUsed + "; width:" + percent + "%\">&nbsp;</div></div></span>");
24

    
25
}
26

    
27
// the servelt context must use the class loader of the Bootloader class otherwise
28
// getting the status will not work in mulithreading environments !!!
29
Bootloader bootloader = Bootloader.getBootloader();
30

    
31
%>
32

    
33
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
34

    
35
<head>
36
  <title>CDM Server</title>
37
  <meta http-equiv="refresh" content="3; URL=index.jsp" />
38
  <link type="text/css" rel="stylesheet" media="all" href="/css/style.css" />
39
  <link type="text/css" rel="stylesheet" media="all" href="/css/server.css" />
40
  <script type="text/javascript" src="/js/jquery.js"></script>
41
  <script type="text/javascript" src="/js/oai-pmh-status.js"></script>
42
</head>
43
<body class="layout-main">
44
    <div id="page" class="clearfix">
45
      <div id="header-wrapper">
46
        <div id="header" class="clearfix">
47
          <div id="header-first">
48
            <div id="logo">
49
              </div>
50
        <h1>CDM Server</h1>
51
          </div><!-- /header-first -->
52
        </div><!-- /header -->
53
      </div><!-- /header-wrapper -->
54

    
55
      <div id="primary-menu-wrapper" class="clearfix">
56
        <div id="primary-menu">
57
            <div id="version"><%= bootloader.readCdmRemoteVersion() %></div>
58
        </div><!-- /primary_menu -->
59
      </div><!-- /primary-menu-wrapper -->
60

    
61
      <div id="main-wrapper">
62
        <div id="main" class="clearfix">
63

    
64
          <div id="sidebar-first">
65
          </div><!-- /sidebar-first -->
66

    
67
          <div id="content-wrapper">
68
            <div id="content">
69
                <!-- ============================= -->
70
                <div class="block-wrapper">
71
                  <h2 class="title block-title pngfix">Server Status</h2>
72
                  <div class="block" id="status">
73
                     <%
74
                       printMemoryUsage(JvmManager.getHeapMemoryUsage(), bootloader.recommendedMinimumSpace(Bootloader.HEAP_CDMSERVER, Bootloader.HEAP_PER_INSTANCE, null), "HeapUsage", "100%", "#F48B65", "#65B1F4", out);
75
                       printMemoryUsage(JvmManager.getPermGenSpaceUsage(), bootloader.recommendedMinimumSpace(Bootloader.PERM_GEN_SPACE_CDMSERVER, Bootloader.PERM_GEN_SPACE_PER_INSTANCE, null), "PermGenSpaceUsage", "100%","#F48B65", "#65B1F4", out);
76
                     %>
77
                  </div>
78
                </div>
79

    
80

    
81
                <div class="block-wrapper">
82
                  <div class="block" id="datasources">
83
                    <h2 class="title block-title pngfix">CDM Server Instances</h2>
84
                    <table>
85
                      <tr><th>Path</th><th> </th><th>Database Url</th><th>Status</th><th>OAI-PMH Provider</th></tr>
86
                                            <%
87
                                           java.util.Set<CdmInstanceProperties> configAndStatus = bootloader.getConfigAndStatus();
88
                                           if(configAndStatus != null){
89
                                             int i = 0;
90
                                             for(CdmInstanceProperties props : configAndStatus){
91
                                               i++;
92
                                               String basePath = "/" + props.getDataSourceName();
93
                                                   URL fullURL = new URL(request.getScheme(),
94
                                                           request.getServerName(),
95
                                                           request.getServerPort(),
96
                                                           basePath);
97

    
98
                                                   String oddOrEven = i % 2 == 0 ? "odd" : "even";
99
                                                   String noBottomBorder = props.getStatus().equals(CdmInstanceProperties.Status.error) ? " style=\"border-bottom:none;\"" : "";
100

    
101
                                               out.append("<tr class=\"entry " + oddOrEven + "\" " +noBottomBorder+ ">");
102
                                               out.append("<td class=\"base-url\"><a href=\"" + fullURL + "\">" + basePath + "</a></td>");
103
                                               out.append("<td class=\"test-url\"><a href=\"" + fullURL + "/portal/classification\">Test</a></td>");
104
                                                   out.append("<td class=\"db-url\">" + props.getUrl() + "</td>");
105
                                                   out.append("<td class=\"status " + props.getStatus() + "\">" + props.getStatus() + "</td>");
106

    
107
                                                   // OAI-PMH Status will be requested using javascript
108
                                                   out.append("<td class=\"oai-pmh\">requesting status ...</td>");
109
                                                   out.append("</tr>");
110
                                                   if(props.getStatus().equals(CdmInstanceProperties.Status.error) || !props.isEnabled()){
111
                                                     out.append("<tr class=\"error-log " + oddOrEven + "\">");
112
                                                     out.append("<td></td><td  class=\"error\" colspan=\"4\">");
113
                                                         for( String problem : props.getProblems()){
114
                                                           out.append("<div>" + problem + "</div>");
115
                                                         }
116
                                                     out.append("</td>");
117
                                                     out.append("</tr>");
118
                                                   }
119
                                             }
120
                                           }
121
                                           %>
122
                    </table>
123
                  </div>
124
                </div>
125
<%/*
126
                <div class="block-wrapper">
127
                  <div class="block" id="test">
128
                    <h2 class="title block-title pngfix">Test your CDM Server (using the default data base)</h2>
129
                    <form name="input" action="/default/portal/taxon/find" method="get">
130
                    <input type="text" name="query"></br>
131
                    <input type="submit" value="submit">
132
                    </form>
133
                  </div>
134
                </div><!-- test -->
135
*/
136
%>
137
                <!-- ============================= -->
138
            </div><!-- /content -->
139
          </div><!-- /content-wrapper -->
140

    
141
          <div id="footer" class="clearfix">
142
          The CDM Server is a component of the <a href="http://wp5.e-taxonomy.eu/">EDIT Platform for Cybertaxonomy</a>.
143
          </div><!-- /footer -->
144

    
145
        </div><!-- /main -->
146
      </div><!-- /main-wrapper -->
147
    </div><!-- /page -->
148
</body>
149
</html>
(2-2/2)