Search in sources :

Example 6 with Cluster

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

the class ClusterRegionsService 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();
    // getting cluster's Regions
    responseJSON.put("regions", getRegionJson(cluster));
    // Send json response
    return responseJSON;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster)

Example 7 with Cluster

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

the class ClusterSelectedRegionService method execute.

@Override
public ObjectNode execute(final HttpServletRequest request) throws Exception {
    String userName = request.getUserPrincipal().getName();
    String pulseData = request.getParameter("pulseData");
    JsonNode parameterMap = mapper.readTree(pulseData);
    String selectedRegionFullPath = parameterMap.get("ClusterSelectedRegion").get("regionFullPath").textValue();
    // get cluster object
    Cluster cluster = Repository.get().getCluster();
    // json object to be sent as response
    ObjectNode responseJSON = mapper.createObjectNode();
    // getting cluster's Regions
    responseJSON.put("clusterName", cluster.getServerName());
    responseJSON.put("userName", userName);
    responseJSON.put("selectedRegion", getSelectedRegionJson(cluster, selectedRegionFullPath));
    // Send json response
    return responseJSON;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 8 with Cluster

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

the class ClusterSelectedRegionsMemberService method getSelectedRegionsMembersJson.

/**
   * Create JSON for selected cluster region's all members
   */
private ObjectNode getSelectedRegionsMembersJson(Cluster cluster, String selectedRegionFullPath) {
    Cluster.Region reg = cluster.getClusterRegion(selectedRegionFullPath);
    if (reg != null) {
        ObjectNode regionMemberJSON = mapper.createObjectNode();
        RegionOnMember[] regionOnMembers = reg.getRegionOnMembers();
        // sort on entry count
        List<RegionOnMember> romList = Arrays.asList(regionOnMembers);
        Collections.sort(romList, romEntryCountComparator);
        for (RegionOnMember rom : romList) {
            ObjectNode memberJSON = mapper.createObjectNode();
            memberJSON.put("memberName", rom.getMemberName());
            memberJSON.put("regionFullPath", rom.getRegionFullPath());
            memberJSON.put("entryCount", rom.getEntryCount());
            memberJSON.put("entrySize", rom.getEntrySize());
            memberJSON.put("accessor", ((rom.getLocalMaxMemory() == 0) ? "True" : "False"));
            logger.trace("calling getSelectedRegionsMembersJson :: rom.getLocalMaxMemory() = {}", rom.getLocalMaxMemory());
            memberJSON.put("memoryReadsTrend", mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND)));
            logger.trace("memoryReadsTrend = {}", rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND).length);
            memberJSON.put("memoryWritesTrend", mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND)));
            logger.trace("memoryWritesTrend = {}", rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND).length);
            memberJSON.put("diskReadsTrend", mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND)));
            logger.trace("diskReadsTrend = {}", rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND).length);
            memberJSON.put("diskWritesTrend", mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND)));
            logger.trace("diskWritesTrend = {}", rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND).length);
            regionMemberJSON.put(rom.getMemberName(), memberJSON);
        }
        logger.debug("calling getSelectedRegionsMembersJson :: regionJSON = {}", regionMemberJSON);
        return regionMemberJSON;
    } else {
        ObjectNode responseJSON = mapper.createObjectNode();
        responseJSON.put("errorOnRegion", "Region [" + selectedRegionFullPath + "] is not available");
        return responseJSON;
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) RegionOnMember(org.apache.geode.tools.pulse.internal.data.Cluster.RegionOnMember)

Example 9 with Cluster

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

the class MemberDetailsService method execute.

public ObjectNode execute(final HttpServletRequest request) throws Exception {
    String userName = request.getUserPrincipal().getName();
    // get cluster object
    Cluster cluster = Repository.get().getCluster();
    // json object to be sent as response
    ObjectNode responseJSON = mapper.createObjectNode();
    JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
    String memberName = requestDataJSON.get("MemberDetails").get("memberName").textValue();
    DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
    Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
    if (clusterMember != null) {
        responseJSON.put("memberId", clusterMember.getId());
        responseJSON.put("name", clusterMember.getName());
        responseJSON.put("host", clusterMember.getHost());
        responseJSON.put("clusterId", cluster.getId());
        responseJSON.put("clusterName", cluster.getServerName());
        responseJSON.put("userName", userName);
        double loadAvg = clusterMember.getLoadAverage();
        responseJSON.put("loadAverage", Double.valueOf(df2.format(loadAvg)));
        responseJSON.put("sockets", clusterMember.getTotalFileDescriptorOpen());
        responseJSON.put("threads", clusterMember.getNumThreads());
        responseJSON.put("offHeapFreeSize", clusterMember.getOffHeapFreeSize());
        responseJSON.put("offHeapUsedSize", clusterMember.getOffHeapUsedSize());
        responseJSON.put("regionsCount", clusterMember.getMemberRegionsList().length);
        // Number of member clients
        responseJSON.put("numClients", clusterMember.getMemberClientsHMap().size());
        Long diskUsageVal = clusterMember.getTotalDiskUsage();
        Double diskUsage = diskUsageVal.doubleValue() / 1024;
        responseJSON.put("diskStorageUsed", Double.valueOf(df2.format(diskUsage)));
        Cluster.Alert[] alertsList = cluster.getAlertsList();
        String status = "Normal";
        for (Cluster.Alert alert : alertsList) {
            if (clusterMember.getName().equals(alert.getMemberName())) {
                if (alert.getSeverity() == Cluster.Alert.SEVERE) {
                    status = "Severe";
                    break;
                } else if (alert.getSeverity() == Cluster.Alert.ERROR) {
                    status = "Error";
                } else if (alert.getSeverity() == Cluster.Alert.WARNING) {
                    status = "Warning";
                }
            }
        }
        responseJSON.put("status", status);
    } else {
        responseJSON.put("errorOnMember", "Member [" + memberName + "] is not available");
    }
    // Send json response
    return responseJSON;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DecimalFormat(java.text.DecimalFormat) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 10 with Cluster

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

the class MemberDiskThroughputService 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();
    // members list
    JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
    String memberName = requestDataJSON.get("MemberDiskThroughput").get("memberName").textValue();
    Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
    if (clusterMember != null) {
        // response
        responseJSON.put("throughputWrites", clusterMember.getThroughputWrites());
        responseJSON.put("throughputWritesTrend", mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_THROUGHPUT_WRITES)));
        responseJSON.put("throughputReads", clusterMember.getThroughputWrites());
        responseJSON.put("throughputReadsTrend", mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_THROUGHPUT_READS)));
    }
    // Send json response
    return responseJSON;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) JsonNode(com.fasterxml.jackson.databind.JsonNode)

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