Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-server / src / main / webapp / manage / MemoryService.jsp @ 929a8c09

History | View | Annotate | Download (2.28 KB)

1
<%@page import="eu.etaxonomy.cdm.server.AssumedMemoryRequirements"%>
2
<%@page import="org.codehaus.jackson.node.JsonNodeFactory"
3
%><%@page import="org.codehaus.jackson.node.ArrayNode"
4
%><%@ page contentType="application/json;charset=UTF-8" language="java"
5
%><%@page import="java.util.Set"
6
%><%@page import="org.codehaus.jackson.map.ObjectMapper"
7
%><%@page import="org.codehaus.jackson.JsonNode"
8
%><%@page import="org.codehaus.jackson.node.ObjectNode"
9
%><%@page import="eu.etaxonomy.cdm.server.JvmManager"
10
%><%@page import="java.lang.management.MemoryUsage"
11
%><%@page import="org.codehaus.jackson.JsonFactory"
12
%><%@page import="org.codehaus.jackson.JsonGenerator"
13
%><%@page import="org.codehaus.jackson.map.ser.StdSerializerProvider"
14
%><%@page import="eu.etaxonomy.cdm.server.Bootloader"
15
%><%
16

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

    
23
    ObjectMapper jsonMapper = new ObjectMapper();
24

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

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

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

    
36
    JsonFactory jsonFactory = new JsonFactory();
37
    JsonGenerator jg = jsonFactory.createJsonGenerator(out);
38
    jg.setCodec(jsonMapper);
39
    node.serialize(jg, new StdSerializerProvider());
40
    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
41
%>
Add picture from clipboard (Maximum size: 40 MB)