Project

General

Profile

Download (2.14 KB) Statistics
| Branch: | Tag: | Revision:
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 = 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  metaSpaceUsage = null;
29
    metaSpaceUsage  = JvmManager.getMetaSpaceUsage();
30
    
31

    
32
    ObjectNode node = jsonMapper.createObjectNode();
33
    node.put("availableProcessors", JvmManager.availableProcessors());
34
    node.put("recommendedMinimumHeap", recommendedMinimumHeap);
35
    node.putPOJO("heapMemoryUsage", heapMemoryUsage);
36
    node.putPOJO("mataSpaceUsage", metaSpaceUsage);
37

    
38
    JsonFactory jsonFactory = new JsonFactory();
39
    JsonGenerator jg = jsonFactory.createJsonGenerator(out);
40
    jg.setCodec(jsonMapper);
41
    node.serialize(jg, new StdSerializerProvider());
42
    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
43
%>
(3-3/4)