Project

General

Profile

« Previous | Next » 

Revision 0c065404

Added by Andreas Kohlbecker over 10 years ago

View differences:

.gitattributes
43 43
src/main/webapp/favicon.ico -text
44 44
src/main/webapp/index.html -text
45 45
src/main/webapp/index.jsp -text
46
src/main/webapp/js/instance-status.js -text
46 47
src/main/webapp/js/jquery.js -text
47 48
src/main/webapp/js/jquery.min.js -text
49
src/main/webapp/js/memory-status.js -text
48 50
src/main/webapp/js/oai-pmh-status.js -text
49
src/main/webapp/js/server-status.js -text
50 51
src/main/webapp/manage/BootloaderService.jsp -text
52
src/main/webapp/manage/MemoryService.jsp -text
51 53
src/main/webapp/manage/index.jsp -text
52 54
src/main/webapp/robots.txt -text
53 55
src/site/apt/getting-started.apt -text
src/main/webapp/js/instance-status.js
1

  
2
$(document).ready(function(){
3

  
4
  function updateInstaceStatus(){
5
      $.getJSON(
6
        "BootloaderService.jsp",
7
        function(data){
8
          for(var i in data) {
9
            var dataSourceName = data[i].dataSourceName;
10
            var status = data[i].status;
11
            var problems = data[i].problems;
12
            $('#' + dataSourceName + ' .status').html(status).attr('class', 'status '+ status);
13
            if(data[i].status == "error" || !data[i].enabled){
14
             /*out.append("<tr class=\"error-log " + oddOrEven + "\">");
15
                                                     out.append("<td></td><td  class=\"error\" colspan=\"4\">");
16
                                                         for( String problem : props.getProblems()){
17
                                                           out.append("<div>" + problem + "</div>");
18
                                                         }
19
                                                     out.append("</td>");
20
                                                     out.append("</tr>");
21
              */
22
              if($('#' + dataSourceName + '-error-log').size() == 0){
23
                // append new table row
24
                var oddeven = $('#' + dataSourceName).attr('class').indexOf('even') > -1 ? 'even': 'odd';
25
                $('#' + dataSourceName).after('<tr id="' + dataSourceName + '-error-log" class="error-log ' + oddeven + '"><td></td><td class="error message" colspan="4"></td></tr>');
26
              }
27
              $('#' + dataSourceName + '-error-log .message').html('<h1>x</h1>');
28
              for(var k in data[i].problems){
29
                $('#' + dataSourceName + '-error-log .message').appendTo('<div>' + data[i].problems[k] + '</div>');
30
              }
31
            }
32
          }
33
        });
34

  
35
    setTimeout(function(){
36
      updateInstaceStatus()
37
      }, 1000);
38
  }
39

  
40
  updateInstaceStatus();
41

  
42
});
src/main/webapp/js/memory-status.js
1

  
2
$(document).ready(function(){
3

  
4
  function updateMemoryStatus() {
5
     $.getJSON(
6
        "MemoryService.jsp",
7
        function(data){
8
          $("#status").html(''); // make empty
9
          $("#status").append(memoryUsageEntry(data.heapMemoryUsage, data.recommendedMinimumHeap, "HeapUsage", "100%", "#F48B65", "#65B1F4"));
10
          $("#status").append(memoryUsageEntry(data.permGenSpaceUsage, data.recommendedMinimumPermGenSpace, "PermGenSpaceUsage", "100%","#F48B65", "#65B1F4"));
11
     }); // end JSON
12

  
13

  
14
    setTimeout(function(){
15
        updateMemoryStatus()
16
        }, 1000);
17

  
18
  } // end updateMemory
19

  
20
  function memoryUsageEntry(memoryUsage, recommended, label, barWidth, cssColorUsed, cssColorMax){
21
    var mb = 1024 * 1024;
22
    var gb = mb * 1024;
23
    var max = memoryUsage.max / mb;
24
    var used = memoryUsage.used / mb;
25
    var percent = used * 100 / max;
26
    var recommendedMB = recommended / mb;
27
    var html;
28

  
29
    html += '<span class="memory-usage">';
30
    html += label + '(' + used + ' of '  + max+ ' MB, recommended: '  + recommendedMB + ' MB)&nbsp;';
31
    html += '<div style="height: 100%; width:' + barWidth + ';background-color:' + cssColorMax + '">';
32
    html += '<div style="background-color:' + cssColorUsed + '; width:' + percent + '%">&nbsp;</div></div></span>';
33

  
34
    return html;
35
  }
36

  
37
  updateMemoryStatus()
38

  
39
});
src/main/webapp/js/server-status.js
1

  
2
$(document).ready(function(){
3
	
4
	$("#datasources table .entry").each(function(){
5
		var entry = $(this);
6
		var url = entry.find('.base-url a').attr('href');
7

  
8
		$.getJSON(
9
			"http://wp5.e-taxonomy.eu/registry/oai/providers.php?format=json&callback=?&find="+encodeURIComponent(url),
10
			function(data){
11
				if(data.providers != undefined && data.providers.provider != undefined){
12
					entry.find('.oai-pmh').css('color', 'green').html("Registered");
13
				} else {
14
					entry.find('.oai-pmh').html("<a href=\"mailto:editsupport@bgbm.org?subject=OAI-PHM Provider Registration&body=" + encodeURIComponent(url) + "\">Request for registration</a>");
15
				}
16
			});
17
		
18
		
19
	});
20
});
src/main/webapp/manage/MemoryService.jsp
1
<%@page import="org.codehaus.jackson.node.JsonNodeFactory"
2
%><%@page import="org.codehaus.jackson.node.ArrayNode"
3
%><%@ page contentType="application/json;charset=UTF-8" language="java"
4
%><%@page import="java.util.Set"
5
%><%@page import="org.codehaus.jackson.map.ObjectMapper"
6
%><%@page import="org.codehaus.jackson.JsonNode"
7
%><%@page import="org.codehaus.jackson.node.ObjectNode"
8
%><%@page import="eu.etaxonomy.cdm.server.JvmManager"
9
%><%@page import="java.lang.management.MemoryUsage"
10
%><%@page import="org.codehaus.jackson.JsonFactory"
11
%><%@page import="org.codehaus.jackson.JsonGenerator"
12
%><%@page import="org.codehaus.jackson.map.ser.StdSerializerProvider"
13
%><%@page import="eu.etaxonomy.cdm.server.Bootloader"
14
%><%
15

  
16
    //the servelt context must use the class loader of the Bootloader class otherwise
