Search in sources :

Example 41 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class PulseController method dataBrowserExport.

@RequestMapping(value = "/dataBrowserExport", method = RequestMethod.GET)
public void dataBrowserExport(HttpServletRequest request, HttpServletResponse response) throws IOException {
    // get query string
    String query = request.getParameter("query");
    String members = request.getParameter("members");
    int limit = 0;
    try {
        limit = Integer.valueOf(request.getParameter("limit"));
    } catch (NumberFormatException e) {
        limit = 0;
        logger.debug(e);
    }
    ObjectNode queryResult = mapper.createObjectNode();
    try {
        if (StringUtils.isNotBlank(query)) {
            // get cluster object
            Cluster cluster = Repository.get().getCluster();
            String userName = request.getUserPrincipal().getName();
            // Call execute query method
            queryResult = cluster.executeQuery(query, members, limit);
            // Add query in history if query is executed successfully
            if (!queryResult.has("error")) {
                // Add html escaped query to history
                String escapedQuery = StringEscapeUtils.escapeHtml(query);
                cluster.addQueryInHistory(escapedQuery, userName);
            }
        }
    } catch (Exception e) {
        logger.debug("Exception Occurred : ", e);
    }
    response.setContentType("application/json");
    response.setHeader("Content-Disposition", "attachment; filename=results.json");
    response.getOutputStream().write(queryResult.toString().getBytes());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class ClusterKeyStatisticsService method execute.

public ObjectNode execute(final HttpServletRequest request) throws Exception {
    // get cluster object
    Cluster cluster = Repository.get().getCluster();
    // json object to be sent as response
    ObjectNode responseJSON = mapper.createObjectNode();
    responseJSON.put("writePerSecTrend", mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_WRITES_PER_SECOND)));
    responseJSON.put("readPerSecTrend", mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_READ_PER_SECOND)));
    responseJSON.put("queriesPerSecTrend", mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_QUERIES_PER_SECOND)));
    // Send json response
    return responseJSON;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster)

Example 43 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class ClusterGCPausesService method execute.

public ObjectNode execute(final HttpServletRequest request) throws Exception {
    // get cluster object
    Cluster cluster = Repository.get().getCluster();
    // json object to be sent as response
    ObjectNode responseJSON = mapper.createObjectNode();
    // cluster's GC Pauses trend added to json response object
    ArrayNode pauses = mapper.createArrayNode();
    for (Object obj : cluster.getStatisticTrend(Cluster.CLUSTER_STAT_GARBAGE_COLLECTION)) {
        if (obj instanceof Number) {
            pauses.add(((Number) obj).longValue());
        }
    }
    responseJSON.put("currentGCPauses", cluster.getGarbageCollectionCount());
    responseJSON.put("gCPausesTrend", pauses);
    // Send json response
    return responseJSON;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)43 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)39 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)18 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 IOException (java.io.IOException)7 DecimalFormat (java.text.DecimalFormat)7 ArrayList (java.util.ArrayList)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Repository (org.apache.geode.tools.pulse.internal.data.Repository)2 File (java.io.File)1 Random (java.util.Random)1 CircularFifoBuffer (org.apache.commons.collections.buffer.CircularFifoBuffer)1 Client (org.apache.geode.tools.pulse.internal.data.Cluster.Client)1 Member (org.apache.geode.tools.pulse.internal.data.Cluster.Member)1 Region (org.apache.geode.tools.pulse.internal.data.Cluster.Region)1