17
    //getting the status will not work in mulithreading environments !!!
18
    Bootloader bootloader = Bootloader.getBootloader();
19
    long recommendedMinimumHeap = bootloader.recommendedMinimumSpace(Bootloader.HEAP_CDMSERVER, Bootloader.HEAP_PER_INSTANCE, null);
20
    long recommendedMinimumPermGenSpace = bootloader.recommendedMinimumSpace(Bootloader.PERM_GEN_SPACE_CDMSERVER, Bootloader.PERM_GEN_SPACE_PER_INSTANCE, null);
21

  
22
    ObjectMapper jsonMapper = new ObjectMapper();
23

  
24
    response.setHeader("Content-Type", "application/json;charset=UTF-8");
25

  
26
    MemoryUsage  heapMemoryUsage = JvmManager.getHeapMemoryUsage();
27
    MemoryUsage  permGenSpaceUsage = JvmManager.getPermGenSpaceUsage();
28

  
29
    ObjectNode node = jsonMapper.createObjectNode();
30
    node.put("recommendedMinimumHeap", recommendedMinimumHeap);
31
    node.put("recommendedMinimumPermGenSpace", recommendedMinimumPermGenSpace);
32
    node.putPOJO("heapMemoryUsage", heapMemoryUsage);
33
    node.putPOJO("permGenSpaceUsage", permGenSpaceUsage);
34

  
35
    JsonFactory jsonFactory = new JsonFactory();
36
    JsonGenerator jg = jsonFactory.createJsonGenerator(out);
37
    jg.setCodec(jsonMapper);
38
    node.serialize(jg, new StdSerializerProvider());
39
    out.append("}"); //TODO why do we have to add the closing bracket ecplicitely ???? ==> it seems as if the serialization stops at some point du to an exception
40
%>

Also available in: Unified diff